diff --git a/hosting/admin.py b/hosting/admin.py
index a4fadcf3..01e713a8 100644
--- a/hosting/admin.py
+++ b/hosting/admin.py
@@ -111,6 +111,7 @@ class VirtualMachinePlanAdmin(admin.ModelAdmin):
class HostingManageVMsAdmin(admin.ModelAdmin):
client = None
def get_urls(self):
+ self.client = oca.Client(settings.OPENNEBULA_USERNAME + ':' + settings.OPENNEBULA_PASSWORD, settings.OPENNEBULA_PROTOCOL + '://' + settings.OPENNEBULA_DOMAIN + ':' + settings.OPENNEBULA_PORT + settings.OPENNEBULA_ENDPOINT)
urls = super().get_urls()
socket.setdefaulttimeout(5)
my_urls = [
@@ -124,13 +125,8 @@ class HostingManageVMsAdmin(admin.ModelAdmin):
s_message = ''
e_message = ''
try :
- client = oca.Client(settings.OPENNEBULA_USERNAME + ':' + settings.OPENNEBULA_PASSWORD, settings.OPENNEBULA_PROTOCOL + '://' + settings.OPENNEBULA_DOMAIN + ':' + settings.OPENNEBULA_PORT + settings.OPENNEBULA_ENDPOINT)
- vm_pool = oca.VirtualMachinePool(client)
+ vm_pool = oca.VirtualMachinePool(self.client)
vm_pool.info()
- for vm in vm_pool:
- vm.info()
- print("%s (memory: %s MB)" % ( vm.name, vm.template.memory))
-
except socket.timeout:
e_message = "Socket timeout error."
except OpenNebulaException:
@@ -150,10 +146,10 @@ class HostingManageVMsAdmin(admin.ModelAdmin):
s_message = ''
e_message = ''
try :
- client = oca.Client(settings.OPENNEBULA_USERNAME + ':' + settings.OPENNEBULA_PASSWORD, settings.OPENNEBULA_PROTOCOL + '://' + settings.OPENNEBULA_DOMAIN + ':' + settings.OPENNEBULA_PORT + settings.OPENNEBULA_ENDPOINT)
# Lets create a test VM with 128MB of ram and 1 CPU
- vm_id = oca.VirtualMachine.allocate(client, '
{{error_msg}}
@@ -10,11 +11,28 @@ {% if vms %}ID | +Name | +Memory | +Status | +User Name | +
---|---|---|---|---|
{{vm.id}} | +{{vm.name}} | +{{vm.template.memory}} | +{{vm.str_state}} | +{{vm.uname}} | +