diff options
| author | masumotok <masumotok@nttdata.co.jp> | 2011-01-14 03:37:41 +0900 |
|---|---|---|
| committer | masumotok <masumotok@nttdata.co.jp> | 2011-01-14 03:37:41 +0900 |
| commit | b887c9bb04aabccf268abcccd32d9ab1c53ebfc0 (patch) | |
| tree | 7de4ea9122ed809a549f2eea11f35715fc79f536 /nova/compute | |
| parent | 41a9ad538cc70d4f8f39eb51c1d137917967b04c (diff) | |
| parent | efd116da3da634156f6acb8190d21f6ef24e0235 (diff) | |
merge trunk rev560
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 29 | ||||
| -rw-r--r-- | nova/compute/manager.py | 23 |
2 files changed, 49 insertions, 3 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index e7e8dc385..a195f57c4 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -109,6 +109,8 @@ class API(base.Base): ramdisk_id = None LOG.debug(_("Creating a raw instance")) # Make sure we have access to kernel and ramdisk (if not raw) + logging.debug("Using Kernel=%s, Ramdisk=%s" % + (kernel_id, ramdisk_id)) if kernel_id: self.image_service.show(context, kernel_id) if ramdisk_id: @@ -172,7 +174,8 @@ class API(base.Base): # Set sane defaults if not specified updates = dict(hostname=generate_hostname(instance_id)) - if 'display_name' not in instance: + if (not hasattr(instance, 'display_name')) or \ + instance.display_name == None: updates['display_name'] = "Server %s" % instance_id instance = self.update(context, instance_id, **updates) @@ -184,7 +187,8 @@ class API(base.Base): FLAGS.scheduler_topic, {"method": "run_instance", "args": {"topic": FLAGS.compute_topic, - "instance_id": instance_id}}) + "instance_id": instance_id, + "availability_zone": availability_zone}}) for group_id in security_groups: self.trigger_security_group_members_refresh(elevated, group_id) @@ -412,7 +416,26 @@ class API(base.Base): rpc.cast(context, self.db.queue_get_for(context, FLAGS.compute_topic, host), {"method": "unrescue_instance", - "args": {"instance_id": instance_id}}) + "args": {"instance_id": instance['id']}}) + + def get_ajax_console(self, context, instance_id): + """Get a url to an AJAX Console""" + + instance = self.get(context, instance_id) + + output = rpc.call(context, + '%s.%s' % (FLAGS.compute_topic, + instance['host']), + {'method': 'get_ajax_console', + 'args': {'instance_id': instance['id']}}) + + 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'])} def lock(self, context, instance_id): """ diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 2c0322bae..00de85828 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -55,6 +55,9 @@ flags.DEFINE_string('compute_driver', 'nova.virt.connection.get_connection', 'Driver to use for controlling virtualization') flags.DEFINE_string('stub_network', False, 'Stub network related code') +flags.DEFINE_string('console_host', socket.gethostname(), + 'Console proxy host to use to connect to instances on' + 'this host.') LOG = logging.getLogger('nova.compute.manager') @@ -125,6 +128,15 @@ class ComputeManager(manager.Manager): state = power_state.NOSTATE self.db.instance_set_state(context, instance_id, state) + def get_console_topic(self, context, **_kwargs): + """Retrieves the console host for a project on this host + Currently this is just set in the flags for each compute + host.""" + #TODO(mdragon): perhaps make this variable by console_type? + return self.db.queue_get_for(context, + FLAGS.console_topic, + FLAGS.console_host) + def get_network_topic(self, context, **_kwargs): """Retrieves the network host for a project on this host""" # TODO(vish): This method should be memoized. This will make @@ -139,6 +151,9 @@ class ComputeManager(manager.Manager): FLAGS.network_topic, host) + def get_console_pool_info(self, context, console_type): + return self.driver.get_console_pool_info(console_type) + @exception.wrap_exception def refresh_security_group_rules(self, context, security_group_id, **_kwargs): @@ -458,6 +473,14 @@ class ComputeManager(manager.Manager): return self.driver.get_console_output(instance_ref) @exception.wrap_exception + def get_ajax_console(self, context, instance_id): + """Return connection information for an ajax console""" + context = context.elevated() + logging.debug(_("instance %s: getting ajax console"), instance_id) + instance_ref = self.db.instance_get(context, instance_id) + + return self.driver.get_ajax_console(instance_ref) + @checks_instance_lock def attach_volume(self, context, instance_id, volume_id, mountpoint): """Attach a volume to an instance.""" |
