): log.fail("Invalid device name:[%s].", device_name) exit(1) network = options.network if network is not None and network not in virthost.get_network_list(): log.fail("No network named: [%s].", network) exit(1) bridge = options.bridge if bridge is not None and bridge not in virthost.get_bridge_list(): log.fail("No bridge named: [%s].", bridge) exit(1) if options.device is None and options.network is None and options.bridge is None: device_name = virthost.get_default_device() if not device_name: log.fail( "Failed to get default device. " "Please specify a NIC or network/bridge for the new created virtual interface." ) exit(1) if options.vif_ip is not None: if not virthost.is_IP_available( options.vif_ip, options.vif_netmask, device_name, network, bridge): log.fail("IP check failed.") exit(1) if options.add_index: vif_index = options.add_index
if device_name is not None and device_name not in virthost.get_all_devices( ): log.fail("Invalid device name:[%s].", device_name) exit(1) network = options.network if network is not None and network not in virthost.get_network_list( ): log.fail("No network named: [%s].", network) exit(1) bridge = options.bridge if bridge is not None and bridge not in virthost.get_bridge_list(): log.fail("No bridge named: [%s].", bridge) exit(1) if options.device is None and options.network is None and options.bridge is None: options.device = virthost.get_default_device() if not options.device: log.fail( "Failed to get default device. " "Please specify a NIC or network for the new created virtual interface." ) exit(1) if not virthost.is_IP_available(options.vif_ip, vif_netmask=options.vif_netmask, device=options.device, network=options.network, bridge=options.bridge): log.fail("IP check failed.") exit(1)