Add hacking script for import vm info into etcd
This commit is contained in:
parent
fea52e0295
commit
8ef053eb49
1 changed files with 28 additions and 0 deletions
28
etcd_import_opennebula_vm.py
Normal file
28
etcd_import_opennebula_vm.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import json
|
||||
import pprint
|
||||
#import etcd3
|
||||
|
||||
with open("nico-vm-one.json", "r") as fd:
|
||||
vmcontent = fd.read()
|
||||
|
||||
#vm = json.loads(vmcontent.decode('utf-8'))
|
||||
vm = json.loads(vmcontent)
|
||||
pprint.pprint(vm['TEMPLATE']['DISK'])
|
||||
|
||||
# storing info
|
||||
|
||||
for_etcd={}
|
||||
for_etcd['data_version'] = "1"
|
||||
for_etcd['vm_id'] = vm['ID']
|
||||
for_etcd['owner'] = vm['UNAME']
|
||||
|
||||
for_etcd['disks'] = []
|
||||
for disk in vm['TEMPLATE']['DISK']:
|
||||
disk_etcd = {}
|
||||
disk_etcd['image_name'] = disk['IMAGE']
|
||||
disk_etcd['image_id'] = disk['IMAGE_ID']
|
||||
disk_etcd['datastore_name'] = disk['DATASTORE']
|
||||
disk_etcd['datastore_id'] = disk['DATASTORE_ID']
|
||||
for_etcd['disks'].append(disk_etcd)
|
||||
|
||||
pprint.pprint(for_etcd)
|
Loading…
Reference in a new issue