def prompt_for_bridge(self): # TODO prompt user to ask about bridging maas nw interface self.should_bridge_maasnw = True self.display_controller.info_message("Configuring MAAS Network") if self.should_bridge_maasnw: log.debug("bridging maas network") self.configure_nat(get_network('br0')) log.debug("configured NAT") self.enable_ipv4_forwarding() log.debug("enabled forwarding") self.gateway = get_ip_addr('br0') # excludes = [self.iface_ip] else: self.gateway = get_default_gateway() # excludes = [self.iface_ip, self.gateway] # excludes = list(map(ip_address, excludes)) # nw = ip_network(self.iface_network, strict=False) # self.dhcp_range = ip_range_max(nw, excludes) self.display_controller.info_message( "Detecting Existing DHCP server") self.start_task("Searching for existing DHCP servers") # TODO Handle existing dhcp with another dialog or user interaction # to accept the consequences. if self.detect_existing_dhcp(self.target_iface): log.error( "An existing DHCP server was found on this interface, " "the network may be incorrectly configured.") pass
def interface_choice_cb(self, choice): self.target_iface = choice self.iface_ip = get_ip_addr(self.target_iface) self.iface_network = get_network(self.target_iface) self.update_progress() self.continue_with_interface()
def prompt_for_bridge(self): # TODO prompt user to ask about bridging maas nw interface self.should_bridge_maasnw = True self.display_controller.status_info_message("Configuring MAAS Network") if self.should_bridge_maasnw: log.debug("bridging maas network") self.configure_nat(get_network('br0')) log.debug("configured NAT") self.enable_ipv4_forwarding() log.debug("enabled forwarding") self.gateway = get_ip_addr('br0') # excludes = [self.iface_ip] else: self.gateway = get_default_gateway() # excludes = [self.iface_ip, self.gateway] # excludes = list(map(ip_address, excludes)) # nw = ip_network(self.iface_network, strict=False) # self.dhcp_range = ip_range_max(nw, excludes) self.display_controller.status_info_message( "Detecting Existing DHCP server") self.tasker.start_task("Searching for existing DHCP servers") # TODO Handle existing dhcp with another dialog or user interaction # to accept the consequences. if self.detect_existing_dhcp(self.target_iface): log.error("An existing DHCP server was found on this interface, " "the network may be incorrectly configured.") pass
def configure_maas_networking(self, cluster_uuid, interface, gateway, dhcp_range, static_range): """ set up or update the node-group-interface. dhcp_range is a tuple of ip addresses as strings: (low, high) """ maas_query_cmd = ('maas maas node-group-interfaces' ' list {}'.format(cluster_uuid)) out = utils.get_command_output(maas_query_cmd) interfaces = json.loads(out['output']) nmatching = len([i for i in interfaces if i['interface'] == interface]) interface_exists = nmatching == 1 paramstr = ('ip={address} interface={interface} ' 'management=2 subnet_mask={netmask} ' 'broadcast_ip={bcast} router_ip={gateway} ' 'ip_range_low={ip_range_low} ' 'ip_range_high={ip_range_high} ' 'static_ip_range_low={static_ip_range_low} ' 'static_ip_range_high={static_ip_range_high}') args = dict(uuid=cluster_uuid, interface=interface, address=get_ip_addr(interface), netmask=get_netmask(interface), bcast=get_bcast_addr(interface), gateway=gateway, ip_range_low=dhcp_range[0], ip_range_high=dhcp_range[1], static_ip_range_low=static_range[0], static_ip_range_high=static_range[1]) if interface_exists: cmd = ('maas maas node-group-interface update {uuid} {interface} ' + paramstr).format(**args) else: cmd = ('maas maas node-group-interfaces new {uuid} ' + paramstr).format(**args) out = utils.get_command_output(cmd) if out['status'] != 0: log.debug("cmd failed: {}\n - output" "={}".format(cmd, out)) raise MaasInstallError("unable to create or update network")
def configure_maas_networking(self, cluster_uuid, interface, gateway, dhcp_range, static_range): """ set up or update the node-group-interface. dhcp_range is a tuple of ip addresses as strings: (low, high) """ maas_query_cmd = ('maas maas node-group-interfaces' ' list {}'.format(cluster_uuid)) out = utils.get_command_output(maas_query_cmd) interfaces = json.loads(out['output']) nmatching = len([i for i in interfaces if i['interface'] == interface]) interface_exists = nmatching == 1 paramstr = ('ip={address} interface={interface} ' 'management=2 subnet_mask={netmask} ' 'broadcast_ip={bcast} router_ip={gateway} ' 'ip_range_low={ip_range_low} ' 'ip_range_high={ip_range_high} ' 'static_ip_range_low={static_ip_range_low} ' 'static_ip_range_high={static_ip_range_high}') args = dict(uuid=cluster_uuid, interface=interface, address=get_ip_addr(interface), netmask=get_netmask(interface), bcast=get_bcast_addr(interface), gateway=gateway, ip_range_low=dhcp_range[0], ip_range_high=dhcp_range[1], static_ip_range_low=static_range[0], static_ip_range_high=static_range[1]) if interface_exists: cmd = ('maas maas node-group-interface update ' '{uuid} {interface} paramstr').format(**args) else: cmd = ('maas maas node-group-interfaces new {uuid} ' + paramstr).format(**args) out = utils.get_command_output(cmd) if out['status'] != 0: log.debug("cmd failed: {}\n - output" "={}".format(cmd, out)) raise MaasInstallError("unable to create or update network")
def interface_choice_cb(self, choice): self.target_iface = choice self.iface_ip = get_ip_addr(self.target_iface) self.iface_network = get_network(self.target_iface) self.prompt_for_dhcp_range()