示例#1
0
 def getNetwork(cls, modobj):
     """Returns addr, broadcast, netmask for each network interface."""
     for iface in network.get_physical_ifaces():
         dhcp_exists = modobj.getDHCP(iface)
         modobj.netsettings.update(
             {iface: cls._get_net(iface, dhcp_exists)})
     modobj.gateway = modobj.get_default_gateway_linux()
示例#2
0
    def __init__(self, save_only=False, managed_iface=None):
        self.save_only = save_only
        self.footer = None
        self.frame = None
        self.screen = None
        self.dns_might_have_changed = False
        self.managediface = managed_iface or network.get_physical_ifaces()[0]
        # Set to true to move all settings to end
        self.globalsave = True
        # Tasks to be executed on Apply
        self.apply_tasks = set()
        self.version = utils.get_fuel_version()

        # settings load
        self.settings = settings_module.Settings()

        self.settings.load(
            os.path.join(os.path.dirname(__file__), "settings.yaml"),
            template_kwargs={"mos_version": self.version})

        self.settings.load(
            consts.SETTINGS_FILE,
            template_kwargs={"mos_version": self.version})

        self.main()
        self.choices = []
示例#3
0
def main(*args, **kwargs):
    if urwid.VERSION < (1, 1, 0):
        print("This program requires urwid 1.1.0 or greater.")

    try:
        default_iface = network.get_physical_ifaces()[0]
    except IndexError:
        print("Unable to detect any network interfaces. Could not start")
        sys.exit(1)

    parser = OptionParser()
    parser.add_option("-s", "--save-only", dest="save_only",
                      action="store_true",
                      help="Save default values and exit.")

    parser.add_option("-i", "--iface", dest="iface", metavar="IFACE",
                      default=default_iface, help="Set IFACE as primary.")

    options, args = parser.parse_args()

    if not network.is_interface_has_ip(options.iface):
        print("Selected interface '{0}' has no assigned IP. "
              "Could not start.".format(options.iface))
        sys.exit(1)

    if options.save_only:
        save_only(options.iface)
    else:
        setup()
示例#4
0
    def __init__(self, save_only=False, managed_iface=None):
        self.save_only = save_only
        self.footer = None
        self.frame = None
        self.screen = None
        self.dns_might_have_changed = False
        self.managediface = managed_iface or network.get_physical_ifaces()[0]
        # Set to true to move all settings to end
        self.globalsave = True
        # Tasks to be executed on Apply
        self.apply_tasks = set()
        self.version = utils.get_fuel_version()
        self.codename = 'xenial'

        # settings load
        self.settings = settings_module.Settings()

        template_kwargs = {
            "mos_version": self.version,
            "codename": self.codename,
        }

        self.settings.load(
            os.path.join(os.path.dirname(__file__), "settings.yaml"),
            template_kwargs=template_kwargs)

        self.settings.load(
            consts.SETTINGS_FILE,
            template_kwargs=template_kwargs)

        self.main()
        self.choices = []
示例#5
0
def main(*args, **kwargs):
    if urwid.VERSION < (1, 1, 0):
        print("This program requires urwid 1.1.0 or greater.")

    try:
        default_iface = network.get_physical_ifaces()[0]
    except IndexError:
        print("Unable to detect any network interfaces. Could not start")
        sys.exit(1)

    parser = OptionParser()
    parser.add_option("-s", "--save-only", dest="save_only",
                      action="store_true",
                      help="Save default values and exit.")

    parser.add_option("-i", "--iface", dest="iface", metavar="IFACE",
                      default=default_iface, help="Set IFACE as primary.")

    options, args = parser.parse_args()

    if not network.is_interface_has_ip(options.iface):
        print("Selected interface '{0}' has no assigned IP. "
              "Could not start.".format(options.iface))
        sys.exit(1)

    if options.save_only:
        save_only(options.iface)
    else:
        setup()
    def test_get_physical_ifaces(self, is_physical_mock, netifaces_mock):
        all_ifaces = ['eth0', 'lo', 'veth0']

        is_physical_mock.side_effect = [True, False, False]
        netifaces_mock.interfaces.return_value = all_ifaces
        data = network.get_physical_ifaces()
        netifaces_mock.interfaces.assert_called_once_with()
        self.assertEqual(['eth0'], data)
示例#7
0
 def getNetwork(cls, modobj):
     """Returns addr, broadcast, netmask for each network interface."""
     for iface in network.get_physical_ifaces():
         dhcp_exists = modobj.getDHCP(iface)
         modobj.netsettings.update(
             {iface: cls._get_net(iface, dhcp_exists)}
         )
     modobj.gateway = modobj.get_default_gateway_linux()
