check that we have the Nagios server details
541988
def connection_params(host, port)
  
        params = {}
  
        if !host.nil?
          params[:host] = host
        elsif !Nagios::Connection.instance.host.nil?
          params[:host] = Nagios::Connection.instance.host
        else
          raise ArgumentError, "You must provide a Nagios host or use Nagios::Connection"
        end

        if !port.nil?
          params[:port] = port
        elsif !Nagios::Connection.instance.port.nil?
          params[:port] = Nagios::Connection.instance.port
        else
          raise ArgumentError, "You must provide a Nagios port or use Nagios::Connection"
        end

        return params
      end
1275845
def server_and_prefix(self):
        """"""
        return(host_port_prefix(self.config.host, self.config.port, self.prefix))
1083930
def server_powerstatus(host=None,
                       admin_username=None,
                       admin_password=None,
                       module=None):
    '''
    
    '''
    ret = __execute_ret('serveraction powerstatus',
                        host=host, admin_username=admin_username,
                        admin_password=admin_password,
                        module=module)

    result = {'retcode': 0}
    if ret['stdout'] == 'ON':
        result['status'] = True
        result['comment'] = 'Power is on'
    if ret['stdout'] == 'OFF':
        result['status'] = False
        result['comment'] = 'Power is on'
    if ret['stdout'].startswith('ERROR'):
        result['status'] = False
        result['comment'] = ret['stdout']

    return result
49156
def server_list_detailed(self):
        '''
        
        '''
        nt_ks = self.compute_conn
        ret = {}
        for item in nt_ks.servers.list():
            try:
                ret[item.name] = {
                    'OS-EXT-SRV-ATTR': {},
                    'OS-EXT-STS': {},
                    'accessIPv4': item.accessIPv4,
                    'accessIPv6': item.accessIPv6,
                    'addresses': item.addresses,
                    'created': item.created,
                    'flavor': {'id': item.flavor['id'],
                               'links': item.flavor['links']},
                    'hostId': item.hostId,
                    'id': item.id,
                    'image': {'id': item.image['id'] if item.image else 'Boot From Volume',
                              'links': item.image['links'] if item.image else ''},
                    'key_name': item.key_name,
                    'links': item.links,
                    'metadata': item.metadata,
                    'name': item.name,
                    'state': item.status,
                    'tenant_id': item.tenant_id,
                    'updated': item.updated,
                    'user_id': item.user_id,
                }
            except TypeError:
                continue

            ret[item.name]['progress'] = getattr(item, 'progress', '0')

            if hasattr(item.__dict__, 'OS-DCF:diskConfig'):
                ret[item.name]['OS-DCF'] = {
                    'diskConfig': item.__dict__['OS-DCF:diskConfig']
                }
            if hasattr(item.__dict__, 'OS-EXT-SRV-ATTR:host'):
                ret[item.name]['OS-EXT-SRV-ATTR']['host'] = \
                    item.__dict__['OS-EXT-SRV-ATTR:host']
            if hasattr(item.__dict__, 'OS-EXT-SRV-ATTR:hypervisor_hostname'):
                ret[item.name]['OS-EXT-SRV-ATTR']['hypervisor_hostname'] = \
                    item.__dict__['OS-EXT-SRV-ATTR:hypervisor_hostname']
            if hasattr(item.__dict__, 'OS-EXT-SRV-ATTR:instance_name'):
                ret[item.name]['OS-EXT-SRV-ATTR']['instance_name'] = \
                    item.__dict__['OS-EXT-SRV-ATTR:instance_name']
            if hasattr(item.__dict__, 'OS-EXT-STS:power_state'):
                ret[item.name]['OS-EXT-STS']['power_state'] = \
                    item.__dict__['OS-EXT-STS:power_state']
            if hasattr(item.__dict__, 'OS-EXT-STS:task_state'):
                ret[item.name]['OS-EXT-STS']['task_state'] = \
                    item.__dict__['OS-EXT-STS:task_state']
            if hasattr(item.__dict__, 'OS-EXT-STS:vm_state'):
                ret[item.name]['OS-EXT-STS']['vm_state'] = \
                    item.__dict__['OS-EXT-STS:vm_state']
            if hasattr(item.__dict__, 'security_groups'):
                ret[item.name]['security_groups'] = \
                    item.__dict__['security_groups']
        return ret
842010
def system_info(conf, args):
    """"""
    src = conf.config['instances'][args.src]
    src_url = api.build_system_url(build_instance_url(src))
    src_auth = tuple([conf.creds['instances'][args.src]['user'],
                      conf.creds['instances'][args.src]['pass']])
    verify_ssl = src.get('verify_ssl', True)
    sysinfo_json = api.system_info(src_url, src_auth, verify_ssl)
    return sysinfo_json
576103
def name_server_monitor(self, query, days_back=0, page=1, **kwargs):
        """"""
        return self._results('name-server-monitor', '/v1/name-server-monitor', query=query, days_back=days_back,
                            page=page, items_path=('alerts', ), **kwargs)
