List status of all configured SNS-SQS message buses and instances subscribed to them.
348277
def ls(args):
    
    table = []
    queues = list(resources.sqs.queues.filter(QueueNamePrefix="github"))
    max_age = datetime.now(tzutc()) - timedelta(days=15)
    for topic in resources.sns.topics.all():
        account_id = ARN(topic.arn).account_id
        try:
            bucket = resources.s3.Bucket("deploy-status-{}".format(account_id))
            status_objects = bucket.objects.filter(Prefix=ARN(topic.arn).resource)
            recent_status_objects = {o.key: o for o in status_objects if o.last_modified > max_age}
        except ClientError:
            continue
        if ARN(topic.arn).resource.startswith("github"):
            for queue in queues:
                queue_name = os.path.basename(queue.url)
                if queue_name.startswith(ARN(topic.arn).resource):
                    row = dict(Topic=topic, Queue=queue)
                    status_object = bucket.Object(os.path.join(queue_name, "status"))
                    if status_object.key not in recent_status_objects:
                        continue
                    try:
                        github, owner, repo, events, instance = os.path.dirname(status_object.key).split("-", 4)
                        status = json.loads(status_object.get()["Body"].read().decode("utf-8"))
                        row.update(status, Owner=owner, Repo=repo, Instance=instance,
                                   Updated=status_object.last_modified)
                    except Exception:
                        pass
                    table.append(row)
    args.columns = ["Owner", "Repo", "Instance", "Status", "Ref", "Commit", "Updated", "Topic", "Queue"]
    page_output(tabulate(table, args))
1374826
public java.util.List<InstanceStatus> getInstanceStatuses() {
        if (instanceStatuses == null) {
            instanceStatuses = new com.amazonaws.internal.SdkInternalList<InstanceStatus>();
        }
        return instanceStatuses;
    }
915916
def _get_vpn_status(self):
        """"""
        # Sleep for a bit to let any changes in state finish
        sleep(0.3)
        # Check if any active connections are a VPN
        bus = SystemBus()
        ids = []
        for name in self.active:
            conn = bus.get(".NetworkManager", name)
            if conn.Vpn:
                ids.append(conn.Id)
        # No active VPN
        return ids
713514
def client_list(self, *args):
        """"""
        if len(self._clients) == 0:
            self.log('No clients connected')
        else:
            self.log(self._clients, pretty=True)
206073
def status(gandi, service):
    """"""

    if not service:
        global_status = gandi.status.status()
        if global_status['status'] == 'FOGGY':
            # something is going on but not affecting services
            filters = {
                'category': 'Incident',
                'current': True,
            }
            events = gandi.status.events(filters)
            for event in events:
                if event['services']:
                    # do not process services
                    continue
                event_url = gandi.status.event_timeline(event)
                service_detail = '%s - %s' % (event['title'], event_url)
                gandi.echo(service_detail)

    # then check other services
    descs = gandi.status.descriptions()
    needed = services = gandi.status.services()
    if service:
        needed = [serv for serv in services
                  if serv['name'].lower() == service.lower()]

    for serv in needed:
        if serv['status'] != 'STORMY':
            output_service(gandi, serv['name'], descs[serv['status']])
            continue

        filters = {
            'category': 'Incident',
            'services': serv['name'],
            'current': True,
        }
        events = gandi.status.events(filters)
        for event in events:
            event_url = gandi.status.event_timeline(event)
            service_detail = '%s - %s' % (event['title'], event_url)
            output_service(gandi, serv['name'], service_detail)

    return services
1280545
def notifications(self):
        
        if self._notifications is None:
            self._notifications = NotificationList(self._version, service_sid=self._solution['sid'], )
        return self._notifications
455523
def all_nodes_that_receive(service, service_configuration=None, run_only=False, deploy_to_only=False):
    
    assert not (run_only and deploy_to_only)

    if service_configuration is None:
        service_configuration = read_services_configuration()
    runs_on = service_configuration[service]['runs_on']
    deployed_to = service_configuration[service].get('deployed_to')
    if deployed_to is None:
        deployed_to = []

    if run_only:
        result = runs_on
    elif deploy_to_only:
        result = deployed_to
    else:
        result = set(runs_on) | set(deployed_to)

    return list(sorted(result))
