+ ####### VIO Specific Changes #########
+ def _genrate_vlanID(self):
+ """
+ Method to get unused vlanID
+ Args:
+ None
+ Returns:
+ vlanID
+ """
+ #Get used VLAN IDs
+ usedVlanIDs = []
+ networks = self.get_network_list()
+ for net in networks:
+ if net.get('provider:segmentation_id'):
+ usedVlanIDs.append(net.get('provider:segmentation_id'))
+ used_vlanIDs = set(usedVlanIDs)
+
+ #find unused VLAN ID
+ for vlanID_range in self.config.get('dataplane_net_vlan_range'):
+ try:
+ start_vlanid , end_vlanid = map(int, vlanID_range.replace(" ", "").split("-"))
+ for vlanID in xrange(start_vlanid, end_vlanid + 1):
+ if vlanID not in used_vlanIDs:
+ return vlanID
+ except Exception as exp:
+ raise vimconn.vimconnException("Exception {} occurred while generating VLAN ID.".format(exp))
+ else:
+ raise vimconn.vimconnConflictException("Unable to create the SRIOV VLAN network."\
+ " All given Vlan IDs {} are in use.".format(self.config.get('dataplane_net_vlan_range')))
+
+
+ def _validate_vlan_ranges(self, dataplane_net_vlan_range):
+ """
+ Method to validate user given vlanID ranges
+ Args: None
+ Returns: None
+ """
+ for vlanID_range in dataplane_net_vlan_range:
+ vlan_range = vlanID_range.replace(" ", "")
+ #validate format
+ vlanID_pattern = r'(\d)*-(\d)*$'
+ match_obj = re.match(vlanID_pattern, vlan_range)
+ if not match_obj:
+ raise vimconn.vimconnConflictException("Invalid dataplane_net_vlan_range {}.You must provide "\
+ "'dataplane_net_vlan_range' in format [start_ID - end_ID].".format(vlanID_range))
+
+ start_vlanid , end_vlanid = map(int,vlan_range.split("-"))
+ if start_vlanid <= 0 :
+ raise vimconn.vimconnConflictException("Invalid dataplane_net_vlan_range {}."\
+ "Start ID can not be zero. For VLAN "\
+ "networks valid IDs are 1 to 4094 ".format(vlanID_range))
+ if end_vlanid > 4094 :
+ raise vimconn.vimconnConflictException("Invalid dataplane_net_vlan_range {}."\
+ "End VLAN ID can not be greater than 4094. For VLAN "\
+ "networks valid IDs are 1 to 4094 ".format(vlanID_range))
+
+ if start_vlanid > end_vlanid:
+ raise vimconn.vimconnConflictException("Invalid dataplane_net_vlan_range {}."\
+ "You must provide a 'dataplane_net_vlan_range' in format start_ID - end_ID and "\
+ "start_ID < end_ID ".format(vlanID_range))
+