Skip to content

Commit

Permalink
Remove ajaxterm from Nova
Browse files Browse the repository at this point in the history
Removes copy of ajaxterm code, nova-ajax-console-proxy,
and support for get_ajax_console from Nova proper.

Implements blueprint remove-ajaxterm
Fixes bug 917963

Change-Id: I2c0ff427c53c0f63a18b10475d6b4cbe9a085d83
  • Loading branch information
ttx committed Feb 7, 2012
1 parent ae377f4 commit 7141072
Show file tree
Hide file tree
Showing 36 changed files with 3 additions and 3,873 deletions.
146 changes: 0 additions & 146 deletions bin/nova-ajax-console-proxy

This file was deleted.

13 changes: 0 additions & 13 deletions nova/compute/api.py
Expand Up @@ -1573,19 +1573,6 @@ def inject_file(self, context, instance, path, file_contents):
self._cast_compute_message('inject_file', context,
instance, params=params)

@wrap_check_policy
def get_ajax_console(self, context, instance):
"""Get a url to an AJAX Console."""
output = self._call_compute_message('get_ajax_console',
context,
instance)
rpc.cast(context, '%s' % FLAGS.ajax_console_proxy_topic,
{'method': 'authorize_ajax_console',
'args': {'token': output['token'], 'host': output['host'],
'port': output['port']}})
return {'url': '%s/?token=%s' % (FLAGS.ajax_console_proxy_url,
output['token'])}

@wrap_check_policy
def get_vnc_console(self, context, instance, console_type):
"""Get a url to an instance Console."""
Expand Down
9 changes: 0 additions & 9 deletions nova/compute/manager.py
Expand Up @@ -1551,15 +1551,6 @@ def _tail_log(self, log, length):
else:
return '\n'.join(log.split('\n')[-int(length):])

@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@wrap_instance_fault
def get_ajax_console(self, context, instance_uuid):
"""Return connection information for an ajax console."""
context = context.elevated()
LOG.debug(_("instance %s: getting ajax console"), instance_uuid)
instance_ref = self.db.instance_get_by_uuid(context, instance_uuid)
return self.driver.get_ajax_console(instance_ref)

@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
@wrap_instance_fault
def get_vnc_console(self, context, instance_uuid, console_type):
Expand Down
9 changes: 0 additions & 9 deletions nova/flags.py
Expand Up @@ -250,15 +250,6 @@ def _get_my_ip():
cfg.StrOpt('network_topic',
default='network',
help='the topic network nodes listen on'),
cfg.StrOpt('ajax_console_proxy_topic',
default='ajax_proxy',
help='the topic ajax proxy nodes listen on'),
cfg.StrOpt('ajax_console_proxy_url',
default='http://127.0.0.1:8000',
help='URL of ajax console proxy, in the form http://host:port'),
cfg.IntOpt('ajax_console_proxy_port',
default=8000,
help='port that ajax_console_proxy binds'),
cfg.StrOpt('vsa_topic',
default='vsa',
help='the topic that nova-vsa service listens on'),
Expand Down
4 changes: 0 additions & 4 deletions nova/tests/fake_libvirt_utils.py
Expand Up @@ -93,10 +93,6 @@ def get_open_port(start_port, end_port):
return int((start_port + end_port) / 2)


def run_ajaxterm(cmd, token, port):
pass


def get_fs_info(path):
return {'total': 128 * (1024 ** 3),
'used': 44 * (1024 ** 3),
Expand Down
1 change: 0 additions & 1 deletion nova/tests/policy.json
Expand Up @@ -20,7 +20,6 @@
"compute:lock": [],
"compute:unlock": [],

"compute:get_ajax_console": [],
"compute:get_vnc_console": [],
"compute:get_console_output": [],

Expand Down
21 changes: 0 additions & 21 deletions nova/tests/test_compute.py
Expand Up @@ -724,16 +724,6 @@ def test_console_output_tail(self):
self.assertEqual(output, 'ANOTHER\nLAST LINE')
self.compute.terminate_instance(self.context, instance['uuid'])

def test_ajax_console(self):
"""Make sure we can get console output from instance"""
instance = self._create_fake_instance()
self.compute.run_instance(self.context, instance['uuid'])

console = self.compute.get_ajax_console(self.context,
instance['uuid'])
self.assert_(set(['token', 'host', 'port']).issubset(console.keys()))
self.compute.terminate_instance(self.context, instance['uuid'])

def test_novnc_vnc_console(self):
"""Make sure we can a vnc console for an instance."""
instance = self._create_fake_instance()
Expand Down Expand Up @@ -2990,17 +2980,6 @@ def vnc_rpc_call_wrapper(*args, **kwargs):
'novnc')
self.compute_api.delete(self.context, instance)

def test_ajax_console(self):
"""Make sure we can an ajax console for an instance."""
def ajax_rpc_call_wrapper(*args, **kwargs):
return {'token': 'asdf', 'host': '0.0.0.0', 'port': 8080}

self.stubs.Set(rpc, 'call', ajax_rpc_call_wrapper)

instance = self._create_fake_instance()
console = self.compute_api.get_ajax_console(self.context, instance)
self.compute_api.delete(self.context, instance)

def test_console_output(self):
instance = self._create_fake_instance()
console = self.compute_api.get_console_output(self.context, instance)
Expand Down
14 changes: 0 additions & 14 deletions nova/tests/test_libvirt.py
Expand Up @@ -1925,20 +1925,6 @@ def test_file_open(self):
finally:
os.unlink(dst_path)

