Kami commented on a change in pull request #1282: Packet driver extensions
URL: https://github.com/apache/libcloud/pull/1282#discussion_r296445771
 
 

 ##########
 File path: libcloud/compute/drivers/packet.py
 ##########
 @@ -88,11 +98,88 @@ class PacketNodeDriver(NodeDriver):
                       'failed': NodeState.ERROR,
                       'active': NodeState.RUNNING}
 
-    def list_nodes(self, ex_project_id):
-        data = self.connection.request('/projects/%s/devices' %
-                                       (ex_project_id),
-                                       params={'include': 'plan'}
-                                       ).object['devices']
+    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
+        super(PacketNodeDriver, self).__init__(key=key, project=None)
+        self.project_name = project
+        self.project_id = None
+        self.projects = self.ex_list_projects()
 
 Review comment:
   Performing any kind of long running operations inside the constructor is not 
the best thing to do.
   
   One approach would be to run this code lazily during the first HTTP request 
if ``self.project_id`` or ``self.project_name`` variable is not set yet.
   
   In addition to that, there could be some kind of argument / method which 
user could use to force check if a specified project is valid. Perhaps 
``ex_validate_project`` argument in this method which defaults to False or 
similar.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to