Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 5A68E200CD5 for ; Thu, 22 Jun 2017 05:11:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5951D160BD5; Thu, 22 Jun 2017 03:11:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 55A4E160BF6 for ; Thu, 22 Jun 2017 05:11:16 +0200 (CEST) Received: (qmail 63379 invoked by uid 500); 22 Jun 2017 03:11:15 -0000 Mailing-List: contact notifications-help@libcloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@libcloud.apache.org Delivered-To: mailing list notifications@libcloud.apache.org Received: (qmail 62736 invoked by uid 500); 22 Jun 2017 03:11:10 -0000 Delivered-To: apmail-libcloud-commits@libcloud.apache.org Received: (qmail 62727 invoked by uid 99); 22 Jun 2017 03:11:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jun 2017 03:11:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C474FE9638; Thu, 22 Jun 2017 03:11:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anthonyshaw@apache.org To: commits@libcloud.apache.org Date: Thu, 22 Jun 2017 03:11:08 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [04/34] libcloud git commit: going to use child of Kubernetes connection archived-at: Thu, 22 Jun 2017 03:11:17 -0000 going to use child of Kubernetes connection Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/7c7576b3 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/7c7576b3 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/7c7576b3 Branch: refs/heads/trunk Commit: 7c7576b3b5e3586b375654eddc2de9b0404f50f9 Parents: 8a6fe5a Author: andy Authored: Sun Jun 4 21:56:31 2017 -0400 Committer: andy Committed: Sun Jun 4 21:56:31 2017 -0400 ---------------------------------------------------------------------- libcloud/container/drivers/gke.py | 90 +++++++--------------------------- libcloud/test/secrets.py-dist | 1 + 2 files changed, 20 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/7c7576b3/libcloud/container/drivers/gke.py ---------------------------------------------------------------------- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index ed85adb..c881716 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -1,7 +1,8 @@ from libcloud.common.google import GoogleOAuth2Credential +from libcloud.container.providers import Provider +from libcloud.container.drivers.kubernetes import KubernetesConnection, KubernetesContainerDriver -from libcloud.container.drivers.kuebernetes import DockerContainerDriver, - KubernetesConnection +API_VERSION = 'v1' class GKEContainerDriver(KubernetesContainerDriver): @@ -21,6 +22,7 @@ class GKEContainerDriver(KubernetesContainerDriver): name = "Google Container Engine" type = Provider.GKE website = 'https://container.googleapis.com' + supports_clusters = True # Google Compute Engine node states are mapped to Libcloud node states # per the following dict. GCE does not have an actual 'stopped' state @@ -35,23 +37,10 @@ class GKEContainerDriver(KubernetesContainerDriver): AUTH_URL = "https://www.googleapis.com/auth/" - IMAGE_PROJECTS = { - "centos-cloud": ["centos"], - "coreos-cloud": ["coreos"], - "debian-cloud": ["debian", "backports"], - "gce-nvme": ["nvme-backports"], - "google-containers": ["container-vm"], - "opensuse-cloud": ["opensuse"], - "rhel-cloud": ["rhel"], - "suse-cloud": ["sles", "suse"], - "ubuntu-os-cloud": ["ubuntu"], - "windows-cloud": ["windows"], - } - BACKEND_SERVICE_PROTOCOLS = ['HTTP', 'HTTPS', 'HTTP2', 'TCP', 'SSL'] def __init__(self, user_id, key=None, datacenter=None, project=None, - auth_type=None, scopes=None, credential_file=None, **kwargs): + auth_type=None, scopes=None, credential_file=None, host=None, port=443, **kwargs): """ :param user_id: The email address (for service accounts) or Client ID (for installed apps) to be used for authentication. @@ -89,68 +78,27 @@ class GKEContainerDriver(KubernetesContainerDriver): if not project: raise ValueError('Project name must be specified using ' '"project" keyword.') - + if host is None: + host = GKEContainerDriver.website self.auth_type = auth_type self.project = project self.scopes = scopes self.credential_file = credential_file or \ GoogleOAuth2Credential.default_credential_file + '.' + self.project - super(GKEContainerDriver, self).__init__(user_id, key, **kwargs) + super(GKEContainerDriver, self).__init__(user_id, key, host=host, port=port, **kwargs) - self.base_path = '/compute/%s/projects/%s' % (API_VERSION, + self.base_path = '/%s/projects/%s' % (API_VERSION, self.project) - self.zone_list = self.ex_list_zones() - self.zone_dict = {} - for zone in self.zone_list: - self.zone_dict[zone.name] = zone - if datacenter: - self.zone = self.ex_get_zone(datacenter) - else: - self.zone = None - - self.region_list = self.ex_list_regions() - self.region_dict = {} - for region in self.region_list: - self.region_dict[region.name] = region - - if self.zone: - self.region = self._get_region_from_zone(self.zone) - else: - self.region = None - - # Volume details are looked up in this name-zone dict. - # It is populated if the volume name is not found or the dict is empty. - self._ex_volume_dict = {} - - def list_images(self, ex_project=None, ex_include_deprecated=False): - """ - Return a list of image objects. If no project is specified, a list of - all non-deprecated global and vendor images images is returned. By - default, only non-deprecated images are returned. + self.website = GKEContainerDriver.website - :keyword ex_project: Optional alternate project name. - :type ex_project: ``str``, ``list`` of ``str``, or ``None`` - - :keyword ex_include_deprecated: If True, even DEPRECATED images will - be returned. - :type ex_include_deprecated: ``bool`` - - :return: List of GCENodeImage objects - :rtype: ``list`` of :class:`GCENodeImage` + def list_clusters(self, zone=None): + """ """ - dep = ex_include_deprecated - if ex_project is not None: - return self.ex_list_project_images(ex_project=ex_project, - ex_include_deprecated=dep) - image_list = self.ex_list_project_images(ex_project=None, - ex_include_deprecated=dep) - for img_proj in list(self.IMAGE_PROJECTS.keys()): - try: - image_list.extend( - self.ex_list_project_images(ex_project=img_proj, - ex_include_deprecated=dep)) - except: - # do not break if an OS type is invalid - pass - return image_list + request = "/zones/%s/clusters" % (zone) + if zone is None: + request = "/zones/clusters" + # https://container.googleapis.com/v1/projects/{projectId}/zones/{zone}/clusters + print(self.website+self.base_path+request) + response = self.connection.request(self.base_path + request, method='GET').object + print(response) http://git-wip-us.apache.org/repos/asf/libcloud/blob/7c7576b3/libcloud/test/secrets.py-dist ---------------------------------------------------------------------- diff --git a/libcloud/test/secrets.py-dist b/libcloud/test/secrets.py-dist index b44be36..b7faf32 100644 --- a/libcloud/test/secrets.py-dist +++ b/libcloud/test/secrets.py-dist @@ -98,3 +98,4 @@ CONTAINER_PARAMS_DOCKER = ('user', 'password') CONTAINER_PARAMS_ECS = ('user', 'password', 'region') CONTAINER_PARAMS_KUBERNETES = ('user', 'password') CONTAINER_PARAMS_RANCHER = ('user', 'password') +CONTAINER_PARAMS_GKE = ('user', 'password')