diff --git a/vmware_nsx/shell/nsx_instance_if_migrate.py b/vmware_nsx/shell/nsx_instance_if_migrate.py index 053a9637b7..d8536a5bd6 100644 --- a/vmware_nsx/shell/nsx_instance_if_migrate.py +++ b/vmware_nsx/shell/nsx_instance_if_migrate.py @@ -37,6 +37,7 @@ def usage(): "[--project-domain-id=] " "[--user-domain-id=] " "[--machine-type=] " "[--nsx-bridge=]\n\n" "Convert libvirt interface definitions on a KVM host, to NSX " "managed vSwitch definitions\n\n" @@ -46,6 +47,7 @@ def usage(): " project domain: Keystone project domain\n" " user domain: Keystone user domain\n" " migrated machine type: Overwrites libvirt's machine type\n" + " log file: Output log of the command execution\n" " NSX managed vSwitch: vSwitch on host, managed by NSX\n\n") sys.exit() @@ -64,6 +66,7 @@ def get_opts(): 'user-domain-id=', 'auth-url=', 'machine-type=', + 'logfile=', 'nsx-bridge=']) except getopt.GetoptError as err: LOG.error(err) @@ -188,6 +191,13 @@ def instance_migrate(libvirt_conn, neutron, instance, machine_type, def main(): opts = get_opts() + if opts.get('logfile'): + f_handler = logging.FileHandler(opts.get('logfile')) + f_formatter = logging.Formatter( + '%(asctime)s %(levelname)s %(message)s') + f_handler.setFormatter(f_formatter) + LOG.addHandler(f_handler) + conn = libvirt.open('qemu:///system') if conn is None: LOG.error('Failed to connect to libvirt')