[jira] [Commented] (LIBCLOUD-851) Azure blob storage - Unable to list blobs of a container
[ https://issues.apache.org/jira/browse/LIBCLOUD-851?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16058238#comment-16058238 ] Daniel Talsky commented on LIBCLOUD-851: I'm having the same problem and have some additional information. I send the following curl call and get the following error: curl -i -X GET -H 'x-ms-version: 2012-02-12' -H 'Accept-Encoding: gzip,deflate' -H 'X-LC-Request-ID: 140216384132432' -H 'User-Agent: libcloud/2.0.0 (Microsoft Azure (blobs)) ' -H 'Authorization: SharedKey apachelibcloudpoc:eewguJMYguV5RCpj3V doAQ69ZqUiXN5TGhPGmftC2qE=' -H 'x-ms-date: Wed, 21 Jun 2017 20:07:32 GMT' --compress 'https://apachelibcloudpoc.blob.core .windows.net/?comp=list=metadata=100' {quote} # begin 140216384132432:140216384230288 response -- 11 400 The value for one of the HTTP headers is not in the correct format. Content-Length: 328 Content-Type: application/xml Server: Microsoft-HTTPAPI/2.0 X-Ms-Request-Id: fec9d225-0001-0114-42ca-ea43fc00 Date: Wed, 21 Jun 2017 20:07:31 GMT InvalidHeaderValueThe value for one of the HTTP header s is not in the correct format. RequestId:fec9d225-0001-0114-42ca-ea43fc00 Time:2017-06-21T20:07:32.6852342Zx-ms-version2012-02-12{quote} It took me a while but I found the following page on the Azure site: https://docs.microsoft.com/en-us/rest/api/storageservices/azure-storage-services-versions-2015-07-08-and-earlier Specifically: {quote} A request made via a SAS is processed according to which service version was used to generate the SAS. Versions 2013-08-15 and 2012-02-12 include a versioning parameter (SignedVersion, or sv), which specifies which version to use to authenticate and execute the SAS request. Version 2012-02-12 and later Requests with Shared Access Signatures (SAS) generated using version 2012-02-12 or later require the SignedVersion (sv) parameter. SignedVersion indicates the service version used for authentication and authorization and for calling the API operation. If the x-ms-version header is passed on the request, it is ignored; only the SignedVersion (sv) parameter determines the service version to use to process the request made via the SAS{quote} In other words, an sv= parameter needs to be added that matches the x-ms-version, and it's not optional for x-ms-version: 2012-02-12. Thanks. > Azure blob storage - Unable to list blobs of a container > > > Key: LIBCLOUD-851 > URL: https://issues.apache.org/jira/browse/LIBCLOUD-851 > Project: Libcloud > Issue Type: Bug > Components: Storage > Environment: Debian GNU/Linux >Reporter: Antoine R. Dumont > Labels: blobstore, storage_drivers > > Hello, > Trying to list the blobs of a container in an azure blob storage, the > instanciation step of a container systematically breaks with a 400 bad > request. > I have not much details in the error message: > {code:title=output|borderStyle=solid} > Traceback (most recent call last): > File "./bin/basic-scenario", line 20, in > container = driver.get_container(container_name=container_name) > File > "/usr/lib/python3/dist-packages/libcloud/storage/drivers/azure_blobs.py", > line 441, in get_container > (response.status), driver=self) > libcloud.common.types.LibcloudError: 0x7f674c6b67f0> 'Unexpected status code: 400' > {code} > Here is the code of ./bin/basic-scenario: > {code:title=basic-scenario|language=python|borderStyle=solid} > #!/usr/bin/env python3 > from libcloud.storage.types import Provider > from libcloud.storage.providers import get_driver > if __name__ == '__main__': ># setup >account_name = 'account-name' >key = 'secret-key' >container_name = 'container-name' ># libcloud setup >cls = get_driver(Provider.AZURE_BLOBS) ># this instanciates ok >driver = cls(key=account_name, secret=key) ># this explodes >container = driver.get_container(container_name=container_name) >for c in driver.iterate_container_objects(container): >print(c) > {code} > Trying to dig in the error, using LIBCLOUD_DEBUG: > {code} > LIBCLOUD_DEBUG=error-output ./bin/basic-scenario > {code} > I have some more input, here is the content of error-output file: > {code} > # begin 140359483662744 request -- > curl -i --head -H 'Authorization: SharedKey > account-name:blabla/blabla/blabla=' -H 'x-ms-version: 2012-02-12' -H > 'User-Agent: libcloud/0.20.0 (Microsoft Azure (blobs)) ' -H 'Accept-Encoding: > gzip,deflate' -H 'x-ms-date: Fri, 09 Sep 2016 10:19:36 GMT' -H > 'X-LC-Request-ID: 140340383662744' --compress > 'https://account-name.blob.core.windows.net:443/container-name?restype=container' > # begin 140359483662744:140359483745056 response -- > HTTP/1.1 400 The value for one of the HTTP headers is not in the
[16/34] libcloud git commit: update for test
update for test Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/94a30995 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/94a30995 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/94a30995 Branch: refs/heads/trunk Commit: 94a309957bbe4f93ec346e0cfa8fb0aa086e05f1 Parents: e16a2b0 Author: andyAuthored: Sun Jun 18 12:14:50 2017 -0400 Committer: andy Committed: Sun Jun 18 12:14:50 2017 -0400 -- libcloud/test/container/test_gke.py | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/94a30995/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index 98ea1f3..3a84aae 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -16,18 +16,13 @@ Tests for Google Container Engine Driver """ -import datetime -import mock import sys import unittest -from libcloud.utils.py3 import httplib +# from libcloud.utils.py3 import httplib from libcloud.container.drivers.gke import GKEContainerDriver, API_VERSION -from libcloud.common.google import (GoogleBaseAuthConnection, -ResourceNotFoundError, ResourceExistsError, -GoogleBaseError) +from libcloud.common.google import (GoogleBaseAuthConnection) from libcloud.test.common.test_google import GoogleAuthMockHttp, GoogleTestCase -from libcloud.compute.base import Node, StorageVolume from libcloud.test import MockHttp from libcloud.test.container import TestCaseMixin
[04/34] libcloud git commit: going to use child of Kubernetes connection
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: andyAuthored: 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
[17/34] libcloud git commit: test gke is broken again
test gke is broken again Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/4cefbbac Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/4cefbbac Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/4cefbbac Branch: refs/heads/trunk Commit: 4cefbbacdb9305c1c1565855f050d5cd8c9d263b Parents: 94a3099 Author: andyAuthored: Sun Jun 18 13:03:00 2017 -0400 Committer: andy Committed: Sun Jun 18 13:03:00 2017 -0400 -- libcloud/test/container/test_gke.py | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/4cefbbac/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index 3a84aae..0129f9c 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -52,13 +52,16 @@ class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): def test_list_images_response(self): pass +def test_server_config(self): +zones = self.driver.get_server_config() +print(zones) + class GKEMockHttp(MockHttp): fixtures = ContainerFileFixtures('gke') json_hdr = {'content-type': 'application/json; charset=UTF-8'} def _get_method_name(self, type, use_param, qs, path): -print("GKEMOCKHTTP", type, use_param, qs, path) api_path = '%s' % API_VERSION project_path = '/projects/%s' % GKE_KEYWORD_PARAMS['project'] path = path.replace(api_path, '') @@ -74,5 +77,10 @@ class GKEMockHttp(MockHttp): type, use_param, qs, path) return method_name +def _zones_us_central1_a_serverconfig(self, method, url, body, headers): +body = self.fixtures.load( +'zones_us-central1-a_instance_serverconfig.json') +return (httplib.OK, body, self.json_hdr, httplib.responses[httplib.OK]) + if __name__ == '__main__': sys.exit(unittest.main())
[22/34] libcloud git commit: fixing documentation
fixing documentation Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/60d64622 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/60d64622 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/60d64622 Branch: refs/heads/trunk Commit: 60d6462264d3221ed27e0bb2a39b319985978321 Parents: e208a9e Author: andyAuthored: Sun Jun 18 19:31:07 2017 -0400 Committer: andy Committed: Sun Jun 18 19:31:07 2017 -0400 -- libcloud/container/drivers/gke.py | 30 -- 1 file changed, 8 insertions(+), 22 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/60d64622/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index 20a9ae4..646838f 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -14,25 +14,11 @@ class GKEConnection(GoogleBaseConnection): """ Connection class for the GKE driver. -GCEConnection extends :class:`google.GoogleBaseConnection` for 2 reasons: - 1. modify request_path for GCE URI. +GKEConnection extends :class:`google.GoogleBaseConnection` for 2 reasons: + 1. modify request_path for GKE URI. 2. Implement gce_params functionality described below. 3. Add request_aggregated_items method for making aggregated API calls. -If the parameter gce_params is set to a dict prior to calling request(), -the URL parameters will be updated to include those key/values FOR A -SINGLE REQUEST. If the response contains a nextPageToken, -gce_params['pageToken'] will be set to its value. This can be used to -implement paging in list: - ->>> params, more_results = {'maxResults': 2}, True ->>> while more_results: -... driver.connection.gce_params=params -... driver.ex_list_urlmaps() -... more_results = 'pageToken' in params -... -[, ] -[] """ host = 'container.googleapis.com' responseCls = GKEResponse @@ -79,7 +65,7 @@ class GKEConnection(GoogleBaseConnection): class GKEContainerDriver(KubernetesContainerDriver): """ -GCE Node Driver class. +GKE Container Driver class. This is the primary driver for interacting with Google Container Engine. It contains all of the standard libcloud methods, @@ -117,16 +103,16 @@ class GKEContainerDriver(KubernetesContainerDriver): operations. :type datacenter: ``str`` -:keyword project: Your GCE project name. (required) +:keyword project: Your GKE project name. (required) :type project: ``str`` -:keyword auth_type: Accepted values are "SA" or "IA" or "GCE" +:keyword auth_type: Accepted values are "SA" or "IA" or "GKE" ("Service Account" or "Installed Application" or - "GCE" if libcloud is being used on a GCE instance + "GKE" if libcloud is being used on a GKE instance with service account enabled). If not supplied, auth_type will be guessed based on value of user_id or if the code is being - executed in a GCE instance. + executed in a GKE instance. :type auth_type: ``str`` :keyword scopes: List of authorization URLs. Default is empty and @@ -134,7 +120,7 @@ class GKEContainerDriver(KubernetesContainerDriver): :type scopes: ``list`` :keyword credential_file: Path to file for caching authentication - information used by GCEConnection. + information used by GKEConnection. :type credential_file: ``str`` """ if not project:
[26/34] libcloud git commit: typo
typo Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/78aed02f Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/78aed02f Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/78aed02f Branch: refs/heads/trunk Commit: 78aed02fc1a239f8188136cd19247566e09d1276 Parents: 7311833 Author: andyAuthored: Mon Jun 19 07:47:06 2017 -0400 Committer: andy Committed: Mon Jun 19 07:47:06 2017 -0400 -- libcloud/test/container/test_gke.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/78aed02f/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index 91f0a16..e909e83 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -52,7 +52,7 @@ class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): def test_list_images_response(self): config = self.driver.list_clusters(ex_zone="us-central1-a") assert "zone" in config -assert config.zone = "us-central1-a" +assert config.zone == "us-central1-a" def test_server_config(self): config = self.driver.get_server_config()
[28/34] libcloud git commit: fixing for parameter name change
fixing for parameter name change Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/8968313a Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/8968313a Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/8968313a Branch: refs/heads/trunk Commit: 8968313a008526679915c5416c07cc33c14bf6f1 Parents: 1ed137b Author: andyAuthored: Tue Jun 20 08:41:02 2017 -0400 Committer: andy Committed: Tue Jun 20 08:41:02 2017 -0400 -- libcloud/container/drivers/gke.py | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/8968313a/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index f95ddf7..9c678f8 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -156,8 +156,8 @@ class GKEContainerDriver(KubernetesContainerDriver): :type ex_zone: ``str`` or :class:`GCEZone` or :class:`NodeLocation` or ``None`` """ -request = "/zones/%s/clusters" % (zone) -if zone is None: +request = "/zones/%s/clusters" % (ex_zone) +if ex_zone is None: request = "/zones/clusters" response = self.connection.request(request, method='GET').object @@ -171,9 +171,9 @@ class GKEContainerDriver(KubernetesContainerDriver): :type ex_zone: ``str`` or :class:`GCEZone` or :class:`NodeLocation` or ``None`` """ -if zone is None: -zone = self.zone -request = "/zones/%s/serverconfig" % (zone) +if ex_zone is None: +ex_zone = self.zone +request = "/zones/%s/serverconfig" % (ex_zone) response = self.connection.request(request, method='GET').object return response
[24/34] libcloud git commit: fixing typos
fixing typos Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/6f3e4c6d Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/6f3e4c6d Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/6f3e4c6d Branch: refs/heads/trunk Commit: 6f3e4c6d622ea0622f3ba0676e704337d00c456e Parents: f049cce Author: andyAuthored: Sun Jun 18 20:39:30 2017 -0400 Committer: andy Committed: Sun Jun 18 20:39:30 2017 -0400 -- docs/container/drivers/gke.rst | 2 +- libcloud/compute/drivers/gce.py | 3 ++- libcloud/container/drivers/gke.py| 18 +- libcloud/container/drivers/kubernetes.py | 1 - libcloud/test/container/test_gke.py | 14 +++--- 5 files changed, 27 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/6f3e4c6d/docs/container/drivers/gke.rst -- diff --git a/docs/container/drivers/gke.rst b/docs/container/drivers/gke.rst index 930c8c6..3edc473 100644 --- a/docs/container/drivers/gke.rst +++ b/docs/container/drivers/gke.rst @@ -21,7 +21,7 @@ https://github.com/apache/libcloud/blob/trunk/demos/gce_demo.py API Docs -.. autoclass:: libcloud.container.drivers.joyent.GKEContainerDriver +.. autoclass:: libcloud.container.drivers.gke.GKEContainerDriver :members: :inherited-members: http://git-wip-us.apache.org/repos/asf/libcloud/blob/6f3e4c6d/libcloud/compute/drivers/gce.py -- diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py index 41eef06..d5e837b 100644 --- a/libcloud/compute/drivers/gce.py +++ b/libcloud/compute/drivers/gce.py @@ -69,7 +69,7 @@ class GCEConnection(GoogleBaseConnection): """ Connection class for the GCE driver. -GCEConnection extends :class:`google.GoogleBaseConnection` for 2 reasons: +GCEConnection extends :class:`google.GoogleBaseConnection` for 3 reasons: 1. modify request_path for GCE URI. 2. Implement gce_params functionality described below. 3. Add request_aggregated_items method for making aggregated API calls. @@ -2750,6 +2750,7 @@ class GCENodeDriver(NodeDriver): :return: A list of zone objects. :rtype: ``list`` of :class:`GCEZone` """ +print("WHEN DO WE DO THIS") list_zones = [] request = '/zones' response = self.connection.request(request, method='GET').object http://git-wip-us.apache.org/repos/asf/libcloud/blob/6f3e4c6d/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index 646838f..f95ddf7 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -14,7 +14,7 @@ class GKEConnection(GoogleBaseConnection): """ Connection class for the GKE driver. -GKEConnection extends :class:`google.GoogleBaseConnection` for 2 reasons: +GKEConnection extends :class:`google.GoogleBaseConnection` for 3 reasons: 1. modify request_path for GKE URI. 2. Implement gce_params functionality described below. 3. Add request_aggregated_items method for making aggregated API calls. @@ -84,8 +84,6 @@ class GKEContainerDriver(KubernetesContainerDriver): AUTH_URL = "https://container.googleapis.com/auth/; -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, host=None, port=443, **kwargs): @@ -150,8 +148,13 @@ class GKEContainerDriver(KubernetesContainerDriver): 'scopes': self.scopes, 'credential_file': self.credential_file} -def list_images(self, zone=None): +def list_clusters(self, ex_zone=None): """ +Return a list of cluster information in the current zone or all zones. + +:keyword ex_zone: Optional zone name or None +:type ex_zone: ``str`` or :class:`GCEZone` or +:class:`NodeLocation` or ``None`` """ request = "/zones/%s/clusters" % (zone) if zone is None: @@ -160,8 +163,13 @@ class GKEContainerDriver(KubernetesContainerDriver): response = self.connection.request(request, method='GET').object return response -def get_server_config(self, zone=None): +def get_server_config(self, ex_zone=None): """ +Return configuration info about the Container Engine service. + +:keyword ex_zone: Optional
[23/34] libcloud git commit: removing issues with joyent
removing issues with joyent Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f049cce1 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f049cce1 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f049cce1 Branch: refs/heads/trunk Commit: f049cce1eabce72ab81d8675038d11f5f4f46733 Parents: 60d6462 Author: andyAuthored: Sun Jun 18 20:02:15 2017 -0400 Committer: andy Committed: Sun Jun 18 20:02:15 2017 -0400 -- docs/container/drivers/joyent.rst | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/f049cce1/docs/container/drivers/joyent.rst -- diff --git a/docs/container/drivers/joyent.rst b/docs/container/drivers/joyent.rst index 8dcaacf..a8b29d3 100644 --- a/docs/container/drivers/joyent.rst +++ b/docs/container/drivers/joyent.rst @@ -17,7 +17,7 @@ Instantiating the driver Download the script:: curl -O https://raw.githubusercontent.com/joyent/sdc-docker/master/tools/sdc-docker-setup.sh - + Now execute the script, substituting the correct values:: bash sdc-docker-setup.sh ~/.ssh/ @@ -28,31 +28,31 @@ This should output something similar to the following:: CloudAPI:https://us-east-1.api.joyent.com Account: jill Key: /Users/localuser/.ssh/sdc-docker.id_rsa - + If you have a pass phrase on your key, the openssl command will prompt you for your pass phrase now and again later. - + Verifying CloudAPI access. CloudAPI access verified. - + Generating client certificate from SSH private key. writing RSA key Wrote certificate files to /Users/localuser/.sdc/docker/jill - + Get Docker host endpoint from cloudapi. Docker service endpoint is: tcp://us-east-1.docker.joyent.com:2376 - + * * * Success. Set your environment as follows: - + export DOCKER_CERT_PATH=/Users/localuser/.sdc/docker/jill export DOCKER_HOST=tcp://us-east-1.docker.joyent.com:2376 export DOCKER_CLIENT_TIMEOUT=300 export DOCKER_TLS_VERIFY=1 - + .. literalinclude:: /examples/container/joyent/instantiate_driver.py :language: python - + API Docs
[08/34] libcloud git commit: fixed my test
fixed my test Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/01f2c374 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/01f2c374 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/01f2c374 Branch: refs/heads/trunk Commit: 01f2c374c587a16281910e93ad5932fd52069edc Parents: 78c72b1 Author: andyAuthored: Tue Jun 13 20:55:10 2017 -0400 Committer: andy Committed: Tue Jun 13 20:55:10 2017 -0400 -- libcloud/test/container/test_gke.py | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/01f2c374/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index 5c17975..25dc708 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -15,24 +15,24 @@ from libcloud.test import unittest -from libcloud.container.drivers.gke import GoogleContainerDriver +from libcloud.container.drivers.gke import GKEContainerDriver from libcloud.test.secrets import CONTAINER_PARAMS_DOCKER -from libcloud.test.container.test_docker import DockerContainerDriverTestCase, DockerMockHttp +from libcloud.test.container.test_kubernetes import KubernetesContainerDriverTestCase, KubernetesMockHttp -class JoyentContainerDriverTestCase(DockerContainerDriverTestCase, unittest.TestCase): +class GKEContainerDriverTestCase(KubernetesContainerDriverTestCase, unittest.TestCase): def setUp(self): # Create a test driver for each version versions = ('linux_124', 'mac_124') self.drivers = [] for version in versions: -JoyentContainerDriver.connectionCls.conn_class = \ -DockerMockHttp +GKEContainerDriver.connectionCls.conn_class = \ +KubernetesMockHttp DockerMockHttp.type = None DockerMockHttp.use_param = 'a' -driver = JoyentContainerDriver(*CONTAINER_PARAMS_DOCKER) +driver = GKEContainerDriver(*CONTAINER_PARAMS_DOCKER) driver.version = version self.drivers.append(driver)
[06/34] libcloud git commit: Update
Update Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b9704214 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b9704214 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b9704214 Branch: refs/heads/trunk Commit: b970421475178d80ea27879bc38e9f1c885065b3 Parents: f222792 Author: andyAuthored: Thu Jun 8 08:20:16 2017 -0400 Committer: andy Committed: Thu Jun 8 08:20:16 2017 -0400 -- libcloud/container/drivers/gke.py | 8 1 file changed, 4 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/b9704214/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index 96c1f8c..02bb33f 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -34,7 +34,7 @@ class GKEConnection(GoogleBaseConnection): [, ] [] """ -host = 'www.googleapis.com' +host = 'container.googleapis.com' responseCls = GKEResponse def __init__(self, user_id, key, secure, auth_type=None, @@ -85,7 +85,7 @@ class GKEContainerDriver(KubernetesContainerDriver): website = 'https://container.googleapis.com' supports_clusters = True -AUTH_URL = "https://www.googleapis.com/auth/; +AUTH_URL = "https://www.googleapis.com/auth/cloudplatform; BACKEND_SERVICE_PROTOCOLS = ['HTTP', 'HTTPS', 'HTTP2', 'TCP', 'SSL'] @@ -156,6 +156,6 @@ class GKEContainerDriver(KubernetesContainerDriver): 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(self.website+self.base_path) +response = self.connection.request(request, method='GET').object print(response)
[31/34] libcloud git commit: test update
test update Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1b0f5ba6 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1b0f5ba6 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1b0f5ba6 Branch: refs/heads/trunk Commit: 1b0f5ba6fed74501196d15efbf8c6cdb37a8853a Parents: f3d8b06 Author: andyAuthored: Wed Jun 21 21:26:43 2017 -0400 Committer: andy Committed: Wed Jun 21 21:26:43 2017 -0400 -- libcloud/test/container/test_gke.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/1b0f5ba6/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index 0e6e7a6..e909e83 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -18,7 +18,7 @@ Tests for Google Container Engine Driver import sys import unittest -import json + from libcloud.utils.py3 import httplib from libcloud.container.drivers.gke import GKEContainerDriver, API_VERSION from libcloud.common.google import (GoogleBaseAuthConnection) @@ -51,8 +51,8 @@ class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): def test_list_images_response(self): config = self.driver.list_clusters(ex_zone="us-central1-a") -assert "clusters" in config -assert config["clusters"][0]["zone"] == "us-central1-a" +assert "zone" in config +assert config.zone == "us-central1-a" def test_server_config(self): config = self.driver.get_server_config()
[20/34] libcloud git commit: removing spaces
removing spaces Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/972ba8c6 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/972ba8c6 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/972ba8c6 Branch: refs/heads/trunk Commit: 972ba8c645ed25094d2014829f79b898a63927e5 Parents: 6a4579d Author: andyAuthored: Sun Jun 18 19:19:43 2017 -0400 Committer: andy Committed: Sun Jun 18 19:19:43 2017 -0400 -- .../fixtures/gke/zones_us-central1-a_instance_serverconfig.json| 2 -- 1 file changed, 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/972ba8c6/libcloud/test/container/fixtures/gke/zones_us-central1-a_instance_serverconfig.json -- diff --git a/libcloud/test/container/fixtures/gke/zones_us-central1-a_instance_serverconfig.json b/libcloud/test/container/fixtures/gke/zones_us-central1-a_instance_serverconfig.json index dd669e2..2b9685c 100644 --- a/libcloud/test/container/fixtures/gke/zones_us-central1-a_instance_serverconfig.json +++ b/libcloud/test/container/fixtures/gke/zones_us-central1-a_instance_serverconfig.json @@ -1,3 +1 @@ - - {"validImageTypes": ["CONTAINER_VM", "COS"], "validNodeVersions": ["1.6.4", "1.6.2", "1.5.7", "1.5.6", "1.4.9"], "defaultClusterVersion": "1.6.4", "validMasterVersions": ["1.6.4", "1.5.7"], "defaultImageType": "COS"}
[19/34] libcloud git commit: adding the server json
adding the server json Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/6a4579d6 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/6a4579d6 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/6a4579d6 Branch: refs/heads/trunk Commit: 6a4579d672c32dd5f35717d4e869cffa91b1944e Parents: 3262d35 Author: andyAuthored: Sun Jun 18 19:17:45 2017 -0400 Committer: andy Committed: Sun Jun 18 19:17:45 2017 -0400 -- .../fixtures/gke/zones_us-central1-a_instance_serverconfig.json | 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/6a4579d6/libcloud/test/container/fixtures/gke/zones_us-central1-a_instance_serverconfig.json -- diff --git a/libcloud/test/container/fixtures/gke/zones_us-central1-a_instance_serverconfig.json b/libcloud/test/container/fixtures/gke/zones_us-central1-a_instance_serverconfig.json new file mode 100644 index 000..dd669e2 --- /dev/null +++ b/libcloud/test/container/fixtures/gke/zones_us-central1-a_instance_serverconfig.json @@ -0,0 +1,3 @@ + + +{"validImageTypes": ["CONTAINER_VM", "COS"], "validNodeVersions": ["1.6.4", "1.6.2", "1.5.7", "1.5.6", "1.4.9"], "defaultClusterVersion": "1.6.4", "validMasterVersions": ["1.6.4", "1.5.7"], "defaultImageType": "COS"}
[GitHub] libcloud pull request #1059: GKE Driver Functional
Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/1059 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[12/34] libcloud git commit: changing the test around
changing the test around Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f2631067 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f2631067 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f2631067 Branch: refs/heads/trunk Commit: f263106797994e4b5add5266fa56c2cf6da87fe4 Parents: 03b666f Author: andyAuthored: Tue Jun 13 21:40:52 2017 -0400 Committer: andy Committed: Tue Jun 13 21:40:52 2017 -0400 -- libcloud/test/container/test_gke.py | 54 ++-- 1 file changed, 38 insertions(+), 16 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/f2631067/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index dfe7881..5b68de9 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -13,26 +13,48 @@ # See the License for the specific language governing permissions and # limitations under the License. -from libcloud.test import unittest +import datetime +import mock +import sys +import unittest -from libcloud.container.drivers.gke import GKEContainerDriver -from libcloud.test.secrets import CONTAINER_PARAMS_DOCKER +from libcloud.utils.py3 import httplib +from libcloud.compute.drivers.gce import ( +GCENodeDriver, API_VERSION, timestamp_to_datetime, GCEAddress, GCEBackend, +GCEBackendService, GCEFirewall, GCEForwardingRule, GCEHealthCheck, +GCENetwork, GCENodeImage, GCERoute, GCERegion, GCETargetHttpProxy, +GCEUrlMap, GCEZone, GCESubnetwork) +from libcloud.common.google import (GoogleBaseAuthConnection, +ResourceNotFoundError, ResourceExistsError, +GoogleBaseError) +from libcloud.test.common.test_google import GoogleAuthMockHttp, GoogleTestCase +from libcloud.compute.base import Node, StorageVolume +from libcloud.test import MockHttp +from libcloud.test.compute import TestCaseMixin +from libcloud.test.file_fixtures import ComputeFileFixtures -from libcloud.test.container.test_kubernetes import KubernetesContainerDriverTestCase, KubernetesMockHttp +from libcloud.test.secrets import GCE_PARAMS, GCE_KEYWORD_PARAMS -class GKEContainerDriverTestCase(KubernetesContainerDriverTestCase, unittest.TestCase): +class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): +""" +Google Compute Engine Test Class. +""" +# Mock out a few specific calls that interact with the user, system or +# environment. +GCEZone._now = lambda x: datetime.datetime(2013, 6, 26, 19, 0, 0) +datacenter = 'us-central1-a' def setUp(self): -# Create a test driver for each version -versions = ('linux_124', 'mac_124') -self.drivers = [] -for version in versions: -GKEContainerDriver.connectionCls.conn_class = \ -KubernetesMockHttp -KubernetesMockHttp.type = None -KubernetesMockHttp.use_param = 'a' -driver = GKEContainerDriver(*CONTAINER_PARAMS_DOCKER) -driver.version = version -self.drivers.append(driver) +GCEMockHttp.test = self +GCENodeDriver.connectionCls.conn_class = GCEMockHttp +GoogleBaseAuthConnection.conn_class = GoogleAuthMockHttp +GCEMockHttp.type = None +kwargs = GCE_KEYWORD_PARAMS.copy() +kwargs['auth_type'] = 'IA' +kwargs['datacenter'] = self.datacenter +self.driver = GCENodeDriver(*GCE_PARAMS, **kwargs) + +def test_default_scopes(self): +self.assertEqual(self.driver.scopes, None)
[01/34] libcloud git commit: update
Repository: libcloud Updated Branches: refs/heads/trunk 98c4fe0a0 -> 42839c65e update Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/7949ca3a Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/7949ca3a Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/7949ca3a Branch: refs/heads/trunk Commit: 7949ca3ac7ca70277157e15424e8aa1a11d953c6 Parents: f3c7474 Author: andyAuthored: Sun May 21 10:36:39 2017 -0700 Committer: andy Committed: Sun May 21 10:36:39 2017 -0700 -- libcloud/container/drivers/gke.py | 153 + 1 file changed, 153 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/7949ca3a/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py new file mode 100644 index 000..3faf009 --- /dev/null +++ b/libcloud/container/drivers/gke.py @@ -0,0 +1,153 @@ +from libcloud.common.google import GoogleOAuth2Credential + + +class GKENodeDriver(NodeDriver): +""" +GCE Node Driver class. + +This is the primary driver for interacting with Google Container Engine. It +contains all of the standard libcloud methods, plus additional ex_* methods +for more features. + +Note that many methods allow either objects or strings (or lists of +objects/strings). In most cases, passing strings instead of objects will +result in additional GKE API calls. +""" +connectionCls = GKEConnection +api_name = 'google' +name = "Google Container Engine" +type = Provider.GKE +website = 'https://container.googleapis.com' + +# Google Compute Engine node states are mapped to Libcloud node states +# per the following dict. GCE does not have an actual 'stopped' state +# but instead uses a 'terminated' state to indicate the node exists +# but is not running. In order to better match libcloud, GCE maps this +# 'terminated' state to 'STOPPED'. +# Also, when a node is deleted from GCE, it no longer exists and instead +# will result in a ResourceNotFound error versus returning a placeholder +# node in a 'terminated' state. +# For more details, please see GCE's docs, +# https://cloud.google.com/compute/docs/instances#checkmachinestatus +NODE_STATE_MAP = { +"PROVISIONING": NodeState.PENDING, +"STAGING": NodeState.PENDING, +"RUNNING": NodeState.RUNNING, +"STOPPING": NodeState.PENDING, +"TERMINATED": NodeState.STOPPED, +"UNKNOWN": NodeState.UNKNOWN +} + +AUTH_URL = "https://www.googleapis.com/auth/; +SA_SCOPES_MAP = { +# list derived from 'gcloud compute instances create --help' +"bigquery": "bigquery", +"cloud-platform": "cloud-platform", +"compute-ro": "compute.readonly", +"compute-rw": "compute", +"datastore": "datastore", +"logging-write": "logging.write", +"monitoring": "monitoring", +"monitoring-write": "monitoring.write", +"service-control": "servicecontrol", +"service-management": "service.management", +"sql": "sqlservice", +"sql-admin": "sqlservice.admin", +"storage-full": "devstorage.full_control", +"storage-ro": "devstorage.read_only", +"storage-rw": "devstorage.read_write", +"taskqueue": "taskqueue", +"useraccounts-ro": "cloud.useraccounts.readonly", +"useraccounts-rw": "cloud.useraccounts", +"userinfo-email": "userinfo.email" +} + +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): +""" +:param user_id: The email address (for service accounts) or Client ID + (for installed apps) to be used for authentication. +:type user_id: ``str`` + +:param key: The RSA Key (for service accounts) or file path containing + key or Client Secret (for installed apps) to be used for + authentication. +:type key: ``str`` + +:keyword datacenter: The name of
[09/34] libcloud git commit: update
update Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/b0eb0d31 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/b0eb0d31 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/b0eb0d31 Branch: refs/heads/trunk Commit: b0eb0d3131489148cc1ead2a308612c8d91eaaa6 Parents: 01f2c37 Author: andyAuthored: Tue Jun 13 21:04:39 2017 -0400 Committer: andy Committed: Tue Jun 13 21:04:39 2017 -0400 -- libcloud/container/drivers/gke.py | 12 1 file changed, 4 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/b0eb0d31/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index 6900952..7e68b36 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -1,6 +1,6 @@ from libcloud.common.google import GoogleOAuth2Credential from libcloud.container.providers import Provider -from libcloud.container.drivers.kubernetes import KubernetesConnection, KubernetesContainerDriver +from libcloud.container.drivers.kubernetes import KubernetesContainerDriver from libcloud.common.google import GoogleResponse from libcloud.common.google import GoogleBaseConnection API_VERSION = 'v1' @@ -39,7 +39,6 @@ class GKEConnection(GoogleBaseConnection): def __init__(self, user_id, key, secure, auth_type=None, credential_file=None, project=None, **kwargs): -print("GKE CONNECTION", "auth_type", auth_type, "cred", credential_file) super(GKEConnection, self).__init__( user_id, key, secure=secure, auth_type=auth_type, credential_file=credential_file, **kwargs) @@ -167,16 +166,13 @@ class GKEContainerDriver(KubernetesContainerDriver): 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) + response = self.connection.request(request, method='GET').object -print(response) def get_server_config(self, zone=None): """ """ request = "/zones/%s/serverconfig" % (zone) -# https://container.googleapis.com/v1/projects/{projectId}/zones/{zone}/clusters -print(self.website+self.base_path) + response = self.connection.request(request, method='GET').object -print(response) +return response
[11/34] libcloud git commit: update of doc code
update of doc code Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/03b666f6 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/03b666f6 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/03b666f6 Branch: refs/heads/trunk Commit: 03b666f6738484f90df49305c93789e57242a728 Parents: 1c11d5e Author: andyAuthored: Tue Jun 13 21:15:43 2017 -0400 Committer: andy Committed: Tue Jun 13 21:15:43 2017 -0400 -- docs/examples/container/gke/instantiate_driver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/03b666f6/docs/examples/container/gke/instantiate_driver.py -- diff --git a/docs/examples/container/gke/instantiate_driver.py b/docs/examples/container/gke/instantiate_driver.py index a5b6143..c23060a 100644 --- a/docs/examples/container/gke/instantiate_driver.py +++ b/docs/examples/container/gke/instantiate_driver.py @@ -3,7 +3,7 @@ from libcloud.container.providers import get_driver cls = get_driver(Provider.GKE) -conn = ComputeEngine('testaccount-...@testproject.iam.gserviceaccount.com', - 'libcloud.json', project='testproject') +conn = cls('testaccount-...@testproject.iam.gserviceaccount.com', + 'libcloud.json', project='testproject') conn.list_images()
[05/34] libcloud git commit: updates
updates Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f2227922 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f2227922 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f2227922 Branch: refs/heads/trunk Commit: f222792230ff44297a8537c3d6f3b54ca3df79c2 Parents: 7c7576b Author: andyAuthored: Tue Jun 6 08:12:04 2017 -0400 Committer: andy Committed: Tue Jun 6 08:12:04 2017 -0400 -- libcloud/container/drivers/gke.py| 85 ++- libcloud/container/drivers/kubernetes.py | 23 2 files changed, 84 insertions(+), 24 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/f2227922/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index c881716..96c1f8c 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -1,10 +1,71 @@ from libcloud.common.google import GoogleOAuth2Credential from libcloud.container.providers import Provider from libcloud.container.drivers.kubernetes import KubernetesConnection, KubernetesContainerDriver - +from libcloud.common.google import GoogleResponse +from libcloud.common.google import GoogleBaseConnection API_VERSION = 'v1' +class GKEResponse(GoogleResponse): +pass + + +class GKEConnection(GoogleBaseConnection): +""" +Connection class for the GKE driver. + +GCEConnection extends :class:`google.GoogleBaseConnection` for 2 reasons: + 1. modify request_path for GCE URI. + 2. Implement gce_params functionality described below. + 3. Add request_aggregated_items method for making aggregated API calls. + +If the parameter gce_params is set to a dict prior to calling request(), +the URL parameters will be updated to include those key/values FOR A +SINGLE REQUEST. If the response contains a nextPageToken, +gce_params['pageToken'] will be set to its value. This can be used to +implement paging in list: + +>>> params, more_results = {'maxResults': 2}, True +>>> while more_results: +... driver.connection.gce_params=params +... driver.ex_list_urlmaps() +... more_results = 'pageToken' in params +... +[, ] +[] +""" +host = 'www.googleapis.com' +responseCls = GKEResponse + +def __init__(self, user_id, key, secure, auth_type=None, + credential_file=None, project=None, **kwargs): +print("GKE CONNECTION", "auth_type", auth_type, "cred", credential_file) +super(GKEConnection, self).__init__( +user_id, key, secure=secure, auth_type=auth_type, +credential_file=credential_file, **kwargs) +self.request_path = '%s/projects/%s' % (API_VERSION, project) +self.gce_params = None + +def request(self, *args, **kwargs): +""" +Perform request then do GCE-specific processing of URL params. + +@inherits: :class:`GoogleBaseConnection.request` +""" +response = super(GKEConnection, self).request(*args, **kwargs) + +# If gce_params has been set, then update the pageToken with the +# nextPageToken so it can be used in the next request. +if self.gce_params: +if 'nextPageToken' in response.object: +self.gce_params['pageToken'] = response.object['nextPageToken'] +elif 'pageToken' in self.gce_params: +del self.gce_params['pageToken'] +self.gce_params = None + +return response + + class GKEContainerDriver(KubernetesContainerDriver): """ GCE Node Driver class. @@ -17,24 +78,13 @@ class GKEContainerDriver(KubernetesContainerDriver): objects/strings). In most cases, passing strings instead of objects will result in additional GKE API calls. """ -connectionCls = KubernetesConnection +connectionCls = GKEConnection api_name = 'google' 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 -# but instead uses a 'terminated' state to indicate the node exists -# but is not running. In order to better match libcloud, GCE maps this -# 'terminated' state to 'STOPPED'. -# Also, when a node is deleted from GCE, it no longer exists and instead -# will result in a ResourceNotFound error versus returning a placeholder -# node in a 'terminated' state. -# For more details, please see GCE's docs, -#
[10/34] libcloud git commit: update for formatting
update for formatting Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1c11d5e2 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1c11d5e2 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1c11d5e2 Branch: refs/heads/trunk Commit: 1c11d5e2bcb2556dd1891ac644e7f01d788492b7 Parents: b0eb0d3 Author: andyAuthored: Tue Jun 13 21:10:41 2017 -0400 Committer: andy Committed: Tue Jun 13 21:10:41 2017 -0400 -- libcloud/container/drivers/gke.py | 22 -- libcloud/test/container/test_gke.py | 4 ++-- 2 files changed, 14 insertions(+), 12 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/1c11d5e2/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index 7e68b36..91f24da 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -81,13 +81,13 @@ class GKEContainerDriver(KubernetesContainerDriver): """ GCE Node Driver class. -This is the primary driver for interacting with Google Container Engine. It -contains all of the standard libcloud methods, plus additional ex_* methods -for more features. +This is the primary driver for interacting with Google Container +Engine. It contains all of the standard libcloud methods, +plus additional ex_* methods for more features. Note that many methods allow either objects or strings (or lists of -objects/strings). In most cases, passing strings instead of objects will -result in additional GKE API calls. +objects/strings). In most cases, passing strings instead of objects +will result in additional GKE API calls. """ connectionCls = GKEConnection api_name = 'google' @@ -101,7 +101,8 @@ class GKEContainerDriver(KubernetesContainerDriver): 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, host=None, port=443, **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. @@ -147,11 +148,11 @@ class GKEContainerDriver(KubernetesContainerDriver): self.credential_file = credential_file or \ GoogleOAuth2Credential.default_credential_file + '.' + self.project -super(GKEContainerDriver, self).__init__(user_id, key, secure=True, host=None, - port=None, **kwargs) +super(GKEContainerDriver, self).__init__(user_id, key, + secure=True, host=None, + port=None, **kwargs) -self.base_path = '/%s/projects/%s' % (API_VERSION, - self.project) +self.base_path = '/%s/projects/%s' % (API_VERSION, self.project) self.website = GKEContainerDriver.website def _ex_connection_class_kwargs(self): @@ -168,6 +169,7 @@ class GKEContainerDriver(KubernetesContainerDriver): request = "/zones/clusters" response = self.connection.request(request, method='GET').object +return response def get_server_config(self, zone=None): """ http://git-wip-us.apache.org/repos/asf/libcloud/blob/1c11d5e2/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index 25dc708..dfe7881 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -31,8 +31,8 @@ class GKEContainerDriverTestCase(KubernetesContainerDriverTestCase, unittest.Tes for version in versions: GKEContainerDriver.connectionCls.conn_class = \ KubernetesMockHttp -DockerMockHttp.type = None -DockerMockHttp.use_param = 'a' +KubernetesMockHttp.type = None +KubernetesMockHttp.use_param = 'a' driver = GKEContainerDriver(*CONTAINER_PARAMS_DOCKER) driver.version = version self.drivers.append(driver)
[34/34] libcloud git commit: changes for #1059
changes for #1059 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/42839c65 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/42839c65 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/42839c65 Branch: refs/heads/trunk Commit: 42839c65ea90c7526af159adb3dfab0970b3601f Parents: 20bd516 Author: Anthony ShawAuthored: Thu Jun 22 13:10:51 2017 +1000 Committer: Anthony Shaw Committed: Thu Jun 22 13:10:51 2017 +1000 -- CHANGES.rst | 4 1 file changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/42839c65/CHANGES.rst -- diff --git a/CHANGES.rst b/CHANGES.rst index ee3c1dc..da18a55 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -57,6 +57,10 @@ Compute Container ~ +- New driver for Google Container Engine + [GITHUB-1059] + (Andy Maheshwari) + - [KUBERNETES] Fix get_container method responding with None [GITHUB-1054] (Anthony Shaw)
[32/34] libcloud git commit: update for test
update for test Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/35bdf4e8 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/35bdf4e8 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/35bdf4e8 Branch: refs/heads/trunk Commit: 35bdf4e8e06aaf46e7f14fe30068496f34394c44 Parents: 1b0f5ba Author: andyAuthored: Wed Jun 21 21:45:35 2017 -0400 Committer: andy Committed: Wed Jun 21 21:45:35 2017 -0400 -- libcloud/test/container/test_gke.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/35bdf4e8/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index e909e83..e4d29d6 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -51,8 +51,8 @@ class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): def test_list_images_response(self): config = self.driver.list_clusters(ex_zone="us-central1-a") -assert "zone" in config -assert config.zone == "us-central1-a" +assert "clusters" in config +assert config["clusters"][0]["zone"] == "us-central1-a" def test_server_config(self): config = self.driver.get_server_config()
[07/34] libcloud git commit: it runs
it runs Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/78c72b15 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/78c72b15 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/78c72b15 Branch: refs/heads/trunk Commit: 78c72b15787279125110026a0c42bb1dbdf65239 Parents: b970421 Author: andyAuthored: Fri Jun 9 23:17:09 2017 -0400 Committer: andy Committed: Fri Jun 9 23:17:09 2017 -0400 -- libcloud/container/drivers/gke.py | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/78c72b15/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index 02bb33f..6900952 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -46,6 +46,18 @@ class GKEConnection(GoogleBaseConnection): self.request_path = '%s/projects/%s' % (API_VERSION, project) self.gce_params = None +def pre_connect_hook(self, params, headers): +""" +Update URL parameters with values from self.gce_params. + +@inherits: :class:`GoogleBaseConnection.pre_connect_hook` +""" +params, headers = super(GKEConnection, self).pre_connect_hook(params, + headers) +if self.gce_params: +params.update(self.gce_params) +return params, headers + def request(self, *args, **kwargs): """ Perform request then do GCE-specific processing of URL params. @@ -85,7 +97,7 @@ class GKEContainerDriver(KubernetesContainerDriver): website = 'https://container.googleapis.com' supports_clusters = True -AUTH_URL = "https://www.googleapis.com/auth/cloudplatform; +AUTH_URL = "https://container.googleapis.com/auth/; BACKEND_SERVICE_PROTOCOLS = ['HTTP', 'HTTPS', 'HTTP2', 'TCP', 'SSL'] @@ -159,3 +171,12 @@ class GKEContainerDriver(KubernetesContainerDriver): print(self.website+self.base_path) response = self.connection.request(request, method='GET').object print(response) + +def get_server_config(self, zone=None): +""" +""" +request = "/zones/%s/serverconfig" % (zone) +# https://container.googleapis.com/v1/projects/{projectId}/zones/{zone}/clusters +print(self.website+self.base_path) +response = self.connection.request(request, method='GET').object +print(response)
[29/34] libcloud git commit: missing json
missing json Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/4d17e75e Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/4d17e75e Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/4d17e75e Branch: refs/heads/trunk Commit: 4d17e75e811b11782db49859dfad49c7092b6541 Parents: 8968313 Author: andyAuthored: Tue Jun 20 08:50:03 2017 -0400 Committer: andy Committed: Tue Jun 20 08:50:03 2017 -0400 -- .../fixtures/gke/zones_us-central1-a_list.json | 29 1 file changed, 29 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/4d17e75e/libcloud/test/container/fixtures/gke/zones_us-central1-a_list.json -- diff --git a/libcloud/test/container/fixtures/gke/zones_us-central1-a_list.json b/libcloud/test/container/fixtures/gke/zones_us-central1-a_list.json new file mode 100644 index 000..5c6770b --- /dev/null +++ b/libcloud/test/container/fixtures/gke/zones_us-central1-a_list.json @@ -0,0 +1,29 @@ +{"clusters": [{ + "currentMasterVersion": "1.6.4", + "currentNodeCount": 3, + "currentNodeVersion": "1.6.4", + "initialClusterVersion": "1.6.4", + "locations": ["us-central1-a"], + "loggingService": "logging.googleapis.com", + "name": "cluster-1", + "network": "default", + "nodeConfig": {"diskSizeGb": 100, +"imageType": "COS", +"machineType": "n1-standard-1", +"oauthScopes": ["https://www.googleapis.com/auth/compute;], +"serviceAccount": "default"}, + "nodeIpv4CidrSize": 24, + "nodePools": [{"autoscaling": {}, + "config": {"diskSizeGb": 100, + "serviceAccount": "default"}, + "initialNodeCount": 3, + "instanceGroupUrls": ["https://www.googleapis.com/compute/v1/projects/project_name;], + "management": {}, + "name": "default-pool", + "status": "RUNNING", + "version": "1.6.4"}], + "selfLink": "https://container.googleapis.com/v1/projects/;, + "servicesIpv4Cidr": "XX.XX.XXX.X/20", + "status": "RUNNING", + "subnetwork": "default", + "zone": "us-central1-a"}]}
[18/34] libcloud git commit: updates
updates Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/3262d355 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/3262d355 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/3262d355 Branch: refs/heads/trunk Commit: 3262d35516f65b3017ceb4b1e5304b5009f17f56 Parents: 4cefbba Author: andyAuthored: Sun Jun 18 19:15:07 2017 -0400 Committer: andy Committed: Sun Jun 18 19:15:07 2017 -0400 -- libcloud/container/drivers/gke.py | 22 +++--- libcloud/test/container/test_gke.py | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/3262d355/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index acac294..519c893 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -42,24 +42,24 @@ class GKEConnection(GoogleBaseConnection): super(GKEConnection, self).__init__( user_id, key, secure=secure, auth_type=auth_type, credential_file=credential_file, **kwargs) -self.request_path = '%s/projects/%s' % (API_VERSION, project) -self.gce_params = None +self.request_path = '/%s/projects/%s' % (API_VERSION, project) +self.gke_params = None def pre_connect_hook(self, params, headers): """ -Update URL parameters with values from self.gce_params. +Update URL parameters with values from self.gke_params. @inherits: :class:`GoogleBaseConnection.pre_connect_hook` """ params, headers = super(GKEConnection, self).pre_connect_hook(params, headers) -if self.gce_params: +if self.gke_params: params.update(self.gce_params) return params, headers def request(self, *args, **kwargs): """ -Perform request then do GCE-specific processing of URL params. +Perform request then do GKE-specific processing of URL params. @inherits: :class:`GoogleBaseConnection.request` """ @@ -67,12 +67,12 @@ class GKEConnection(GoogleBaseConnection): # If gce_params has been set, then update the pageToken with the # nextPageToken so it can be used in the next request. -if self.gce_params: +if self.gke_params: if 'nextPageToken' in response.object: -self.gce_params['pageToken'] = response.object['nextPageToken'] -elif 'pageToken' in self.gce_params: -del self.gce_params['pageToken'] -self.gce_params = None +self.gke_params['pageToken'] = response.object['nextPageToken'] +elif 'pageToken' in self.gke_params: +del self.gke_params['pageToken'] +self.gke_params = None return response @@ -179,7 +179,7 @@ class GKEContainerDriver(KubernetesContainerDriver): """ if zone is None: zone = self.zone -request = "/zones/%s/serverconfig" % (self.zone) +request = "/zones/%s/serverconfig" % (zone) response = self.connection.request(request, method='GET').object return response http://git-wip-us.apache.org/repos/asf/libcloud/blob/3262d355/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index 0129f9c..5d0f41e 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -19,7 +19,7 @@ Tests for Google Container Engine Driver import sys import unittest -# from libcloud.utils.py3 import httplib +from libcloud.utils.py3 import httplib from libcloud.container.drivers.gke import GKEContainerDriver, API_VERSION from libcloud.common.google import (GoogleBaseAuthConnection) from libcloud.test.common.test_google import GoogleAuthMockHttp, GoogleTestCase @@ -62,7 +62,7 @@ class GKEMockHttp(MockHttp): json_hdr = {'content-type': 'application/json; charset=UTF-8'} def _get_method_name(self, type, use_param, qs, path): -api_path = '%s' % API_VERSION +api_path = '/%s' % API_VERSION project_path = '/projects/%s' % GKE_KEYWORD_PARAMS['project'] path = path.replace(api_path, '') # This replace is separate, since there is a call with a different
[27/34] libcloud git commit: typo
typo Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/1ed137bc Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1ed137bc Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1ed137bc Branch: refs/heads/trunk Commit: 1ed137bcc1e5d9d2a05c95f76e282f6e612e Parents: 78aed02 Author: andyAuthored: Tue Jun 20 08:39:33 2017 -0400 Committer: andy Committed: Tue Jun 20 08:39:33 2017 -0400 -- libcloud/compute/drivers/gce.py | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/1ed137bc/libcloud/compute/drivers/gce.py -- diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py index d5e837b..07032d6 100644 --- a/libcloud/compute/drivers/gce.py +++ b/libcloud/compute/drivers/gce.py @@ -2750,7 +2750,6 @@ class GCENodeDriver(NodeDriver): :return: A list of zone objects. :rtype: ``list`` of :class:`GCEZone` """ -print("WHEN DO WE DO THIS") list_zones = [] request = '/zones' response = self.connection.request(request, method='GET').object
[21/34] libcloud git commit: fixing bug
fixing bug Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e208a9ee Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e208a9ee Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e208a9ee Branch: refs/heads/trunk Commit: e208a9eeaec6171e5813e665ad36f67cea3c17ea Parents: 972ba8c Author: andyAuthored: Sun Jun 18 19:26:01 2017 -0400 Committer: andy Committed: Sun Jun 18 19:26:01 2017 -0400 -- libcloud/container/drivers/gke.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/e208a9ee/libcloud/container/drivers/gke.py -- diff --git a/libcloud/container/drivers/gke.py b/libcloud/container/drivers/gke.py index 519c893..20a9ae4 100644 --- a/libcloud/container/drivers/gke.py +++ b/libcloud/container/drivers/gke.py @@ -54,7 +54,7 @@ class GKEConnection(GoogleBaseConnection): params, headers = super(GKEConnection, self).pre_connect_hook(params, headers) if self.gke_params: -params.update(self.gce_params) +params.update(self.gke_params) return params, headers def request(self, *args, **kwargs):
[13/34] libcloud git commit: updated
updated Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/06c8ccb3 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/06c8ccb3 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/06c8ccb3 Branch: refs/heads/trunk Commit: 06c8ccb3d9f65b04ddfeca56cc45976d1211eaea Parents: f263106 Author: andyAuthored: Tue Jun 13 21:50:24 2017 -0400 Committer: andy Committed: Tue Jun 13 21:50:24 2017 -0400 -- docs/container/drivers/gke.rst | 51 +++- libcloud/test/container/test_gke.py | 3 ++ 2 files changed, 13 insertions(+), 41 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/06c8ccb3/docs/container/drivers/gke.rst -- diff --git a/docs/container/drivers/gke.rst b/docs/container/drivers/gke.rst index d2c5548..930c8c6 100644 --- a/docs/container/drivers/gke.rst +++ b/docs/container/drivers/gke.rst @@ -1,58 +1,27 @@ Google Container Driver Documentation -`Google Container Platform`_ is a Docker hosting service, provided by Google. +`Google Container Platform`_ is a Kubernetes hosting service, provided by Google. Docker-native tools and elastic hosts make deploying on Google Cloud as easy as running Docker on your laptop. There is no special software to install or configure. -Mix Docker containers with container-native Linux to extend the benefits of containerization to legacy applications and stateful services. +Mix Kubernetes containers with container-native Linux to extend the benefits of containerization to legacy applications and stateful services. +Examples + -Instantiating the driver - - -Download the script:: - - - -Now execute the script, substituting the correct values:: - - - -This should output something similar to the following:: - -Setting up Docker client for SDC using: -CloudAPI:https://us-east-1.api.joyent.com -Account: jill -Key: /Users/localuser/.ssh/sdc-docker.id_rsa - -If you have a pass phrase on your key, the openssl command will -prompt you for your pass phrase now and again later. - -Verifying GoogleCloudAPI access. -CloudAPI access verified. - -Generating client certificate from SSH private key. -writing RSA key -Wrote certificate files to /Users/localuser/.sdc/docker/jill - -Get Docker host endpoint from cloudapi. -Docker service endpoint is: tcp://us-east-1.docker.joyent.com:2376 +Additional example code can be found in the "demos" directory of Libcloud here: +https://github.com/apache/libcloud/blob/trunk/demos/gce_demo.py -* * * -Success. Set your environment as follows: +1. Getting Driver with Service Account authentication +~ -export DOCKER_CERT_PATH=/Users/localuser/.sdc/docker/jill -export DOCKER_HOST=tcp://us-east-1.docker.joyent.com:2376 -export DOCKER_CLIENT_TIMEOUT=300 -export DOCKER_TLS_VERIFY=1 +.. literalinclude:: /examples/compute/gce/gce_service_account.py -.. literalinclude:: /examples/container/joyent/instantiate_driver.py - :language: python API Docs -.. autoclass:: libcloud.container.drivers.joyent.GoogleContainerDriver +.. autoclass:: libcloud.container.drivers.joyent.GKEContainerDriver :members: :inherited-members: http://git-wip-us.apache.org/repos/asf/libcloud/blob/06c8ccb3/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index 5b68de9..faa35c1 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -12,6 +12,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +""" +Tests for Google Container Engine Driver +""" import datetime import mock
[33/34] libcloud git commit: Merge branch 'github-1059' into trunk
Merge branch 'github-1059' into trunk Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/20bd5163 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/20bd5163 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/20bd5163 Branch: refs/heads/trunk Commit: 20bd51634252a1a581ff5d307c5c45a26a6831f1 Parents: 98c4fe0 35bdf4e Author: Anthony ShawAuthored: Thu Jun 22 13:09:04 2017 +1000 Committer: Anthony Shaw Committed: Thu Jun 22 13:09:04 2017 +1000 -- docs/container/drivers/gke.rst | 27 +++ .../container/gke/instantiate_driver.py | 9 + libcloud/compute/drivers/gce.py | 2 +- libcloud/container/drivers/gke.py | 179 +++ libcloud/container/drivers/kubernetes.py| 22 +-- libcloud/container/providers.py | 2 + libcloud/container/types.py | 1 + ...nes_us-central1-a_instance_serverconfig.json | 1 + .../fixtures/gke/zones_us-central1-a_list.json | 29 +++ libcloud/test/container/test_gke.py | 93 ++ libcloud/test/secrets.py-dist | 5 + 11 files changed, 359 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/20bd5163/libcloud/compute/drivers/gce.py --
[1/3] libcloud git commit: FAM-966 fixed block_device_mapping parsing in node's extra
Repository: libcloud Updated Branches: refs/heads/trunk 42839c65e -> a6d11ab75 FAM-966 fixed block_device_mapping parsing in node's extra Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/9020eca9 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/9020eca9 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/9020eca9 Branch: refs/heads/trunk Commit: 9020eca984115cddeedff6a021079b70c1eb9b58 Parents: 42839c6 Author: Hennadii StasAuthored: Wed Jun 14 18:31:56 2017 +0300 Committer: Anthony Shaw Committed: Thu Jun 22 13:12:51 2017 +1000 -- libcloud/compute/drivers/ec2.py | 44 +++- 1 file changed, 43 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/9020eca9/libcloud/compute/drivers/ec2.py -- diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py index 589c03a..94b8c75 100644 --- a/libcloud/compute/drivers/ec2.py +++ b/libcloud/compute/drivers/ec2.py @@ -2508,6 +2508,24 @@ OUTSCALE_INC_REGION_DETAILS = { Define the extra dictionary for specific resources """ RESOURCE_EXTRA_ATTRIBUTES_MAP = { +'ebs_instance_block_device': { +'attach_time': { +'xpath': 'ebs/attachTime', +'transform_func': parse_date +}, +'delete_on_termination': { +'xpath': 'ebs/deleteOnTermination', +'transform_func': str +}, +'status': { +'xpath': 'ebs/status', +'transform_func': str +}, +'volume_id': { +'xpath': 'ebs/volumeId', +'transform_func': str +} +}, 'ebs_volume': { 'snapshot_id': { 'xpath': 'ebs/snapshotId', @@ -6462,7 +6480,8 @@ class BaseEC2NodeDriver(NodeDriver): element, RESOURCE_EXTRA_ATTRIBUTES_MAP['node']) # Add additional properties to our extra dictionary -extra['block_device_mapping'] = self._to_device_mappings(element) +extra['block_device_mapping'] = self._to_instance_device_mappings( +element) extra['groups'] = self._get_security_groups(element) extra['network_interfaces'] = self._to_interfaces(element) extra['product_codes'] = product_codes @@ -6991,6 +7010,29 @@ class BaseEC2NodeDriver(NodeDriver): return mapping +def _to_instance_device_mappings(self, object): +return [self._to_instance_device_mapping(el) for el in object.findall( +fixxpath(xpath='blockDeviceMapping/item', namespace=NAMESPACE)) +] + +def _to_instance_device_mapping(self, element): +""" +Parse the XML element and return a dictionary of device properties. +Additional information can be found at https://goo.gl/OGK88a. + +:rtype: ``dict`` +""" +mapping = {} + +mapping['device_name'] = findattr(element=element, + xpath='deviceName', + namespace=NAMESPACE) +mapping['ebs'] = self._get_extra_dict( +element, +RESOURCE_EXTRA_ATTRIBUTES_MAP['ebs_instance_block_device']) + +return mapping + def _to_internet_gateways(self, object, xpath): return [self._to_internet_gateway(el) for el in object.findall(fixxpath(xpath=xpath,
[GitHub] libcloud pull request #1075: Fix Node.extra having incomplete block_device_m...
Github user asfgit closed the pull request at: https://github.com/apache/libcloud/pull/1075 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[3/3] libcloud git commit: changes for #1075
changes for #1075 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a6d11ab7 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a6d11ab7 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a6d11ab7 Branch: refs/heads/trunk Commit: a6d11ab7511788c27ce8ba712baf2531f87b15dc Parents: f30c0fc Author: Anthony ShawAuthored: Thu Jun 22 13:14:10 2017 +1000 Committer: Anthony Shaw Committed: Thu Jun 22 13:14:10 2017 +1000 -- CHANGES.rst | 5 + 1 file changed, 5 insertions(+) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/a6d11ab7/CHANGES.rst -- diff --git a/CHANGES.rst b/CHANGES.rst index da18a55..7954dfc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -26,6 +26,11 @@ Common Compute ~~~ +- [EC2] Fix node's Block Device Mapping was parsed from incorrect mapping. + EbsInstanceBlockDevice is different from EbsBlockDevice. + [GITHUB-1075] + (Gennadiy Stas) + - [GANDI] Fixes the location name in image and instance type classes [GITHUB-1065] (Sayoun)
[2/3] libcloud git commit: FAM-966 unittests improved Closes #1075
FAM-966 unittests improved Closes #1075 Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f30c0fc9 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f30c0fc9 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f30c0fc9 Branch: refs/heads/trunk Commit: f30c0fc9cf25839fbdc97754ff022d32c18ec8b8 Parents: 9020eca Author: Hennadii StasAuthored: Mon Jun 19 13:59:47 2017 +0300 Committer: Anthony Shaw Committed: Thu Jun 22 13:13:00 2017 +1000 -- libcloud/compute/drivers/ec2.py | 2 +- libcloud/test/compute/test_ec2.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/f30c0fc9/libcloud/compute/drivers/ec2.py -- diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py index 94b8c75..0397d2b 100644 --- a/libcloud/compute/drivers/ec2.py +++ b/libcloud/compute/drivers/ec2.py @@ -2513,7 +2513,7 @@ RESOURCE_EXTRA_ATTRIBUTES_MAP = { 'xpath': 'ebs/attachTime', 'transform_func': parse_date }, -'delete_on_termination': { +'delete': { 'xpath': 'ebs/deleteOnTermination', 'transform_func': str }, http://git-wip-us.apache.org/repos/asf/libcloud/blob/f30c0fc9/libcloud/test/compute/test_ec2.py -- diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py index adb39d3..14bb71f 100644 --- a/libcloud/test/compute/test_ec2.py +++ b/libcloud/test/compute/test_ec2.py @@ -237,7 +237,9 @@ class EC2Tests(LibcloudTestCase, TestCaseMixin): self.assertEqual(node.extra['block_device_mapping'][0]['device_name'], '/dev/sda1') self.assertEqual(node.extra['block_device_mapping'][0]['ebs']['volume_id'], 'vol-5e312311') self.assertTrue(node.extra['block_device_mapping'][0]['ebs']['delete']) - + self.assertEqual(node.extra['block_device_mapping'][0]['ebs']['status'], 'attached') + self.assertEqual(node.extra['block_device_mapping'][0]['ebs']['attach_time'], + datetime(2013, 4, 9, 18, 1, 1, tzinfo=UTC)) self.assertEqual(public_ips[0], '1.2.3.4') nodes = self.driver.list_nodes(ex_node_ids=['i-4382922a',
[GitHub] libcloud pull request #1076: Add SSL URI support for LIBCLOUD-458
GitHub user ayleph opened a pull request: https://github.com/apache/libcloud/pull/1076 Add SSL URI support for LIBCLOUD-458 Add an optional argument to retrieve the x-cdn-ssl-uri of a Cloud Files container. ## Changes Title (replace this with a logical title for your changes) ### Description Replace this with the PR description (mention the changes you have made, why you have made them, provide some background and any references to the provider documentation if needed, etc.). For more information on contributing, please see [Contributing](http://libcloud.readthedocs.org/en/latest/development.html#contributing) section of our documentation. ### Status Replace this: describe the PR status. Examples: - work in progress - done, ready for review ### Checklist (tick everything that applies) - [ ] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide) (required, can be done after the PR checks) - [ ] Documentation - [ ] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html) - [ ] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes) (required for bigger changes) You can merge this pull request into a Git repository by running: $ git pull https://github.com/ayleph/libcloud trunk Alternatively you can review and apply these changes as the patch at: https://github.com/apache/libcloud/pull/1076.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1076 commit e7a3ade5dc69d1953831d57a9c0fc2f1ba2b0b67 Author: aylephDate: 2017-06-22T05:13:17Z Add SSL URI support for LIBCLOUD-458 Add an optional argument to retrieve the x-cdn-ssl-uri of a Cloud Files container. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[14/34] libcloud git commit: update
update Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e459ef68 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e459ef68 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e459ef68 Branch: refs/heads/trunk Commit: e459ef6812441e391399815b0364363d1cb477f8 Parents: 06c8ccb Author: andyAuthored: Sat Jun 17 17:40:36 2017 -0400 Committer: andy Committed: Sat Jun 17 17:40:36 2017 -0400 -- libcloud/test/container/test_gke.py | 30 +- libcloud/test/secrets.py-dist | 4 2 files changed, 29 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/libcloud/blob/e459ef68/libcloud/test/container/test_gke.py -- diff --git a/libcloud/test/container/test_gke.py b/libcloud/test/container/test_gke.py index faa35c1..f38e5f5 100644 --- a/libcloud/test/container/test_gke.py +++ b/libcloud/test/container/test_gke.py @@ -35,9 +35,9 @@ from libcloud.compute.base import Node, StorageVolume from libcloud.test import MockHttp from libcloud.test.compute import TestCaseMixin -from libcloud.test.file_fixtures import ComputeFileFixtures +from libcloud.test.file_fixtures import ContainerFileFixtures -from libcloud.test.secrets import GCE_PARAMS, GCE_KEYWORD_PARAMS +from libcloud.test.secrets import GKE_PARAMS, GKE_KEYWORD_PARAMS class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): @@ -50,10 +50,10 @@ class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): datacenter = 'us-central1-a' def setUp(self): -GCEMockHttp.test = self -GCENodeDriver.connectionCls.conn_class = GCEMockHttp +GKEMockHttp.test = self +GKEContainerDriver.connectionCls.conn_class = GCEMockHttp GoogleBaseAuthConnection.conn_class = GoogleAuthMockHttp -GCEMockHttp.type = None +GKEMockHttp.type = None kwargs = GCE_KEYWORD_PARAMS.copy() kwargs['auth_type'] = 'IA' kwargs['datacenter'] = self.datacenter @@ -61,3 +61,23 @@ class GKEContainerDriverTestCase(GoogleTestCase, TestCaseMixin): def test_default_scopes(self): self.assertEqual(self.driver.scopes, None) + + +class GCEMockHttp(MockHttp): +fixtures = ContainerFileFixtures('gce') +json_hdr = {'content-type': 'application/json; charset=UTF-8'} + +def _get_method_name(self, type, use_param, qs, path): +api_path = '/container/%s' % API_VERSION +project_path = '/projects/%s' % GKE_KEYWORD_PARAMS['project'] +path = path.replace(api_path, '') +# This replace is separate, since there is a call with a different +# project name +path = path.replace(project_path, '') +# The path to get project information is the base path, so use a fake +# '/project' path instead +if not path: +path = '/project' +method_name = super(GKEMockHttp, self)._get_method_name( +type, use_param, qs, path) +return method_name http://git-wip-us.apache.org/repos/asf/libcloud/blob/e459ef68/libcloud/test/secrets.py-dist -- diff --git a/libcloud/test/secrets.py-dist b/libcloud/test/secrets.py-dist index b7faf32..1b30bf2 100644 --- a/libcloud/test/secrets.py-dist +++ b/libcloud/test/secrets.py-dist @@ -24,6 +24,10 @@ GANDI_PARAMS = ('user',) GCE_PARAMS = ('em...@developer.gserviceaccount.com', 'key') # Service Account Authentication # GCE_PARAMS = ('client_id', 'client_secret') # Installed App Authentication GCE_KEYWORD_PARAMS = {'project': 'project_name'} +GKE_PARAMS = ('em...@developer.gserviceaccount.com', 'key') # Service Account Authentication +# GCE_PARAMS = ('client_id', 'client_secret') # Installed App Authentication +GKE_KEYWORD_PARAMS = {'project': 'project_name'} + HOSTINGCOM_PARAMS = ('user', 'secret') IBM_PARAMS = ('user', 'secret') ONAPP_PARAMS = ('key')
[GitHub] libcloud pull request #1075: Fix Node.extra having incomplete block_device_m...
GitHub user uty opened a pull request: https://github.com/apache/libcloud/pull/1075 Fix Node.extra having incomplete block_device_mapping on EC2 ## Fix `Node.extra` having incomplete `block_device_mapping` on EC2 ### Description Fix node's Block Device Mapping was parsed from incorrect mapping. [EbsInstanceBlockDevice](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsInstanceBlockDevice.html) is different from [EbsBlockDevice](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html). ### Status - done, ready for review ### Checklist (tick everything that applies) - [x] [Code linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide) (required, can be done after the PR checks) - [ ] Documentation - [x] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html) - [ ] [ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes) (required for bigger changes) You can merge this pull request into a Git repository by running: $ git pull https://github.com/Scalr/libcloud for-upstream/ec2-instance-bdm Alternatively you can review and apply these changes as the patch at: https://github.com/apache/libcloud/pull/1075.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #1075 commit 9a950fde80ce383d3dbd8a937f9d8ddb2f0b3edb Author: Hennadii StasDate: 2017-06-14T15:31:56Z FAM-966 fixed block_device_mapping parsing in node's extra commit 8b9ab72c72afe8b7ee0b4e6dec03438977a79371 Author: Hennadii Stas Date: 2017-06-19T10:59:47Z FAM-966 unittests improved --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---