1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | ODL_NETWORK = 'network' ODL_NETWORKS = 'networks' ODL_SUBNET = 'subnet' ODL_SUBNETS = 'subnets' ODL_PORT = 'port' ODL_PORTS = 'ports' #下面是创建、更新、删除、网络组件的代码 def create_network_postcommit(self, context): self.synchronize('create', ODL_NETWORKS, context) def update_network_postcommit(self, context): self.synchronize('update', ODL_NETWORKS, context) def delete_network_postcommit(self, context): self.synchronize('delete', ODL_NETWORKS, context) def create_subnet_postcommit(self, context): self.synchronize('create', ODL_SUBNETS, context) def update_subnet_postcommit(self, context): self.synchronize('update', ODL_SUBNETS, context) def delete_subnet_postcommit(self, context): self.synchronize('delete', ODL_SUBNETS, context) def create_port_postcommit(self, context): self.synchronize('create', ODL_PORTS, context) def update_port_postcommit(self, context): self.synchronize('update', ODL_PORTS, context) def delete_port_postcommit(self, context): self.synchronize('delete', ODL_PORTS, context) #下面是把端口绑定到子网的代码 def bind_port(self, context): LOG.debug(_("Attempting to bind port %(port)s on " "network %(network)s"), {'port': context.current['id'], 'network': context.network.current['id']}) for segment in context.network.network_segments: if self.check_segment(segment): context.set_binding(segment[api.ID], self.vif_type, self.vif_details, status=n_const.PORT_STATUS_ACTIVE) LOG.debug(_("Bound using segment: %s"), segment) return else: LOG.debug(_("Refusing to bind port for segment ID %(id)s, " "segment %(seg)s, phys net %(physnet)s, and " "network type %(nettype)s"), {'id': segment[api.ID], 'seg': segment[api.SEGMENTATION_ID], 'physnet': segment[api.PHYSICAL_NETWORK], 'nettype': segment[api.NETWORK_TYPE]}) |
欢迎光临 51学通信论坛2017新版 (http://bbs.51xuetongxin.com/) | Powered by Discuz! X3 |