Check if zpool-features is available
343692
def has_feature_flags():
    '''
    
    '''
    # get man location
    man = salt.utils.path.which('man')
    return _check_retcode('{man} zpool-features'.format(
        man=man
    )) if man else 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
824589
def zfs():
    '''
    
    '''
    grains = {}
    grains['zfs_support'] = __utils__['zfs.is_supported']()
    grains['zfs_feature_flags'] = __utils__['zfs.has_feature_flags']()
    if grains['zfs_support']:
        grains = salt.utils.dictupdate.update(grains, _zfs_pool_data(), merge_lists=True)

    return grains
988667
function ( name ) {
		// valid connection
		if ( name in pool ) {
			return {
				active: pool[name].active,
				count:  pool[name].count
			};
		}

		// failure
		return {active: false};
	}
261681
def _available(name, ret):
    '''
    
    '''
    avail = False
    if 'service.available' in __salt__:
        avail = __salt__['service.available'](name)
    elif 'service.get_all' in __salt__:
        avail = name in __salt__['service.get_all']()
    if not avail:
        ret['result'] = False
        ret['comment'] = 'The named service {0} is not available'.format(name)
    return avail
1020494
def has_idle_connection(cls, pid):
        
        with cls._lock:
            cls._ensure_pool_exists(pid)
            return bool(cls._pools[pid].idle_connections)
172311
def available(self):
        

        for module_name in self.packages:
            if importlib.util.find_spec(module_name):
                return True
        return False
967466
def check(self, feature):
        """"""
        assert hasattr(feature.transformer, 'fit')
        assert hasattr(feature.transformer, 'transform')
        assert hasattr(feature.transformer, 'fit_transform')
420072
public function check()
    {
        $this->goodPools = getInstance()->sysCache->get($this->name) ?? [];
        if (!$this->goodPools) {
            return false;
        }

        $nowPools = $this->getAllTargets();
        $newPools = array_keys($this->goodPools);
        $loses    = array_diff($nowPools, $newPools);

        if (!empty($loses)) {
            foreach ($loses as $lost) {
                $this->removeTarget($lost);
            }
            writeln('Redis Proxy Remove ( ' . implode(',', $loses) . ' ) from Cluster');
        }

        $adds = array_diff($newPools, $nowPools);
        if (!empty($adds)) {
            foreach ($adds as $add) {
                $this->addTarget($add, $this->pools[$add]);
            }
            writeln('Redis Proxy Add ( ' . implode(',', $adds) . ' ) into Cluster');
        }

        return true;
    }
628279
def is_available(self):
        
        # if the availability flag is raised, return True immediately.
        # NOTE: subsequent API failures will lower this flag. we do this here
        # to ensure we don't keep hitting Cuckoo with requests while
        # availability is there.
        if self.server_available:
            return True

        # otherwise, we have to check with the cloud.
        else:
            try:
                response = self._request("cuckoo/status")

                # we've got cuckoo.
                if response.status_code == 200:
                    self.server_available = True
                    return True

            except sandboxapi.SandboxError:
                pass

        self.server_available = False
        return False
759502
def detach(zpool, device):
    '''
    

    '''
    ## Update storage pool
    res = __salt__['cmd.run_all'](
        __utils__['zfs.zpool_command'](
            command='detach',
            target=[zpool, device],
        ),
        python_shell=False,
    )

    ret = __utils__['zfs.parse_command_result'](res, 'detatched')
    if ret['detatched']:
        ## NOTE: lookup zpool status for vdev config
        ret['vdevs'] = _clean_vdev_config(
            __salt__['zpool.status'](zpool=zpool)[zpool]['config'][zpool],
        )

    return ret
978162
def check_member_pool(self, member, pool_name):
        '''
        
        '''
        members = self.bigIP.LocalLB.Pool.get_member(pool_names=[pool_name])[0]
        for mem in members:
            if member == mem.address:
                return True
        return False
959433
def _get_template_pool_lock(self, id):
        """"""
        try:
            return self._hosting_device_locks[id]
        except KeyError:
            self._hosting_device_locks[id] = threading.Lock()
            return self._hosting_device_locks.get(id)
716212
def _check_available(name):
    '''
    
    '''
    _status = _systemctl_status(name)
    sd_version = salt.utils.systemd.version(__context__)
    if sd_version is not None and sd_version >= 231:
        # systemd 231 changed the output of "systemctl status" for unknown
        # services, and also made it return an exit status of 4. If we are on
        # a new enough version, check the retcode, otherwise fall back to
        # parsing the "systemctl status" output.
        # See: https://github.com/systemd/systemd/pull/3385
        # Also: https://github.com/systemd/systemd/commit/3dced37
        return 0 <= _status['retcode'] < 4

    out = _status['stdout'].lower()
    if 'could not be found' in out:
        # Catch cases where the systemd version is < 231 but the return code
        # and output changes have been backported (e.g. RHEL 7.3).
        return False

    for line in salt.utils.itertools.split(out, '\n'):
        match = re.match(r'\s+loaded:\s+(\S+)', line)
        if match:
            ret = match.group(1) != 'not-found'
            break
    else:
        raise CommandExecutionError(
            'Failed to get information on unit \'%s\'' % name
        )
    return ret
991094
def show_pool(self, pool, **_params):
        """"""
        return self.get(self.pool_path % (pool), params=_params)
1294162
def is_available(self):
        """"""
        if hasattr(self._viewh.wrapped_func, 'is_available'):
            return self._viewh.wrapped_func.is_available(self._obj)
        return True
1334625
def CheckLocation():
  """"""
  for url in (config.CONFIG["Client.server_urls"] +
              config.CONFIG["Client.control_urls"]):
    if "staging" in url or "localhost" in url:
      # This is ok.
      return
  logging.error("Poolclient should only be run against test or staging.")
  exit()