You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2019/07/06 09:27:25 UTC

[libcloud] branch trunk updated (7a6b625 -> c7c5cb8)

This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git.


    from 7a6b625  Add changelog entry for #1301.
     add 268f647  pricing + packet.net
     add 20e4412  pep8 packet.net
     add 2d1a999  remove forgotten print
     add cfd95ba  packet.net error handling
     add 7abf942  Include cpu info in extra key
     add e2787f4  Return locations code instead of name
     add 162cbe1  Return size id because size name returned by list_nodes is different than the one returned by list_sizes
     add a179aac  Extend the Packet driver
     add 44e37d5  Fix linter errors
     add e6f77f8  Fix linter warning
     add c7bb63b  Update Packet URL & logo
     add 77d33cd  Use asyncio instead of multiprocessing to parallelize requests in Packet driver in case of Python3, while maintaining Python2 compatibility
     add 65b5158  Fix flake8 errors
     add 2d1864a  Fix flake8 error
     add 9f0f19a  Add ip assignment methods & tests
     add 1a6a1c5  Add volume methods in Packet compute driver
     add 4d61c13  Add attach_volume, detach_volume & volume tests for Packet
     add e7561fe  Fix indentation
     add 8bd705b  Add extra metadata in locations, use proper location id in Packet driver, save location code in extra, add ex_describe_attachment in Packet driver
     add 32c6de3  Optionally specify node when detaching volume in Packet driver, return full facility dict in extra
     add 14c2b75  Call attach_volume if disk is given as arg of create_node
     add ad11dfb  Create and attach a new volme if disk_size has been given in crceate_node
     add ca8e25b  Assign ips upon machine creation
     add 9282873  Assign ips upon machine creation
     add 6d18930  Rename Packet specific methods
     new 68ecf5b  Merge branch 'packet-driver-extensions-cherrypick' of https://github.com/mistio/libcloud into mistio-packet-driver-extensions-cherrypick
     new f82502a  Fix GCE driver tests failure which were failing because of the new ``extra`` attribute which was added to the base ``NodeLocation`` class.
     new 5403fdd  Add changelog entry for #1282.
     new 20e1874  Fix lint.
     new 8e2e9b1  Retrieve list of projects lazily on first access to self.projects variable instead of doing it inside the constructor.
     new c7c5cb8  Merge branch 'mistio-packet-driver-extensions-cherrypick' into trunk

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.rst                                        |   9 +-
 docs/_static/images/provider_logos/packet.png      | Bin 41262 -> 44295 bytes
 docs/_static/images/provider_logos/packetnet.png   | Bin 17846 -> 0 bytes
 docs/compute/_supported_methods_block_storage.rst  |   2 +-
 .../_supported_methods_image_management.rst        |   2 +-
 .../_supported_methods_key_pair_management.rst     |   2 +-
 docs/compute/_supported_methods_main.rst           |   2 +-
 docs/compute/_supported_providers.rst              |   2 +-
 docs/compute/drivers/packet.rst                    |   4 +-
 libcloud/compute/base.py                           |   3 +-
 libcloud/compute/drivers/gce.py                    |   2 +-
 libcloud/compute/drivers/packet.py                 | 677 +++++++++++++++++++--
 libcloud/data/pricing.json                         |   9 +
 .../test/compute/fixtures/packet/associate_ip.json |  36 ++
 .../compute/fixtures/packet/attach_volume.json     |  11 +
 .../fixtures/packet/bgp_config_project_1.json      |  17 +
 .../fixtures/packet/bgp_config_project_2.json      |  17 +
 .../fixtures/packet/bgp_config_project_3.json      |   1 +
 .../fixtures/packet/bgp_session_create.json        |  14 +
 .../compute/fixtures/packet/bgp_session_get.json   |  14 +
 .../test/compute/fixtures/packet/bgp_sessions.json |  16 +
 .../compute/fixtures/packet/create_volume.json     |  38 ++
 .../compute/fixtures/packet/device_events.json     | 202 ++++++
 libcloud/test/compute/fixtures/packet/devices.json |   2 +-
 .../fixtures/packet/devices_for_project.json       | 440 +++++++++++++
 .../test/compute/fixtures/packet/ip_address.json   |  38 ++
 .../compute/fixtures/packet/ip_assignments.json    | 178 ++++++
 .../compute/fixtures/packet/node_bandwidth.json    | 139 +++++
 .../compute/fixtures/packet/project_events.json    |  95 +++
 .../test/compute/fixtures/packet/project_ips.json  | 191 ++++++
 .../test/compute/fixtures/packet/projects.json     | 125 ++++
 .../test/compute/fixtures/packet/reserve_ip.json   |  29 +
 libcloud/test/compute/fixtures/packet/volumes.json | 122 ++++
 libcloud/test/compute/test_packet.py               | 291 ++++++++-
 34 files changed, 2683 insertions(+), 47 deletions(-)
 delete mode 100644 docs/_static/images/provider_logos/packetnet.png
 create mode 100644 libcloud/test/compute/fixtures/packet/associate_ip.json
 create mode 100644 libcloud/test/compute/fixtures/packet/attach_volume.json
 create mode 100644 libcloud/test/compute/fixtures/packet/bgp_config_project_1.json
 create mode 100644 libcloud/test/compute/fixtures/packet/bgp_config_project_2.json
 create mode 100644 libcloud/test/compute/fixtures/packet/bgp_config_project_3.json
 create mode 100644 libcloud/test/compute/fixtures/packet/bgp_session_create.json
 create mode 100644 libcloud/test/compute/fixtures/packet/bgp_session_get.json
 create mode 100644 libcloud/test/compute/fixtures/packet/bgp_sessions.json
 create mode 100644 libcloud/test/compute/fixtures/packet/create_volume.json
 create mode 100644 libcloud/test/compute/fixtures/packet/device_events.json
 create mode 100644 libcloud/test/compute/fixtures/packet/devices_for_project.json
 create mode 100644 libcloud/test/compute/fixtures/packet/ip_address.json
 create mode 100644 libcloud/test/compute/fixtures/packet/ip_assignments.json
 create mode 100644 libcloud/test/compute/fixtures/packet/node_bandwidth.json
 create mode 100644 libcloud/test/compute/fixtures/packet/project_events.json
 create mode 100644 libcloud/test/compute/fixtures/packet/project_ips.json
 create mode 100644 libcloud/test/compute/fixtures/packet/projects.json
 create mode 100644 libcloud/test/compute/fixtures/packet/reserve_ip.json
 create mode 100644 libcloud/test/compute/fixtures/packet/volumes.json


