From 02b287eff846320a4b4f19d42fa23270ea00d4ff Mon Sep 17 00:00:00 2001 From: meow Date: Wed, 4 Mar 2020 14:44:41 +0500 Subject: [PATCH] small cleaning --- uncloud/opennebula/management/commands/syncvm.py | 5 ++--- uncloud/opennebula/models.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/uncloud/opennebula/management/commands/syncvm.py b/uncloud/opennebula/management/commands/syncvm.py index ff620f7..458528b 100644 --- a/uncloud/opennebula/management/commands/syncvm.py +++ b/uncloud/opennebula/management/commands/syncvm.py @@ -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'] diff --git a/uncloud/opennebula/models.py b/uncloud/opennebula/models.py index e69b4d0..0748ff5 100644 --- a/uncloud/opennebula/models.py +++ b/uncloud/opennebula/models.py @@ -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'],