示例#1
0
 def update_l2_gateway(self, context, id, l2_gateway):
     """Update l2 gateway."""
     self._admin_check(context, 'UPDATE')
     gw = l2_gateway[self.gateway_resource]
     if 'devices' in gw:
         devices = gw['devices']
     with context.session.begin(subtransactions=True):
         l2gw_db = self._get_l2_gateway(context, id)
         if l2gw_db.network_connections:
             raise l2gw_exc.L2GatewayInUse(gateway_id=id)
         dev_db = self._get_l2_gateway_devices(context, id)
         if not gw.get('devices'):
             l2gw_db.name = gw.get('name')
             return self._make_l2_gateway_dict(l2gw_db)
         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="")
             interface_db = self._get_l2_gw_interfaces(
                 context, dev_db[0].id)
             self._delete_l2_gateway_interfaces(context, interface_db)
             interface_dict_list = []
             self.validate_device_name(context, dev_name, id)
             for interfaces in device['interfaces']:
                 interface_dict_list.append(interfaces)
             self._update_interfaces_db(context, interface_dict_list,
                                        dev_db)
     if gw.get('name'):
         l2gw_db.name = gw.get('name')
     return self._make_l2_gateway_dict(l2gw_db)
示例#2
0
 def delete_l2_gateway(self, context, id):
     """delete the l2 gateway by id."""
     self.l2gateway_db._admin_check(context, 'DELETE')
     with context.session.begin(subtransactions=True):
         gw_db = self.l2gateway_db._get_l2_gateway(context, id)
         if gw_db is None:
             raise l2gw_exc.L2GatewayNotFound(gateway_id=id)
         if gw_db.network_connections:
             raise l2gw_exc.L2GatewayInUse(gateway_id=id)
         return gw_db
示例#3
0
 def validate_l2_gateway_for_delete(self, context, l2gw_id):
     self._admin_check(context, 'DELETE')
     gw_db = self._get_l2_gateway(context, l2gw_id)
     if gw_db.network_connections:
         raise l2gw_exc.L2GatewayInUse(gateway_id=l2gw_id)
     return