X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=httpserver.py;h=ecf878c592cf226c817293f7c0c5f12fd7d93bd5;hb=8940f6c1341c3fa60bf0c20727b65dc79d345d88;hp=870d680247f4f4b398c5a80a2881c86c75ab946f;hpb=2a5a0c5f6604a8dea29bcae20d9a1b2d00bdb8ff;p=osm%2Fopenvim.git diff --git a/httpserver.py b/httpserver.py index 870d680..ecf878c 100644 --- a/httpserver.py +++ b/httpserver.py @@ -37,7 +37,8 @@ import threading import datetime import hashlib import os -import RADclass +import imp +#import only if needed because not needed in test mode. To allow an easier installation import RADclass from jsonschema import validate as js_v, exceptions as js_e import host_thread as ht from vim_schema import host_new_schema, host_edit_schema, tenant_new_schema, \ @@ -50,6 +51,8 @@ from vim_schema import host_new_schema, host_edit_schema, tenant_new_schema, \ global my global url_base global config_dic +global RADclass_module +RADclass=None #RADclass module is charged only if not in test mode url_base="/openvim" @@ -535,9 +538,14 @@ def http_post_hosts(): ip_name=host['ip_name'] user=host['user'] password=host.get('password', None) + if not RADclass_module: + try: + RADclass_module = imp.find_module("RADclass") + except (IOError, ImportError) as e: + raise ImportError("Cannot import RADclass.py Openvim not properly installed" +str(e)) #fill rad info - rad = RADclass.RADclass() + rad = RADclass_module.RADclass() (return_status, code) = rad.obtain_RAD(user, password, ip_name) #return @@ -599,7 +607,6 @@ def http_post_hosts(): sriov['source_name'] = index index += 1 interfaces.append ({'pci':str(port_k), 'Mbps': port_v['speed']/1000000, 'sriovs': new_sriovs, 'mac':port_v['mac'], 'source_name':port_v['source_name']}) - #@TODO LA memoria devuelta por el RAD es incorrecta, almenos para IVY1, NFV100 memory=node['memory']['node_size'] / (1024*1024*1024) #memory=get_next_2pow(node['memory']['hugepage_nr']) host['numas'].append( {'numa_socket': node['id'], 'hugepages': node['memory']['hugepage_nr'], 'memory':memory, 'interfaces': interfaces, 'cores': cores } )