Merge pull request #26118 from rallytime/one-testing

Wrote even more unit tests for the OpenNebula driver
This commit is contained in:
C. R. Oldham 2015-08-08 15:11:39 -06:00
commit 8b89e46f53
2 changed files with 783 additions and 129 deletions

View File

@ -2366,6 +2366,118 @@ def template_instantiate(call=None, kwargs=None):
return data
def template_update(call=None, kwargs=None):
'''
Replaces the template contents.
.. versionadded:: Boron
template_id
The ID of the template to update. Can be used instead of ``template_name``.
template_name
The name of the template to update. Can be used instead of ``template_id``.
path
The path to a file containing the elements of the template to be updated.
Syntax within the file can be the usual attribute=value or XML. Can be
used instead of ``data``.
data
Contains the elements of the template to be updated. Syntax can be the
usual attribute=value or XML. Data provided my be wrapped in double
quotes. Can be used instead of ``path``.
update_type
There are two ways to update a template: ``replace`` the whole template
or ``merge`` the new template with the existing one.
CLI Example:
.. code-block:: bash
salt-cloud --function template_update opennebula template_id=1 update_type=replace \
path=/path/to/template_update_file.txt
salt-cloud -f template_update opennebula template_name=my-template update_type=merge \
data="CPU='1.0' DISK=[IMAGE='Ubuntu-14.04'] GRAPHICS=[LISTEN='0.0.0.0',TYPE='vnc'] \
MEMORY='1024' NETWORK='yes' NIC=[NETWORK='192net',NETWORK_UNAME='oneadmin'] \
OS=[ARCH='x86_64'] SUNSTONE_CAPACITY_SELECT='YES' SUNSTONE_NETWORK_SELECT='YES' \
VCPU='1'"
'''
if call != 'function':
raise SaltCloudSystemExit(
'The template_update function must be called with -f or --function.'
)
if kwargs is None:
kwargs = {}
template_id = kwargs.get('template_id', None)
template_name = kwargs.get('template_name', None)
path = kwargs.get('path', None)
data = kwargs.get('data', None)
update_type = kwargs.get('update_type', None)
update_args = ['replace', 'merge']
if update_type is None:
raise SaltCloudSystemExit(
'The template_update function requires an \'update_type\' to be provided.'
)
if update_type == update_args[0]:
update_number = 0
elif update_type == update_args[1]:
update_number = 1
else:
raise SaltCloudSystemExit(
'The update_type argument must be either {0} or {1}.'.format(
update_args[0],
update_args[1]
)
)
if template_id:
if template_name:
log.warning(
'Both the \'template_id\' and \'template_name\' arguments were provided. '
'\'template_id\' will take precedence.'
)
elif template_name:
template_id = get_template_id(kwargs={'name': template_name})
else:
raise SaltCloudSystemExit(
'The template_update function requires either a \'template_id\' '
'or a \'template_name\' to be provided.'
)
if data:
if path:
log.warning(
'Both the \'data\' and \'path\' arguments were provided. '
'\'data\' will take precedence.'
)
elif path:
data = salt.utils.fopen(path, mode='r').read()
else:
raise SaltCloudSystemExit(
'The template_update function requires either \'data\' or a file '
'\'path\' to be provided.'
)
server, user, password = _get_xml_rpc()
auth = ':'.join([user, password])
response = server.one.template.update(auth, int(template_id), data, int(update_number))
ret = {
'action': 'template.update',
'updated': response[0],
'template_id': response[1],
'error_code': response[2],
}
return ret
def vm_action(name, kwargs=None, call=None):
'''
Submits an action to be performed on a given virtual machine.
@ -2683,7 +2795,7 @@ def vm_deploy(name, kwargs=None, call=None):
host_id = kwargs.get('host_id', None)
host_name = kwargs.get('host_name', None)
capacity_maintained = kwargs.get('capacity_maintained', True)
datastore_id = int(kwargs.get('datastore_id', None))
datastore_id = kwargs.get('datastore_id', None)
datastore_name = kwargs.get('datastore_name', None)
if host_id:
@ -2705,7 +2817,7 @@ def vm_deploy(name, kwargs=None, call=None):
log.warning(
'Both the \'datastore_id\' and \'datastore_name\' arguments were provided. '
'\'datastore_id\' will take precedence.'
)
)
elif datastore_name:
datastore_id = get_datastore_id(kwargs={'name': datastore_name})
else:
@ -2864,7 +2976,7 @@ def vm_disk_save(name, kwargs=None, call=None):
kwargs = {}
disk_id = kwargs.get('disk_id', None)
image_name = kwargs.get('image_name', False)
image_name = kwargs.get('image_name', None)
image_type = kwargs.get('image_type', '')
snapshot_id = int(kwargs.get('snapshot_id', '-1'))
@ -3399,7 +3511,7 @@ def vm_snapshot_delete(vm_name, kwargs=None, call=None):
server, user, password = _get_xml_rpc()
auth = ':'.join([user, password])
vm_id = int(get_vm_id(kwargs={'name': vm_name}))
response = server.one.vm.snapshotcreate(auth, vm_id, int(snapshot_id))
response = server.one.vm.snapshotdelete(auth, vm_id, int(snapshot_id))
data = {
'action': 'vm.snapshotdelete',
@ -3427,7 +3539,7 @@ def vm_snapshot_revert(vm_name, kwargs=None, call=None):
.. code-block:: bash
salt-cloud -a vm_snapshot_create my-vm snapshot_name=my-new-snapshot
salt-cloud -a vm_snapshot_revert my-vm snapshot_id=42
'''
if call != 'action':
raise SaltCloudSystemExit(
@ -3497,12 +3609,25 @@ def vm_update(name, kwargs=None, call=None):
path = kwargs.get('path', None)
data = kwargs.get('data', None)
update_type = kwargs.get('update_type', None)
update_args = ['replace', 'merge']
if update_type is None:
raise SaltCloudSystemExit(
'The vm_update function requires an \'update_type\' to be provided.'
)
if update_type == update_args[0]:
update_number = 0
elif update_type == update_args[1]:
update_number = 1
else:
raise SaltCloudSystemExit(
'The update_type argument must be either {0} or {1}.'.format(
update_args[0],
update_args[1]
)
)
if data:
if path:
log.warning(
@ -3517,15 +3642,10 @@ def vm_update(name, kwargs=None, call=None):
'to be provided.'
)
update_number = 0
if update_type == 'merge':
update_number = 1
server, user, password = _get_xml_rpc()
auth = ':'.join([user, password])
vm_id = int(get_vm_id(kwargs={'name': name}))
response = server.one.vm.update(auth, vm_id, data, update_number)
response = server.one.vm.update(auth, vm_id, data, int(update_number))
ret = {
'action': 'vm.update',
@ -3754,7 +3874,7 @@ def vn_delete(call=None, kwargs=None):
server, user, password = _get_xml_rpc()
auth = ':'.join([user, password])
response = server.one.image.delete(auth, int(vn_id))
response = server.one.vn.delete(auth, int(vn_id))
data = {
'action': 'vn.delete',
@ -3875,7 +3995,7 @@ def vn_hold(call=None, kwargs=None):
kwargs = {}
vn_id = kwargs.get('vn_id', None)
vn_name = kwargs.get('vn_name'. None)
vn_name = kwargs.get('vn_name', None)
path = kwargs.get('path', None)
data = kwargs.get('data', None)
@ -4151,118 +4271,6 @@ def vn_reserve(call=None, kwargs=None):
return ret
def template_update(call=None, kwargs=None):
'''
Replaces the template contents.
.. versionadded:: Boron
template_id
The ID of the template to update. Can be used instead of ``template_name``.
template_name
The name of the template to update. Can be used instead of ``template_id``.
path
The path to a file containing the elements of the template to be updated.
Syntax within the file can be the usual attribute=value or XML. Can be
used instead of ``data``.
data
Contains the elements of the template to be updated. Syntax can be the
usual attribute=value or XML. Data provided my be wrapped in double
quotes. Can be used instead of ``path``.
update_type
There are two ways to update a template: ``replace`` the whole template
or ``merge`` the new template with the existing one.
CLI Example:
.. code-block:: bash
salt-cloud --function template_update opennebula template_id=1 update_type=replace \
path=/path/to/template_update_file.txt
salt-cloud -f template_update opennebula template_name=my-template update_type=merge \
data="CPU='1.0' DISK=[IMAGE='Ubuntu-14.04'] GRAPHICS=[LISTEN='0.0.0.0',TYPE='vnc'] \
MEMORY='1024' NETWORK='yes' NIC=[NETWORK='192net',NETWORK_UNAME='oneadmin'] \
OS=[ARCH='x86_64'] SUNSTONE_CAPACITY_SELECT='YES' SUNSTONE_NETWORK_SELECT='YES' \
VCPU='1'"
'''
if call != 'function':
raise SaltCloudSystemExit(
'The template_update function must be called with -f or --function.'
)
if kwargs is None:
kwargs = {}
template_id = kwargs.get('template_id', None)
template_name = kwargs.get('template_name', None)
path = kwargs.get('path', None)
data = kwargs.get('data', None)
update_type = kwargs.get('update_type', None)
update_args = ['replace', 'merge']
if update_type is None:
raise SaltCloudSystemExit(
'The template_update function requires an \'update_type\' to be provided.'
)
if template_id:
if template_name:
log.warning(
'Both the \'template_id\' and \'template_name\' arguments were provided. '
'\'template_id\' will take precedence.'
)
elif template_name:
template_id = get_template_id(kwargs={'name': template_name})
else:
raise SaltCloudSystemExit(
'The template_update function requires either a \'template_id\' '
'or a \'template_name\' to be provided.'
)
if data:
if path:
log.warning(
'Both the \'data\' and \'path\' arguments were provided. '
'\'data\' will take precedence.'
)
elif path:
data = salt.utils.fopen(path, mode='r').read()
else:
raise SaltCloudSystemExit(
'The template_update function requires either \'data\' or a file '
'\'path\' to be provided.'
)
if update_type == update_args[0]:
update_number = 0
elif update_type == update_args[1]:
update_number = 1
else:
raise SaltCloudSystemExit(
'The update_type argument must be either {0} or {1}.'.format(
update_args[0],
update_args[1]
)
)
server, user, password = _get_xml_rpc()
auth = ':'.join([user, password])
response = server.one.template.update(auth, int(template_id), data, int(update_number))
ret = {
'action': 'template.update',
'updated': response[0],
'template_id': response[1],
'error_code': response[2],
}
return ret
# Helper Functions
def _get_node(name):

View File

@ -20,6 +20,7 @@ from salt.exceptions import SaltCloudSystemExit
# Global Variables
opennebula.__active_provider_name__ = ''
opennebula.__opts__ = {}
VM_NAME = 'my-vm'
@skipIf(NO_MOCK, NO_MOCK_REASON)
@ -717,8 +718,8 @@ class OpenNebulaTestCase(TestCase):
def test_secgroup_update_bad_update_type_value(self):
'''
Tests that a SaltCloudSystemExit is raised when the secgroup_id and
secgroup_name kwargs are missing.
Tests that a SaltCloudSystemExit is raised when the update_type contains
an invalid value.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.secgroup_update,
@ -822,18 +823,64 @@ class OpenNebulaTestCase(TestCase):
'function',
kwargs={'vm_name': 'test'})
def test_template_update_function_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--function or -f is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.template_update,
call='foo')
def test_template_update_bad_update_type_value(self):
'''
Tests that a SaltCloudSystemExit is raised when the update_type contains
and invalid value.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.template_update,
call='function',
kwargs={'update_type': 'foo'})
def test_template_update_no_template_id_or_template_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the template_id and the
template_name args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.template_update,
call='function',
kwargs={'update_type': 'merge'})
def test_template_update_no_data_or_path(self):
'''
Tests that a SaltCloudSystemExit is raised when the data and the
path args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.template_update,
call='function',
kwargs={'update_type': 'merge',
'template_id': '0'})
def test_vm_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit, opennebula.vm_action, 'foo')
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_action,
VM_NAME,
call='foo')
def test_vm_action_no_action(self):
'''
Tests that a SaltCloudSystemExit is raised when the action arg is missing
'''
self.assertRaises(SaltCloudSystemExit, opennebula.vm_action, 'action')
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_action,
VM_NAME,
call='action')
def test_vm_allocate_function_error(self):
'''
@ -849,6 +896,605 @@ class OpenNebulaTestCase(TestCase):
'''
self.assertRaises(SaltCloudSystemExit, opennebula.vm_allocate, 'function')
def test_vm_attach_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_attach,
VM_NAME,
call='foo')
def test_vm_attach_no_data_or_path(self):
'''
Tests that a SaltCloudSystemExit is raised when the data and
path kwargs are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_attach,
VM_NAME,
call='action')
def test_vm_attach_nic_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_attach_nic,
VM_NAME,
call='foo')
def test_vm_attach_nic_no_data_or_path(self):
'''
Tests that a SaltCloudSystemExit is raised when the data and
path kwargs are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_attach_nic,
VM_NAME,
call='action')
def test_vm_deploy_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_deploy,
VM_NAME,
call='foo')
def test_vm_deploy_no_host_id_or_host_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the host_id and the
host_name args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_deploy,
VM_NAME,
call='action',
kwargs=None)
def test_vm_detach_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_detach,
VM_NAME,
call='foo')
def test_vm_detach_no_disk_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the disk_id ar is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_detach,
VM_NAME,
call='action')
def test_vm_detach_nic_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_detach_nic,
VM_NAME,
call='foo')
def test_vm_detach_nic_no_nic_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the nic_id arg is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_detach_nic,
VM_NAME,
call='action')
def test_vm_disk_save_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_save,
VM_NAME,
call='foo')
def test_vm_disk_save_no_disk_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the disk_id arg is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_save,
VM_NAME,
call='action',
kwargs={'image_name': 'foo'})
def test_vm_disk_save_no_image_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the image_name arg is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_save,
VM_NAME,
call='action',
kwargs={'disk_id': '0'})
def test_vm_disk_snapshot_create_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_snapshot_create,
VM_NAME,
call='foo')
def test_vm_disk_snapshot_create_no_disk_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the disk_id arg is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_snapshot_create,
VM_NAME,
call='action',
kwargs={'description': 'foo'})
def test_vm_disk_snapshot_create_no_description(self):
'''
Tests that a SaltCloudSystemExit is raised when the image_name arg is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_snapshot_create,
VM_NAME,
call='action',
kwargs={'disk_id': '0'})
def test_vm_disk_snapshot_delete_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_snapshot_delete,
VM_NAME,
call='foo')
def test_vm_disk_snapshot_delete_no_disk_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the disk_id arg is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_snapshot_delete,
VM_NAME,
call='action',
kwargs={'snapshot_id': '0'})
def test_vm_disk_snapshot_delete_no_snapshot_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the snapshot_id arg is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_snapshot_delete,
VM_NAME,
call='action',
kwargs={'disk_id': '0'})
def test_vm_disk_snapshot_revert_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_snapshot_revert,
VM_NAME,
call='foo')
def test_vm_disk_snapshot_revert_no_disk_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the disk_id arg is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_snapshot_revert,
VM_NAME,
call='action',
kwargs={'snapshot_id': '0'})
def test_vm_disk_snapshot_revert_no_snapshot_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the snapshot_id arg is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_disk_snapshot_revert,
VM_NAME,
call='action',
kwargs={'disk_id': '0'})
def test_vm_info_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_info,
VM_NAME,
call='foo')
def test_vm_migrate_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_migrate,
VM_NAME,
call='foo')
def test_vm_migrate_no_datastore_id_or_datastore_name(self):
'''
Tests that a SaltCLoudSystemExit is raised when the datastore_id and the
datastore_name args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_migrate,
VM_NAME,
call='action',
kwargs=None)
def test_vm_migrate_no_host_id_or_host_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the the host_id and the
host_name args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_migrate,
VM_NAME,
call='action',
kwargs={'datastore_id': '0'})
def test_vm_monitoring_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_monitoring,
VM_NAME,
call='foo')
def test_vm_resize_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_resize,
VM_NAME,
call='foo')
def test_vm_resize_no_data_or_path(self):
'''
Tests that a SaltCloudSystemExit is raised when the data and path args
are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_resize,
VM_NAME,
call='action',
kwargs=None)
def test_vm_snapshot_create_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_snapshot_create,
VM_NAME,
call='foo')
def test_vm_snapshot_create_no_snapshot_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the snapshot_name arg
is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_snapshot_create,
VM_NAME,
call='action',
kwargs=None)
def test_vm_snapshot_delete_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_snapshot_delete,
VM_NAME,
call='foo')
def test_vm_snapshot_delete_no_snapshot_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the snapshot_id arg
is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_snapshot_delete,
VM_NAME,
call='action',
kwargs=None)
def test_vm_snapshot_revert_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_snapshot_revert,
VM_NAME,
call='foo')
def test_vm_snapshot_revert_no_snapshot_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the snapshot_id arg
is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_snapshot_revert,
VM_NAME,
call='action',
kwargs=None)
def test_vm_update_action_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--action or -a is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_update,
VM_NAME,
call='foo')
def test_vm_update_no_update_type(self):
'''
Tests that a SaltCloudSystemExit is raised when the update_type arg
is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_update,
VM_NAME,
call='action',
kwargs=None)
def test_vm_update_bad_update_type_value(self):
'''
Tests that a SaltCloudSystemExit is raised when the update_type kwarg is
not a valid value.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_update,
VM_NAME,
call='action',
kwargs={'update_type': 'foo'})
def test_vm_update_no_data_or_path(self):
'''
Tests that a SaltCloudSystemExit is raised when the data and path args
are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vm_update,
VM_NAME,
call='action',
kwargs={'update_type': 'merge'})
def test_vn_add_ar_function_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--function or -f is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_add_ar,
call='foo')
def test_vn_add_ar_no_vn_id_or_vn_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the vn_id and vn_name
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_add_ar,
call='function',
kwargs=None)
def test_vn_add_ar_no_path_or_data(self):
'''
Tests that a SaltCloudSystemExit is raised when the path and data
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_add_ar,
call='function',
kwargs={'vn_id': '0'})
def test_vn_allocate_function_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--function or -f is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_allocate,
call='foo')
def test_vn_allocate_no_data_or_path(self):
'''
Tests that a SaltCloudSystemExit is raised when the path and data
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_allocate,
call='function',
kwargs=None)
def test_vn_delete_function_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--function or -f is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_delete,
call='foo')
def test_vn_delete_no_vn_id_or_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the vn_id and name
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_delete,
call='function',
kwargs=None)
def test_vn_free_ar_function_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--function or -f is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_free_ar,
call='foo')
def test_vn_free_ar_no_ar_id(self):
'''
Tests that a SaltCloudSystemExit is raised when the ar_id is missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_free_ar,
call='function',
kwargs=None)
def test_vn_free_ar_no_vn_id_or_vn_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the vn_id and vn_name
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_free_ar,
call='function',
kwargs={'ar_id': '0'})
def test_vn_hold_function_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--function or -f is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_hold,
call='foo')
def test_vn_hold_no_vn_id_or_vn_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the vn_id and vn_name
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_hold,
call='function',
kwargs=None)
def test_vn_hold_no_data_or_path(self):
'''
Tests that a SaltCloudSystemExit is raised when the data and path
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_hold,
call='function',
kwargs={'vn_id': '0'})
def test_vn_info_function_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--function or -f is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_info,
call='foo')
def test_vn_info_no_vn_id_or_vn_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the vn_id and vn_name
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_info,
call='function',
kwargs=None)
def test_vn_release_function_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--function or -f is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_release,
call='foo')
def test_vn_release_no_vn_id_or_vn_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the vn_id and vn_name
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_release,
call='function',
kwargs=None)
def test_vn_release_no_data_or_path(self):
'''
Tests that a SaltCloudSystemExit is raised when the data and path
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_release,
call='function',
kwargs={'vn_id': '0'})
def test_vn_reserve_function_error(self):
'''
Tests that a SaltCloudSystemExit is raised when something other than
--function or -f is provided.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_reserve,
call='foo')
def test_vn_reserve_no_vn_id_or_vn_name(self):
'''
Tests that a SaltCloudSystemExit is raised when the vn_id and vn_name
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_reserve,
call='function',
kwargs=None)
def test_vn_reserve_no_data_or_path(self):
'''
Tests that a SaltCloudSystemExit is raised when the data and path
args are missing.
'''
self.assertRaises(SaltCloudSystemExit,
opennebula.vn_reserve,
call='function',
kwargs={'vn_id': '0'})
if __name__ == '__main__':
from integration import run_tests