Check if an existing server in the system take part to
    the current deployment
187051
def is_in_current_deployment(server, extra_prefix=""):
    
    return re.match(r"^%s" % '-'.join([DEFAULT_PREFIX, extra_prefix]),
                    server.name) is not None
132768
def _check_connections(self):
        """"""

        for server in self._servers:
            if self._is_reachable(server):
                server['down_until'] = 0
            else:
                server['down_until'] = time.time() + 5
390209
def check_config(config):
    '''
        
    '''
    # Check server URL
    url = config.get("Server", "url")
    try:
        urlopen(url)
    except Exception as e:
        logger.error(
            "The configured OpenSubmit server URL ({0}) seems to be invalid: {1}".format(url, e))
        return False
    # Check directory specification
    targetdir = config.get("Execution", "directory")
    if platform.system() is not "Windows" and not targetdir.startswith("/"):
        logger.error(
            "Please use absolute paths, starting with a /, in your Execution-directory setting.")
        return False
    if not targetdir.endswith(os.sep):
        logger.error(
            "Your Execution-directory setting must end with a " + os.sep)
        return False
    return True
23121
def check_servers(session, machines, extra_prefix="",
                  force_deploy=False, key_name=None, image_id=None,
                  flavors='m1.medium', network=None, ext_net=None,
                  scheduler_hints=None):
    

    scheduler_hints = scheduler_hints or []
    nclient = nova.Client(NOVA_VERSION, session=session,
                          region_name=os.environ['OS_REGION_NAME'])
    servers = nclient.servers.list(
        search_opts={'name': '-'.join([DEFAULT_PREFIX, extra_prefix])})
    wanted = _get_total_wanted_machines(machines)
    if force_deploy:
        for server in servers:
            server.delete()
        servers = []

    if len(servers) == wanted:
        logger.info("[nova]: Reusing existing servers : %s", servers)
        return servers
    elif len(servers) > 0 and len(servers) < wanted:
        raise Exception("Only %s/%s servers found" % (servers, wanted))

    # starting the servers
    total = 0
    for machine in machines:
        number = machine.number
        roles = machine.roles
        logger.info("[nova]: Starting %s servers" % number)
        logger.info("[nova]: for roles %s" % roles)
        logger.info("[nova]: with extra hints %s" % scheduler_hints)
        for _ in range(number):
            flavor = machine.flavour
            if isinstance(flavors, str):
                flavor = flavors
            else:
                flavor_to_id, _ = flavors
                flavor = flavor_to_id[flavor]

            if scheduler_hints:
                _scheduler_hints = \
                    scheduler_hints[total % len(scheduler_hints)]
            else:
                _scheduler_hints = []

            server = nclient.servers.create(
                name='-'.join([DEFAULT_PREFIX, extra_prefix, str(total)]),
                image=image_id,
                flavor=flavor,
                nics=[{'net-id': network['id']}],
                key_name=key_name,
                security_groups=[SECGROUP_NAME],
                scheduler_hints=_scheduler_hints)
            servers.append(server)
            total = total + 1
    return servers
157361
def local_run():
  """"""
  server_software = os.environ.get('SERVER_SOFTWARE')
  if server_software is None:
    return True
  if 'remote_api' in server_software:
    return False
  if server_software.startswith(('Development', 'testutil')):
    return True
  return False
764607
def is_server_running(host, port):
    
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        return s.connect_ex((host, port)) == 0
    finally:
        s.close()
1124942
def get_pending_reboot():
    '''
    
    '''

    # Order the checks for reboot pending in most to least likely.
    checks = (get_pending_update,
              get_pending_file_rename,
              get_pending_servermanager,
              get_pending_component_servicing,
              get_reboot_required_witnessed,
              get_pending_computer_name,
              get_pending_domain_join)

    for check in checks:
        if check():
            return True

    return False
1272605
def check_virtualserver(self, name):
        '''
        
        '''
        vs = self.bigIP.LocalLB.VirtualServer
        for v in vs.get_list():
            if v.split('/')[-1] == name:
                return True
        return False
253970
def is_available(self) -> bool:
        """"""
        status_response = self.get_state(
            'api/host/daemonCheck.json'
        )

        if not status_response:
            return False

        return status_response.get('result') == 1
173908
def check_config_state(self):
        """"""
        config = self.config
        self.update_server_map(config)
        for member in config['members']:
            cfg_member_info = self.default_params.copy()
            cfg_member_info.update(member)
            # Remove attributes we can't check.
            for attr in ('priority', 'votes', 'tags', 'buildIndexes'):
                cfg_member_info.pop(attr, None)
            cfg_member_info['host'] = cfg_member_info['host'].lower()

            real_member_info = self.default_params.copy()
            info = self.member_info(member["_id"])
            real_member_info["_id"] = info['_id']
            member_hostname = self._servers.hostname(info['server_id'])
            real_member_info["host"] = member_hostname.lower()
            real_member_info.update(info['rsInfo'])
            logger.debug("real_member_info({member_id}): {info}".format(member_id=member['_id'], info=info))
            for key in cfg_member_info:
                if cfg_member_info[key] != real_member_info.get(key, None):
                    logger.debug("{key}: {value1} ! = {value2}".format(key=key, value1=cfg_member_info[key], value2=real_member_info.get(key, None)))
                    return False
        return True
