def _get_all_segmentation_ids(self): vlan_ids = cdb.get_ovs_vlans() vlanids = '' for v_id in vlan_ids: if int(v_id) > 0: vlanids = str(v_id) + ',' + vlanids return vlanids.strip(',')
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 = cdb.get_ovs_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 = self._get_segmentation_id(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_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 = self._get_segmentation_id(ovs_output[0]['id']) vlan_ids = ','.join(str(vlan[0]) for vlan in cdb.get_ovs_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]