示例#8
0
    def test_get_physical_ifaces(self, is_physical_mock, netifaces_mock):
        all_ifaces = ['eth0', 'lo', 'veth0']

        is_physical_mock.side_effect = [True, False, False]
        netifaces_mock.interfaces.return_value = all_ifaces
        data = network.get_physical_ifaces()
        netifaces_mock.interfaces.assert_called_once_with()
        self.assertEqual(['eth0'], data)
示例#9
0
def main(*args, **kwargs):
    if urwid.VERSION < (1, 1, 0):
        print("This program requires urwid 1.1.0 or greater.")

    network_interfaces = network.get_physical_ifaces()
    if not network_interfaces:
        print("Unable to detect any network interfaces. Could not start")
        sys.exit(1)

    default_iface = network_interfaces[0]

    for nic in network_interfaces:
        if network.is_interface_has_ip(nic):
            default_iface = nic
            break

    parser = optparse.OptionParser()
    parser.add_option("-s", "--save-only", dest="save_only",
                      action="store_true",
                      help="Save default values and exit.")

    parser.add_option("-i", "--iface", dest="iface", metavar="IFACE",
                      default=default_iface, help="Set IFACE as primary.")

    parser.add_option("-l", "--lock-file",
                      default=consts.DEFAULT_LOCK_FILE,
                      help="Path to the process lock file. If unspecified, "
                           "the default {} is used."
                           .format(consts.DEFAULT_LOCK_FILE))

    options, args = parser.parse_args()

    if not utils.lock_running(options.lock_file):
        sys.exit(1)

    if not network.is_interface_has_ip(options.iface):
        print("Selected interface '{0}' has no assigned IP. "
              "Could not start.".format(options.iface))
        sys.exit(1)

    if options.save_only:
        setup(save_only=True,
              managed_iface=options.iface)
    else:
        if not os.isatty(sys.stdin.fileno()):
            print("Stdin is not a tty, can't run fuelmenu "
                  "in interactive mode.")
            sys.exit(1)
        setup()
示例#10
0
def main(*args, **kwargs):
    if urwid.VERSION < (1, 1, 0):
        print("This program requires urwid 1.1.0 or greater.")

    network_interfaces = network.get_physical_ifaces()
    if not network_interfaces:
        print("Unable to detect any network interfaces. Could not start")
        sys.exit(1)

    default_iface = network_interfaces[0]

    for nic in network_interfaces:
        if network.is_interface_has_ip(nic):
            default_iface = nic
            break

    parser = OptionParser()
    parser.add_option("-s", "--save-only", dest="save_only",
                      action="store_true",
                      help="Save default values and exit.")

    parser.add_option("-i", "--iface", dest="iface", metavar="IFACE",
                      default=default_iface, help="Set IFACE as primary.")

    parser.add_option("-l", "--lock-file",
                      default=consts.DEFAULT_LOCK_FILE,
                      help="Path to the process lock file. If unspecified, "
                           "the default {} is used."
                           .format(consts.DEFAULT_LOCK_FILE))

    options, args = parser.parse_args()

    if not utils.lock_running(options.lock_file):
        sys.exit(1)

    if not network.is_interface_has_ip(options.iface):
        print("Selected interface '{0}' has no assigned IP. "
              "Could not start.".format(options.iface))
        sys.exit(1)

    if options.save_only:
        setup(save_only=True,
              managed_iface=options.iface)
    else:
        setup()
示例#11
0
    def __init__(self):
        self.footer = None
        self.frame = None
        self.screen = None
        self.managediface = network.get_physical_ifaces()[0]
        # Set to true to move all settings to end
        self.globalsave = True
        self.version = utils.get_fuel_version()

        # settings load
        self.settings = settings_module.Settings()

        self.settings.load(
            os.path.join(os.path.dirname(__file__), "settings.yaml"),
            template_kwargs={"mos_version": self.version})

        self.settings.load(
            consts.SETTINGS_FILE,
            template_kwargs={"mos_version": self.version})

        self.main()
        self.choices = []
示例#12
0
    def __init__(self):
        self.footer = None
        self.frame = None
        self.screen = None
        self.managediface = network.get_physical_ifaces()[0]
        self.dns_might_have_changed = False
        # Set to true to move all settings to end
        self.globalsave = True
        self.version = utils.get_fuel_version()

        # settings load
        self.settings = settings_module.Settings()

        self.settings.load(
            os.path.join(os.path.dirname(__file__), "settings.yaml"),
            template_kwargs={"mos_version": self.version})

        self.settings.load(
            consts.SETTINGS_FILE,
            template_kwargs={"mos_version": self.version})

        self.main()
        self.choices = []