desc
stringlengths 3
26.7k
| decl
stringlengths 11
7.89k
| bodies
stringlengths 8
553k
|
---|---|---|
'Tests that a SaltCloudSystemExit is raised when trying to call list_nodes
with --action or -a.'
| def test_list_nodes_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_nodes, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_nodes_min
with --action or -a.'
| def test_list_nodes_min_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_nodes_min, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_nodes_full
with --action or -a.'
| def test_list_nodes_full_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_nodes_full, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_nodes_full
with --action or -a.'
| def test_list_nodes_select_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_nodes_select, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_folders
with anything other than --function or -f.'
| def test_list_folders_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_folders, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_snapshots
with anything other than --function or -f.'
| def test_list_snapshots_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_snapshots, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_hosts_by_cluster
with anything other than --function or -f.'
| def test_list_hosts_by_cluster_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_hosts_by_cluster, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_clusters_by_datacenter
with anything other than --function or -f.'
| def test_list_clusters_by_datacenter_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_clusters_by_datacenter, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_hosts_by_datacenter
with anything other than --function or -f.'
| def test_list_hosts_by_datacenter_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_hosts_by_datacenter, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_hbas
with anything other than --function or -f.'
| def test_list_hbas_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_hbas, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_dvs
with anything other than --function or -f.'
| def test_list_dvs_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_dvs, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_vapps
with anything other than --function or -f.'
| def test_list_vapps_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_vapps, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_templates
with anything other than --function or -f.'
| def test_list_templates_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.list_templates, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call create_datacenter
with anything other than --function or -f.'
| def test_create_datacenter_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datacenter, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call create_cluster
with anything other than --function or -f.'
| def test_create_cluster_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_cluster, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call rescan_hba
with anything other than --function or -f.'
| def test_rescan_hba_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.rescan_hba, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call upgrade_tools_all
with anything other than --function or -f.'
| def test_upgrade_tools_all_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.upgrade_tools_all, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call enter_maintenance_mode
with anything other than --function or -f.'
| def test_enter_maintenance_mode_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.enter_maintenance_mode, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call exit_maintenance_mode
with anything other than --function or -f.'
| def test_exit_maintenance_mode_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.exit_maintenance_mode, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call create_folder
with anything other than --function or -f.'
| def test_create_folder_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_folder, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call add_host
with anything other than --function or -f.'
| def test_add_host_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.add_host, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call remove_host
with anything other than --function or -f.'
| def test_remove_host_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.remove_host, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call connect_host
with anything other than --function or -f.'
| def test_connect_host_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.connect_host, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call disconnect_host
with anything other than --function or -f.'
| def test_disconnect_host_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.disconnect_host, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call reboot_host
with anything other than --function or -f.'
| def test_reboot_host_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.reboot_host, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call create_datastore_cluster
with anything other than --function or -f.'
| def test_create_datastore_cluster_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datastore_cluster, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call show_instance
with anything other than --action or -a.'
| def test_show_instance_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.show_instance, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call start
with anything other than --action or -a.'
| def test_start_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.start, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call stop
with anything other than --action or -a.'
| def test_stop_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.stop, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call suspend
with anything other than --action or -a.'
| def test_suspend_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.suspend, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call reset
with anything other than --action or -a.'
| def test_reset_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.reset, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call terminate
with anything other than --action or -a.'
| def test_terminate_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.terminate, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call destroy
with --function or -f.'
| def test_destroy_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.destroy, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call upgrade_tools
with anything other than --action or -a.'
| def test_upgrade_tools_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.upgrade_tools, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call create_snapshot
with anything other than --action or -a.'
| def test_create_snapshot_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_snapshot, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call revert_to_snapshot
with anything other than --action or -a.'
| def test_revert_to_snapshot_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.revert_to_snapshot, name=VM_NAME, call='function')
|
'Tests that a SaltCloudSystemExit is raised when trying to call remove_all_snapshots
with anything other than --action or -a.'
| def test_remove_all_snapshots_call(self):
| self.assertRaises(SaltCloudSystemExit, vmware.remove_all_snapshots, name=VM_NAME, call='function')
|
'Tests that avail_sizes returns an empty dictionary.'
| def test_avail_sizes(self):
| self.assertEqual(vmware.avail_sizes(call='foo'), {})
|
'Tests that a SaltCloudSystemExit is raised when no kwargs are provided to
create_datacenter.'
| def test_create_datacenter_no_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datacenter, kwargs=None, call='function')
|
'Tests that a SaltCloudSystemExit is raised when name is not present in
kwargs that are provided to create_datacenter.'
| def test_create_datacenter_no_name_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datacenter, kwargs={'foo': 'bar'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when name is present in kwargs
that are provided to create_datacenter but is an empty string.'
| def test_create_datacenter_name_too_short(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datacenter, kwargs={'name': ''}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when name is present in kwargs
that are provided to create_datacenter but is a string with length <= 80.'
| def test_create_datacenter_name_too_long(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datacenter, kwargs={'name': 'cCD2GgJGPG1DUnPeFBoPeqtdmUxIWxDoVFbA14vIG0BPoUECkgbRMnnY6gaUPBvIDCcsZ5HU48ubgQu5c'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when no kwargs are provided to
create_cluster.'
| def test_create_cluster_no_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_cluster, kwargs=None, call='function')
|
'Tests that a SaltCloudSystemExit is raised when neither the name nor the
datacenter is present in kwargs that are provided to create_cluster.'
| def test_create_cluster_no_name_no_datacenter_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_cluster, kwargs={'foo': 'bar'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when the name is present but the
datacenter is not present in kwargs that are provided to create_cluster.'
| def test_create_cluster_no_datacenter_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_cluster, kwargs={'name': 'my-cluster'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when the datacenter is present
but the name is not present in kwargs that are provided to create_cluster.'
| def test_create_cluster_no_name_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_cluster, kwargs={'datacenter': 'my-datacenter'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when no kwargs are provided to
rescan_hba.'
| def test_rescan_hba_no_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.rescan_hba, kwargs=None, call='function')
|
'Tests that a SaltCloudSystemExit is raised when host is not present in
kwargs that are provided to rescan_hba.'
| def test_rescan_hba_no_host_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.rescan_hba, kwargs={'foo': 'bar'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when no kwargs are provided to
create_snapshot.'
| def test_create_snapshot_no_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_snapshot, name=VM_NAME, kwargs=None, call='action')
|
'Tests that a SaltCloudSystemExit is raised when snapshot_name is not present
in kwargs that are provided to create_snapshot.'
| def test_create_snapshot_no_snapshot_name_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_snapshot, name=VM_NAME, kwargs={'foo': 'bar'}, call='action')
|
'Tests that a SaltCloudSystemExit is raised when esxi_host_user is not
specified in the cloud provider configuration when calling add_host.'
| def test_add_host_no_esxi_host_user_in_config(self):
| with patch.dict(vmware.__opts__, {'providers': PROVIDER_CONFIG}, clean=True):
self.assertRaisesWithMessage(SaltCloudSystemExit, 'You must specify the ESXi host username in your providers config.', vmware.add_host, kwargs=None, call='function')
|
'Tests that a SaltCloudSystemExit is raised when esxi_host_password is not
specified in the cloud provider configuration when calling add_host.'
| def test_add_host_no_esxi_host_password_in_config(self):
| provider_config_additions = {'esxi_host_user': 'root'}
provider_config = deepcopy(PROVIDER_CONFIG)
provider_config['vcenter01']['vmware'].update(provider_config_additions)
with patch.dict(vmware.__opts__, {'providers': provider_config}, clean=True):
self.assertRaisesWithMessage(SaltCloudSystemExit, 'You must specify the ESXi host password in your providers config.', vmware.add_host, kwargs=None, call='function')
|
'Tests that the profile is configured correctly when deploying using an image'
| def test_no_clonefrom_just_image(self):
| profile_additions = {'image': 'some-image.iso'}
provider_config = deepcopy(PROVIDER_CONFIG)
profile = deepcopy(PROFILE)
profile['base-gold'].update(profile_additions)
provider_config_additions = {'profiles': profile}
provider_config['vcenter01']['vmware'].update(provider_config_additions)
vm_ = {'profile': profile}
with patch.dict(vmware.__opts__, {'providers': provider_config}, clean=True):
self.assertEqual(config.is_profile_configured(vmware.__opts__, 'vcenter01:vmware', 'base-gold', vm_=vm_), True)
|
'Tests that the profile is configured correctly when deploying by cloning from a template'
| def test_just_clonefrom(self):
| profile_additions = {'clonefrom': 'test-template', 'image': 'should ignore image'}
provider_config = deepcopy(PROVIDER_CONFIG)
profile = deepcopy(PROFILE)
profile['base-gold'].update(profile_additions)
provider_config_additions = {'profiles': profile}
provider_config['vcenter01']['vmware'].update(provider_config_additions)
vm_ = {'profile': profile}
with patch.dict(vmware.__opts__, {'providers': provider_config}, clean=True):
self.assertEqual(config.is_profile_configured(vmware.__opts__, 'vcenter01:vmware', 'base-gold', vm_=vm_), True)
|
'Tests that creating a new controller, ensuring that it will generate a controller key
if one is not provided'
| def test_add_new_ide_controller_helper(self):
| with patch('salt.cloud.clouds.vmware.randint', return_value=101) as randint_mock:
controller_label = 'Some label'
bus_number = 1
spec = vmware._add_new_ide_controller_helper(controller_label, None, bus_number)
self.assertEqual(spec.device.key, randint_mock.return_value)
spec = vmware._add_new_ide_controller_helper(controller_label, 200, bus_number)
self.assertEqual(spec.device.key, 200)
self.assertEqual(spec.device.busNumber, bus_number)
self.assertEqual(spec.device.deviceInfo.label, controller_label)
self.assertEqual(spec.device.deviceInfo.summary, controller_label)
|
'Tests that when adding IDE/CD drives, controller keys will be in the apparent
safe-range on ESX 5.5 but randomly generated on other versions (i.e. 6)'
| def test_manage_devices_just_cd(self):
| device_map = {'ide': {'IDE 0': {}, 'IDE 1': {}}, 'cd': {'CD/DVD Drive 1': {'controller': 'IDE 0'}}}
with patch('salt.cloud.clouds.vmware.get_vcenter_version', return_value='VMware ESXi 5.5.0'):
specs = vmware._manage_devices(device_map, vm=None)['device_specs']
self.assertEqual(specs[0].device.key, vmware.SAFE_ESX_5_5_CONTROLLER_KEY_INDEX)
self.assertEqual(specs[1].device.key, (vmware.SAFE_ESX_5_5_CONTROLLER_KEY_INDEX + 1))
self.assertEqual(specs[2].device.controllerKey, vmware.SAFE_ESX_5_5_CONTROLLER_KEY_INDEX)
with patch('salt.cloud.clouds.vmware.get_vcenter_version', return_value='VMware ESXi 6'):
with patch('salt.cloud.clouds.vmware.randint', return_value=100) as first_key:
specs = vmware._manage_devices(device_map, vm=None)['device_specs']
self.assertEqual(specs[0].device.key, first_key.return_value)
self.assertEqual(specs[2].device.controllerKey, first_key.return_value)
|
'Tests that a SaltCloudSystemExit is raised when host is not present in
kwargs that are provided to add_host.'
| def test_add_host_no_host_in_kwargs(self):
| provider_config_additions = {'esxi_host_user': 'root', 'esxi_host_password': 'myhostpassword'}
provider_config = deepcopy(PROVIDER_CONFIG)
provider_config['vcenter01']['vmware'].update(provider_config_additions)
with patch.dict(vmware.__opts__, {'providers': provider_config}, clean=True):
self.assertRaisesWithMessage(SaltCloudSystemExit, 'You must specify either the IP or DNS name of the host system.', vmware.add_host, kwargs={'foo': 'bar'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when both cluster and datacenter
are present in kwargs that are provided to add_host.'
| def test_add_host_both_cluster_and_datacenter_in_kwargs(self):
| provider_config_additions = {'esxi_host_user': 'root', 'esxi_host_password': 'myhostpassword'}
provider_config = deepcopy(PROVIDER_CONFIG)
provider_config['vcenter01']['vmware'].update(provider_config_additions)
with patch.dict(vmware.__opts__, {'providers': provider_config}, clean=True):
self.assertRaisesWithMessage(SaltCloudSystemExit, 'You must specify either the cluster name or the datacenter name.', vmware.add_host, kwargs={'host': 'my-esxi-host', 'datacenter': 'my-datacenter', 'cluster': 'my-cluster'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when neither cluster nor
datacenter is present in kwargs that are provided to add_host.'
| def test_add_host_neither_cluster_nor_datacenter_in_kwargs(self):
| provider_config_additions = {'esxi_host_user': 'root', 'esxi_host_password': 'myhostpassword'}
provider_config = deepcopy(PROVIDER_CONFIG)
provider_config['vcenter01']['vmware'].update(provider_config_additions)
with patch.dict(vmware.__opts__, {'providers': provider_config}, clean=True):
self.assertRaisesWithMessage(SaltCloudSystemExit, 'You must specify either the cluster name or the datacenter name.', vmware.add_host, kwargs={'host': 'my-esxi-host'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when the specified cluster present
in kwargs that are provided to add_host does not exist in the VMware
environment.'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_add_host_cluster_not_exists(self):
| with patch('salt.cloud.clouds.vmware._get_si', MagicMock(return_value=None)):
with patch('salt.utils.vmware.get_mor_by_property', MagicMock(return_value=None)):
provider_config_additions = {'esxi_host_user': 'root', 'esxi_host_password': 'myhostpassword'}
provider_config = deepcopy(PROVIDER_CONFIG)
provider_config['vcenter01']['vmware'].update(provider_config_additions)
with patch.dict(vmware.__opts__, {'providers': provider_config}, clean=True):
self.assertRaisesWithMessage(SaltCloudSystemExit, 'Specified cluster does not exist.', vmware.add_host, kwargs={'host': 'my-esxi-host', 'cluster': 'my-cluster'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when the specified datacenter
present in kwargs that are provided to add_host does not exist in the VMware
environment.'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_add_host_datacenter_not_exists(self):
| with patch('salt.cloud.clouds.vmware._get_si', MagicMock(return_value=None)):
with patch('salt.utils.vmware.get_mor_by_property', MagicMock(return_value=None)):
provider_config_additions = {'esxi_host_user': 'root', 'esxi_host_password': 'myhostpassword'}
provider_config = deepcopy(PROVIDER_CONFIG)
provider_config['vcenter01']['vmware'].update(provider_config_additions)
with patch.dict(vmware.__opts__, {'providers': provider_config}, clean=True):
self.assertRaisesWithMessage(SaltCloudSystemExit, 'Specified datacenter does not exist.', vmware.add_host, kwargs={'host': 'my-esxi-host', 'datacenter': 'my-datacenter'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when no kwargs are provided to
remove_host.'
| def test_remove_host_no_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.remove_host, kwargs=None, call='function')
|
'Tests that a SaltCloudSystemExit is raised when host is not present in
kwargs that are provided to remove_host.'
| def test_remove_host_no_host_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.remove_host, kwargs={'foo': 'bar'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when the specified host present
in kwargs that are provided to remove_host does not exist in the VMware
environment.'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_remove_host_not_exists(self):
| with patch('salt.cloud.clouds.vmware._get_si', MagicMock(return_value=None)):
with patch('salt.utils.vmware.get_mor_by_property', MagicMock(return_value=None)):
self.assertRaises(SaltCloudSystemExit, vmware.remove_host, kwargs={'host': 'my-host'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when no kwargs are provided to
connect_host.'
| def test_connect_host_no_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.connect_host, kwargs=None, call='function')
|
'Tests that a SaltCloudSystemExit is raised when host is not present in
kwargs that are provided to connect_host.'
| def test_connect_host_no_host_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.connect_host, kwargs={'foo': 'bar'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when the specified host present
in kwargs that are provided to connect_host does not exist in the VMware
environment.'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_connect_host_not_exists(self):
| with patch('salt.cloud.clouds.vmware._get_si', MagicMock(return_value=None)):
with patch('salt.utils.vmware.get_mor_by_property', MagicMock(return_value=None)):
self.assertRaises(SaltCloudSystemExit, vmware.connect_host, kwargs={'host': 'my-host'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when no kwargs are provided to
disconnect_host.'
| def test_disconnect_host_no_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.disconnect_host, kwargs=None, call='function')
|
'Tests that a SaltCloudSystemExit is raised when host is not present in
kwargs that are provided to disconnect_host.'
| def test_disconnect_host_no_host_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.disconnect_host, kwargs={'foo': 'bar'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when the specified host present
in kwargs that are provided to disconnect_host does not exist in the VMware
environment.'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_disconnect_host_not_exists(self):
| with patch('salt.cloud.clouds.vmware._get_si', MagicMock(return_value=None)):
with patch('salt.utils.vmware.get_mor_by_property', MagicMock(return_value=None)):
self.assertRaises(SaltCloudSystemExit, vmware.disconnect_host, kwargs={'host': 'my-host'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when no kwargs are provided to
reboot_host.'
| def test_reboot_host_no_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.reboot_host, kwargs=None, call='function')
|
'Tests that a SaltCloudSystemExit is raised when host is not present in
kwargs that are provided to reboot_host.'
| def test_reboot_host_no_host_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.reboot_host, kwargs={'foo': 'bar'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when the specified host present
in kwargs that are provided to connect_host does not exist in the VMware
environment.'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_reboot_host_not_exists(self):
| with patch('salt.cloud.clouds.vmware._get_si', MagicMock(return_value=None)):
with patch('salt.utils.vmware.get_mor_by_property', MagicMock(return_value=None)):
self.assertRaises(SaltCloudSystemExit, vmware.reboot_host, kwargs={'host': 'my-host'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when no kwargs are provided to
create_datastore_cluster.'
| def test_create_datastore_cluster_no_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datastore_cluster, kwargs=None, call='function')
|
'Tests that a SaltCloudSystemExit is raised when name is not present in
kwargs that are provided to create_datastore_cluster.'
| def test_create_datastore_cluster_no_name_in_kwargs(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datastore_cluster, kwargs={'foo': 'bar'}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when name is present in kwargs
that are provided to create_datastore_cluster but is an empty string.'
| def test_create_datastore_cluster_name_too_short(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datastore_cluster, kwargs={'name': ''}, call='function')
|
'Tests that a SaltCloudSystemExit is raised when name is present in kwargs
that are provided to create_datastore_cluster but is a string with length <= 80.'
| def test_create_datastore_cluster_name_too_long(self):
| self.assertRaises(SaltCloudSystemExit, vmware.create_datastore_cluster, kwargs={'name': 'cCD2GgJGPG1DUnPeFBoPeqtdmUxIWxDoVFbA14vIG0BPoUECkgbRMnnY6gaUPBvIDCcsZ5HU48ubgQu5c'}, call='function')
|
'Test that disk move type is
set to createNewChildDiskBacking'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_quick_linked_clone(self):
| self._test_clone_type(vmware.QUICK_LINKED_CLONE)
|
'Test that disk move type is
set to moveChildMostDiskBacking'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_current_state_linked_clone(self):
| self._test_clone_type(vmware.CURRENT_STATE_LINKED_CLONE)
|
'Test that disk move type is
set to moveAllDiskBackingsAndAllowSharing'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_copy_all_disks_full_clone(self):
| self._test_clone_type(vmware.COPY_ALL_DISKS_FULL_CLONE)
|
'Test that disk move type is
set to moveAllDiskBackingsAndDisallowSharing'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_flatten_all_all_disks_full_clone(self):
| self._test_clone_type(vmware.FLATTEN_DISK_FULL_CLONE)
|
'Test that invalid disk move type
raises error'
| @skipIf((HAS_LIBS is False), 'Install pyVmomi to be able to run this unit test.')
def test_raises_error_for_invalid_disk_move_type(self):
| with self.assertRaises(SaltCloudSystemExit):
self._test_clone_type('foobar')
|
'Assertions for checking that a certain clone type
works'
| def _test_clone_type(self, clone_type):
| obj_ref = MagicMock()
obj_ref.snapshot = vim.vm.Snapshot(None, None)
obj_ref.snapshot.currentSnapshot = vim.vm.Snapshot(None, None)
clone_spec = vmware.handle_snapshot(vim.vm.ConfigSpec(), obj_ref, vim.vm.RelocateSpec(), False, {'snapshot': {'disk_move_type': clone_type}})
self.assertEqual(clone_spec.location.diskMoveType, clone_type)
obj_ref2 = MagicMock()
obj_ref2.snapshot = vim.vm.Snapshot(None, None)
obj_ref2.snapshot.currentSnapshot = vim.vm.Snapshot(None, None)
clone_spec2 = vmware.handle_snapshot(vim.vm.ConfigSpec(), obj_ref2, vim.vm.RelocateSpec(), True, {'snapshot': {'disk_move_type': clone_type}})
self.assertEqual(clone_spec2.location.diskMoveType, clone_type)
|
'Tests that a SaltCloudSystemExit is raised when trying to call avail_images
with --action or -a.'
| def test_avail_images_call(self):
| self.assertRaises(SaltCloudSystemExit, dimensiondata.avail_images, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call avail_locations
with --action or -a.'
| def test_avail_locations_call(self):
| self.assertRaises(SaltCloudSystemExit, dimensiondata.avail_locations, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call avail_sizes
with --action or -a.'
| def test_avail_sizes_call(self):
| self.assertRaises(SaltCloudSystemExit, dimensiondata.avail_sizes, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call list_nodes
with --action or -a.'
| def test_list_nodes_call(self):
| self.assertRaises(SaltCloudSystemExit, dimensiondata.list_nodes, call='action')
|
'Tests that a SaltCloudSystemExit is raised when trying to call destroy
with --function or -f.'
| def test_destroy_call(self):
| self.assertRaises(SaltCloudSystemExit, dimensiondata.destroy, name=VM_NAME, call='function')
|
'Tests that avail_sizes returns an empty dictionary.'
| @skipIf((HAS_LIBCLOUD is False), "Install 'libcloud' to be able to run this unit test.")
def test_avail_sizes(self):
| sizes = dimensiondata.avail_sizes(call='foo')
self.assertEqual(len(sizes), 1)
self.assertEqual(sizes['default']['name'], 'default')
|
'Test that the module picks up installed deps'
| def test_import(self):
| with patch('salt.config.check_driver_dependencies', return_value=True) as p:
get_deps = dimensiondata.get_dependencies()
self.assertEqual(get_deps, True)
if (LooseVersion(mock_version) >= LooseVersion('2.0.0')):
self.assertTrue((p.call_count >= 1))
|
'Test that the first configured instance of a dimensiondata driver is matched'
| def test_provider_matches(self):
| p = dimensiondata.get_configured_provider()
self.assertNotEqual(p, None)
|
'Test if query node data is filtering out unpreferred IP addresses.'
| def test_query_node_data_filter_preferred_ip_addresses(self):
| zero_ip = '0.0.0.0'
private_ips = [zero_ip, '1.1.1.1', '2.2.2.2']
vm = {'name': None}
data = MagicMock()
data.public_ips = []
dimensiondata.NodeState = MagicMock()
dimensiondata.NodeState.RUNNING = True
with patch('salt.cloud.clouds.dimensiondata.show_instance', MagicMock(return_value={'state': True, 'name': 'foo', 'public_ips': [], 'private_ips': private_ips})):
with patch('salt.cloud.clouds.dimensiondata.preferred_ip', _preferred_ip(private_ips, [zero_ip])):
with patch('salt.cloud.clouds.dimensiondata.ssh_interface', MagicMock(return_value='private_ips')):
self.assertEqual(dimensiondata._query_node_data(vm, data).public_ips, [zero_ip])
|
'Tests that a SaltCloudSystemExit is raised when trying to call destroy
with --function or -f.'
| def test_destroy_call(self):
| self.assertRaises(SaltCloudSystemExit, gce.destroy, vm_name=VM_NAME, call='function')
|
'Test that the module picks up installed deps'
| def test_import(self):
| with patch('salt.config.check_driver_dependencies', return_value=True) as p:
get_deps = gce.get_dependencies()
self.assertEqual(get_deps, True)
if (LooseVersion(mock_version) >= LooseVersion('2.0.0')):
self.assert_called_once(p)
|
'Test that the first configured instance of a gce driver is matched'
| def test_provider_matches(self):
| p = gce.get_configured_provider()
self.assertNotEqual(p, None)
|
'We should not be using the ``:doc:`` inline markup option when
cross-referencing locations. Use ``:ref:`` or ``:mod:`` instead.
This test checks for reference to ``:doc:`` usage.
See Issue #12788 for more information.
https://github.com/saltstack/salt/issues/12788'
| def test_check_for_doc_inline_markup(self):
| salt_dir = integration.CODE_DIR
salt_dir += '/'
cmd = ('grep -r :doc: ' + salt_dir)
grep_call = salt.modules.cmdmod.run_stdout(cmd=cmd).split('\n')
test_ret = {}
for line in grep_call:
if line.startswith('Binary'):
continue
(key, val) = line.split(':', 1)
if (('man' in key) or key.endswith('test_doc.py') or key.endswith('doc/conf.py') or key.endswith('/conventions/documentation.rst') or key.endswith('doc/topics/releases/2016.11.2.rst') or key.endswith('doc/topics/releases/2016.11.3.rst') or key.endswith('doc/topics/releases/2016.3.5.rst')):
continue
if (test_ret.get(key) is None):
test_ret[key] = [val.lstrip()]
else:
test_ret[key].append(val.lstrip())
self.maxDiff = None
self.assertEqual(test_ret, {})
|
'Test to ensure that unsupported types cannot be passed to the template compiler'
| def test_compile_template_bad_type(self):
| ret = template.compile_template(['1', '2', '3'], None, None, None, None)
self.assertDictEqual(ret, {})
|
'Test to ensure that a file with Windows newlines, when rendered by a
template renderer, does not eat the CR character.'
| @skipIf(NO_MOCK, NO_MOCK_REASON)
def test_compile_template_preserves_windows_newlines(self):
| def _get_rend(renderer, value):
"\n We need a new MagicMock each time since we're dealing with StringIO\n objects which are read like files.\n "
return {renderer: MagicMock(return_value=StringIO(value))}
input_data_windows = 'foo\r\nbar\r\nbaz\r\n'
input_data_non_windows = input_data_windows.replace('\r\n', '\n')
renderer = 'test'
blacklist = whitelist = []
ret = template.compile_template(':string:', _get_rend(renderer, input_data_non_windows), renderer, blacklist, whitelist, input_data=input_data_windows).read()
self.assertEqual(ret, input_data_windows)
ret = template.compile_template(':string:', _get_rend(renderer, input_data_non_windows), renderer, blacklist, whitelist, input_data=input_data_non_windows).read()
self.assertEqual(ret, input_data_non_windows)
ret = template.compile_template(':string:', _get_rend(renderer, input_data_windows), renderer, blacklist, whitelist, input_data=input_data_windows).read()
self.assertEqual(ret, input_data_windows)
|
'Check that all renderers specified in the pipe string are available.'
| def test_check_render_pipe_str(self):
| ret = template.check_render_pipe_str('jinja|json', self.render_dict, None, None)
self.assertIn(('fake_jinja_func', ''), ret)
self.assertIn(('fake_json_func', ''), ret)
self.assertNotIn(('OBVIOUSLY_NOT_HERE', ''), ret)
|
'Check that all renderers specified in the pipe string are available.'
| def test_check_renderer_blacklisting(self):
| ret = template.check_render_pipe_str('jinja|json', self.render_dict, ['jinja'], None)
self.assertListEqual([('fake_json_func', '')], ret)
ret = template.check_render_pipe_str('jinja|json', self.render_dict, None, ['jinja'])
self.assertListEqual([('fake_jinja_func', '')], ret)
ret = template.check_render_pipe_str('jinja|json', self.render_dict, ['jinja'], ['jinja'])
self.assertListEqual([], ret)
ret = template.check_render_pipe_str('jinja|json', self.render_dict, ['jinja'], ['jinja', 'json'])
self.assertListEqual([('fake_json_func', '')], ret)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.