small cleaning

This commit is contained in:
ahmadbilalkhalid 2020-03-04 14:44:41 +05:00
parent a662b1fe29
commit 02b287eff8
2 changed files with 5 additions and 6 deletions

View file

@ -5,13 +5,12 @@ import uncloud.secrets as secrets
from xmlrpc.client import ServerProxy as RPCClient
from django_auth_ldap.backend import LDAPBackend
from django.core.management.base import BaseCommand
from xmltodict import parse
from opennebula.models import VM as VMModel
from django_auth_ldap.backend import LDAPBackend
class Command(BaseCommand):
help = 'Syncronize VM information from OpenNebula'
@ -30,7 +29,7 @@ class Command(BaseCommand):
backend = LDAPBackend()
for i, vm in enumerate(vms):
for vm in vms:
vm_id = vm['ID']
vm_owner = vm['UNAME']

View file

@ -19,7 +19,7 @@ class VM(models.Model):
@property
def ram_in_gb(self):
return int(self.data['TEMPLATE']['MEMORY'])/1024.0
return int(self.data['TEMPLATE']['MEMORY'])/1024
@property
def disks(self):
@ -41,10 +41,10 @@ class VM(models.Model):
disks = [
{
'size_in_gb': int(d['SIZE'])/1024.0,
'size_in_gb': int(d['SIZE'])/1024,
'opennebula_source': d['SOURCE'],
'opennebula_name': d['IMAGE'],
'image_size_in_gb': int(d['ORIGINAL_SIZE'])/1024.0,
'image_size_in_gb': int(d['ORIGINAL_SIZE'])/1024,
'pool_name': d['POOL_NAME'],
'image': d['IMAGE'],
'source': d['SOURCE'],