示例#1
0
 def _validate_any_seg_id_empty_in_interface_dict(self, devices):
     """Validate segmentation_id for consistency."""
     for device in devices:
         interface_list = device['interfaces']
         if not interface_list:
             raise l2gw_exc.L2GatewayInterfaceRequired()
         if constants.SEG_ID in interface_list[0]:
             for interfaces in interface_list[1:len(interface_list)]:
                 if constants.SEG_ID not in interfaces:
                     raise l2gw_exc.L2GatewaySegmentationRequired()
         if constants.SEG_ID not in interface_list[0]:
             for interfaces in interface_list[1:len(interface_list)]:
                 if constants.SEG_ID in interfaces:
                     raise l2gw_exc.L2GatewaySegmentationRequired()
示例#2
0
 def validate_l2_gateway_for_update(self, context, id, l2_gateway):
     self._admin_check(context, 'UPDATE')
     gw = l2_gateway[self.gateway_resource]
     devices = None
     dev_db = None
     if 'devices' in gw:
         devices = gw['devices']
     if not devices:
         return
     with context.session.begin(subtransactions=True):
         # Attemp to retrieve l2gw
         gw_db = self._get_l2_gateway(context, id)
         if devices:
             for device in devices:
                 dev_name = device['device_name']
                 dev_db = self._get_l2gw_devices_by_name_andl2gwid(
                     context, dev_name, id)
                 if not dev_db:
                     raise l2gw_exc.L2GatewayDeviceNotFound(
                         device_id=dev_name)
                 self.validate_device_name(context, dev_name, id)
                 interface_list = device['interfaces']
                 if not interface_list:
                     raise l2gw_exc.L2GatewayInterfaceRequired()
                 if constants.SEG_ID in interface_list[0]:
                     for interfaces in interface_list:
                         if constants.SEG_ID not in interfaces:
                             raise l2gw_exc.L2GatewaySegmentationRequired()
                 if constants.SEG_ID not in interface_list[0]:
                     for interfaces in interface_list[1:]:
                         if constants.SEG_ID in interfaces:
                             raise l2gw_exc.L2GatewaySegmentationRequired()
                 if gw_db.devices:
                     if gw_db.devices[0].interfaces[0]['segmentation_id']:
                         if constants.SEG_ID not in interface_list[0]:
                             raise l2gw_exc.L2GatewaySegmentationIDExists()
                     else:
                         if constants.SEG_ID in interface_list[0]:
                             raise l2gw_exc.\
                                 L2GatewaySegmentationIDNotExists()