Пример #1
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})
Пример #2
0
    def test_create_node_ex_os_disk_delete(self):
        location = NodeLocation("any_location", "", "", self.driver)
        size = NodeSize("any_size", "", 0, 0, 0, 0, driver=self.driver)
        image = AzureImage("1", "1", "ubuntu", "pub", location.id, 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,
            ex_os_disk_delete=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("diskSizeGB" not in storage_profile["osDisk"])
        self.assertEqual(storage_profile["osDisk"]["deleteOption"], "Delete")
        self.assertTrue(
            storage_profile["imageReference"],
            {
                "publisher": image.publisher,
                "offer": image.offer,
                "sku": image.sku,
                "version": image.version,
            },
        )
Пример #3
0
    def test_create_node_compute_gallery_image(self):
        location = NodeLocation("any_location", "", "", self.driver)
        size = NodeSize("any_size", "", 0, 0, 0, 0, driver=self.driver)
        image = AzureComputeGalleryImage("sub-id00", "resource-group00",
                                         "gallery00", "image00", 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("diskSizeGB" not in storage_profile["osDisk"])
        self.assertTrue("deleteOption" not in storage_profile["osDisk"])
        self.assertTrue(
            storage_profile["imageReference"],
            {
                "id":
                "/subscriptions/sub-id00/resourceGroups/resource-group00/providers/Microsoft.Compute/galleries/gallery00/images/image00"
            },
        )
Пример #4
0
    def test_create_node_storage_account_not_provided_and_not_ex_use_managed_disks(
        self,
    ):
        location = NodeLocation("any_location", "", "", self.driver)
        size = NodeSize("any_size", "", 0, 0, 0, 0, driver=self.driver)
        image = AzureImage("1", "1", "ubuntu", "pub", location.id, self.driver)
        auth = NodeAuthPassword("any_password")

        # ex_storage_account=None and ex_use_managed_disks=False should throw
        expected_msg = "ex_use_managed_disks is False, must provide ex_storage_account"
        self.assertRaisesRegex(
            ValueError,
            expected_msg,
            self.driver.create_node,
            "test-node-1",
            size,
            image,
            auth,
            location=location,
            ex_resource_group="000000",
            ex_storage_account=None,
            ex_user_name="any_user",
            ex_network="000000",
            ex_subnet="000000",
            ex_use_managed_disks=False,
        )

        # ex_storage_account=None and ex_use_managed_disks=True, should not throw
        node = self.driver.create_node(
            "test-node-1",
            size,
            image,
            auth,
            location=location,
            ex_resource_group="000000",
            ex_storage_account=None,
            ex_user_name="any_user",
            ex_network="000000",
            ex_subnet="000000",
            ex_use_managed_disks=True,
        )
        self.assertTrue(node)
Пример #5
0
    def test_create_node_storage_account_not_provided_and_not_ex_use_managed_disks(
            self):
        location = NodeLocation('any_location', '', '', self.driver)
        size = NodeSize('any_size', '', 0, 0, 0, 0, driver=self.driver)
        image = AzureImage('1', '1', 'ubuntu', 'pub', location.id, self.driver)
        auth = NodeAuthPassword('any_password')

        # ex_storage_account=None and ex_use_managed_disks=False should throw
        expected_msg = "ex_use_managed_disks is False, must provide ex_storage_account"
        self.assertRaisesRegex(ValueError,
                               expected_msg,
                               self.driver.create_node,
                               'test-node-1',
                               size,
                               image,
                               auth,
                               location=location,
                               ex_resource_group='000000',
                               ex_storage_account=None,
                               ex_user_name='any_user',
                               ex_network='000000',
                               ex_subnet='000000',
                               ex_use_managed_disks=False)

        # ex_storage_account=None and ex_use_managed_disks=True, should not throw
        node = self.driver.create_node('test-node-1',
                                       size,
                                       image,
                                       auth,
                                       location=location,
                                       ex_resource_group='000000',
                                       ex_storage_account=None,
                                       ex_user_name='any_user',
                                       ex_network='000000',
                                       ex_subnet='000000',
                                       ex_use_managed_disks=True)
        self.assertTrue(node)