Get host availability calendar for a given listing
979449
def get_listing_calendar(self, listing_id, starting_date=datetime.datetime.now(), calendar_months=6):
        
        params = {
            '_format': 'host_calendar_detailed'
        }

        starting_date_str = starting_date.strftime("%Y-%m-%d")
        ending_date_str = (
            starting_date + datetime.timedelta(days=30)).strftime("%Y-%m-%d")

        r = self._session.get(API_URL + "/calendars/{}/{}/{}".format(
            str(listing_id), starting_date_str, ending_date_str), params=params)
        r.raise_for_status()

        return r.json()
886830
def _get_hosts(self, host):
        
        try:
            return shlex.split(host)
        except ValueError:
            raise Exception("Unparsable host {}".format(host))
945296
def _get_hgroup(name, array):
    ''''''
    hostgroup = None
    for temp in array.list_hgroups():
        if temp['name'] == name:
            hostgroup = temp
            break
    return hostgroup
421822
def get_scheduler_from_hostname(self, host_name):
        
        scheduler_uuid = self.hosts_schedulers.get(host_name, None)
        return self.schedulers.get(scheduler_uuid, None)
1158771
def cli(env, identifier, sortby, cpu, domain, hostname, memory, tag, columns):
    """"""

    mgr = SoftLayer.DedicatedHostManager(env.client)
    guests = mgr.list_guests(host_id=identifier,
                             cpus=cpu,
                             hostname=hostname,
                             domain=domain,
                             memory=memory,
                             tags=tag,
                             mask=columns.mask())

    table = formatting.Table(columns.columns)
    table.sortby = sortby

    for guest in guests:
        table.add_row([value or formatting.blank()
                       for value in columns.row(guest)])

    env.fout(table)
812014
function processSchedule(host,api_key,category,format,mode,pid) {
	var path = '/nitro/api/schedules';

	var today = new Date();
	var todayStr = today.toISOString();

	var query = nitro.newQuery();
	query.add(api.fSchedulesStartFrom,todayStr,true);

	if (mode == 'genre') {
		for (var c in category) {
			query.add(api.fSchedulesGenre,category[c]);
		}
	}
	for (var f in format) {
		query.add(api.fSchedulesFormat,format[f]);
	}
	if (search != '') {
		query.add(api.fSchedulesQ,search);
	}
	if (mode == 'pid') {
		query.add(api.fSchedulesDescendantsOf,pid);
	}
	if (channel != '') {
		query.add(api.fSchedulesServiceMasterBrand,channel);
	}
	if (partner_pid) {
		query.add(api.fSchedulesPartnerPid,partner_pid);
	}
	if (sid) {
		query.add(api.fSchedulesSid,sid);
	}

	query.add(api.mSchedulesAncestorTitles)
		.add(api.fSchedulesPageSize,pageSize);

	nitro.make_request(host,path,api_key,query,{},function(obj){
		var result = scheduleResponse(obj);
		var dest = nitro.getReturn();
		if (dest.callback) {
			// call the callback's next required destination
			// e.g. second and subsequent pages
			if (dest.path) {
				nitro.make_request(host,dest.path,api_key,dest.query,{},dest.callback);
			}
			else {
				dest.callback();
			}
		}
	});
}
166419
def list_calendar_events(self, all_events=None, context_codes=None, end_date=None, excludes=None, start_date=None, type=None, undated=None):
        
        path = {}
        data = {}
        params = {}

        # OPTIONAL - type
        """Defaults to "event""""
        if type is not None:
            self._validate_enum(type, ["event", "assignment"])
            params["type"] = type

        # OPTIONAL - start_date
        """Only return events since the start_date (inclusive).
        Defaults to today. The value should be formatted as: yyyy-mm-dd or ISO 8601 YYYY-MM-DDTHH:MM:SSZ."""
        if start_date is not None:
            params["start_date"] = start_date

        # OPTIONAL - end_date
        """Only return events before the end_date (inclusive).
        Defaults to start_date. The value should be formatted as: yyyy-mm-dd or ISO 8601 YYYY-MM-DDTHH:MM:SSZ.
        If end_date is the same as start_date, then only events on that day are
        returned."""
        if end_date is not None:
            params["end_date"] = end_date

        # OPTIONAL - undated
        """Defaults to false (dated events only).
        If true, only return undated events and ignore start_date and end_date."""
        if undated is not None:
            params["undated"] = undated

        # OPTIONAL - all_events
        """Defaults to false (uses start_date, end_date, and undated criteria).
        If true, all events are returned, ignoring start_date, end_date, and undated criteria."""
        if all_events is not None:
            params["all_events"] = all_events

        # OPTIONAL - context_codes
        """List of context codes of courses/groups/users whose events you want to see.
        If not specified, defaults to the current user (i.e personal calendar,
        no course/group events). Limited to 10 context codes, additional ones are
        ignored. The format of this field is the context type, followed by an
        underscore, followed by the context id. For example: course_42"""
        if context_codes is not None:
            params["context_codes"] = context_codes

        # OPTIONAL - excludes
        """Array of attributes to exclude. Possible values are "description", "child_events" and "assignment""""
        if excludes is not None:
            params["excludes"] = excludes

        self.logger.debug("GET /api/v1/calendar_events with query params: {params} and form data: {data}".format(params=params, data=data, **path))
        return self.generic_request("GET", "/api/v1/calendar_events".format(**path), data=data, params=params, all_pages=True)
