def list_users(self, **kwargs): """ Prints a list of all the users of the branch specified by <branch-name>, sorted by username You can filter the results (case insensitive) with the --filter=<text> option """ branch_name = getOptionFrom(kwargs, 'branch-name', None) u_filter = getOptionFrom(kwargs, 'filter', default=None) users = run_recipe_without_confirmation( self.Server.list_users, branch_name, filter=u_filter ) table = GUMTable(hrules='FRAME') table.from_dict_list( users, formatters={ 'name': highlighter(default='bold_yellow') }, titles={ 'name': 'Username', 'sn': 'SN' }) print table.sorted('name')
def list_instances(self, **kwargs): """ Lists all existing max instances. This list will include instances that are not actually running and instances that are not even loaded on supervisor, for example old instances that are pending to delete. """ maxserver = self.Server instances = maxserver.get_instances() table = GUMTable() table.from_dict_list( instances, hide=["circus_tcp", "mongo_database"], formatters={ 'name': highlighter(default='bold_yellow'), }, titles={ 'name': 'Name', 'port_index': 'Index', 'server': 'Server access', 'ldap': 'Ldap configuration', 'circus': ' Circus' }) print table.sorted('port_index')
def status(self, **kwargs): """ Lists status for one or all active max instances. The status listed here is the status reported by supervisor. There's a special status 'not found'. Instances on this state are that are created, but already not loaded into supervisor. """ instance_name = getOptionFrom(kwargs, 'instance-name', default='all') oauth = self.Server instances = oauth.get_instances() if instance_name != 'all': instances = [instance for instance in instances if instance['name'] == instance_name] statuses = [] for instance in instances: status = oauth.get_status(instance['name']) statuses.append(status) table = GUMTable() table.from_dict_list( statuses, formatters={ 'name': highlighter(default='bold_yellow'), 'status': highlighter(values={ 'running': 'green', 'unknown': 'red', 'down': 'red', 'backoff': 'red', 'fatal': 'red', 'not found': 'cyan', 'stopped': 'red'} ) }, titles={ 'name': 'Name', 'status': 'Status', 'pid': 'PID', 'uptime': 'Started', 'server': 'Server access' }) print table.sorted('name')
def list_instances(self, **kwargs): instances = self.Server.get_instances() table = GUMTable() table.from_dict_list( instances, formatters={ 'environment': highlighter(default='bold_yellow'), }, titles={ 'name': 'Name', }) print table.sorted('environment')