Пример #1
0
 def setUp(self):
     KamateraTestDriver.connectionCls.conn_class = KamateraMockHttp
     self.driver = KamateraTestDriver(*KAMATERA_PARAMS)
     self.eu_node_location = NodeLocation(
         id="EU", name="Amsterdam", country="The Netherlands", driver=self.driver
     )
     self.il_node_location = NodeLocation(
         id="IL", name="Rosh Haayin", country="Israel", driver=self.driver
     )
     self.centos_8_EU_node_image = NodeImage(
         id="EU:6000C2987c9641fd2619a149ba2ca01a",
         name="CentOS 8.0 64-bit - Minimal Configuration",
         driver=self.driver,
         extra={
             "datacenter": "EU",
             "os": "CentOS",
             "code": "8.0 64bit_minimal",
             "osDiskSizeGB": 5,
             "ramMBMin": {"A": 256, "B": 256, "T": 256, "D": 256},
         },
     )
     self.small_node_size = self.driver.ex_get_size(
         ramMB=4096,
         diskSizeGB=30,
         cpuType="B",
         cpuCores=2,
         monthlyTrafficPackage="t5000",
         id="small",
         name="small",
     )
 def setUp(self):
     KamateraTestDriver.connectionCls.conn_class = KamateraMockHttp
     self.driver = KamateraTestDriver(*KAMATERA_PARAMS)
     self.eu_node_location = NodeLocation(id='EU',
                                          name='Amsterdam',
                                          country='The Netherlands',
                                          driver=self.driver)
     self.il_node_location = NodeLocation(id='IL',
                                          name='Rosh Haayin',
                                          country='Israel',
                                          driver=self.driver)
     self.centos_8_EU_node_image = NodeImage(
         id='EU:6000C2987c9641fd2619a149ba2ca01a',
         name='CentOS 8.0 64-bit - Minimal Configuration',
         driver=self.driver,
         extra={
             'datacenter': 'EU',
             'os': 'CentOS',
             'code': '8.0 64bit_minimal',
             'osDiskSizeGB': 5,
             "ramMBMin": {
                 "A": 256,
                 "B": 256,
                 "T": 256,
                 "D": 256
             }
         })
     self.small_node_size = self.driver.ex_get_size(
         ramMB=4096,
         diskSizeGB=30,
         cpuType='B',
         cpuCores=2,
         monthlyTrafficPackage='t5000',
         id='small',
         name='small')
Пример #3
0
 def list_locations(self):
     return [
         NodeLocation("DCAUCKLAND", "RimuHosting Auckland", "NZ", self),
         NodeLocation("DCDALLAS", "RimuHosting Dallas", "US", self),
         NodeLocation("DCLONDON", "RimuHosting London", "GB", self),
         NodeLocation("DCSYDNEY", "RimuHosting Sydney", "AU", self),
     ]
Пример #4
0
 def list_locations(self):
     return [
         NodeLocation('DCAUCKLAND', "RimuHosting Auckland", 'NZ', self),
         NodeLocation('DCDALLAS', "RimuHosting Dallas", 'US', self),
         NodeLocation('DCLONDON', "RimuHosting London", 'GB', self),
         NodeLocation('DCSYDNEY', "RimuHosting Sydney", 'AU', self),
     ]
Пример #5
0
    def list_locations(self):
        """
        Lists available locations

        Locations cannot be set or retrieved via the API, but currently
        there are two locations, DFW and ORD.

        @inherits: :class:`OpenStack_1_0_NodeDriver.list_locations`
        """
        if self.region == 'us':
            locations = [NodeLocation(0, "Rackspace DFW1/ORD1", 'US', self)]
        elif self.region == 'uk':
            locations = [NodeLocation(0, 'Rackspace UK London', 'UK', self)]

        return locations
Пример #6
0
 def _to_location(self, loc):
     # XXX for some reason the API returns location names like
     # "East US" instead of "eastus" which is what is actually needed
     # for other API calls, so do a name->id fixup.
     loc_id = loc.lower().replace(" ", "")
     return NodeLocation(loc_id, loc, self._location_to_country.get(loc_id),
                         self.connection.driver)
