def test_manage_devices_just_cd(self): ''' 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) ''' 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)
def test_manage_devices_just_cd(self): """ 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) """ 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)