212587
def on_change(self, server_description):
        """"""
        # We do no I/O holding the lock.
        with self._lock:
            # Any monitored server was definitely in the topology description
            # once. Check if it's still in the description or if some state-
            # change removed it. E.g., we got a host list from the primary
            # that didn't include this server.
            if self._description.has_server(server_description.address):
                td_old = self._description
                if self._publish_server:
                    old_server_description = td_old._server_descriptions[
                        server_description.address]
                    self._events.put((
                        self._listeners.publish_server_description_changed,
                        (old_server_description, server_description,
                         server_description.address, self._topology_id)))

                self._description = updated_topology_description(
                    self._description, server_description)

                self._update_servers()

                if self._publish_tp:
                    self._events.put((
                        self._listeners.publish_topology_description_changed,
                        (td_old, self._description, self._topology_id)))

                # Wake waiters in select_servers().
                self._condition.notify_all()
507689
def _raise_server_index(self):
        """"""

        self._current_server_index = (self._current_server_index + 1) % len(self._servers)

        return self._current_server_index
498532
def server_enabled(s_name, **connection_args):
    '''
    
    '''
    server = _server_get(s_name, **connection_args)
    return server is not None and server.get_state() == 'ENABLED'
575987
def check_service(self, info):
        """"""
        now = current_time_millis()
        next_time = now
        i = 0
        while i < 3:
            for record in self.cache.entries_with_name(info.type):
                if record.type == _TYPE_PTR and \
                        not record.is_expired(now) and \
                        record.alias == info.name:
                    if (info.name.find('.') < 0):
                        info.name = info.name + ".[" + \
                                info.address + \
                                ":" + info.port + \
                                "]." + info.type
                        self.check_service(info)
                        return
                    raise NonUniqueNameException
            if now < next_time:
                self.wait(next_time - now)
                now = current_time_millis()
                continue
            out = DNSOutgoing(_FLAGS_QR_QUERY | _FLAGS_AA)
            self.debug = out
            out.add_question(
                    DNSQuestion(info.type, _TYPE_PTR, _CLASS_IN))
            out.add_authorative_answer(
                    DNSPointer(info.type,
                        _TYPE_PTR, _CLASS_IN, info.ttl, info.name))
            self.send(out)
            i += 1
            next_time += _CHECK_TIME
562801
def check_server_power():
    
    if power_state_flag:
        power_state = get_data(sess, oid_power_state, helper)
        power_state_summary_output, power_state_long_output = state_summary(power_state, 'Server power', server_power_state, helper, server_power_state[3])
        add_output(power_state_summary_output, power_state_long_output, helper)
1357912
def _check_once(self):
        
        address = self._server_description.address
        if self._publish:
            self._listeners.publish_server_heartbeat_started(address)
        with self._pool.get_socket({}) as sock_info:
            response, round_trip_time = self._check_with_socket(sock_info)
            self._avg_round_trip_time.add_sample(round_trip_time)
            sd = ServerDescription(
                address=address,
                ismaster=response,
                round_trip_time=self._avg_round_trip_time.get())
            if self._publish:
                self._listeners.publish_server_heartbeat_succeeded(
                    address, round_trip_time, response)

            return sd
1253435
def server_show(server_id, profile=None, **kwargs):
    '''
    
    '''
    conn = _auth(profile, **kwargs)
    return conn.server_show(server_id)
1196139
function checkServerIP()
    {
        $remoteHostIP   = eZSys::clientIP();
        $serverIPList   = $this->ini->variable( 'ServerSettings', 'ServerIP');

        if ( $serverIPList === false )
        {
            $this->logger->writeTimedString( "Skipped the IP check because ServerIP is not set in the settings. Remote host is: $remoteHostIP.", 'checkServerIP' );
            return true;
        }


        if ( is_array( $serverIPList ) && in_array( $remoteHostIP, $serverIPList ) )
        {
            return true;
        }

        $this->logger->writeTimedString( "server with ip = $remoteHostIP does not exist.", 'checkServerIP failed' );
        $this->logger->writeTimedString( $serverIPList, 'serverIPList from ini file is' );

        return false;
    }
1272144
def server_show(self, server_id):
        '''
        
        '''
        ret = {}
        try:
            servers = self.server_list_detailed()
        except AttributeError:
            raise SaltCloudSystemExit('Corrupt server in server_list_detailed. Remove corrupt servers.')
        for server_name, server in six.iteritems(servers):
            if six.text_type(server['id']) == server_id:
                ret[server_name] = server
        return ret
1271542
def check(self, radl):
        """"""

        if not radl.get_system_by_name(self.system):
            raise RADLParseException("Invalid system id '%s'" % self.system, line=self.line)
        if not radl.get_configure_by_name(self.configure):
            raise RADLParseException("Invalid configure id '%s'" % self.configure, line=self.line)
193875
def managed(name, servers=None):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': 'NTP servers already configured as specified'}

    if not _check_servers(servers):
        ret['result'] = False
        ret['comment'] = 'NTP servers must be a list of strings'

    before_servers = _get_servers()
    desired_servers = set(servers)

    if before_servers == desired_servers:
        return ret

    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = ('NTP servers will be updated to: {0}'
                          .format(', '.join(sorted(desired_servers))))
        return ret

    __salt__['ntp.set_servers'](*desired_servers)
    after_servers = _get_servers()

    if after_servers == desired_servers:
        ret['comment'] = 'NTP servers updated'
        ret['changes'] = {'old': sorted(before_servers),
                          'new': sorted(after_servers)}
    else:
        ret['result'] = False
        ret['comment'] = 'Failed to update NTP servers'
        if before_servers != after_servers:
            ret['changes'] = {'old': sorted(before_servers),
                              'new': sorted(after_servers)}

    return ret