[libcloud] 05/06: Retrieve list of projects lazily on first access to self.projects variable instead of doing it inside the constructor.

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 8e2e9b18d0db61cb16947ce00f227c76e944f13c
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Thu Jul 4 23:34:35 2019 +0200

    Retrieve list of projects lazily on first access to self.projects
    variable instead of doing it inside the constructor.
    
    Also perform project_id assignment lazily as part of the same method.
---
 libcloud/compute/drivers/packet.py | 56 ++++++++++++++++++++++++++++++--------
 1 file changed, 44 insertions(+), 12 deletions(-)

diff --git a/libcloud/compute/drivers/packet.py b/libcloud/compute/drivers/packet.py
index 683c844..86521d6 100644
--- a/libcloud/compute/drivers/packet.py
+++ b/libcloud/compute/drivers/packet.py
@@ -100,21 +100,53 @@ class PacketNodeDriver(NodeDriver):
                       'active': NodeState.RUNNING}
 
     def __init__(self, key, project=None):
-        # initialize a NodeDriver for Packet using the API token
-        # and optionally the project (name or id)
-        # If project specified we need to be sure this is a valid project
-        # so we create the variable self.project_id
+        """
+        Initialize a NodeDriver for Packet using the API token
+        and optionally the project (name or id).
+
+        If project name is specified we validate it lazily and populate
+        self.project_id during the first access of self.projects variable
+        """
         super(PacketNodeDriver, self).__init__(key=key)
