forked from uncloud/uncloud
small cleaning
This commit is contained in:
parent
a662b1fe29
commit
02b287eff8
2 changed files with 5 additions and 6 deletions
|
@ -5,13 +5,12 @@ import uncloud.secrets as secrets
|
||||||
|
|
||||||
from xmlrpc.client import ServerProxy as RPCClient
|
from xmlrpc.client import ServerProxy as RPCClient
|
||||||
|
|
||||||
|
from django_auth_ldap.backend import LDAPBackend
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from xmltodict import parse
|
from xmltodict import parse
|
||||||
|
|
||||||
from opennebula.models import VM as VMModel
|
from opennebula.models import VM as VMModel
|
||||||
|
|
||||||
from django_auth_ldap.backend import LDAPBackend
|
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'Syncronize VM information from OpenNebula'
|
help = 'Syncronize VM information from OpenNebula'
|
||||||
|
@ -30,7 +29,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
backend = LDAPBackend()
|
backend = LDAPBackend()
|
||||||
|
|
||||||
for i, vm in enumerate(vms):
|
for vm in vms:
|
||||||
vm_id = vm['ID']
|
vm_id = vm['ID']
|
||||||
vm_owner = vm['UNAME']
|
vm_owner = vm['UNAME']
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class VM(models.Model):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ram_in_gb(self):
|
def ram_in_gb(self):
|
||||||
return int(self.data['TEMPLATE']['MEMORY'])/1024.0
|
return int(self.data['TEMPLATE']['MEMORY'])/1024
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def disks(self):
|
def disks(self):
|
||||||
|
@ -41,10 +41,10 @@ class VM(models.Model):
|
||||||
|
|
||||||
disks = [
|
disks = [
|
||||||
{
|
{
|
||||||
'size_in_gb': int(d['SIZE'])/1024.0,
|
'size_in_gb': int(d['SIZE'])/1024,
|
||||||
'opennebula_source': d['SOURCE'],
|
'opennebula_source': d['SOURCE'],
|
||||||
'opennebula_name': d['IMAGE'],
|
'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'],
|
'pool_name': d['POOL_NAME'],
|
||||||
'image': d['IMAGE'],
|
'image': d['IMAGE'],
|
||||||
'source': d['SOURCE'],
|
'source': d['SOURCE'],
|
||||||
|
|
Loading…
Add table
Reference in a new issue