#[ $OPENMANO_VER_NUM -ge 5009 ] && DB_VERSION=20 #0.5.9 => 20
#[ $OPENMANO_VER_NUM -ge 5015 ] && DB_VERSION=21 #0.5.15 => 21
#[ $OPENMANO_VER_NUM -ge 5016 ] && DB_VERSION=22 #0.5.16 => 22
-#[ $OPENMANO_VER_NUM -ge 5019 ] && DB_VERSION=23 #0.5.20 => 23
+#[ $OPENMANO_VER_NUM -ge 5020 ] && DB_VERSION=23 #0.5.20 => 23
#TODO ... put next versions here
function upgrade_to_1(){
#myvim.new_vminstance(self,vimURI,tenant_id,name,description,image_id,flavor_id,net_dict)
i = 0
for sce_vnf in scenarioDict['vnfs']:
- nfv_availability_zones = []
+ vnf_availability_zones = []
for vm in sce_vnf['vms']:
vm_av = vm.get('availability_zone')
- if vm_av and vm_av not in nfv_availability_zones:
- nfv_availability_zones.append(vm_av)
+ if vm_av and vm_av not in vnf_availability_zones:
+ vnf_availability_zones.append(vm_av)
+
+ # check if there is enough availability zones available at vim level.
+ if myvims[datacenter_id].availability_zone and vnf_availability_zones:
+ if len(vnf_availability_zones) > len(myvims[datacenter_id].availability_zone):
+ raise NfvoException('No enough availability zones at VIM for this deployment', HTTP_Bad_Request)
+
for vm in sce_vnf['vms']:
i += 1
myVMDict = {}
#print ">>>>>>>>>>>>>>>>>>>>>>>>>>>"
if 'availability_zone' in myVMDict:
- counter_availability_zone = nfv_availability_zones.index(myVMDict['availability_zone'])
+ av_index = vnf_availability_zones.index(myVMDict['availability_zone'])
else:
- counter_availability_zone = None
+ av_index = None
vm_id = myvim.new_vminstance(myVMDict['name'], myVMDict['description'], myVMDict.get('start', None),
myVMDict['imageRef'], myVMDict['flavorRef'], myVMDict['networks'],
- availavility_zone_index=counter_availability_zone,
- nfv_availability_zones=nfv_availability_zones)
+ availability_zone_index=av_index,
+ availability_zone_list=vnf_availability_zones)
#print "VIM vm instance id (server id) for scenario %s: %s" % (scenarioDict['name'],vm_id)
vm['vim_id'] = vm_id
rollbackList.append({'what':'vm','where':'vim','vim_id':datacenter_id,'uuid':vm_id})
sce_vnf_list = sorted(scenarioDict['vnfs'], key=lambda k: k['name'])
#for sce_vnf in scenarioDict['vnfs']:
for sce_vnf in sce_vnf_list:
- nfv_availability_zones = []
+ vnf_availability_zones = []
for vm in sce_vnf['vms']:
vm_av = vm.get('availability_zone')
- if vm_av and vm_av not in nfv_availability_zones:
- nfv_availability_zones.append(vm_av)
+ if vm_av and vm_av not in vnf_availability_zones:
+ vnf_availability_zones.append(vm_av)
# check if there is enough availability zones available at vim level.
- if myvims[datacenter_id].availability_zone:
- vim_availability_zones = myvims[datacenter_id].availability_zone
- nfv_availability_zones_num = len(vim_availability_zones)
- if len(nfv_availability_zones) > nfv_availability_zones_num:
- raise NfvoException('No enough availablity zones for this deployment', HTTP_Bad_Request)
+ if myvims[datacenter_id].availability_zone and vnf_availability_zones:
+ if len(vnf_availability_zones) > len(myvims[datacenter_id].availability_zone):
+ raise NfvoException('No enough availability zones at VIM for this deployment', HTTP_Bad_Request)
if sce_vnf.get("datacenter"):
vim = myvims[ sce_vnf["datacenter"] ]
else:
cloud_config_vm = cloud_config
- if 'availability_zone' in myVMDict and myVMDict.get('availability_zone'):
- counter_availability_zone = nfv_availability_zones.index(myVMDict['availability_zone'])
+ if myVMDict.get('availability_zone'):
+ av_index = vnf_availability_zones.index(myVMDict['availability_zone'])
else:
- counter_availability_zone = None
+ av_index = None
task = new_task("new-vm", (myVMDict['name'], myVMDict['description'], myVMDict.get('start', None),
myVMDict['imageRef'], myVMDict['flavorRef'], myVMDict['networks'],
- cloud_config_vm, myVMDict['disks'], counter_availability_zone,
- nfv_availability_zones), depends=task_depends)
+ cloud_config_vm, myVMDict['disks'], av_index,
+ vnf_availability_zones), depends=task_depends)
instance_tasks[task["id"]] = task
tasks_to_launch[myvim_thread_id].append(task)
vm_id = task["id"]
raise vimconnNotImplemented( "Should have implemented this" )
def new_vminstance(self, name, description, start, image_id, flavor_id, net_list, cloud_config=None, disk_list=None,
- availavility_zone_index=None, nfv_availability_zones=None):
+ availability_zone_index=None, availability_zone_list=None):
"""Adds a VM instance to VIM
Params:
'start': (boolean) indicates if VM must start or created in pause mode.
'disk_list': (optional) list with additional disks to the VM. Each item is a dict with:
'image_id': (optional). VIM id of an existing image. If not provided an empty disk must be mounted
'size': (mandatory) string with the size of the disk in GB
- availavility_zone_index: Index of nfv_availability_zones to use for this this VM
- nfv_availability_zones: list of availability zones given by user in the VNFC descriptor. Ignore if
- availability_zone_index is None
+ availability_zone_index: Index of availability_zone_list to use for this this VM. None if not AV required
+ availability_zone_list: list of availability zones given by user in the VNFD descriptor. Ignore if
+ availability_zone_index is None
Returns the instance identifier or raises an exception on error
"""
raise vimconnNotImplemented( "Should have implemented this" )
self.format_vimconn_exception(e)
def new_vminstance(self, name, description, start, image_id, flavor_id, net_list, cloud_config=None,
- disk_list=None):
+ disk_list=None, availability_zone_index=None, availability_zone_list=None):
"""Create a new VM/instance in AWS
Params: name
decription
else:
self.availability_zone = self._get_openstack_availablity_zones()
- def _get_vm_availavility_zone(self, availavility_zone_index, nfv_availability_zones):
+ def _get_vm_availability_zone(self, availability_zone_index, availability_zone_list):
"""
- Return a list with all availability zones create during datacenter attach.
- :return: List with availability zones
+ Return thge availability zone to be used by the created VM.
+ :return: The VIM availability zone to be used or None
"""
- openstack_avilability_zone = self.availability_zone
-
- # check if VIM offer enough availability zones describe in the VNFC
- if self.availability_zone and availavility_zone_index is not None \
- and 0 <= len(nfv_availability_zones) <= len(self.availability_zone):
-
- if nfv_availability_zones:
- vnf_azone = nfv_availability_zones[availavility_zone_index]
- zones_available = []
-
- for nfv_zone in nfv_availability_zones:
- for vim_zone in openstack_avilability_zone:
- if nfv_zone is vim_zone:
- zones_available.append(nfv_zone)
-
- if len(zones_available) == len(openstack_avilability_zone) and vnf_azone in openstack_avilability_zone:
- return vnf_azone
- else:
- return openstack_avilability_zone[availavility_zone_index]
+ if availability_zone_index is None:
+ if not self.config.get('availability_zone'):
+ return None
+ elif isinstance(self.config.get('availability_zone'), str):
+ return self.config['availability_zone']
+ else:
+ # TODO consider using a different parameter at config for default AV and AV list match
+ return self.config['availability_zone'][0]
+
+ vim_availability_zones = self.availability_zone
+ # check if VIM offer enough availability zones describe in the VNFD
+ if vim_availability_zones and len(availability_zone_list) <= len(vim_availability_zones):
+ # check if all the names of NFV AV match VIM AV names
+ match_by_index = False
+ for av in availability_zone_list:
+ if av not in vim_availability_zones:
+ match_by_index = True
+ break
+ if match_by_index:
+ return vim_availability_zones[availability_zone_index]
+ else:
+ return availability_zone_list[availability_zone_index]
else:
- raise vimconn.vimconnConflictException("No enough availablity zones for this deployment")
- return None
+ raise vimconn.vimconnConflictException("No enough availability zones at VIM for this deployment")
- def new_vminstance(self, name, description, start, image_id, flavor_id, net_list,cloud_config=None,disk_list=None,
- availavility_zone_index=None, nfv_availability_zones=None):
+ def new_vminstance(self, name, description, start, image_id, flavor_id, net_list, cloud_config=None, disk_list=None,
+ availability_zone_index=None, availability_zone_list=None):
'''Adds a VM instance to VIM
Params:
start: indicates if VM must start or boot in pause mode. Ignored
'disk_list': (optional) list with additional disks to the VM. Each item is a dict with:
'image_id': (optional). VIM id of an existing image. If not provided an empty disk must be mounted
'size': (mandatory) string with the size of the disk in GB
- availavility_zone_index:counter for instance order in vim availability_zones availables
- nfv_availability_zones: Lost given by user in the VNFC descriptor.
+ availability_zone_index: Index of availability_zone_list to use for this this VM. None if not AV required
+ availability_zone_list: list of availability zones given by user in the VNFD descriptor. Ignore if
+ availability_zone_index is None
#TODO ip, security groups
Returns the instance identifier
'''
raise vimconn.vimconnException('Timeout creating volumes for instance ' + name,
http_code=vimconn.HTTP_Request_Timeout)
# get availability Zone
- vm_av_zone = self._get_vm_availavility_zone(availavility_zone_index, nfv_availability_zones)
+ vm_av_zone = self._get_vm_availability_zone(availability_zone_index, availability_zone_list)
self.logger.debug("nova.servers.create({}, {}, {}, nics={}, meta={}, security_groups={}, "
"availability_zone={}, key_name={}, userdata={}, config_drive={}, "
#print text
return -vim_response.status_code,text
- def new_vminstance(self,name,description,start,image_id,flavor_id,net_list, cloud_config=None, disk_list=None):
+ def new_vminstance(self, name, description, start, image_id, flavor_id, net_list, cloud_config=None, disk_list=None,
+ availability_zone_index=None, availability_zone_list=None):
'''Adds a VM instance to VIM
Params:
start: indicates if VM must start or boot in pause mode. Ignored
return None
def new_vminstance(self, name=None, description="", start=False, image_id=None, flavor_id=None, net_list={},
- cloud_config=None, disk_list=None):
+ cloud_config=None, disk_list=None, availability_zone_index=None, availability_zone_list=None):
"""Adds a VM instance to VIM
Params:
start: indicates if VM must start or boot in pause mode. Ignored