+
         self.project_name = project
         self.project_id = None
-        self.projects = self.ex_list_projects()
-        if project:
-            for project_obj in self.projects:
-                if project in [project_obj.name, project_obj.id]:
-                    self.project_id = project_obj.id
-                    break
-            if not self.project_id:
-                self.project_name = None
+
+        # Lazily populated on first access to self.project
+        self._project = project
+
+        # Variable which indicates if self._projects has been populated yet and
+        # has been called self._project validated
+        self._projects_populated = False
+        self._projects = None
+
+    @property
+    def projects(self):
+        """
+        Lazily retrieve projects and set self.project_id variable on initial
+        access to self.projects variable.
+        """
+        if not self._projects_populated:
+            # NOTE: Each Packet account needs at least one project, but to be
+            # on the safe side and avoid infinite loop in case there are no
+            # projects on the account, we don't use a more robust way to
+            # determine if project list has been populated yet
+            self._projects = self.ex_list_projects()
+            self._projects_populated = True
+
+            # If project name is specified, verify it's valid and populate
+            # self.project_id
+            if self._project:
+                for project_obj in self._projects:
+                    if self._project in [project_obj.name, project_obj.id]:
+                        self.project_id = project_obj.id
+                        break
+
+                if not self.project_id:
+                    # Invalid project name
+                    self.project_name = None
+
+        return self._projects
 
     def ex_list_projects(self):
         projects = []


[libcloud] 04/06: Fix lint.

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 20e1874fa5959b813a304a41043e6d665111c163
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Thu Jul 4 23:27:45 2019 +0200

    Fix lint.
---
 libcloud/compute/drivers/packet.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/libcloud/compute/drivers/packet.py b/libcloud/compute/drivers/packet.py
