def recreate(self, record, uuid): """ Called on xend start / restart, or machine restart, when read from saved config. Needs to check network exists, create it otherwise """ # Create instance (do this first, to check record) network = XendNetwork(record, uuid) # Create network if it doesn't already exist if not bridge_exists(network.name_label): if network.managed: Ovsctl.bridge_create(network.name_label) else: log.info("Not recreating missing unmanaged network %s" % network.name_label) return uuid
def create(self, record): """ Called from API, to create a new network """ # Create new uuids uuid = genuuid.gen_regularUuid() # Create instance (do this first, to check record) network = XendNetwork(record, uuid) # Check network doesn't already exist name_label = network.name_label if bridge_exists(name_label): del network raise UniqueNameError(name_label, "network") # Create the bridge Ovsctl.bridge_create(network.name_label) XendNode.instance().save_networks() return uuid