return information about replica set
3945
def info(self):
        """"""
        hosts = ','.join(x['host'] for x in self.members())
        mongodb_uri = 'mongodb://' + hosts + '/?replicaSet=' + self.repl_id
        result = {"id": self.repl_id,
                  "auth_key": self.auth_key,
                  "members": self.members(),
                  "mongodb_uri": mongodb_uri,
                  "orchestration": 'replica_sets'}
        if self.login:
            # Add replicaSet URI parameter.
            uri = ('%s&replicaSet=%s'
                   % (self.mongodb_auth_uri(hosts), self.repl_id))
            result['mongodb_auth_uri'] = uri
        return result
98898
def info(self):
        """"""
        uri = ','.join(x['hostname'] for x in self.routers)
        mongodb_uri = 'mongodb://' + uri
        result = {'id': self.id,
                  'shards': self.members,
                  'configsvrs': self.configsvrs,
                  'routers': self.routers,
                  'mongodb_uri': mongodb_uri,
                  'orchestration': 'sharded_clusters'}
        if self.login:
            result['mongodb_auth_uri'] = self.mongodb_auth_uri(uri)
        return result
728302
def get_replicas(self, keyspace, key):
        
        t = self.token_map
        if not t:
            return []
        try:
            return t.get_replicas(keyspace, t.token_class.from_key(key))
        except NoMurmur3:
            return []
1115701
def cluster_version(self):
        """"""
        versionstr = self.client.info()['version']['number']
        return [int(x) for x in versionstr.split('.')]
372037
def swarm_service_info(service_name=str):
    '''
    
    '''
    try:
        salt_return = {}
        client = docker.APIClient(base_url='unix://var/run/docker.sock')
        service = client.inspect_service(service=service_name)
        getdata = salt.utils.json.dumps(service)
        dump = salt.utils.json.loads(getdata)
        version = dump['Version']['Index']
        name = dump['Spec']['Name']
        network_mode = dump['Spec']['EndpointSpec']['Mode']
        ports = dump['Spec']['EndpointSpec']['Ports']
        swarm_id = dump['ID']
        create_date = dump['CreatedAt']
        update_date = dump['UpdatedAt']
        labels = dump['Spec']['Labels']
        replicas = dump['Spec']['Mode']['Replicated']['Replicas']
        network = dump['Endpoint']['VirtualIPs']
        image = dump['Spec']['TaskTemplate']['ContainerSpec']['Image']
        for items in ports:
            published_port = items['PublishedPort']
            target_port = items['TargetPort']
            published_mode = items['PublishMode']
            protocol = items['Protocol']
            salt_return.update({'Service Name': name,
                                'Replicas': replicas,
                                'Service ID': swarm_id,
                                'Network': network,
                                'Network Mode': network_mode,
                                'Creation Date': create_date,
                                'Update Date': update_date,
                                'Published Port': published_port,
                                'Target Port': target_port,
                                'Published Mode': published_mode,
                                'Protocol': protocol,
                                'Docker Image': image,
                                'Minion Id': __context__['server_name'],
                                'Version': version})
    except TypeError:
        salt_return = {}
        salt_return.update({'Error': 'service_name arg is missing?'})
    return salt_return
1193951
def _initiate_replset(self, port, name, maxwait=30):
        """"""
        if not self.args['replicaset'] and name != 'configRepl':
            if self.args['verbose']:
                print('Skipping replica set initialization for %s' % name)
            return

        con = self.client('localhost:%i' % port)
        try:
            rs_status = con['admin'].command({'replSetGetStatus': 1})
            return rs_status
        except OperationFailure as e:
            # not initiated yet
            for i in range(maxwait):
                try:
                    con['admin'].command({'replSetInitiate':
                                          self.config_docs[name]})
                    break
                except OperationFailure as e:
                    print(e.message + " - will retry")
                    time.sleep(1)

            if self.args['verbose']:
                print("initializing replica set '%s' with configuration: %s"
                      % (name, self.config_docs[name]))
            print("replica set '%s' initialized." % name)
1330547
def get_my_info():
    
    result = {}
    result['host_name'] = platform.node()
    result['real_host_name'] = platform.node()
    result['dist'] = platform.dist()
    result['nago_version'] = nago.get_version()
    return result
1107620
def getSlaveStatus(self):
        
        info_dict = {}
        if self.checkVersion('9.1'):
            cols = ['procpid', 'usename', 'application_name', 
                    'client_addr', 'client_port', 'backend_start', 'state', 
                    'sent_location', 'write_location', 'flush_location', 
                    'replay_location', 'sync_priority', 'sync_state',]
            cur = self._conn.cursor()
            cur.execute("""SELECT %s FROM pg_stat_replication;""" 
                        % ','.join(cols))
            rows = cur.fetchall()
            for row in rows:
                info_dict[row[0]] = dict(zip(cols[1:], row[1:]))
        else:
            return None
        return info_dict
899086
def validate_replicas(self, data):
        """"""
        environment = data.get('environment')
        if environment and environment.replicas:
            validate_replicas(data.get('framework'), environment.replicas)