884223
def monitor_instances(self, instance_ids):
        
        params = {}
        self.build_list_params(params, instance_ids, 'InstanceId')
        return self.get_list('MonitorInstances', params,
                             [('item', InstanceInfo)], verb='POST')
660716
def list_subscriptions(self, service):
        """"""
        data = {
            'service': service,
        }
        return self._perform_post_request(self.list_subscriptions_endpoint, data, self.token_header)
234270
def status(self, reference_id, **params):
        
        return self.get(MESSAGING_STATUS_RESOURCE.format(reference_id=reference_id),
                        **params)
236205
def list_queues(runas=None, *args):
    '''
    
    '''
    if runas is None and not salt.utils.platform.is_windows():
        runas = salt.utils.user.get_user()
    cmd = [RABBITMQCTL, 'list_queues', '-q']
    cmd.extend(args)
    res = __salt__['cmd.run_all'](cmd, reset_system_locale=False, runas=runas, python_shell=False)
    _check_response(res)
    return _output_to_dict(res['stdout'])
234454
def get_task_statuses(self):
        

        params = {'taskstatus': ''}

        resp = self._client.get(self.resource(), params=params)
        self.parse(self._client, resp, obj=self)

        return dict([(task.name, task) for task in self._tasks])
1344672
def status(ctx, services, show_all):
    """"""
    logger.debug("running command %s (%s)", ctx.command.name, ctx.params,
                 extra={"command": ctx.command.name, "params": ctx.params})

    home = ctx.obj["HOME"]
    services_path = os.path.join(home, SERVICES)

    def print_status(service):
        service_dir = os.path.join(services_path, service)
        if os.path.exists(service_dir):
            pidfile = service_dir + ".pid"
            if os.path.exists(pidfile):
                try:
                    with open(pidfile) as fh:
                        pid = int(fh.read().strip())
                    os.kill(pid, 0)
                    status = "running (pid: {})".format(pid)
                except OSError:
                    status = "not running (stale pidfile)"
            else:
                status = "not running"
        else:
            status = "no such service"
        click.secho("{} - {}".format(service, status))

    if show_all:
        for service in next(os.walk(services_path))[1]:
            print_status(service)
    elif services:
        for service in services:
            print_status(service)
    else:
        raise click.UsageError("You must specify a service name or use --show-all")
675031
def get_instance_status(self):
        
        status_url = self._get_url('status_path')
        res = self.rest_client.session.get(status_url)
        _handle_http_errors(res)
        return res.json()
488399
async def sync_services(self):
        

        services = {}
        servs = await self.list_services()

        for i, serv in enumerate(servs):
            info = await self.service_info(serv)
            status = await self.service_status(serv)
            messages = await self.get_messages(serv)
            headline = await self.get_headline(serv)

            services[serv] = states.ServiceState(info['short_name'], info['long_name'], info['preregistered'], i)
            services[serv].state = status['numeric_status']

            for message in messages:
                services[serv].post_message(message.level, message.message, message.count, message.created)
            if headline is not None:
                services[serv].set_headline(headline.level, headline.message, headline.created)

        return services
238813
def list_subnets(conn=None, call=None, kwargs=None):
    '''
    

    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_subnets function must be called with '
            '-f or --function.'
        )
    if conn is None:
        conn = get_conn()
    if kwargs is None or (isinstance(kwargs, dict) and 'network' not in kwargs):
        raise SaltCloudSystemExit(
            'A `network` must be specified'
        )
    return conn.list_subnets(filters={'network': kwargs['network']})
619502
def check_ips(self, addrs):
        
        tasks = []
        for addr in addrs:
            tasks.append(self._check_ip(addr))
        return self._loop.run_until_complete(asyncio.gather(*tasks))