1047015
def server_pxe():
    '''
    
    '''
    if __execute_cmd('config -g cfgServerInfo -o \
            cfgServerFirstBootDevice PXE'):
        if __execute_cmd('config -g cfgServerInfo -o cfgServerBootOnce 1'):
            return server_reboot
        else:
            log.warning('failed to set boot order')
            return False

    log.warning('failed to configure PXE boot')
    return False
757900
def os_deployment_servers(self):
        
        if not self.__os_deployment_servers:
            self.__os_deployment_servers = OsDeploymentServers(self.__connection)
        return self.__os_deployment_servers
172827
def check_rest(args):
    ''''''
    nni_config = Config(get_config_filename(args))
    rest_port = nni_config.get_config('restServerPort')
    running, _ = check_rest_server_quick(rest_port)
    if not running:
        print_normal('Restful server is running...')
    else:
        print_normal('Restful server is not running...')
950487
def checkTikaServer(scheme="http", serverHost=ServerHost, port=Port, tikaServerJar=TikaServerJar, classpath=None, config_path=None):
    '''
    
    '''
    if classpath is None:
        classpath = TikaServerClasspath
    if port is None:
        port = '443' if scheme == 'https' else '80'

    urlp = urlparse(tikaServerJar)
    serverEndpoint = '%s://%s:%s' % (scheme, serverHost, port)
    jarPath = os.path.join(TikaJarPath, 'tika-server.jar')
    if 'localhost' in serverEndpoint or '127.0.0.1' in serverEndpoint:
        alreadyRunning = checkPortIsOpen(serverHost, port)

        if not alreadyRunning:
            if not os.path.isfile(jarPath) and urlp.scheme != '':
                getRemoteJar(tikaServerJar, jarPath)

            if not checkJarSig(tikaServerJar, jarPath):
                os.remove(jarPath)
                tikaServerJar = getRemoteJar(tikaServerJar, jarPath)

            status = startServer(jarPath, TikaJava, serverHost, port, classpath, config_path)
            if not status:
                log.error("Failed to receive startup confirmation from startServer.")
                raise RuntimeError("Unable to start Tika server.")
    return serverEndpoint
592937
def is_running(self, port):
        """"""
        try:
            con = self.client('localhost:%s' % port)
            con.admin.command('ping')
            return True
        except (AutoReconnect, ConnectionFailure, OperationFailure):
            # Catch OperationFailure to work around SERVER-31916.
            return False
407105
private function checkHosts():bool
    {
        if (null === $this->config) {
            return (true);
        }
        $current_env = FEnv::get("framework.env");
        $ip = ToolsExceptions::getClientIp();
        $result = true;
        if ("dev" === $current_env) {
            if (property_exists($this->config, "hosts_denied_dev")) {
                $dd = $this->config->hosts_denied_dev;
                if (null !== $dd) {
                    if (false != in_array("*", $dd)) {
                        $result = false;
                    } elseif (false != in_array($ip, $dd)) {
                        $result = false;
                    }
                }
            }
            if (property_exists($this->config, "hosts_allowed_dev")) {
                $dd = $this->config->hosts_allowed_dev;
                if (null !== $dd) {
                    if (true == in_array("*", $dd) && $result) {
                        $result = true;
                    } elseif (true === in_array($ip, $dd) && false === $result) {
                        $result = true;
                    }
                }
            }
        } elseif ("prod" === $current_env) {
            if (property_exists($this->config, "hosts_denied_prod")) {
                $dd = $this->config->hosts_denied_prod;
                if (null !== $dd) {
                    if (false != in_array("*", $dd)) {
                        $result = false;
                    } elseif (false != in_array($ip, $dd)) {
                        $result = false;
                    }
                }
            }
            if (property_exists($this->config, "hosts_allowed_prod")) {
                $dd = $this->config->hosts_allowed_prod;
                if (null !== $dd) {
                    if (true == in_array("*", $dd) && $result) {
                        $result = true;
                    } elseif (true === in_array($ip, $dd) && false === $result) {
                        $result = true;
                    }
                }
            }
        }

        if (false === $result) {
            throw new Server403(new \ArrayObject(array("solution" =>
                "Add the current host to the allowed hosts list")));
        }

        return (true);
    }
177795
public static function isAdminIP() {
        if (!isset($_SERVER['REMOTE_ADDR']))
            return false;

        static $whiteList; if (!$whiteList) {
            $ips = ['127.0.0.1', $_SERVER['SERVER_ADDR']];

            if (!self::$defaultConfig)
                return in_array($_SERVER['REMOTE_ADDR'], $ips);

            $values = self::$defaultConfig->get('admin.ip.whitelist', []);
            if (!is_array($values)) $values = [$values];
            $whiteList = \array_keys(\array_flip(\array_merge($ips, $values)));
        }
        return in_array($_SERVER['REMOTE_ADDR'], $whiteList);
    }