Пример #7
0
    def test_create_node(self):
        location = NodeLocation('any_location', '', '', self.driver)
        size = NodeSize('any_size', '', 0, 0, 0, 0, driver=self.driver)
        image = NodeImage('1', '1', self.driver)
        auth = NodeAuthPassword('any_password')

        node = self.driver.create_node('test-node-1',
                                       size,
                                       image,
                                       auth,
                                       location=location,
                                       ex_resource_group='000000',
                                       ex_storage_account='000000',
                                       ex_user_name='any_user',
                                       ex_network='000000',
                                       ex_subnet='000000',
                                       ex_use_managed_disks=True)
        hardware_profile = node.extra['properties']['hardwareProfile']
        os_profile = node.extra['properties']['osProfile']
        storage_profile = node.extra['properties']['storageProfile']

        self.assertEqual(node.name, 'test-node-1')
        self.assertEqual(node.state, NodeState.UPDATING)
        self.assertEqual(node.private_ips, ['10.0.0.1'])
        self.assertEqual(node.public_ips, [])
        self.assertEqual(node.extra['location'], location.id)
        self.assertEqual(hardware_profile['vmSize'], size.id)
        self.assertEqual(os_profile['adminUsername'], 'any_user')
        self.assertEqual(os_profile['adminPassword'], 'any_password')
        self.assertTrue('managedDisk' in storage_profile['osDisk'])
        self.assertTrue(storage_profile['imageReference'], {'id': image.id})
Пример #8
0
 def _to_location(self, data):
     extra = data.get('features', [])
     return NodeLocation(id=data['slug'],
                         name=data['name'],
                         country=None,
                         extra=extra,
                         driver=self)
Пример #9
0
 def _to_locations(self, object):
     return [
         NodeLocation(element.attrib["label"],
                      element.findtext("description"),
                      element.findtext("description"), self)
         for element in object.findall('facilities/facility')
     ]
Пример #10
0
 def _to_location(self, data):
     name = data.get('location').get('city', '')
     country = data.get('location').get('country', '')
     return NodeLocation(id=data['slug'],
                         name=name,
                         country=country,
                         driver=self)
Пример #11
0
    def list_locations(self):
        """Lists available locations

        Locations cannot be set or retrieved via the API, but currently
        there are two locations, DFW and ORD.
        """
        return [NodeLocation(0, "Rackspace DFW1/ORD1", 'US', self)]
Пример #12
0
    def setUp(self):
        ECSMockHttp.test = self
        ECSDriver.connectionCls.conn_class = ECSMockHttp
        ECSMockHttp.use_param = "Action"
        ECSMockHttp.type = None

        self.driver = ECSDriver(*ECS_PARAMS, region=self.region)
        self.fake_size = NodeSize(
            "ecs.t1.small", "ecs t1 small", None, None, None, None, self.driver
        )
        self.fake_image = NodeImage(
            self.image_id, name="ubuntu 14.04 64bit", driver=self.driver
        )
        self.fake_node = Node(
            id="fake-node1",
            name="fake-node",
            state=NodeState.RUNNING,
            public_ips=None,
            private_ips=None,
            driver=self.driver,
        )
        self.fake_volume = StorageVolume(
            id="fake-volume1",
            name="fake-volume",
            size=self.fake_size,
            driver=self.driver,
        )
        self.fake_snapshot = VolumeSnapshot(id="fake-snapshot1", driver=self.driver)
        self.fake_location = NodeLocation(
            id=self.region, name=self.region, country=None, driver=self.driver
        )
        self.fake_instance_id = "fake_instance_id"
        self.fake_security_group_id = "fake_security_group_id"
Пример #13
0
    def test_ex_place_balancer_order(self):
        packages = self.driver.ex_list_balancer_packages()
        lb_package = [p for p in packages if p.capacity == 50][0]

        self.assertTrue(
            self.driver.ex_place_balancer_order(
                lb_package, NodeLocation("dal05", None, None, None)))
Пример #14
0
 def _to_location(self, data):
     return NodeLocation(
         id=data['id'],
         name=data['handle'],
         country='GB',
         driver=self
     )
Пример #15
0
    def _to_location(self, data):
        extra_keys = ['continent', 'state', 'ddos_protection',
                      'block_storage', 'regioncode']
        extra = self._helper.handle_extra(extra_keys, data)

        return NodeLocation(id=data['DCID'], name=data['name'],
                            country=data['country'], extra=extra, driver=self)
Пример #16
0
 def _to_location(self, data):
     extra = data
     return NodeLocation(id=data['id'],
                         name=data['name'],
                         country=None,
                         driver=self,
                         extra=extra)
