From a3077cbb859a9237f9516ed0f073fe00839277c4 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 1 Nov 2010 16:25:56 -0700 Subject: basics to get proxied ajaxterm working with virsh --- nova/virt/libvirt.qemu.xml.template | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'nova/virt') diff --git a/nova/virt/libvirt.qemu.xml.template b/nova/virt/libvirt.qemu.xml.template index 2538b1ade..d5a249665 100644 --- a/nova/virt/libvirt.qemu.xml.template +++ b/nova/virt/libvirt.qemu.xml.template @@ -4,6 +4,9 @@ hvm %(basepath)s/kernel %(basepath)s/ramdisk + root=/dev/vda1 console=ttyS0 @@ -25,9 +28,15 @@ + + + + + -- cgit From 08963a0df7a6d1c90ba12ce60cbf15c93b0b70e6 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 21 Dec 2010 14:44:53 -0800 Subject: prototype works with kvm. now moving call from api to compute --- nova/virt/libvirt.qemu.xml.template | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt.qemu.xml.template b/nova/virt/libvirt.qemu.xml.template index d5a249665..1f0c8a3ff 100644 --- a/nova/virt/libvirt.qemu.xml.template +++ b/nova/virt/libvirt.qemu.xml.template @@ -4,9 +4,6 @@ hvm %(basepath)s/kernel %(basepath)s/ramdisk - root=/dev/vda1 console=ttyS0 @@ -28,15 +25,22 @@ - - - - - ---> + + + + + + + + + + + -- cgit From a84e2b9131e4c8b212c9de0b9ad4931f7743ff75 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 21 Dec 2010 18:20:55 -0800 Subject: move prototype code from api into compute worker --- nova/virt/libvirt_conn.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 509ed97a0..f2110e4e8 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -42,6 +42,10 @@ from nova.compute import disk from nova.compute import instance_types from nova.compute import power_state from nova.virt import images +import subprocess +import random +import uuid +from xml.dom import minidom libvirt = None libxml2 = None @@ -71,7 +75,9 @@ flags.DEFINE_string('libvirt_uri', flags.DEFINE_bool('allow_project_net_traffic', True, 'Whether to allow in project network traffic') - +flags.DEFINE_string('console_dmz', + 'tonbuntu:8000', + 'location of console proxy') def get_connection(read_only): # These are loaded late so that there's no need to install these @@ -310,6 +316,47 @@ class LibvirtConnection(object): d.addCallback(self._dump_file) return d + @exception.wrap_exception + def get_ajax_console(self, instance): + def get_open_port(): + for i in xrange(0,100): # don't loop forever + port = random.randint(10000, 12000) + cmd = 'netcat 0.0.0.0 %s -w 2 < /dev/null' % (port,) + # this Popen will exit with 0 only if the port is in use, + # so a nonzero return value implies it is unused + port_is_unused = (subprocess.Popen(cmd, shell=True).wait() != 0) + if port_is_unused: + return port + raise 'Unable to find an open port' + + def get_pty_for_instance(instance_name): + stdout, stderr = utils.execute('virsh dumpxml %s' % instance_name) + dom = minidom.parseString(stdout) + serials = dom.getElementsByTagName('serial') + for serial in serials: + if serial.getAttribute('type') == 'pty': + source = serial.getElementsByTagName('source')[0] + return source.getAttribute('path') + + port = get_open_port() + token = str(uuid.uuid4()) + + host = instance['host'] + + if FLAGS.libvirt_type == 'uml': + pass #FIXME + elif FLAGS.libvirt_type == 'xen': + pass #FIXME + else: + ajaxterm_cmd = 'socat - %s' % get_pty_for_instance(instance['name']) + + cmd = '%s/tools/ajaxterm/ajaxterm.py --command "%s" -t %s -p %s' \ + % (utils.novadir(), ajaxterm_cmd, token, port) + + subprocess.Popen(cmd, shell=True) + return 'http://%s/?token=%s&host=%s&port=%s' \ + % (FLAGS.console_dmz, token, host, port) + @defer.inlineCallbacks def _create_image(self, inst, libvirt_xml): # syntactic nicety -- cgit From 28645bec4a6d084f6dc6fa51184061844826cb12 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 21 Dec 2010 23:15:00 -0800 Subject: a few more fixes after merge with trunk --- nova/virt/libvirt_conn.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index d39e3cc5b..b186a7c45 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -42,6 +42,7 @@ import shutil import random import subprocess import uuid +from xml.dom import minidom from eventlet import event @@ -86,6 +87,9 @@ flags.DEFINE_string('libvirt_uri', flags.DEFINE_bool('allow_project_net_traffic', True, 'Whether to allow in project network traffic') +flags.DEFINE_string('console_dmz', + 'tonbuntu:8000', + 'location of console proxy') def get_connection(read_only): @@ -389,13 +393,13 @@ class LibvirtConnection(object): def get_open_port(): for i in xrange(0,100): # don't loop forever port = random.randint(10000, 12000) - cmd = 'netcat 0.0.0.0 %s -w 2 < /dev/null' % (port,) - # this Popen will exit with 0 only if the port is in use, + # netcat will exit with 0 only if the port is in use, # so a nonzero return value implies it is unused - port_is_unused = (subprocess.Popen(cmd, shell=True).wait() != 0) - if port_is_unused: + cmd = 'netcat 0.0.0.0 %s -w 1 < /dev/null || echo free' % (port) + stdout, stderr = utils.execute(cmd) + if stdout.strip() == 'free': return port - raise 'Unable to find an open port' + raise Exception('Unable to find an open port') def get_pty_for_instance(instance_name): stdout, stderr = utils.execute('virsh dumpxml %s' % instance_name) -- cgit From 19f389b3dcc89f0115dc6fc1a6ca606338ad866a Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 22 Dec 2010 12:36:37 -0800 Subject: working connection security --- nova/virt/libvirt_conn.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index b186a7c45..800312c98 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -87,9 +87,6 @@ flags.DEFINE_string('libvirt_uri', flags.DEFINE_bool('allow_project_net_traffic', True, 'Whether to allow in project network traffic') -flags.DEFINE_string('console_dmz', - 'tonbuntu:8000', - 'location of console proxy') def get_connection(read_only): @@ -426,8 +423,9 @@ class LibvirtConnection(object): % (utils.novadir(), ajaxterm_cmd, token, port) subprocess.Popen(cmd, shell=True) - return 'http://%s/?token=%s&host=%s&port=%s' \ - % (FLAGS.console_dmz, token, host, port) + return {'token': token, 'host': host, 'port': port} + #return 'http://%s/?token=%s&host=%s&port=%s' \ + # % (FLAGS.console_dmz, token, host, port) def _create_image(self, inst, libvirt_xml, prefix='', disk_images=None): # syntactic nicety -- cgit From 0093342106cc270859df0511dbefad8ec8fc2320 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 22 Dec 2010 13:31:33 -0800 Subject: use libvirt python bindings instead of system call --- nova/virt/libvirt_conn.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 800312c98..658efa8d1 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -392,17 +392,18 @@ class LibvirtConnection(object): port = random.randint(10000, 12000) # netcat will exit with 0 only if the port is in use, # so a nonzero return value implies it is unused - cmd = 'netcat 0.0.0.0 %s -w 1 < /dev/null || echo free' % (port) + cmd = 'netcat 0.0.0.0 %s -w 1 Date: Wed, 22 Dec 2010 18:52:43 -0800 Subject: minor notes, commit before rewriting proxy with eventlet --- nova/virt/libvirt_conn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 658efa8d1..55754ea48 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -389,7 +389,7 @@ class LibvirtConnection(object): def get_ajax_console(self, instance): def get_open_port(): for i in xrange(0,100): # don't loop forever - port = random.randint(10000, 12000) + port = random.randint(10000, 12000) #TODO - make flag # netcat will exit with 0 only if the port is in use, # so a nonzero return value implies it is unused cmd = 'netcat 0.0.0.0 %s -w 1 Date: Thu, 23 Dec 2010 00:23:08 -0800 Subject: move port range for ajaxterm to flag --- nova/virt/libvirt_conn.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 55754ea48..1049eaefa 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -87,6 +87,9 @@ flags.DEFINE_string('libvirt_uri', flags.DEFINE_bool('allow_project_net_traffic', True, 'Whether to allow in project network traffic') +flags.DEFINE_string('ajaxterm_portrange', + '10000-12000', + 'Range of ports that ajaxterm should randomly try to bind') def get_connection(read_only): @@ -388,8 +391,9 @@ class LibvirtConnection(object): @exception.wrap_exception def get_ajax_console(self, instance): def get_open_port(): + start_port, end_port = FLAGS.ajaxterm_portrange.split("-") for i in xrange(0,100): # don't loop forever - port = random.randint(10000, 12000) #TODO - make flag + port = random.randint(int(start_port), int(end_port)) # netcat will exit with 0 only if the port is in use, # so a nonzero return value implies it is unused cmd = 'netcat 0.0.0.0 %s -w 1 Date: Thu, 23 Dec 2010 00:58:15 -0800 Subject: removing xen/uml specific switches. If they need special treatment, we can add it --- nova/virt/libvirt_conn.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index d855770b7..3c0efd18f 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -427,12 +427,7 @@ class LibvirtConnection(object): host = instance['host'] - if FLAGS.libvirt_type == 'uml': - pass #FIXME - elif FLAGS.libvirt_type == 'xen': - pass #FIXME - else: - ajaxterm_cmd = 'socat - %s' % get_pty_for_instance(instance['name']) + ajaxterm_cmd = 'socat - %s' % get_pty_for_instance(instance['name']) cmd = '%s/tools/ajaxterm/ajaxterm.py --command "%s" -t %s -p %s' \ % (utils.novadir(), ajaxterm_cmd, token, port) -- cgit From 43dfae5926bafa1575aee9624651cfcb8f170bb3 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 23 Dec 2010 01:22:54 -0800 Subject: some pep8 fixes --- nova/virt/libvirt_conn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 3c0efd18f..40a430d86 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -402,7 +402,7 @@ class LibvirtConnection(object): def get_ajax_console(self, instance): def get_open_port(): start_port, end_port = FLAGS.ajaxterm_portrange.split("-") - for i in xrange(0,100): # don't loop forever + for i in xrange(0,100): # don't loop forever port = random.randint(int(start_port), int(end_port)) # netcat will exit with 0 only if the port is in use, # so a nonzero return value implies it is unused -- cgit From 35638077a186f9315ac6e30cdbe096730a540ed8 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 28 Dec 2010 17:42:33 -0800 Subject: add in unit tests --- nova/virt/fake.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'nova/virt') diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 238acf798..b97dbd511 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -260,6 +260,8 @@ class FakeConnection(object): def get_console_output(self, instance): return 'FAKE CONSOLE OUTPUT' + def get_ajax_console(self, instance): + return 'http://fakeajaxconsole.com/?token=FAKETOKEN' class FakeInstance(object): -- cgit From f4a2d86519434f934bd6c90ba401b08875420d19 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Mon, 3 Jan 2011 05:17:42 -0800 Subject: temp --- nova/virt/xenapi/vm_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 9d1b51848..8d344d84c 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -360,7 +360,8 @@ class VMHelper(HelperBase): if i >= 3 and i <= 11: ref = node.childNodes # Name and Value - diags[ref[0].firstChild.data] = ref[6].firstChild.data + if len(ref) > 6: + diags[ref[0].firstChild.data] = ref[6].firstChild.data return diags except cls.XenAPI.Failure as e: return {"Unable to retrieve diagnostics": e} -- cgit From 8df8dd5cedb8bd84053fa489df8b9cf34ee68895 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 3 Jan 2011 08:56:36 -0800 Subject: add stubs for xen driver --- nova/virt/xenapi/vmops.py | 5 +++++ nova/virt/xenapi_conn.py | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'nova/virt') diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 76f31635a..146b9e6df 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -281,3 +281,8 @@ class VMOps(object): """Return snapshot of console""" # TODO: implement this to fix pylint! return 'FAKE CONSOLE OUTPUT of instance' + + def get_ajax_console(self, instance): + """Return link to instance's ajax console""" + # TODO: implement this! + return 'http://fakeajaxconsole/fake_url' diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py index f17c8f39d..e1ad04b15 100644 --- a/nova/virt/xenapi_conn.py +++ b/nova/virt/xenapi_conn.py @@ -175,6 +175,10 @@ class XenAPIConnection(object): """Return snapshot of console""" return self._vmops.get_console_output(instance) + def get_ajax_console(self, instance): + """Return link to instance's ajax console""" + return self._vmops.get_ajax_console(instance) + def attach_volume(self, instance_name, device_path, mountpoint): """Attach volume storage to VM instance""" return self._volumeops.attach_volume(instance_name, -- cgit From a073e6eab677d8903bd35f94e5e8ebce9d392c2d Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Mon, 3 Jan 2011 16:05:55 -0800 Subject: Add support for rbd volumes. --- nova/virt/libvirt_conn.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 00edfbdc8..b515e53d7 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -223,11 +223,24 @@ class LibvirtConnection(object): def attach_volume(self, instance_name, device_path, mountpoint): virt_dom = self._conn.lookupByName(instance_name) mount_device = mountpoint.rpartition("/")[2] - xml = """ - - - - """ % (device_path, mount_device) + if device_path.startswith('/dev/'): + xml = """ + + + + """ % (device_path, mount_device) + elif ':' in device_path: + (protocol, name) = device_path.split(':') + xml = """ + + + + """ % (protocol, + name, + mount_device) + else: + raise exception.Invalid(_("Invalid device path %s") % device_path) + virt_dom.attachDevice(xml) def _get_disk_xml(self, xml, device): -- cgit From ee2d8a5bcdaf938b7047131d7809d1b6b3120b59 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Mon, 3 Jan 2011 22:51:19 -0800 Subject: some fixes per vish's feedback --- nova/virt/libvirt_conn.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 6471e8c0c..a36af16e2 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -438,7 +438,7 @@ class LibvirtConnection(object): stdout, stderr = utils.execute(cmd) if stdout.strip() == 'free': return port - raise Exception('Unable to find an open port') + raise Exception(_('Unable to find an open port')) def get_pty_for_instance(instance_name): virt_dom = self._conn.lookupByName(instance_name) @@ -452,7 +452,6 @@ class LibvirtConnection(object): port = get_open_port() token = str(uuid.uuid4()) - host = instance['host'] ajaxterm_cmd = 'socat - %s' % get_pty_for_instance(instance['name']) @@ -462,8 +461,6 @@ class LibvirtConnection(object): subprocess.Popen(cmd, shell=True) return {'token': token, 'host': host, 'port': port} - #return 'http://%s/?token=%s&host=%s&port=%s' \ - # % (FLAGS.console_dmz, token, host, port) def _create_image(self, inst, libvirt_xml, prefix='', disk_images=None): # syntactic nicety -- cgit From 7c01430020ceabec765f388b70685808064cda3f Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 4 Jan 2011 16:22:47 -0800 Subject: some more cleanup --- nova/virt/libvirt.xml.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt.xml.template b/nova/virt/libvirt.xml.template index 3317c9eca..2eb7d9488 100644 --- a/nova/virt/libvirt.xml.template +++ b/nova/virt/libvirt.xml.template @@ -72,7 +72,7 @@ - + -- cgit From e774f2cd7206b5ae632a42c1eda7330858b1613c Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 5 Jan 2011 03:51:21 -0400 Subject: pep8 --- nova/virt/xenapi/vm_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 8d344d84c..b91c37fb0 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -361,7 +361,8 @@ class VMHelper(HelperBase): ref = node.childNodes # Name and Value if len(ref) > 6: - diags[ref[0].firstChild.data] = ref[6].firstChild.data + diags[ref[0].firstChild.data] = \ + ref[6].firstChild.data return diags except cls.XenAPI.Failure as e: return {"Unable to retrieve diagnostics": e} -- cgit From 732d1946b5de78ec5e5ad8ac13b7d02c5fd90d10 Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Wed, 5 Jan 2011 09:40:19 -0400 Subject: self.XENAPI... --- nova/virt/xenapi/vmops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 76f31635a..67c95a068 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -215,7 +215,7 @@ class VMOps(object): ret = None try: ret = self._session.wait_for_task(instance_id, task) - except XenAPI.Failure, exc: + except self.XenAPI.Failure, exc: logging.warn(exc) callback(ret) -- cgit From b437a98738c7a564205d1b27e36b844cd54445d1 Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Wed, 5 Jan 2011 14:16:14 -0600 Subject: add in xs-console worker and tests. --- nova/virt/fake.py | 5 +++++ nova/virt/libvirt_conn.py | 8 ++++++++ nova/virt/xenapi_conn.py | 7 +++++++ 3 files changed, 20 insertions(+) (limited to 'nova/virt') diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 706888b0d..acabb8034 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -272,6 +272,11 @@ class FakeConnection(object): def get_console_output(self, instance): return 'FAKE CONSOLE OUTPUT' + def get_console_pool_info(self, console_type): + return {'address' : '127.0.0.1', + 'username' : 'fakeuser', + 'password' : 'fakepassword'} + class FakeInstance(object): diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 65cf65098..51353147f 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -671,6 +671,14 @@ class LibvirtConnection(object): fw = NWFilterFirewall(self._conn) fw.ensure_security_group_filter(security_group_id) + def get_console_pool_info(self, console_type): + #TODO(mdragon): console proxy should be implemented for libvirt, + # in case someone wants to use it with kvm or + # such. For now return fake data. + return {'address' : '127.0.0.1', + 'username' : 'fakeuser', + 'password' : 'fakepassword'} + class NWFilterFirewall(object): """ diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py index 7f03d6c2b..abad0a08a 100644 --- a/nova/virt/xenapi_conn.py +++ b/nova/virt/xenapi_conn.py @@ -52,6 +52,7 @@ reactor thread if the VM.get_by_name_label or VM.get_record calls block. import logging import sys +import urlparse import xmlrpclib from eventlet import event @@ -177,6 +178,12 @@ class XenAPIConnection(object): """Detach volume storage to VM instance""" return self._volumeops.detach_volume(instance_name, mountpoint) + def get_console_pool_info(self, console_type): + xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url) + return {'address' : xs_url.netloc, + 'username' : FLAGS.xenapi_connection_username, + 'password' : FLAGS.xenapi_connection_password} + class XenAPISession(object): """The session to invoke XenAPI SDK calls""" -- cgit From 9b99e385967c4ba21d94d82aa62115fc11634118 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 5 Jan 2011 14:57:31 -0800 Subject: socat will need to be added to our nova sudoers --- nova/virt/libvirt_conn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index a36af16e2..d83c57741 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -454,7 +454,7 @@ class LibvirtConnection(object): token = str(uuid.uuid4()) host = instance['host'] - ajaxterm_cmd = 'socat - %s' % get_pty_for_instance(instance['name']) + ajaxterm_cmd = 'sudo socat - %s' % get_pty_for_instance(instance['name']) cmd = '%s/tools/ajaxterm/ajaxterm.py --command "%s" -t %s -p %s' \ % (utils.novadir(), ajaxterm_cmd, token, port) -- cgit From f21f078113fc81c1dcee4f3a077bd555c0cf85f6 Mon Sep 17 00:00:00 2001 From: Monsyne Dragon Date: Wed, 5 Jan 2011 19:45:46 -0600 Subject: Fix a bunch of pep8 stuff --- nova/virt/fake.py | 6 +++--- nova/virt/libvirt_conn.py | 8 ++++---- nova/virt/xenapi_conn.py | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 13490b12e..849261f07 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -290,9 +290,9 @@ class FakeConnection(object): return 'FAKE CONSOLE OUTPUT' def get_console_pool_info(self, console_type): - return {'address' : '127.0.0.1', - 'username' : 'fakeuser', - 'password' : 'fakepassword'} + return {'address': '127.0.0.1', + 'username': 'fakeuser', + 'password': 'fakepassword'} class FakeInstance(object): diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index ded1004cd..0e3b6dff6 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -697,10 +697,10 @@ class LibvirtConnection(object): def get_console_pool_info(self, console_type): #TODO(mdragon): console proxy should be implemented for libvirt, # in case someone wants to use it with kvm or - # such. For now return fake data. - return {'address' : '127.0.0.1', - 'username' : 'fakeuser', - 'password' : 'fakepassword'} + # such. For now return fake data. + return {'address': '127.0.0.1', + 'username': 'fakeuser', + 'password': 'fakepassword'} class NWFilterFirewall(object): diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py index c702059f7..86efb6b07 100644 --- a/nova/virt/xenapi_conn.py +++ b/nova/virt/xenapi_conn.py @@ -189,9 +189,9 @@ class XenAPIConnection(object): def get_console_pool_info(self, console_type): xs_url = urlparse.urlparse(FLAGS.xenapi_connection_url) - return {'address' : xs_url.netloc, - 'username' : FLAGS.xenapi_connection_username, - 'password' : FLAGS.xenapi_connection_password} + return {'address': xs_url.netloc, + 'username': FLAGS.xenapi_connection_username, + 'password': FLAGS.xenapi_connection_password} class XenAPISession(object): -- cgit From ea4cde387c04e450c7bea9407772ca4276ea54f4 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Tue, 11 Jan 2011 11:06:16 +0100 Subject: Fixed a number of issues with the iptables firewall backend: * Port specifications for firewalls come back from the data store as integers, but were compared as strings. * --icmp-type was misspelled as --icmp_type (underscore vs dash) * There weren't any unit tests for these issues. --- nova/virt/libvirt_conn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 3a4b6d469..759ef62ab 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -1105,15 +1105,15 @@ class IptablesFirewallDriver(FirewallDriver): icmp_type = rule.from_port icmp_code = rule.to_port - if icmp_type == '-1': + if icmp_type == -1: icmp_type_arg = None else: icmp_type_arg = '%s' % icmp_type - if not icmp_code == '-1': + if not icmp_code == -1: icmp_type_arg += '/%s' % icmp_code if icmp_type_arg: - args += ['-m', 'icmp', '--icmp_type', icmp_type_arg] + args += ['-m', 'icmp', '--icmp-type', icmp_type_arg] args += ['-j ACCEPT'] our_rules += [' '.join(args)] -- cgit From eb48bdce5ad131245977dff50030f5561b8809c1 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 11 Jan 2011 14:33:20 -0800 Subject: bah - pep8 errors --- nova/virt/fake.py | 1 + nova/virt/libvirt_conn.py | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 925c32e4d..8abe08e41 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -292,6 +292,7 @@ class FakeConnection(object): def get_ajax_console(self, instance): return 'http://fakeajaxconsole.com/?token=FAKETOKEN' + class FakeInstance(object): def __init__(self): diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index dc31d8357..4a907c88f 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -445,7 +445,7 @@ class LibvirtConnection(object): def get_ajax_console(self, instance): def get_open_port(): start_port, end_port = FLAGS.ajaxterm_portrange.split("-") - for i in xrange(0,100): # don't loop forever + for i in xrange(0, 100): # don't loop forever port = random.randint(int(start_port), int(end_port)) # netcat will exit with 0 only if the port is in use, # so a nonzero return value implies it is unused @@ -469,10 +469,11 @@ class LibvirtConnection(object): token = str(uuid.uuid4()) host = instance['host'] - ajaxterm_cmd = 'sudo socat - %s' % get_pty_for_instance(instance['name']) + ajaxterm_cmd = 'sudo socat - %s' \ + % get_pty_for_instance(instance['name']) cmd = '%s/tools/ajaxterm/ajaxterm.py --command "%s" -t %s -p %s' \ - % (utils.novadir(), ajaxterm_cmd, token, port) + % (utils.novadir(), ajaxterm_cmd, token, port) subprocess.Popen(cmd, shell=True) return {'token': token, 'host': host, 'port': port} -- cgit From c29fe496c1124369a8b9b77aeee84e8296f964f9 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Wed, 12 Jan 2011 11:28:05 -0600 Subject: fixed pause and resume --- nova/virt/xenapi/vmops.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index e20930fe8..5ca127f36 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -252,7 +252,7 @@ class VMOps(object): raise Exception(_("suspend: instance not present %s") % instance_name) task = self._session.call_xenapi('Async.VM.suspend', vm) - self._wait_with_callback(task, callback) + self._wait_with_callback(instance.id, task, callback) def resume(self, instance, callback): """resume the specified instance""" @@ -262,7 +262,7 @@ class VMOps(object): raise Exception(_("resume: instance not present %s") % instance_name) task = self._session.call_xenapi('Async.VM.resume', vm, False, True) - self._wait_with_callback(task, callback) + self._wait_with_callback(instance.id, task, callback) def get_info(self, instance_id): """Return data about VM instance""" -- cgit From f3332a1a63db657b84b52cf17ff46a853dfd063c Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 13 Jan 2011 01:25:08 +0000 Subject: Fixes #701055. Move instance termination code inline to prevent manager from prematurely marking it as destroyed. --- nova/virt/libvirt_conn.py | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index bd863b3a2..c03046703 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -197,40 +197,27 @@ class LibvirtConnection(object): pass # If the instance is already terminated, we're still happy - done = event.Event() - # We'll save this for when we do shutdown, # instead of destroy - but destroy returns immediately timer = utils.LoopingCall(f=None) - def _wait_for_shutdown(): + while True: try: state = self.get_info(instance['name'])['state'] db.instance_set_state(context.get_admin_context(), instance['id'], state) if state == power_state.SHUTDOWN: - timer.stop() + break except Exception: db.instance_set_state(context.get_admin_context(), instance['id'], power_state.SHUTDOWN) - timer.stop() + break + + if cleanup: + self._cleanup(instance) - timer.f = _wait_for_shutdown - timer_done = timer.start(interval=0.5, now=True) - - # NOTE(termie): this is strictly superfluous (we could put the - # cleanup code in the timer), but this emulates the - # previous model so I am keeping it around until - # everything has been vetted a bit - def _wait_for_timer(): - timer_done.wait() - if cleanup: - self._cleanup(instance) - done.send() - - greenthread.spawn(_wait_for_timer) - return done + return True def _cleanup(self, instance): target = os.path.join(FLAGS.instances_path, instance['name']) -- cgit