def test_run_ajaxterm(self):
self.mox.StubOutWithMock(utils, 'execute')
token = 's3cr3tt0ken'
shell_cmd = 'shell-cmd.py'
port = 2048
utils.execute(mox.IgnoreArg(),
'--command', shell_cmd,
'-t', token,
'-p', port)

# Start test
self.mox.ReplayAll()
libvirt_utils.run_ajaxterm(shell_cmd, token, port)

def test_get_fs_info(self):
# Use a 1024-byte block size (df -k) because OS X does not support
# the -B flag
Expand Down
8 changes: 0 additions & 8 deletions nova/tests/test_virt_drivers.py
Expand Up @@ -288,14 +288,6 @@ def test_get_console_output(self):
console_output = self.connection.get_console_output(instance_ref)
self.assertTrue(isinstance(console_output, basestring))

@catch_notimplementederror
def test_get_ajax_console(self):
instance_ref, network_info = self._get_running_instance()
ajax_console = self.connection.get_ajax_console(instance_ref)
self.assertIn('token', ajax_console)
self.assertIn('host', ajax_console)
self.assertIn('port', ajax_console)

@catch_notimplementederror
def test_get_vnc_console(self):
instance_ref, network_info = self._get_running_instance()
Expand Down
3 changes: 0 additions & 3 deletions nova/tests/test_vmwareapi.py
Expand Up @@ -259,6 +259,3 @@ def test_diagnostics(self):

def test_get_console_output(self):
pass

def test_get_ajax_console(self):
pass
4 changes: 0 additions & 4 deletions nova/virt/driver.py
Expand Up @@ -191,10 +191,6 @@ def get_console_output(self, instance):
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()

def get_ajax_console(self, instance):
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()

def get_vnc_console(self, instance):
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
Expand Down
5 changes: 0 additions & 5 deletions nova/virt/fake.py
Expand Up @@ -219,11 +219,6 @@ def interface_stats(self, instance_name, iface_id):
def get_console_output(self, instance):
return 'FAKE CONSOLE OUTPUT\nANOTHER\nLAST LINE'

def get_ajax_console(self, instance):
return {'token': 'FAKETOKEN',
'host': 'fakeajaxconsole.com',
'port': 6969}

def get_vnc_console(self, instance):
return {'internal_access_path': 'FAKE',
'host': 'fakevncconsole.com',
Expand Down
26 changes: 0 additions & 26 deletions nova/virt/libvirt/connection.py
Expand Up @@ -102,9 +102,6 @@
cfg.BoolOpt('use_cow_images',
default=True,
help='Whether to use cow images'),
cfg.StrOpt('ajaxterm_portrange',
default='10000-12000',
help='Range of ports that ajaxterm should try to bind'),
cfg.StrOpt('cpuinfo_xml_template',
default=utils.abspath('virt/cpuinfo.xml.template'),
help='CpuInfo XML Template (Used only live migration now)'),
Expand Down Expand Up @@ -777,29 +774,6 @@ def get_console_output(self, instance):

return libvirt_utils.load_file(fpath)

@exception.wrap_exception()
def get_ajax_console(self, instance):
def get_pty_for_instance(instance_name):
virt_dom = self._lookup_by_name(instance_name)
xml = virt_dom.XMLDesc(0)
dom = minidom.parseString(xml)

for serial in dom.getElementsByTagName('serial'):
if serial.getAttribute('type') == 'pty':
source = serial.getElementsByTagName('source')[0]
return source.getAttribute('path')

start_port, end_port = FLAGS.ajaxterm_portrange.split("-")
port = libvirt_utils.get_open_port(int(start_port), int(end_port))
token = str(uuid.uuid4())
host = instance['host']

ajaxterm_cmd = 'sudo netcat - %s' \
% get_pty_for_instance(instance['name'])

libvirt_utils.run_ajaxterm(ajaxterm_cmd, token, port)
return {'token': token, 'host': host, 'port': port}

@staticmethod
def get_host_ip_addr():
return FLAGS.my_ip
Expand Down
12 changes: 0 additions & 12 deletions nova/virt/libvirt/utils.py
Expand Up @@ -237,18 +237,6 @@ def get_open_port(start_port, end_port):
raise Exception(_('Unable to find an open port'))


def run_ajaxterm(cmd, token, port):
"""Run ajaxterm
:param cmd: Command to connect to
:param token: Token to require for authentication
:param port: Port to run on
"""
cmd = ['%s/tools/ajaxterm/ajaxterm.py' % utils.novadir(),
'--command', cmd, '-t', token, '-p', port]
execute(*cmd)


def get_fs_info(path):
"""Get free/used/total space info for a filesystem
Expand Down
4 changes: 0 additions & 4 deletions nova/virt/vmwareapi/vmops.py
Expand Up @@ -719,10 +719,6 @@ def get_console_output(self, instance):
else:
return ""

def get_ajax_console(self, instance):
"""Return link to instance's ajax console."""
return 'http://fakeajaxconsole/fake_url'

def _set_machine_id(self, client_factory, instance, network_info):
"""
Set the machine id of the VM for guest tools to pick up and reconfigure
Expand Down
4 changes: 0 additions & 4 deletions nova/virt/vmwareapi_conn.py
Expand Up @@ -174,10 +174,6 @@ def get_console_output(self, instance):
"""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 get_volume_connector(self, _instance):
"""Return volume connector information"""
# TODO(vish): When volume attaching is supported, return the
Expand Down

0 comments on commit 7141072

Please sign in to comment.