1369657
def collect_instance(self, nick, host, port, unix_socket, auth):
        

        # Connect to redis and get the info
        info = self._get_info(host, port, unix_socket, auth)
        if info is None:
            return

        # The structure should include the port for multiple instances per
        # server
        data = dict()

        # Role needs to be handled outside the the _KEYS dict
        # since the value is a string, not a int / float
        # Also, master_sync_in_progress is only available if the
        # redis instance is a slave, so default it here so that
        # the metric is cleared if the instance flips from slave
        # to master
        if 'role' in info:
            if info['role'] == "master":
                data['replication.master'] = 1
                data['replication.master_sync_in_progress'] = 0
            else:
                data['replication.master'] = 0

        # Connect to redis and get the maxmemory config value
        # Then calculate the % maxmemory of memory used
        maxmemory_config = self._get_config(host, port, unix_socket, auth,
                                            'maxmemory')
        if maxmemory_config and 'maxmemory' in maxmemory_config.keys():
            maxmemory = float(maxmemory_config['maxmemory'])

            # Only report % used if maxmemory is a non zero value
            if maxmemory == 0:
                maxmemory_percent = 0.0
            else:
                maxmemory_percent = info['used_memory'] / maxmemory * 100
                maxmemory_percent = round(maxmemory_percent, 2)
            data['memory.used_percent'] = float("%.2f" % maxmemory_percent)

        # Iterate over the top level keys
        for key in self._KEYS:
            if self._KEYS[key] in info:
                data[key] = info[self._KEYS[key]]

        # Iterate over renamed keys for 2.6 support
        for key in self._RENAMED_KEYS:
            if self._RENAMED_KEYS[key] in info:
                data[key] = info[self._RENAMED_KEYS[key]]

        # Look for databaase speific stats
        for dbnum in range(0, int(self.config.get('databases',
                                                  self._DATABASE_COUNT))):
            db = 'db%i' % dbnum
            if db in info:
                for key in info[db]:
                    data['%s.%s' % (db, key)] = info[db][key]

        # Time since last save
        for key in ['last_save_time', 'rdb_last_save_time']:
            if key in info:
                data['last_save.time_since'] = int(time.time()) - info[key]

        # Publish the data to graphite
        for key in data:
            self.publish(self._publish_key(nick, key),
                         data[key],
                         precision=self._precision(data[key]),
                         metric_type='GAUGE')
1236499
def info(gandi, resource, stat):
    
    output_keys = ['name', 'type', 'size', 'memory', 'console', 'vhost',
                   'dc', 'sftp_server', 'git_server', 'snapshot']

    paas = gandi.paas.info(resource)
    paas_hosts = []
    list_vhost = gandi.vhost.list({'paas_id': paas['id']})

    df = gandi.paas.quota(paas['id'])
    paas.update({'df': df})

    if stat:
        cache = gandi.paas.cache(paas['id'])
        paas.update({'cache': cache})

    for host in list_vhost:
        paas_hosts.append(host['name'])

    output_paas(gandi, paas, [], paas_hosts, output_keys)

    return paas
1010751
def fetchref(self, ref):
        """"""
        log.debug('[%s] Fetching ref: %s', self.name, ref)
        fetch_info = self.repo.remotes.origin.fetch(ref).pop()
        return fetch_info.ref
957903
def info(self):
        
        info = redis_conn.info()
        return _CacheInfo(info['keyspace_hits'],
                          info['keyspace_misses'],
                          self.size())
746354
def get_info(cls):
        
        return '\n'.join(
            [str(cls._instances[key]) for key in cls._instances]
        )
437534
def get_info(self):
        ''''''
        if self._min_disk:
            for path in self._resource_paths:
                usage = psutil.disk_usage(path)

                yield ResourceInfo(path, usage.free, self._min_disk)

        if self._min_memory:
            usage = psutil.virtual_memory()

            yield ResourceInfo(None, usage.available, self._min_memory)
151023
def calculate_size(name, replica_timestamps, target_replica):
    
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += INT_SIZE_IN_BYTES
    for replica_timestamps_item in replica_timestamps:
        key = replica_timestamps_item[0]
        val = replica_timestamps_item[1]
        data_size += calculate_size_str(key)
        data_size += LONG_SIZE_IN_BYTES

    data_size += calculate_size_address(target_replica)
    return data_size
731219
def member_info(self, member_id):
        """"""
        server_id = self._servers.host_to_server_id(
            self.member_id_to_host(member_id))
        server_info = self._servers.info(server_id)
        result = {'_id': member_id, 'server_id': server_id,
                  'mongodb_uri': server_info['mongodb_uri'],
                  'procInfo': server_info['procInfo'],
                  'statuses': server_info['statuses']}
        if self.login:
            result['mongodb_auth_uri'] = self.mongodb_auth_uri(
                self._servers.hostname(server_id))
        result['rsInfo'] = {}
        if server_info['procInfo']['alive']:
            # Can't call serverStatus on arbiter when running with auth enabled.
            # (SERVER-5479)
            if self.login or self.auth_key:
                arbiter_ids = [member['_id'] for member in self.arbiters()]
                if member_id in arbiter_ids:
                    result['rsInfo'] = {
                        'arbiterOnly': True, 'secondary': False, 'primary': False}
                    return result
            repl = self.run_command('serverStatus', arg=None, is_eval=False, member_id=member_id)['repl']
            logger.debug("member {member_id} repl info: {repl}".format(**locals()))
            for key in ('votes', 'tags', 'arbiterOnly', 'buildIndexes', 'hidden', 'priority', 'slaveDelay', 'votes', 'secondary'):
                if key in repl:
                    result['rsInfo'][key] = repl[key]
            result['rsInfo']['primary'] = repl.get('ismaster', False)

        return result