libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [libcloud] Kami commented on a change in pull request #1305: adding gridscale driver to libcloud
Date Tue, 09 Jul 2019 15:34:02 GMT
Kami commented on a change in pull request #1305: adding gridscale driver to libcloud
URL: https://github.com/apache/libcloud/pull/1305#discussion_r301654196
 
 

 ##########
 File path: libcloud/compute/drivers/gridscale.py
 ##########
 @@ -0,0 +1,977 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+import json
+import time
+
+from libcloud.common.gridscale import GridscaleBaseDriver
+from libcloud.common.gridscale import GridscaleConnection
+from libcloud.compute.base import NodeImage, NodeLocation, VolumeSnapshot, \
+    Node, StorageVolume, KeyPair, NodeState, StorageVolumeState, NodeAuthSSHKey
+from libcloud.compute.providers import Provider
+from libcloud.utils.iso8601 import parse_date
+
+
+class GridscaleIp(object):
+    """
+    Ip Object
+
+    :param id: uuid
+    :type id: ``str``
+    :param family: family of ip (v4 or v6)
+    :type family: ``str``
+    :param prefix: prefix of ip
+    :type prefix: ``str``
+    :param ip_address: Ip address
+    :type ip_address: ``str``
+    :param create_time: Time ip was created
+    :type create_time: ``str``
+    """
+
+    def __init__(self, id, family, prefix, create_time, address):
+        self.id = id
+        self.family = family
+        self.prefix = prefix
+        self.create_time = create_time
+        self.ip_address = address
+
+    def __repr__(self):
+        return ('Ip: id={}, family={}, prefix={}, create_time={},Ip_address={}'
+                .format(self.id, self.family,
+                        self.prefix,
+                        self.create_time,
+                        self.ip_address))
+
+
+class GridscaleNetwork(object):
+    """
+    Network Object
+
+    :param id: uuid
+    :type id: ``str``
+    :param name: Name of Network
+    :type name: ``str``
+    :param status: Network status
+    :type status: ``str``
+    :param relations: object related to network
+    :type relations: ``object``
+    :param create_time: Time Network was created
+    :type create_time: ``str``
+    """
+
+    def __init__(self, id, name, status, create_time, relations):
+        self.id = id
+        self.name = name
+        self.status = status
+        self.create_time = create_time
+        self.relations = relations
+
+    def __repr__(self):
+        return ('Network: id={}, name={}, status={}, create_time={}, '
+                'relations={}'.format(self.id, self.name, self.status,
+                                      self.create_time, self.relations))
+
+
+class GridscaleNodeDriver(GridscaleBaseDriver):
+    """
+    create and entry in libcloud/compute/providers for gridscale
+    """
+    connectionCls = GridscaleConnection
+    type = Provider.GRIDSCALE
+    name = 'gridscale'
+    website = 'https://gridscale.io'
+
+    def __init__(self, user_id, key, **kwargs):
+        super(GridscaleNodeDriver, self).__init__(user_id, key, **kwargs)
+
+    def list_nodes(self):
+        """
+        List all nodes.
+
+        :return: List of node objects
+        :rtype: ``list`` of :class:`.Node`
+        """
+        result = self._sync_request(data=None, endpoint='objects/servers/')
+        nodes = []
+        for key, value in self._get_response_dict(result).items():
+            node = self._to_node(value)
+            nodes.append(node)
+            continue
 
 Review comment:
   This continue here is redundant, but not a blocker.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message