Пример #1
0
 def test_detail_vs_ptr_error(self):
     mock = self.set_mock('SoftLayer_Virtual_Guest', 'getReverseDomainRecords')
     mock.side_effect = SoftLayerAPIError("SoftLayer_Exception", "Not Found")
     result = self.run_command(['vs', 'detail', '100'])
     self.assert_no_fail(result)
     output = json.loads(result.output)
     self.assertEqual(output.get('ptr', None), None)
Пример #2
0
 def test_detail_vs_dedicated_host_not_found(self):
     ex = SoftLayerAPIError('SoftLayer_Exception', 'Not found')
     mock = self.set_mock('SoftLayer_Virtual_DedicatedHost', 'getObject')
     mock.side_effect = ex
     result = self.run_command(['vs', 'detail', '100'])
     self.assert_no_fail(result)
     self.assertEqual(json.loads(result.output)['dedicated_host_id'], 37401)
     self.assertIsNone(json.loads(result.output)['dedicated_host'])
Пример #3
0
 def test_volume_set_lun_id_not_in_range(self):
     value = '-1'
     lun_mock = self.set_mock('SoftLayer_Network_Storage', 'createOrUpdateLunId')
     lun_mock.side_effect = SoftLayerAPIError(
         'SoftLayer_Exception_Network_Storage_Iscsi_InvalidLunId',
         'The LUN ID specified is out of the valid range: %s [min: 0 max: 4095]' % (value))
     result = self.run_command('block volume-set-lun-id 1234 42'.split())
     self.assertIsNotNone(result.exception)
     self.assertIn('The LUN ID specified is out of the valid range', result.exception.faultString)
Пример #4
0
 def test_vs_migrate_exception(self):
     ex = SoftLayerAPIError('SoftLayer_Exception', 'PROBLEM')
     mock = self.set_mock('SoftLayer_Virtual_Guest', 'migrate')
     mock.side_effect = ex
     result = self.run_command(['vs', 'migrate', '-g', '100'])
     self.assert_no_fail(result)
     self.assertIn('Failed to migrate', result.output)
     self.assert_not_called_with('SoftLayer_Account', 'getVirtualGuests')
     self.assert_called_with('SoftLayer_Virtual_Guest', 'migrate', identifier=100)
     self.assert_not_called_with('SoftLayer_Virtual_Guest', 'migrateDedicatedHost', args=(999), identifier=100)
Пример #5
0
 def test_get_item_details_with_invoice_item_id(self):
     mock = self.set_mock('SoftLayer_Billing_Item', 'getObject')
     mock.side_effect = SoftLayerAPIError(
         404, "Unable to find object with id of '123456'.")
     self.manager.get_item_detail(123456)
     self.assert_called_with('SoftLayer_Billing_Item',
                             'getObject',
                             identifier=123456)
     self.assert_called_with('SoftLayer_Billing_Invoice_Item',
                             'getBillingItem',
                             identifier=123456)