def migratable_vc_domains(self): """ Gets the VC Migration Manager API client. Returns: MigratableVcDomains: """ if not self.__migratable_vc_domains: self.__migratable_vc_domains = MigratableVcDomains(self.__connection) return self.__migratable_vc_domains
def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self.vcmigrationmanager = MigratableVcDomains(self.connection)
class MigratableVcDomainsTest(TestCase): def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self.vcmigrationmanager = MigratableVcDomains(self.connection) @mock.patch.object(ResourceClient, 'create') def test_test_compatibility(self, mock_create): timeoutValue = 26 migrationInformation = MigratableVcDomains. \ make_migration_information('192.168.9.32', 'Administrator', 'password', 'Administrator', 'password', enclosureGroupUri='/rest/enclosure-groups/uri') self.vcmigrationmanager.test_compatibility(migrationInformation, timeout=timeoutValue) mock_create.assert_called_once_with(migrationInformation, timeout=timeoutValue) @mock.patch.object(ResourceClient, 'create') def test_test_compatibility_default(self, mock_create): migrationInformation = MigratableVcDomains. \ make_migration_information('192.168.9.32', 'Administrator', 'password', 'Administrator', 'password', enclosureGroupUri='/rest/enclosure-groups/uri') self.vcmigrationmanager.test_compatibility(migrationInformation) mock_create.assert_called_once_with(migrationInformation, timeout=-1) @mock.patch.object(ResourceClient, 'get') def test_get_migration_report(self, mock_get): uri = '/rest/migratable-vc-domains/uri' self.vcmigrationmanager.get_migration_report(uri) mock_get.assert_called_once_with(uri) @mock.patch.object(ResourceClient, 'update') def test_migrate_with_full_uri(self, mock_update): migrationInformation = { 'migrationState': 'Migrated', 'type': 'migratable-vc-domains', 'category': 'migratable-vc-domains' } uriValue = '/rest/migratable-vc-domains/uri' timeoutValue = 26 self.vcmigrationmanager.migrate(uriValue, timeout=timeoutValue) mock_update.assert_called_once_with(migrationInformation, uri=uriValue, timeout=timeoutValue) @mock.patch.object(ResourceClient, 'update') def test_migrate_with_id(self, mock_update): migrationInformation = { 'migrationState': 'Migrated', 'type': 'migratable-vc-domains', 'category': 'migratable-vc-domains' } id = 'uri' uriValue = '/rest/migratable-vc-domains/' + id timeoutValue = 26 self.vcmigrationmanager.migrate(id, timeout=timeoutValue) mock_update.assert_called_once_with(migrationInformation, uri=uriValue, timeout=timeoutValue) @mock.patch.object(ResourceClient, 'update') def test_migrate_default(self, mock_update): migrationInformation = { 'migrationState': 'Migrated', 'type': 'migratable-vc-domains', 'category': 'migratable-vc-domains' } uriValue = '/rest/migratable-vc-domains/uri' self.vcmigrationmanager.migrate(uriValue) mock_update.assert_called_once_with(migrationInformation, uri=uriValue, timeout=-1) @mock.patch.object(ResourceClient, 'delete') def test_delete(self, mock_delete): timeoutValue = 26 uriValue = '/rest/migratable-vc-domains/uri' self.vcmigrationmanager.delete(uriValue, timeout=timeoutValue) mock_delete.assert_called_once_with(uriValue, timeout=timeoutValue) @mock.patch.object(ResourceClient, 'delete') def test_delete_default(self, mock_delete): uriValue = '/rest/migratable-vc-domains/uri' self.vcmigrationmanager.delete(uriValue) mock_delete.assert_called_once_with(uriValue, timeout=-1)
} pp = PrettyPrinter() # Try load config from a file (if there is a config file) print("Loading configuration.") config = try_load_from_file(config) # Obtain the master OneView client print("Setting up OneView client.") oneview_client = OneViewClient(config) # Create the dict that VC Migration Manager requires to start the process migrationInformation = MigratableVcDomains.make_migration_information(config['enclosure_hostname'], config['enclosure_username'], config['enclosure_password'], config['vcmUsername'], config['vcmPassword'], enclosureGroupUri=config['enclosure_group_uri']) # Start a migration by first creating a compatibility report print("Create a compatibility report for enclosure '%s'." % migrationInformation['credentials']['oaIpAddress']) compatibility_report = oneview_client.migratable_vc_domains.test_compatibility(migrationInformation) print("Complete. Created a compatibility report for enclosure '%s'.\n uri = '%s'" % (compatibility_report['credentials']['oaIpAddress'], compatibility_report['uri'])) # We got the compatibility report as part of the previous call, but one may need to get it later on print("Get the '%s' compatibility report." % compatibility_report['credentials']['oaIpAddress']) compatibility_report = oneview_client.migratable_vc_domains.get_migration_report(compatibility_report['uri']) print("Complete. Obtained the compatibility report for '%s'.\n Here is the compatibility report:" % compatibility_report['credentials']['oaIpAddress']) pp.pprint(compatibility_report)
pp = PrettyPrinter() # Try load config from a file (if there is a config file) print("Loading configuration.") config = try_load_from_file(config) # Obtain the master OneView client print("Setting up OneView client.") oneview_client = OneViewClient(config) # Create the dict that VC Migration Manager requires to start the process migrationInformation = MigratableVcDomains.make_migration_information( config['enclosure_hostname'], config['enclosure_username'], config['enclosure_password'], config['vcmUsername'], config['vcmPassword'], enclosureGroupUri=config['enclosure_group_uri']) # Start a migration by first creating a compatibility report print("Create a compatibility report for enclosure '%s'." % migrationInformation['credentials']['oaIpAddress']) compatibility_report = oneview_client.migratable_vc_domains.test_compatibility( migrationInformation) print( "Complete. Created a compatibility report for enclosure '%s'.\n uri = '%s'" % (compatibility_report['credentials']['oaIpAddress'], compatibility_report['uri'])) # We got the compatibility report as part of the previous call, but one may need to get it later on
def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self.vcmigrationmanager = MigratableVcDomains(self.connection)
class MigratableVcDomainsTest(TestCase): def setUp(self): self.host = '127.0.0.1' self.connection = connection(self.host) self.vcmigrationmanager = MigratableVcDomains(self.connection) @mock.patch.object(ResourceClient, 'create') def test_test_compatibility(self, mock_create): timeoutValue = 26 migrationInformation = MigratableVcDomains. \ make_migration_information('192.168.9.32', 'Administrator', 'password', 'Administrator', 'password', enclosureGroupUri='/rest/enclosure-groups/uri') self.vcmigrationmanager.test_compatibility(migrationInformation, timeout=timeoutValue) mock_create.assert_called_once_with(migrationInformation, timeout=timeoutValue) @mock.patch.object(ResourceClient, 'create') def test_test_compatibility_default(self, mock_create): migrationInformation = MigratableVcDomains. \ make_migration_information('192.168.9.32', 'Administrator', 'password', 'Administrator', 'password', enclosureGroupUri='/rest/enclosure-groups/uri') self.vcmigrationmanager.test_compatibility(migrationInformation) mock_create.assert_called_once_with(migrationInformation, timeout=-1) @mock.patch.object(ResourceClient, 'get') def test_get_migration_report(self, mock_get): uri = '/rest/migratable-vc-domains/uri' self.vcmigrationmanager.get_migration_report(uri) mock_get.assert_called_once_with(uri) @mock.patch.object(ResourceClient, 'update') def test_migrate_with_full_uri(self, mock_update): migrationInformation = { 'migrationState': 'Migrated', 'type': 'migratable-vc-domains', 'category': 'migratable-vc-domains' } uriValue = '/rest/migratable-vc-domains/uri' timeoutValue = 26 self.vcmigrationmanager.migrate(uriValue, timeout=timeoutValue) mock_update.assert_called_once_with(migrationInformation, uri=uriValue, timeout=timeoutValue) @mock.patch.object(ResourceClient, 'update') def test_migrate_with_id(self, mock_update): migrationInformation = { 'migrationState': 'Migrated', 'type': 'migratable-vc-domains', 'category': 'migratable-vc-domains' } id = 'uri' uriValue = '/rest/migratable-vc-domains/' + id timeoutValue = 26 self.vcmigrationmanager.migrate(id, timeout=timeoutValue) mock_update.assert_called_once_with(migrationInformation, uri=uriValue, timeout=timeoutValue) @mock.patch.object(ResourceClient, 'update') def test_migrate_default(self, mock_update): migrationInformation = { 'migrationState': 'Migrated', 'type': 'migratable-vc-domains', 'category': 'migratable-vc-domains' } uriValue = '/rest/migratable-vc-domains/uri' self.vcmigrationmanager.migrate(uriValue) mock_update.assert_called_once_with(migrationInformation, uri=uriValue, timeout=-1) @mock.patch.object(ResourceClient, 'delete') def test_delete(self, mock_delete): timeoutValue = 26 uriValue = '/rest/migratable-vc-domains/uri' self.vcmigrationmanager.delete(uriValue, timeout=timeoutValue) mock_delete.assert_called_once_with(uriValue, timeout=timeoutValue) @mock.patch.object(ResourceClient, 'delete') def test_delete_default(self, mock_delete): uriValue = '/rest/migratable-vc-domains/uri' self.vcmigrationmanager.delete(uriValue) mock_delete.assert_called_once_with(uriValue, timeout=-1)