Add create vm function
This commit is contained in:
parent
ec945cc31b
commit
b62819ae79
2 changed files with 17 additions and 0 deletions
|
@ -83,3 +83,19 @@ class OpenNebulaManager():
|
||||||
protocol=settings.OPENNEBULA_PROTOCOL)
|
protocol=settings.OPENNEBULA_PROTOCOL)
|
||||||
)
|
)
|
||||||
return user_pool
|
return user_pool
|
||||||
|
|
||||||
|
def create_virtualmachine(self, template_id):
|
||||||
|
template_pool = oca.VmTemplatePool(self.oneadmin_client)
|
||||||
|
template_pool.info()
|
||||||
|
|
||||||
|
template = template_pool.get_by_id(template_id)
|
||||||
|
|
||||||
|
vm_id = template.instantiate()
|
||||||
|
self.oneadmin.call(
|
||||||
|
oca.VirtualMachine.METHODS['chown'],
|
||||||
|
vm_id,
|
||||||
|
self.opennebula_user.id,
|
||||||
|
self.opennebula_user.group_ids[0]
|
||||||
|
)
|
||||||
|
return vm_id
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@ class VirtualMachineTestCase(TestCase):
|
||||||
|
|
||||||
def test_model_can_delete_a_virtualmachine(self):
|
def test_model_can_delete_a_virtualmachine(self):
|
||||||
"""Test the virtualmachine model can delete a virtualmachine."""
|
"""Test the virtualmachine model can delete a virtualmachine."""
|
||||||
|
self.virtualmachine.save()
|
||||||
old_count = VirtualMachine.objects.count()
|
old_count = VirtualMachine.objects.count()
|
||||||
VirtualMachine.objects.first().delete()
|
VirtualMachine.objects.first().delete()
|
||||||
new_count = VirtualMachine.objects.count()
|
new_count = VirtualMachine.objects.count()
|
||||||
|
|
Loading…
Reference in a new issue