Пример #17
0
    def list_locations(self):
        response = self.connection.request("api/datacenter")
        countries = {
            1: "RU",
            2: "CH",
            3: "GB",
            5: "RU",
            8: "RU",
            9: "RU",
            10: "RU",
            21: "DE",
            25: "RU",
            29: "NL",
            32: "RU",
        }

        locations = []
        for loc in response.object["datacenters"]:
            location_id = loc["id"]
            location_name = loc["name"]
            country = countries.get(location_id)
            if country:
                locations.append(
                    NodeLocation(location_id, location_name, country, self))
            else:
                warnings.warn(
                    f"Unknown datacenter: ({location_id}) {location_name}")
        return locations
Пример #18
0
    def setUp(self):
        ECSMockHttp.test = self
        ECSDriver.connectionCls.conn_classes = (ECSMockHttp, ECSMockHttp)
        ECSMockHttp.use_param = 'Action'
        ECSMockHttp.type = None

        self.driver = ECSDriver(*ECS_PARAMS, region=self.region)
        self.fake_size = NodeSize('ecs.t1.small', 'ecs t1 small', None, None,
                                  None, None, self.driver)
        self.fake_image = NodeImage(self.image_id,
                                    name='ubuntu 14.04 64bit',
                                    driver=self.driver)
        self.fake_node = Node(id='fake-node1',
                              name='fake-node',
                              state=NodeState.RUNNING,
                              public_ips=None,
                              private_ips=None,
                              driver=self.driver)
        self.fake_volume = StorageVolume(id='fake-volume1',
                                         name='fake-volume',
                                         size=self.fake_size,
                                         driver=self.driver)
        self.fake_snapshot = VolumeSnapshot(id='fake-snapshot1',
                                            driver=self.driver)
        self.fake_location = NodeLocation(id=self.region,
                                          name=self.region,
                                          country=None,
                                          driver=self.driver)
Пример #19
0
    def test_create_node_invalid_disk_size(self):
        image = NodeImage(id=1,
                          name='Ubuntu 8.10 (intrepid)',
                          driver=self.driver)
        size = NodeSize(1,
                        '256 slice',
                        None,
                        None,
                        None,
                        None,
                        driver=self.driver)
        location = NodeLocation(id=1,
                                name='Europe',
                                country='England',
                                driver=self.driver)

        try:
            self.driver.create_node(name='foo',
                                    image=image,
                                    size=size,
                                    location=location)
        except ValueError:
            pass
        else:
            self.fail('Invalid disk size provided but an exception was not'
                      ' thrown')
Пример #20
0
    def test_create_node(self):
        VoxelMockHttp.type = 'CREATE_NODE'
        image = NodeImage(id=1,
                          name='Ubuntu 8.10 (intrepid)',
                          driver=self.driver)
        size = NodeSize(1,
                        '256 slice',
                        1024,
                        500,
                        None,
                        None,
                        driver=self.driver)
        location = NodeLocation(id=1,
                                name='Europe',
                                country='England',
                                driver=self.driver)

        node = self.driver.create_node(name='foo',
                                       image=image,
                                       size=size,
                                       location=location)
        self.assertEqual(node.id, '1234')

        node = self.driver.create_node(name='foo',
                                       image=image,
                                       size=size,
                                       location=location,
                                       voxel_access=True)
        self.assertEqual(node.id, '1234')
Пример #21
0
    def run(self, credentials, name, size_id, image_id, location_id=None):
        driver = self._get_driver_for_credentials(credentials=credentials)
        size = NodeSize(id=size_id,
                        name=None,
                        ram=None,
                        disk=None,
                        bandwidth=None,
                        price=None,
                        driver=driver)
        image = NodeImage(id=image_id, name=None, driver=driver)
        location = NodeLocation(id=location_id,
                                name=None,
                                country=None,
                                driver=driver)

        self.logger.info('Creating node...')

        kwargs = {'name': name, 'size': size, 'image': image}

        if location_id:
            kwargs['location'] = location

        node = driver.create_node(**kwargs)

        self.logger.info('Node successfully created: %s' % (node))
        return node
