Exemplo n.º 1
0
    def test_normal_migration(self):
        selected = [MountPoint("C:\\", 1024), MountPoint("E:\\", 2048)]

        source_credentials = Credentials("username", "password", "domain")
        storage = [
            MountPoint("C:\\", 1024),
            MountPoint("E:\\", 2048),
            MountPoint("D:\\", 2048)
        ]
        source = Workload("127.0.0.1", source_credentials, storage)

        cloud_credentials = Credentials("username", "password", "cloud")
        target = MigrationTarget(CloudType.vSphere, cloud_credentials, None)

        migration = Migration(selected, source, target)
        migration.run()
        self.assertEqual(migration.migration_target.target_vm.ip, "127.0.0.1")
        self.assertEqual(
            migration.migration_target.target_vm.credentials.username,
            "username")
        self.assertEqual(
            migration.migration_target.target_vm.credentials.password,
            "password")
        self.assertEqual(
            migration.migration_target.target_vm.credentials.domain, "domain")
        self.assertEqual(
            [(s.mount_point_name, s.size)
             for s in migration.migration_target.target_vm.storage],
            [('C:\\', 1024), ('E:\\', 2048)])
        self.assertEqual(migration.migration_state, MigrationState.SUCCESS)
Exemplo n.º 2
0
    def test_no_selected_storages_in_source(self):
        selected = [MountPoint("C:\\", 1024), MountPoint("E:\\", 2048)]

        source_credentials = Credentials("username", "password", "domain")
        storage = [MountPoint("D:\\", 2048), MountPoint("F:\\", 2048)]
        source = Workload("localhost", source_credentials, storage)

        cloud_credentials = Credentials("username", "password", "cloud")
        target = MigrationTarget(CloudType.vSphere, cloud_credentials, None)

        with self.assertRaises(Exception):
            migration = Migration(selected, source, target)
            migration.run()