示例#1
0
    def __init__(self, config):
        """
        :param: config
        {
            "proxy_url": xxx,
            "proxy_port": xxx,
            "proxy_username": xxx,
            "proxy_password": xxx,
            "proxy_rdns": xxx,
            "proxy_type": xxx,
            "google_credentials": xxx,
            "google_project": xxx,
            "google_subscriptions": xxx,
            "google_topic": xxx,
            "batch_size": xxx,
            "base64encoded": True/False,
        }
        """

        self._config = config
        self._config["scopes"] = PUBSUB_SCOPES
        self._config["service_name"] = "pubsub"
        self._config["version"] = "v1"
        self._logger = logger
        self._client = gwc.create_google_client(self._config)
        self._base64encoded = scutil.is_true(self._config.get("base64encoded"))
    def __init__(self, logger, config):
        """
        :param: config
        {
            "proxy_url": xxx,
            "proxy_port": xxx,
            "proxy_username": xxx,
            "proxy_password": xxx,
            "proxy_rdns": xxx,
            "proxy_type": xxx,
            "google_credentials": xxx,
            "google_project": xxx,
            "google_subscriptions": xxx,
            "google_topic": xxx,
            "batch_size": xxx,
            "base64encoded": True/False,
        }
        """

        self._config = config
        self._config["scopes"] = RESOURCE_MGR_SCOPES
        self._config["service_name"] = "cloudresourcemanager"
        self._config["version"] = "v1beta1"
        self._logger = logger
        self._client = gwc.create_google_client(self._config)
示例#3
0
    def handleList(self, conf_info):
        logger.info("start listing google subscriptions")
        for required in self.valid_params:
            if not self.callerArgs or not self.callerArgs.get(required):
                logger.error('Missing "%s"', required)
                raise Exception('Missing "{}"'.format(required))

        stanza_name = self.callerArgs[ggc.google_credentials_name][0]
        config = gconf.get_google_settings(scc.getMgmtUri(),
                                           self.getSessionKey(),
                                           cred_name=stanza_name)

        project = self.callerArgs[ggc.google_project][0]
        config.update({
            "service_name":
            "storage",
            "version":
            "v1",
            "scopes":
            ["https://www.googleapis.com/auth/cloud-platform.read-only"]
        })
        storage = create_google_client(config)

        buckets = storage.buckets()
        bucket_names = list()
        request = buckets.list(project=project)
        while request:
            try:
                response = request.execute()
            except googleapiclient.errors.HttpError, exc:
                RH_Err.ctl(400, exc)
            names = [item.get('name') for item in response.get('items')]
            bucket_names.extend(names)
            request = buckets.list_next(request, response)
示例#4
0
    def __init__(self, logger, config):
        """
        :param: config
        {
            "proxy_url": xxx,
            "proxy_port": xxx,
            "proxy_username": xxx,
            "proxy_password": xxx,
            "proxy_rdns": xxx,
            "proxy_type": xxx,
            "google_credentials": xxx,
        }
        """

        self._config = config
        self._config["scopes"] = MONITOR_SCOPES
        self._config["service_name"] = "monitoring"
        self._config["version"] = "v3"
        self._logger = logger
        self._client = gwc.create_google_client(self._config)