869918
def cli(env, sortby, cpu, domain, datacenter, hostname, memory, network,
        hourly, monthly, tag, columns, limit):
    """"""

    vsi = SoftLayer.VSManager(env.client)
    guests = vsi.list_instances(hourly=hourly,
                                monthly=monthly,
                                hostname=hostname,
                                domain=domain,
                                cpus=cpu,
                                memory=memory,
                                datacenter=datacenter,
                                nic_speed=network,
                                tags=tag,
                                mask=columns.mask(),
                                limit=limit)

    table = formatting.Table(columns.columns)
    table.sortby = sortby
    for guest in guests:
        table.add_row([value or formatting.blank()
                       for value in columns.row(guest)])

    env.fout(table)
1071139
def _getEventsOnDay(self, request, day):
        """"""
        home = request.site.root_page
        return getAllEventsByDay(request, day, day, home=home)[0]
755494
def list(cls, datacenter=None):
        """"""
        options = {}
        if datacenter:
            datacenter_id = int(Datacenter.usable_id(datacenter))
            options['datacenter_id'] = datacenter_id

        return cls.call('hosting.vlan.list', options)
1217016
def resources_availability(self):
        """"""
        # Flatten the list.
        availabilities = list(
            chain(
                *[org.check_availability() for org in self.organizations]
            )
        )
        # Filter out the unknown
        availabilities = [a for a in availabilities if type(a) is bool]
        if availabilities:
            # Trick will work because it's a sum() of booleans.
            return round(100. * sum(availabilities) / len(availabilities), 2)
        # if nothing is unavailable, everything is considered OK
        return 100
937916
def _events_available_in_scheduled_slot(events, slots, X, **kwargs):
    
    slot_availability_array = lpu.slot_availability_array(slots=slots,
                                                          events=events)

    label = 'Event scheduled when not available'
    for row, event in enumerate(slot_availability_array):
        for col, availability in enumerate(event):
            if availability == 0:
                yield Constraint(
                    f'{label} - event: {row}, slot: {col}',
                    X[row, col] <= availability
                )
688490
def retrieve_calendar
      response = send_calendar_request("/#{@id}", :get)
      @raw = JSON.parse(response.body)
      instance_variable_set(:@summary, @raw['summary'])
      instance_variable_set(:@location, @raw['location'])
      instance_variable_set(:@description, @raw['description'])
      instance_variable_set(:@time_zone, @raw['timeZone'])
      @html_link = @raw['htmlLink']

      self
    end
106525
def _get_host_details(self):
        """"""
        # Assuming only one system present as part of collection,
        # as we are dealing with iLO's here.
        status, headers, system = self._rest_get('/rest/v1/Systems/1')
        if status < 300:
            stype = self._get_type(system)
            if stype not in ['ComputerSystem.0', 'ComputerSystem.1']:
                msg = "%s is not a valid system type " % stype
                raise exception.IloError(msg)
        else:
            msg = self._get_extended_error(system)
            raise exception.IloError(msg)

        return system
1261194
def scheduled(self, offset=0, count=25):
        ''''''
        return self.client('jobs', 'scheduled', self.name, offset, count)
171977
@Override
  public List<String> listHosts() {
    try {
      // TODO (dano): only return hosts whose agents completed registration (i.e. has id nodes)
      return provider.get("listHosts").getChildren(Paths.configHosts());
    } catch (KeeperException.NoNodeException e) {
      return emptyList();
    } catch (KeeperException e) {
      throw new HeliosRuntimeException("listing hosts failed", e);
    }
  }
216687
def list(self, where):
        '''
        
        '''
        if where == 'pillar':
            schedule = self._get_schedule(include_opts=False)
        elif where == 'opts':
            schedule = self._get_schedule(include_pillar=False)
        else:
            schedule = self._get_schedule()

        # Fire the complete event back along with the list of schedule
        evt = salt.utils.event.get_event('minion', opts=self.opts, listen=False)
        evt.fire_event({'complete': True, 'schedule': schedule},
                       tag='/salt/minion/minion_schedule_list_complete')