def delete_network(self, context, id): vlan_id = ovs_db_v2.get_vlan(id) result = super(OVSQuantumPluginV2, self).delete_network(context, id) ovs_db_v2.release_vlan_id(vlan_id) if self.rpc: self.notifier.network_delete(self.context, id) return result
def create_network_bulk(self, context, networks): """ Perform this operation in the context of the configured device plugins. """ LOG.debug("create_network_bulk() called\n") try: args = [context, networks] ovs_output = self._plugins[ const.VSWITCH_PLUGIN].create_network_bulk(context, networks) vlan_ids = odb.get_vlans() vlanids = '' for v_id in vlan_ids: vlanids = str(v_id[0]) + ',' + vlanids vlanids = vlanids.strip(',') LOG.debug("ovs_output: %s\n " % ovs_output) ovs_networks = ovs_output for ovs_network in ovs_networks: vlan_id = odb.get_vlan(ovs_network['id']) vlan_name = conf.VLAN_NAME_PREFIX + str(vlan_id) args = [ovs_network['tenant_id'], ovs_network['name'], ovs_network['id'], vlan_name, vlan_id, {'vlan_ids':vlanids}] nexus_output = self._invoke_plugin_per_device( const.NEXUS_PLUGIN, "create_network", args) return ovs_output except: # TODO (Sumit): Check if we need to perform any rollback here raise
def update_port(self, context, id, port): if self.rpc: original_port = super(OVSQuantumPluginV2, self).get_port(context, id) port = super(OVSQuantumPluginV2, self).update_port(context, id, port) if self.rpc: if original_port['admin_state_up'] != port['admin_state_up']: vlan_id = ovs_db_v2.get_vlan(port['network_id']) self.notifier.port_update(self.context, port, vlan_id) return port
def get_device_details(self, context, **kwargs): """Agent requests device details""" agent_id = kwargs.get('agent_id') device = kwargs.get('device') LOG.debug("Device %s details requested from %s", device, agent_id) port = ovs_db_v2.get_port(device) if port: vlan_id = ovs_db_v2.get_vlan(port['network_id']) entry = {'device': device, 'vlan_id': vlan_id, 'network_id': port['network_id'], 'port_id': port['id'], 'admin_state_up': port['admin_state_up']} # Set the port status to UP ovs_db_v2.set_port_status(port['id'], api_common.PORT_STATUS_UP) else: entry = {'device': device} LOG.debug("%s can not be found in database", device) return entry
def update_network(self, context, id, network): """ Perform this operation in the context of the configured device plugins. """ LOG.debug("update_network() called\n") args = [context, id, network] ovs_output = self._invoke_plugin_per_device(const.VSWITCH_PLUGIN, self._func_name(), args) vlan_id = odb.get_vlan(ovs_output[0]['id']) vlan_ids = ','.join(str(vlan[0]) for vlan in odb.get_vlans()) args = [ovs_output[0]['tenant_id'], id, {'vlan_id': vlan_id}, {'net_admin_state': ovs_output[0]['admin_state_up']}, {'vlan_ids': vlan_ids}] nexus_output = self._invoke_plugin_per_device(const.NEXUS_PLUGIN, self._func_name(), args) return ovs_output[0]
def delete_network(self, context, id): """ Perform this operation in the context of the configured device plugins. """ try: base_plugin_ref = QuantumManager.get_plugin() n = base_plugin_ref.get_network(context, id) tenant_id = n['tenant_id'] vlan_id = odb.get_vlan(id) output = [] args = [tenant_id, id, {const.VLANID:vlan_id}, {const.CONTEXT:context}, {const.BASE_PLUGIN_REF:base_plugin_ref}] nexus_output = self._invoke_plugin_per_device(const.NEXUS_PLUGIN, self._func_name(), args) args = [context, id] ovs_output = self._invoke_plugin_per_device(const.VSWITCH_PLUGIN, self._func_name(), args) return ovs_output[0] except: raise
def _extend_network_dict(self, context, network): if self._check_provider_view_auth(context, network): if not self.enable_tunneling: network['provider:vlan_id'] = ovs_db_v2.get_vlan(network['id'])