Merge pull request #234 from Modulos/create_vm

Create vm
This commit is contained in:
Levi Velázquez 2017-05-09 23:33:45 -05:00 committed by GitHub
commit 5861bec4a6
2 changed files with 17 additions and 0 deletions

View file

@ -83,3 +83,19 @@ class OpenNebulaManager():
protocol=settings.OPENNEBULA_PROTOCOL)
)
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

View file

@ -84,6 +84,7 @@ class VirtualMachineTestCase(TestCase):
def test_model_can_delete_a_virtualmachine(self):
"""Test the virtualmachine model can delete a virtualmachine."""
self.virtualmachine.save()
old_count = VirtualMachine.objects.count()
VirtualMachine.objects.first().delete()
new_count = VirtualMachine.objects.count()