def start(self): ''' Start the static vlan. ''' self.logger.info("starting static vlan '%s'" % self.name) # Find the physical interface. physical_if = interface.get( self.dry_run, self.logger, self.physical_interface, root_ipdb = self.root_ipdb, ) # Create the VLAN interface. vlan_if = vlan.create( self.dry_run, self.logger, self.vlan_name, physical_if, self.id, root_ipdb = self.root_ipdb, ) # Create the veth pair. root_veth_if = veth.create( self.dry_run, self.logger, self.root_veth_name, self.netns_veth_name, root_ipdb = self.root_ipdb, ) # Move the netns veth interface to the network namespace. netns_veth_if = root_veth_if.peer_get(peer_netns=self.netns) netns_veth_if.netns_set(self.netns) # Add the assigned address for the VLAN to the netns veth # interface. netns_veth_if.add_ip(self.address, self.netmask) # Create a bridge for the physical interface to connect to the # network namespace via the veth pair. bridge_if = bridge.create( self.dry_run, self.logger, self.bridge_name, root_ipdb = self.root_ipdb, ) # Add the physical interface and the root veth interface to the # bridge. bridge_if.add_port(vlan_if) bridge_if.add_port(root_veth_if) # Finally, we're done! Bring up the interfaces! physical_if.up() vlan_if.up() root_veth_if.up() netns_veth_if.up() bridge_if.up() self.logger.info("finished starting static vlan '%s'" % self.name)
def interface_get(self, name): ''' Get an interface of the given name from this namespace. ''' return interface.get(self.dry_run, self.logger, name, netns=self)