index 376daa9..683c844 100644
--- a/libcloud/compute/drivers/packet.py
+++ b/libcloud/compute/drivers/packet.py
@@ -172,7 +172,7 @@ def _list_async(driver):
         return loop.run_until_complete(loc['_list_async'](loc['self']))
 
     def ex_list_nodes_for_project(self, ex_project_id, include='plan', page=1,
-                               per_page=1000):
+                                  per_page=1000):
         params = {
             'include': include,
             'page': page,
@@ -199,7 +199,8 @@ def _list_async(driver):
                 size.get('line') == 'baremetal']
 
     def create_node(self, name, size, image, location,
-                    ex_project_id=None, ip_addresses=[], cloud_init=None, **kwargs):
+                    ex_project_id=None, ip_addresses=[], cloud_init=None,
+                    **kwargs):
         """
         Create a node.
 
@@ -236,7 +237,8 @@ def _list_async(driver):
         if kwargs.get('disk'):
             self.attach_volume(node, kwargs.get('disk'))
         if kwargs.get('disk_size'):
-            volume = self.create_volume(size=kwargs.get('disk_size'), location=location)
+            volume = self.create_volume(size=kwargs.get('disk_size'),
+                                        location=location)
             self.attach_volume(node, volume)
         return node
 
@@ -574,7 +576,8 @@ def _list_async(driver):
 
     def list_volumes(self, ex_project_id=None):
         if ex_project_id:
-            return self.ex_list_volumes_for_project(ex_project_id=ex_project_id)
+            return self.ex_list_volumes_for_project(
+                ex_project_id=ex_project_id)
 
         # if project has been specified during driver initialization, then
         # return nodes for this project only
@@ -593,8 +596,8 @@ def _list_async(driver):
         # In case of Python3 use asyncio to perform requests in parallel
         return self.list_resources_async('volumes')
 
-    def ex_list_volumes_for_project(self, ex_project_id, include='plan', page=1,
-                                 per_page=1000):
+    def ex_list_volumes_for_project(self, ex_project_id, include='plan',
+                                    page=1, per_page=1000):
         params = {
             'include': include,
             'page': page,


[libcloud] 03/06: Add changelog entry for #1282.

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 5403fdd327d4b225cdb815cc952ec454ebab4a39
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Thu Jul 4 23:26:32 2019 +0200

    Add changelog entry for #1282.
---
 CHANGES.rst | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/CHANGES.rst b/CHANGES.rst
index 23641d3..c4bb7bd 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -12,6 +12,8 @@ General
   possible and the first project which was returned by the API was always
   selected. (GITHUB-1293)
   [Miguel Caballer - @micafer]
+- Add new ``extra`` attribute to the base ``NodeLocation`` class. (GITHUB-1282)
+  [Dimitris Moraitis - @d-mo]
 
 Compute
 ~~~~~~~
@@ -29,6 +31,11 @@ Compute
 - [OpenStack] Fix a bug with retrieving floating IP address when a
   ``device_owner`` of a port is ``compute:None``. (GITHUB-1295)
   [Miguel Caballer - @micafer]
+- [Packet] Add various new extension methods to Packet.net driver
+  (``ex_reinstall_node``, ``ex_list_projects``,
+  ``ex_get_bgp_config_for_project``, ``ex_get_bgp_config``,
+  ``ex_list_nodes_for_project``, etc.). (GITHUB-1282)
+  [Dimitris Moraitis - @d-mo]
 
 - [Maxihost] Add new compute driver for Maxihost provider
   (https://www.maxihost.com/). (GITHUB-1298)


[libcloud] 01/06: Merge branch 'packet-driver-extensions-cherrypick' of https://github.com/mistio/libcloud into mistio-packet-driver-extensions-cherrypick

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit 68ecf5b24b55d90388c49afa374fdc965b3985a6
Merge: c77fa8b 6d18930
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Thu Jul 4 23:19:44 2019 +0200

    Merge branch 'packet-driver-extensions-cherrypick' of https://github.com/mistio/libcloud into mistio-packet-driver-extensions-cherrypick

 CHANGES.rst                                        |   2 +-
 docs/_static/images/provider_logos/packet.png      | Bin 41262 -> 44295 bytes
 docs/_static/images/provider_logos/packetnet.png   | Bin 17846 -> 0 bytes
 docs/compute/_supported_methods_block_storage.rst  |   2 +-
 .../_supported_methods_image_management.rst        |   2 +-
 .../_supported_methods_key_pair_management.rst     |   2 +-
 docs/compute/_supported_methods_main.rst           |   2 +-
 docs/compute/_supported_providers.rst              |   2 +-
 docs/compute/drivers/packet.rst                    |   4 +-
 libcloud/compute/base.py                           |   3 +-
 libcloud/compute/drivers/packet.py                 | 642 +++++++++++++++++++--
 libcloud/data/pricing.json                         |   9 +
 .../test/compute/fixtures/packet/associate_ip.json |  36 ++
 .../compute/fixtures/packet/attach_volume.json     |  11 +
 .../fixtures/packet/bgp_config_project_1.json      |  17 +
 .../fixtures/packet/bgp_config_project_2.json      |  17 +
 .../fixtures/packet/bgp_config_project_3.json      |   1 +
 .../fixtures/packet/bgp_session_create.json        |  14 +
 .../compute/fixtures/packet/bgp_session_get.json   |  14 +
 .../test/compute/fixtures/packet/bgp_sessions.json |  16 +
 .../compute/fixtures/packet/create_volume.json     |  38 ++
 .../compute/fixtures/packet/device_events.json     | 202 +++++++
 libcloud/test/compute/fixtures/packet/devices.json |   2 +-
 .../fixtures/packet/devices_for_project.json       | 440 ++++++++++++++
 .../test/compute/fixtures/packet/ip_address.json   |  38 ++
 .../compute/fixtures/packet/ip_assignments.json    | 178 ++++++
 .../compute/fixtures/packet/node_bandwidth.json    | 139 +++++
 .../compute/fixtures/packet/project_events.json    |  95 +++
 .../test/compute/fixtures/packet/project_ips.json  | 191 ++++++
 .../test/compute/fixtures/packet/projects.json     | 125 ++++
 .../test/compute/fixtures/packet/reserve_ip.json   |  29 +
 libcloud/test/compute/fixtures/packet/volumes.json | 122 ++++
 libcloud/test/compute/test_packet.py               | 291 +++++++++-
 33 files changed, 2640 insertions(+), 46 deletions(-)



[libcloud] 06/06: Merge branch 'mistio-packet-driver-extensions-cherrypick' into trunk

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit c7c5cb84d4a356aa648f19288edc848d0a7a76eb
Merge: 7a6b625 8e2e9b1
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sat Jul 6 11:20:00 2019 +0200

    Merge branch 'mistio-packet-driver-extensions-cherrypick' into trunk
    
    Closes #1282.

 CHANGES.rst                                        |   9 +-
 docs/_static/images/provider_logos/packet.png      | Bin 41262 -> 44295 bytes
 docs/_static/images/provider_logos/packetnet.png   | Bin 17846 -> 0 bytes
 docs/compute/_supported_methods_block_storage.rst  |   2 +-
 .../_supported_methods_image_management.rst        |   2 +-
 .../_supported_methods_key_pair_management.rst     |   2 +-
 docs/compute/_supported_methods_main.rst           |   2 +-
 docs/compute/_supported_providers.rst              |   2 +-
 docs/compute/drivers/packet.rst                    |   4 +-
 libcloud/compute/base.py                           |   3 +-
 libcloud/compute/drivers/gce.py                    |   2 +-
 libcloud/compute/drivers/packet.py                 | 677 +++++++++++++++++++--
 libcloud/data/pricing.json                         |   9 +
 .../test/compute/fixtures/packet/associate_ip.json |  36 ++
 .../compute/fixtures/packet/attach_volume.json     |  11 +
 .../fixtures/packet/bgp_config_project_1.json      |  17 +
 .../fixtures/packet/bgp_config_project_2.json      |  17 +
 .../fixtures/packet/bgp_config_project_3.json      |   1 +
 .../fixtures/packet/bgp_session_create.json        |  14 +
 .../compute/fixtures/packet/bgp_session_get.json   |  14 +
 .../test/compute/fixtures/packet/bgp_sessions.json |  16 +
 .../compute/fixtures/packet/create_volume.json     |  38 ++
 .../compute/fixtures/packet/device_events.json     | 202 ++++++
 libcloud/test/compute/fixtures/packet/devices.json |   2 +-
 .../fixtures/packet/devices_for_project.json       | 440 +++++++++++++
 .../test/compute/fixtures/packet/ip_address.json   |  38 ++
 .../compute/fixtures/packet/ip_assignments.json    | 178 ++++++
 .../compute/fixtures/packet/node_bandwidth.json    | 139 +++++
 .../compute/fixtures/packet/project_events.json    |  95 +++
 .../test/compute/fixtures/packet/project_ips.json  | 191 ++++++
 .../test/compute/fixtures/packet/projects.json     | 125 ++++
 .../test/compute/fixtures/packet/reserve_ip.json   |  29 +
 libcloud/test/compute/fixtures/packet/volumes.json | 122 ++++
 libcloud/test/compute/test_packet.py               | 291 ++++++++-
 34 files changed, 2683 insertions(+), 47 deletions(-)



[libcloud] 02/06: Fix GCE driver tests failure which were failing because of the new ``extra`` attribute which was added to the base ``NodeLocation`` class.

Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit f82502af1511f4261996b0171f5dae8eb47a9109
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Thu Jul 4 23:25:10 2019 +0200

    Fix GCE driver tests failure which were failing because of the new
    ``extra`` attribute which was added to the base ``NodeLocation`` class.
---
 libcloud/compute/drivers/gce.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 317898f..5930936 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -1630,7 +1630,7 @@ class GCEZone(NodeLocation):
         self.extra = extra
         country = name.split('-')[0]
         super(GCEZone, self).__init__(id=str(id), name=name, country=country,
-                                      driver=driver)
+                                      driver=driver, extra=extra)
 
     @property
     def time_until_mw(self):