Example #1
0
def try_add_aws_exporter_to_manager(manager):
    # noinspection PyBroadException
    try:
        RemoteRunAwsService.init()
        if RemoteRunAwsService.is_running_on_aws() and ('aws' == env_singleton.env.get_deployment()):
            manager.add_exporter_to_list(AWSExporter)
    except Exception:
        logger.error("Failed adding aws exporter to manager. Exception info:", exc_info=True)
Example #2
0
def populate_exporter_list():
    manager = ReportExporterManager()
    RemoteRunAwsService.init()
    if RemoteRunAwsService.is_running_on_aws():
        manager.add_exporter_to_list(AWSExporter)

    if len(manager.get_exporters_list()) != 0:
        logger.debug(
            "Populated exporters list with the following exporters: {0}".
            format(str(manager.get_exporters_list())))
Example #3
0
    def get(self):
        action = request.args.get('action')
        if action == 'list_aws':
            is_aws = RemoteRunAwsService.is_running_on_aws()
            resp = {'is_aws': is_aws}
            if is_aws:
                is_auth = RemoteRunAwsService.update_aws_auth_params()
                resp['auth'] = is_auth
                if is_auth:
                    resp['instances'] = AwsService.get_instances()
            return jsonify(resp)

        return {}
Example #4
0
    def get(self):
        action = request.args.get("action")
        if action == "list_aws":
            is_aws = RemoteRunAwsService.is_running_on_aws()
            resp = {"is_aws": is_aws}
            if is_aws:
                try:
                    resp["instances"] = AwsService.get_instances()
                except NoCredentialsError as e:
                    resp["error"] = NO_CREDS_ERROR_FORMAT.format(e)
                    return jsonify(resp)
                except ClientError as e:
                    resp["error"] = CLIENT_ERROR_FORMAT.format(e)
                    return jsonify(resp)
            return jsonify(resp)

        return {}
Example #5
0
    def get(self):
        action = request.args.get('action')
        if action == 'list_aws':
            is_aws = RemoteRunAwsService.is_running_on_aws()
            resp = {'is_aws': is_aws}
            if is_aws:
                try:
                    resp['instances'] = AwsService.get_instances()
                except NoCredentialsError as e:
                    resp['error'] = NO_CREDS_ERROR_FORMAT.format(e.message)
                    return jsonify(resp)
                except ClientError as e:
                    resp['error'] = CLIENT_ERROR_FORMAT.format(e.message)
                    return jsonify(resp)
            return jsonify(resp)

        return {}