// GetActiveScheduledMaintenances gets a list of any upcoming maintenances. // This endpoint will only return scheduled maintenances in the In Progress or Verifying state.
775864
func (c *Client) GetActiveScheduledMaintenances() (ScheduledMaintenancesResponse, error) {
	s := ScheduledMaintenancesResponse{}
	err := c.request("api/v2/scheduled-maintenances/active.json", &s)
	return s, err
}
203308
func getSchedulerDBIntervals() ([]contract.Interval, error) {
	var err error
	var intervals []contract.Interval

	intervals, err = dbClient.Intervals()

	if err != nil {
		LoggingClient.Error("failed connecting to metadata and retrieving intervals:" + err.Error())
		return intervals, err
	}

	if intervals != nil {
		LoggingClient.Debug("successfully queried support-scheduler intervals...")
		for _, v := range intervals {
			LoggingClient.Debug("found interval", "name", v.Name, "id", v.ID, "start", v.Start)
		}
	}
	return intervals, nil
}
1002411
func (p *propInstance) MaintenanceScheduled() bool {
	if p.Instance == nil {
		return false
	}
	return p.Instance.MaintenanceScheduled()
}
397597
func (s *Server) runActiveServices() error {
	// Run it once at the start so we get some initial status
	s.FetchStatusResponse()

	nodes, _ := s.getNodes()
	prober := newProber(s, nodes)
	prober.MaxRTT = s.ProbeInterval
	prober.OnIdle = func() {
		// Fetch results and update set of nodes to probe every
		// ProbeInterval
		s.updateCluster(prober.getResults())
		if nodes, err := s.getNodes(); err == nil {
			prober.setNodes(nodes)
		}
	}
	prober.RunLoop()
	defer prober.Stop()

	return s.Server.Serve()
}
1128573
func (client *Client) DeleteRunstatusMaintenance(ctx context.Context, maintenance RunstatusMaintenance) error {
	if maintenance.URL == "" {
		return fmt.Errorf("empty URL for %#v", maintenance)
	}

	_, err := client.runstatusRequest(ctx, maintenance.URL, nil, "DELETE")
	return err
}
511646
func (c *Client) BackupGetSchedule(id string) (*BackupScheduleResponse, error) {
	var bsr = &BackupScheduleResponse{}
	values := url.Values{
		"SUBID": {id},
	}
	if err := c.post(`server/backup_get_schedule`, values, &bsr); err != nil {
		return nil, err
	}
	return bsr, nil
}
1258736
func (s *userServiceImpl) RescheduleDeactivation(ctx context.Context, identityID uuid.UUID) error {
	rescheduledDeactivation := time.Now().Add(s.config.GetUserDeactivationRescheduleDelay())

	err := s.ExecuteInTransaction(func() error {
		return s.Repositories().Identities().BumpDeactivationSchedule(ctx, identityID, rescheduledDeactivation)
	})

	return err
}
1242867
func (m *Monitor) HostMaintenance(hosts []string, modes []aurora.MaintenanceMode, interval, timeout int) (map[string]bool, error) {

	//  Transform modes to monitor for into a set for easy lookup
	desiredMode := make(map[aurora.MaintenanceMode]struct{})
	for _, mode := range modes {
		desiredMode[mode] = struct{}{}
	}

	// Turn slice into a host set to eliminate duplicates.
	// We also can't use a simple count because multiple modes means we can have multiple matches for a single host.
	// I.e. host A transitions from ACTIVE to DRAINING to DRAINED while monitored
	remainingHosts := make(map[string]struct{})
	for _, host := range hosts {
		remainingHosts[host] = struct{}{}
	}

	hostResult := make(map[string]bool)

	ticker := time.NewTicker(time.Second * time.Duration(interval))
	defer ticker.Stop()
	timer := time.NewTimer(time.Second * time.Duration(timeout))
	defer timer.Stop()

	for {
		select {
		case <-ticker.C:
			// Client call has multiple retries internally
			_, result, err := m.Client.MaintenanceStatus(hosts...)
			if err != nil {
				// Error is either a payload error or a severe connection error
				for host := range remainingHosts {
					hostResult[host] = false
				}
				return hostResult, errors.Wrap(err, "client error in monitor")
			}

			for _, status := range result.GetStatuses() {

				if _, ok := desiredMode[status.GetMode()]; ok {
					hostResult[status.GetHost()] = true
					delete(remainingHosts, status.GetHost())

					if len(remainingHosts) == 0 {
						return hostResult, nil
					}
				}
			}

		case <-timer.C:
			for host := range remainingHosts {
				hostResult[host] = false
			}

			return hostResult, newTimedoutError(errors.New("host maintenance monitor timed out"))
		}
	}
}
614678
func (_m *Facade) GetServicesForScheduling(_a0 datastore.Context, _a1 []string) []*service.Service {
	ret := _m.Called(_a0, _a1)

	var r0 []*service.Service
	if rf, ok := ret.Get(0).(func(datastore.Context, []string) []*service.Service); ok {
		r0 = rf(_a0, _a1)
	} else {
		r0 = ret.Get(0).([]*service.Service)
	}

	return r0
}
209484
func UpdateMaintenanceSchedule(s maintenance.Schedule) *master.Call {
	return &master.Call{
		Type: master.Call_UPDATE_MAINTENANCE_SCHEDULE,
		UpdateMaintenanceSchedule: &master.Call_UpdateMaintenanceSchedule{
			Schedule: s,
		},
	}
}
1053183
func (bridge *Bridge) GetAllSchedules() ([]Schedule, error) {
	uri := fmt.Sprintf("/api/%s/schedules", bridge.Username)
	body, _, err := bridge.Get(uri)
	if err != nil {
		return []Schedule{}, err
	}

	// Each index key is the topmost element of the json array.
	// Unmarshal the array, loop through each index key, and add it to the list
	schedules := map[string]Schedule{}
	err = json.Unmarshal(body, &schedules)
	if err != nil {
		return []Schedule{}, err
	}
	scheduleList := []Schedule{}
	for key, value := range schedules {
		schedule := Schedule{}
		schedule = value
		schedule.ID = key
		scheduleList = append(scheduleList, schedule)
	}
	return scheduleList, nil
}
362262
func (b *build) cancelScheduled(q *BuildQueue) int {
	numBuilds := b.numFolded()

	metrics.BuildQueueEntries.With(map[string]string{
		metrics.LabelBuildQueueName: q.name,
		metrics.LabelBuildState:     metrics.BuildStateWaiting,
	}).Sub(float64(numBuilds))

	b.reportStatus(q, false)

	return numBuilds
}
1249392
func (r Hardware_Router) GetMonitoringActiveAlarms(startDate *datatypes.Time, endDate *datatypes.Time) (resp []datatypes.Container_Monitoring_Alarm_History, err error) {
	params := []interface{}{
		startDate,
		endDate,
	}
	err = r.Session.DoRequest("SoftLayer_Hardware_Router", "getMonitoringActiveAlarms", params, &r.Options, &resp)
	return
}
470108
func (s *scheduler) scheduleDeliveries(pend chan uint64, done chan []byte, quit chan struct{}, wg *sync.WaitGroup) {
	// Clean up the goroutine and pipeline when done
	defer wg.Done()
	defer close(done)

	// Keep reading notifications and scheduling deliveries
	for {
		select {
		case <-quit:
			return

		case idx, ok := <-pend:
			// New section retrieval pending
			if !ok {
				return
			}
			// Wait until the request is honoured
			s.lock.Lock()
			res := s.responses[idx]
			s.lock.Unlock()

			select {
			case <-quit:
				return
			case <-res.done:
			}
			// Deliver the result
			select {
			case <-quit:
				return
			case done <- res.cached:
			}
		}
	}
}
940350
func (r Provisioning_Maintenance_Window) GetMaintenanceClassifications() (resp []datatypes.Provisioning_Maintenance_Classification, err error) {
	err = r.Session.DoRequest("SoftLayer_Provisioning_Maintenance_Window", "getMaintenanceClassifications", nil, &r.Options, &resp)
	return
}
1222224
func getSchedulerDBIntervalActions() ([]contract.IntervalAction, error) {
	var err error
	var intervalActions []contract.IntervalAction

	intervalActions, err = dbClient.IntervalActions()
	if err != nil {
		LoggingClient.Error("error connecting to metadata and retrieving interval actions:" + err.Error())
		return intervalActions, err
	}

	// debug information only
	if intervalActions != nil {
		LoggingClient.Debug("successfully queried support-scheduler interval actions...")
		for _, v := range intervalActions {
			LoggingClient.Debug("found interval action", "name", v.Name, "id", v.ID, "interval", v.Interval, "target", v.Target)
		}
	}
	return intervalActions, nil
}
1115264
func (api *ServicesAPI) TriggerMaintenance(id string) (task *Task, err error) {
	body := []byte{}
	res, err := api.client.restClient.Post(
		api.client.Endpoint+serviceUrl+id+"/trigger_maintenance",
		"application/json",
		bytes.NewReader(body),
		api.client.options.TokenOptions)
	if err != nil {
		return
	}
	defer res.Body.Close()
	task, err = getTask(getError(res))
	return
}