示例#1
0
    def test_vm_validator_retrieve_image_info_cross_subscription(self, factory_mock):
        ns = argparse.Namespace()
        cmd = mock.MagicMock()

        data_disk = mock.MagicMock()
        data_disk.storage_account_type = 'Standard_LRS'
        image_info = mock.MagicMock()
        client_mock = mock.MagicMock()
        image_info.storage_profile.os_disk.os_type.value = 'someOS'
        image_info.storage_profile.data_disks = [data_disk]
        client_mock.images.get.return_value = image_info
        factory_mock.return_value = client_mock

        ns.image = '/subscriptions/0b1f6471-1bf0-4dda-aec3-xxxxxxxxxxxx/resourceGroups/foo/providers/Microsoft.Compute/images/bar'
        ns.admin_username = '******'
        ns.admin_password = '******'
        ns.storage_sku = ['Premium_LRS']
        ns.ultra_ssd_enabled = None
        ns.os_caching, ns.data_caching = None, None
        ns.os_type, ns.attach_os_disk, ns.storage_account, ns.storage_container_name, ns.use_unmanaged_disk, ns.data_disk_sizes_gb = None, None, None, None, False, None
        ns.size = 'Standard_DS1_v2'
        _validate_vm_create_storage_profile(cmd, ns, False)

        self.assertEqual(ns.os_type, 'someOS')
        self.assertTrue(0 in ns.disk_info)
示例#2
0
    def test_vm_validator_retrieve_image_info_cross_subscription(
            self, factory_mock):
        ns = argparse.Namespace()
        cmd = mock.MagicMock()

        data_disk = mock.MagicMock()
        data_disk.storage_account_type = 'Standard_LRS'
        image_info = mock.MagicMock()
        client_mock = mock.MagicMock()
        image_info.storage_profile.os_disk.os_type.value = 'someOS'
        image_info.storage_profile.data_disks = [data_disk]
        client_mock.images.get.return_value = image_info
        factory_mock.return_value = client_mock

        ns.image = '/subscriptions/0b1f6471-1bf0-4dda-aec3-xxxxxxxxxxxx/resourceGroups/foo/providers/Microsoft.Compute/images/bar'
        ns.admin_username = '******'
        ns.admin_password = '******'
        ns.storage_sku = ['Premium_LRS']
        ns.ultra_ssd_enabled = None
        ns.os_caching, ns.data_caching = None, None
        ns.os_type, ns.attach_os_disk, ns.storage_account, ns.storage_container_name, ns.use_unmanaged_disk, ns.data_disk_sizes_gb = None, None, None, None, False, None
        ns.size = 'Standard_DS1_v2'
        _validate_vm_create_storage_profile(cmd, ns, False)

        self.assertEqual(ns.os_type, 'someOS')
        self.assertTrue(0 in ns.disk_info)
示例#3
0
    def test_vm_validator_retrieve_image_info_cross_subscription(
            self, factory_mock):
        ns = argparse.Namespace()
        cmd = mock.MagicMock()

        image_info = mock.MagicMock()
        client_mock = mock.MagicMock()
        image_info.storage_profile.os_disk.os_type.value = 'someOS'
        image_info.storage_profile.data_disks = ['does not matter']
        client_mock.images.get.return_value = image_info
        factory_mock.return_value = client_mock

        ns.image = '/subscriptions/0b1f6471-1bf0-4dda-aec3-xxxxxxxxxxxx/resourceGroups/foo/providers/Microsoft.Compute/images/bar'
        ns.admin_username = '******'
        ns.admin_password = '******'
        ns.storage_sku = 'Premium_LRS'
        ns.os_type, ns.attach_os_disk, ns.storage_account, ns.storage_container_name, ns.use_unmanaged_disk = None, None, None, None, False
        _validate_vm_create_storage_profile(cmd, ns, False)

        self.assertEqual(ns.os_type, 'someOS')
        self.assertEqual(ns.image_data_disks, ['does not matter'])