Exemplo n.º 1
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()
Exemplo n.º 2
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()
Exemplo n.º 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()
Exemplo n.º 4
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()
 def test_interface_has_ip_true(self, addrs_mock):
     iface = 'eth0'
     addrs_mock.return_value = {netifaces.AF_INET: '192.168.1.2'}
     self.assertTrue(network.is_interface_has_ip(iface))
     addrs_mock.assert_called_once_with(iface)
 def test_interface_has_ip_false(self, addrs_mock):
     iface = 'eth0'
     addrs_mock.return_value = {'some_key': 'some_value'}
     self.assertFalse(network.is_interface_has_ip(iface))
     addrs_mock.assert_called_once_with(iface)
Exemplo n.º 7
0
 def test_interface_has_ip_true(self, addrs_mock):
     iface = 'eth0'
     addrs_mock.return_value = {netifaces.AF_INET: '192.168.1.2'}
     self.assertTrue(network.is_interface_has_ip(iface))
     addrs_mock.assert_called_once_with(iface)
Exemplo n.º 8
0
 def test_interface_has_ip_false(self, addrs_mock):
     iface = 'eth0'
     addrs_mock.return_value = {'some_key': 'some_value'}
     self.assertFalse(network.is_interface_has_ip(iface))
     addrs_mock.assert_called_once_with(iface)