Пример #22
0
    def list_locations(self):
        """
        List available facilities for deployment

        Retrieve all facilities that a Linode can be deployed in.

        @rtype: C{list} of L{NodeLocation}
        """
        params = {"api_action": "avail.datacenters"}
        data = self.connection.request(API_ROOT, params=params).objects[0]
        nl = []
        for dc in data:
            country = None
            if "USA" in dc["LOCATION"]:
                country = "US"
            elif "UK" in dc["LOCATION"]:
                country = "GB"
            elif "JP" in dc["LOCATION"]:
                country = "JP"
            else:
                country = "??"
            nl.append(
                NodeLocation(dc["DATACENTERID"], dc["LOCATION"], country,
                             self))
        return nl
Пример #23
0
 def __init__(self,
              tenant_id,
              subscription_id,
              key,
              secret,
              secure=True,
              host=None,
              port=None,
              api_version=None,
              region=None,
              **kwargs):
     self.tenant_id = tenant_id
     self.subscription_id = subscription_id
     super(AzureNodeDriver, self).__init__(key=key,
                                           secret=secret,
                                           secure=secure,
                                           host=host,
                                           port=port,
                                           api_version=api_version,
                                           region=region,
                                           **kwargs)
     if self.region is not None:
         loc_id = self.region.lower().replace(" ", "")
         country = self._location_to_country.get(loc_id)
         self.default_location = NodeLocation(loc_id, self.region, country,
                                              self)
     else:
         self.default_location = None
Пример #24
0
    def test_create_node_with_ssh_keys(self):
        image = NodeImage(id='01000000-0000-4000-8000-000030060200',
                          name='Ubuntu Server 16.04 LTS (Xenial Xerus)',
                          extra={'type': 'template'},
                          driver=self.driver)
        location = NodeLocation(id='fi-hel1',
                                name='Helsinki #1',
                                country='FI',
                                driver=self.driver)
        size = NodeSize(id='1xCPU-1GB',
                        name='1xCPU-1GB',
                        ram=1024,
                        disk=30,
                        bandwidth=2048,
                        extra={'storage_tier': 'maxiops'},
                        price=None,
                        driver=self.driver)

        auth = NodeAuthSSHKey('publikey')
        node = self.driver.create_node(name='test_server',
                                       size=size,
                                       image=image,
                                       location=location,
                                       auth=auth)
        self.assertTrue(
            re.match(
                '^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$',
                node.id))
        self.assertEquals(node.name, 'test_server')
        self.assertEquals(node.state, NodeState.STARTING)
        self.assertTrue(len(node.public_ips) > 0)
        self.assertTrue(len(node.private_ips) > 0)
        self.assertEquals(node.driver, self.driver)
Пример #25
0
 def _construct_node_location(self, zone):
     return NodeLocation(
         id=zone["id"],
         name=zone["description"],
         country=self._parse_country(zone["id"]),
         driver=self,
     )
Пример #26
0
 def _to_loc(self, loc):
     return NodeLocation(
         id=loc['id'],
         name=loc['name'],
         country=loc['country'],
         driver=self
     )
Пример #27
0
 def list_locations(self):
     """
     This feature does not exist in ECP. Returns hard coded dummy location.
     """
     return [
         NodeLocation(id=1, name="Cloud", country='', driver=self),
     ]
Пример #28
0
 def _to_location(self, data):
     location = NodeLocation(
         id=data['object_uuid'],
         name=data['name'],
         country=data['country'],
         driver=self.connection.driver,
     )
     return location
Пример #29
0
    def list_locations(self):
        """
        Returns a list of locations of nodes

        >>> from libcloud.compute.drivers.dummy import DummyNodeDriver
        >>> driver = DummyNodeDriver(0)
        >>> sorted([loc.name + " in " + loc.country for loc in
        ...         driver.list_locations()])
        ['Island Datacenter in FJ', 'London Loft in GB', "Paul's Room in US"]

        @inherits: :class:`NodeDriver.list_locations`
        """
        return [
            NodeLocation(id=1, name="Paul's Room", country="US", driver=self),
            NodeLocation(id=2, name="London Loft", country="GB", driver=self),
            NodeLocation(id=3, name="Island Datacenter", country="FJ", driver=self),
        ]
Пример #30
0
 def _to_location(self, vdc, dc, driver):
     """
     Generates the :class:`NodeLocation` class.
     """
     identifier = vdc.findtext('id')
     name = vdc.findtext('name')
     country = dc.findtext('name')
     return NodeLocation(identifier, name, country, driver)