def update_router(self, context, id, router): LOG.debug( _("Update router in progress: id=%(id)s " "router=%(router)r"), { 'id': id, 'router': router }) session = context.session processed_request = {} if not router['router'].get('admin_state_up', True): raise n_exc.NotImplementedError( _('admin_state_up=False ' 'routers are not ' 'supported.')) with session.begin(subtransactions=True): original_router = super(SdnvePluginV2, self).get_router(context, id) processed_request['router'] = self._process_request( router['router'], original_router) updated_router = super(SdnvePluginV2, self).update_router(context, id, router) if processed_request['router']: (res, data) = self.sdnve_client.sdnve_update( 'router', id, processed_request['router']) if res not in constants.HTTP_ACCEPTABLE: super(SdnvePluginV2, self).update_router(context, id, {'router': original_router}) raise sdnve_exc.SdnveException( msg=(_('Update router failed in SDN-VE: %s') % res)) return updated_router
def update_router(self, context, id, router): LOG.debug("Update router in progress: id=%(id)s " "router=%(router)r", {'id': id, 'router': router}) session = context.session processed_request = {} if not router['router'].get('admin_state_up', True): raise n_exc.NotImplementedError(_('admin_state_up=False ' 'routers are not ' 'supported.')) with session.begin(subtransactions=True): original_router = super(SdnvePluginV2, self).get_router( context, id) processed_request['router'] = self._process_request( router['router'], original_router) updated_router = super(SdnvePluginV2, self).update_router( context, id, router) if processed_request['router']: egw = processed_request['router'].get('external_gateway_info') # Check for existing empty set (different from None) in request if egw == {}: processed_request['router'][ 'external_gateway_info'] = {'network_id': 'null'} (res, data) = self.sdnve_client.sdnve_update( 'router', id, processed_request['router']) if res not in constants.HTTP_ACCEPTABLE: super(SdnvePluginV2, self).update_router( context, id, {'router': original_router}) raise sdnve_exc.SdnveException( msg=(_('Update router failed in SDN-VE: %s') % res)) return updated_router
def update_router(self, context, id, router): LOG.debug(_("MidonetPluginV2.update_router called: id=%(id)s " "router=%(router)r"), router) if router['router'].get('admin_state_up') is False: raise q_exc.NotImplementedError(_('admin_state_up=False ' 'routers are not ' 'supported.')) op_gateway_set = False op_gateway_clear = False # figure out which operation it is in if ('external_gateway_info' in router['router'] and 'network_id' in router['router']['external_gateway_info']): op_gateway_set = True elif ('external_gateway_info' in router['router'] and router['router']['external_gateway_info'] == {}): op_gateway_clear = True qports = super(MidonetPluginV2, self).get_ports( context, {'device_id': [id], 'device_owner': ['network:router_gateway']}) assert len(qports) == 1 qport = qports[0] snat_ip = qport['fixed_ips'][0]['ip_address'] qport['network_id'] session = context.session with session.begin(subtransactions=True): qrouter = super(MidonetPluginV2, self).update_router(context, id, router) changed_name = router['router'].get('name') if changed_name: self.client.update_router(id, changed_name) if op_gateway_set: # find a qport with the network_id for the router qports = super(MidonetPluginV2, self).get_ports( context, {'device_id': [id], 'device_owner': ['network:router_gateway']}) assert len(qports) == 1 qport = qports[0] snat_ip = qport['fixed_ips'][0]['ip_address'] self.client.set_router_external_gateway(id, self.provider_router, snat_ip) if op_gateway_clear: self.client.clear_router_external_gateway(id) LOG.debug(_("MidonetPluginV2.update_router exiting: qrouter=%r"), qrouter) return qrouter
def create_subnet(self, context, subnet): """Create Neutron subnet. Creates a Neutron subnet and a DHCP entry in MidoNet bridge. """ LOG.debug(_("MidonetPluginV2.create_subnet called: subnet=%r"), subnet) if subnet['subnet']['ip_version'] == 6: raise q_exc.NotImplementedError( _("MidoNet doesn't support IPv6.")) net = super(MidonetPluginV2, self).get_network( context, subnet['subnet']['network_id'], fields=None) if net['subnets']: raise q_exc.NotImplementedError( _("MidoNet doesn't support multiple subnets " "on the same network.")) session = context.session with session.begin(subtransactions=True): sn_entry = super(MidonetPluginV2, self).create_subnet(context, subnet) bridge = self.client.get_bridge(sn_entry['network_id']) gateway_ip = subnet['subnet']['gateway_ip'] network_address, prefix = subnet['subnet']['cidr'].split('/') self.client.create_dhcp(bridge, gateway_ip, network_address, prefix) # For external network, link the bridge to the provider router. if net['router:external']: gateway_ip = sn_entry['gateway_ip'] network_address, length = sn_entry['cidr'].split('/') self.client.link_bridge_to_provider_router( bridge, self.provider_router, gateway_ip, network_address, length) LOG.debug(_("MidonetPluginV2.create_subnet exiting: sn_entry=%r"), sn_entry) return sn_entry
def update_router(self, context, id, router): if not router['router'].get('admin_state_up', True): raise n_exc.NotImplementedError( _('admin_state_up=False ' 'routers are not ' 'supported.')) original_router = {} updated_router = {} with context.session.begin(subtransactions=True): original_router = super(SdnveL3ServicePlugin, self).get_router(context, id) updated_router = super(SdnveL3ServicePlugin, self).update_router(context, id, router) try: self.driver.update_router(context, id, original_router, router) return updated_router except Exception as e: LOG.error(_LE("Update router failed in SDN-VE with error %s"), e)
def get_ports_count(self, context, filters=None): """Return the number of ports. The result depends on the identity of the user making the request (as indicated by the context) as well as any filters. :param context: neutron api request context :param filters: a dictionary with keys that are valid keys for a network as listed in the :obj:`RESOURCE_ATTRIBUTE_MAP` object in :file:`neutron/api/v2/attributes.py`. Values in this dictiontary are an iterable containing values that will be used for an exact match comparison for that value. Each result returned by this function will have matched one of the values for each key in filters. .. note:: this method is optional, as it was not part of the originally defined plugin API. """ raise exceptions.NotImplementedError()
def update_network(self, context, id, network): """Update Neutron network. Update an existing Neutron network and its corresponding MidoNet bridge. """ LOG.debug(_("MidonetPluginV2.update_network called: id=%(id)r, " "network=%(network)r"), {'id': id, 'network': network}) # Reject admin_state_up=False if network['network'].get('admin_state_up') and network['network'][ 'admin_state_up'] is False: raise q_exc.NotImplementedError(_('admin_state_up=False ' 'networks are not ' 'supported.')) session = context.session with session.begin(subtransactions=True): net = super(MidonetPluginV2, self).update_network( context, id, network) self.client.update_bridge(id, net['name']) LOG.debug(_("MidonetPluginV2.update_network exiting: net=%r"), net) return net
def get_floatingips_count(self, context, filters=None): raise qexception.NotImplementedError()