Fix a bunch of pep8 stuff
This commit is contained in:
@@ -85,8 +85,3 @@ class Controller(wsgi.Controller):
|
|||||||
except exception.NotFound:
|
except exception.NotFound:
|
||||||
return faults.Fault(exc.HTTPNotFound())
|
return faults.Fault(exc.HTTPNotFound())
|
||||||
return exc.HTTPAccepted()
|
return exc.HTTPAccepted()
|
||||||
|
|
||||||
# def detail(self, req, id):
|
|
||||||
# """ Returns a complete list of consoles for this instance"""
|
|
||||||
# return _translate_detail_keys({})
|
|
||||||
|
|
||||||
|
|||||||
@@ -112,11 +112,9 @@ class ComputeManager(manager.Manager):
|
|||||||
FLAGS.network_topic,
|
FLAGS.network_topic,
|
||||||
host)
|
host)
|
||||||
|
|
||||||
|
|
||||||
def get_console_pool_info(self, context, console_type):
|
def get_console_pool_info(self, context, console_type):
|
||||||
return self.driver.get_console_pool_info(console_type)
|
return self.driver.get_console_pool_info(console_type)
|
||||||
|
|
||||||
|
|
||||||
@exception.wrap_exception
|
@exception.wrap_exception
|
||||||
def refresh_security_group(self, context, security_group_id, **_kwargs):
|
def refresh_security_group(self, context, security_group_id, **_kwargs):
|
||||||
"""This call passes stright through to the virtualization driver."""
|
"""This call passes stright through to the virtualization driver."""
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
.. automodule:: nova.console
|
.. automodule:: nova.console
|
||||||
:platform: Unix
|
:platform: Unix
|
||||||
:synopsis: Wrapper around console proxies such as xvp to set up multitenant VM console access
|
:synopsis: Wrapper around console proxies such as xvp to set up
|
||||||
|
multitenant VM console access
|
||||||
.. moduleauthor:: Monsyne Dragon <mdragon@rackspace.com>
|
.. moduleauthor:: Monsyne Dragon <mdragon@rackspace.com>
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ from nova import rpc
|
|||||||
|
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
|
||||||
class ConsoleAPI(base.Base):
|
class ConsoleAPI(base.Base):
|
||||||
"""API for spining up or down console proxy connections"""
|
"""API for spining up or down console proxy connections"""
|
||||||
|
|
||||||
@@ -70,7 +71,6 @@ class ConsoleAPI(base.Base):
|
|||||||
{"method": "add_console",
|
{"method": "add_console",
|
||||||
"args": {"instance_id": instance['id']}})
|
"args": {"instance_id": instance['id']}})
|
||||||
|
|
||||||
|
|
||||||
def _get_console_topic(self, context, instance_host):
|
def _get_console_topic(self, context, instance_host):
|
||||||
topic = self.db.queue_get_for(context,
|
topic = self.db.queue_get_for(context,
|
||||||
FLAGS.compute_topic,
|
FLAGS.compute_topic,
|
||||||
|
|||||||
@@ -56,4 +56,3 @@ class ConsoleProxy(object):
|
|||||||
def fix_console_password(self, password):
|
def fix_console_password(self, password):
|
||||||
"""Trim password to length, and any other massaging"""
|
"""Trim password to length, and any other massaging"""
|
||||||
return password
|
return password
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ Fake ConsoleProxy driver for tests.
|
|||||||
from nova import exception
|
from nova import exception
|
||||||
from nova.console import driver
|
from nova.console import driver
|
||||||
|
|
||||||
|
|
||||||
class FakeConsoleProxy(driver.ConsoleProxy):
|
class FakeConsoleProxy(driver.ConsoleProxy):
|
||||||
"""Fake ConsoleProxy driver."""
|
"""Fake ConsoleProxy driver."""
|
||||||
|
|
||||||
@@ -56,4 +57,3 @@ class FakeConsoleProxy(driver.ConsoleProxy):
|
|||||||
def fix_console_password(self, password):
|
def fix_console_password(self, password):
|
||||||
"""Trim password to length, and any other massaging"""
|
"""Trim password to length, and any other massaging"""
|
||||||
return password
|
return password
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ flags.DEFINE_string('console_driver',
|
|||||||
flags.DEFINE_boolean('stub_compute', False,
|
flags.DEFINE_boolean('stub_compute', False,
|
||||||
'Stub calls to compute worker for tests')
|
'Stub calls to compute worker for tests')
|
||||||
|
|
||||||
|
|
||||||
class ConsoleProxyManager(manager.Manager):
|
class ConsoleProxyManager(manager.Manager):
|
||||||
|
|
||||||
""" Sets up and tears down any proxy connections needed for accessing
|
""" Sets up and tears down any proxy connections needed for accessing
|
||||||
@@ -89,7 +90,6 @@ class ConsoleProxyManager(manager.Manager):
|
|||||||
self.db.console_delete(context, console_id)
|
self.db.console_delete(context, console_id)
|
||||||
self.driver.teardown_console(context, console)
|
self.driver.teardown_console(context, console)
|
||||||
|
|
||||||
|
|
||||||
def get_pool_for_instance_host(self, context, instance_host):
|
def get_pool_for_instance_host(self, context, instance_host):
|
||||||
context = context.elevated()
|
context = context.elevated()
|
||||||
console_type = self.driver.console_type
|
console_type = self.driver.console_type
|
||||||
@@ -120,5 +120,3 @@ class ConsoleProxyManager(manager.Manager):
|
|||||||
pool_info['compute_host'] = instance_host
|
pool_info['compute_host'] = instance_host
|
||||||
pool = self.db.console_pool_create(context, pool_info)
|
pool = self.db.console_pool_create(context, pool_info)
|
||||||
return pool
|
return pool
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ flags.DEFINE_integer('console_xvp_multiplex_port',
|
|||||||
"port for XVP to multiplex VNC connections on")
|
"port for XVP to multiplex VNC connections on")
|
||||||
FLAGS = flags.FLAGS
|
FLAGS = flags.FLAGS
|
||||||
|
|
||||||
|
|
||||||
class XVPConsoleProxy(driver.ConsoleProxy):
|
class XVPConsoleProxy(driver.ConsoleProxy):
|
||||||
"""Sets up XVP config, and manages xvp daemon"""
|
"""Sets up XVP config, and manages xvp daemon"""
|
||||||
|
|
||||||
@@ -187,7 +188,4 @@ class XVPConsoleProxy(driver.ConsoleProxy):
|
|||||||
#xvp will blow up on passwords that are too long (mdragon)
|
#xvp will blow up on passwords that are too long (mdragon)
|
||||||
password = password[:maxlen]
|
password = password[:maxlen]
|
||||||
out, err = utils.execute('xvp %s' % flag, process_input=password)
|
out, err = utils.execute('xvp %s' % flag, process_input=password)
|
||||||
#p = subprocess.Popen(['xvp', flag], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
|
||||||
#out,err = p.communicate(password)
|
|
||||||
return out.strip()
|
return out.strip()
|
||||||
|
|
||||||
|
|||||||
@@ -895,12 +895,15 @@ def host_get_networks(context, host):
|
|||||||
"""
|
"""
|
||||||
return IMPL.host_get_networks(context, host)
|
return IMPL.host_get_networks(context, host)
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
|
|
||||||
|
|
||||||
def console_pool_create(context, values):
|
def console_pool_create(context, values):
|
||||||
"""Create console pool."""
|
"""Create console pool."""
|
||||||
return IMPL.console_pool_create(context, values)
|
return IMPL.console_pool_create(context, values)
|
||||||
|
|
||||||
|
|
||||||
def console_pool_get(context, pool_id):
|
def console_pool_get(context, pool_id):
|
||||||
"""Get a console pool."""
|
"""Get a console pool."""
|
||||||
return IMPL.console_pool_get(context, pool_id)
|
return IMPL.console_pool_get(context, pool_id)
|
||||||
@@ -926,20 +929,22 @@ def console_create(context,values):
|
|||||||
"""Create a console."""
|
"""Create a console."""
|
||||||
return IMPL.console_create(context, values)
|
return IMPL.console_create(context, values)
|
||||||
|
|
||||||
|
|
||||||
def console_delete(context, console_id):
|
def console_delete(context, console_id):
|
||||||
"""Delete a console."""
|
"""Delete a console."""
|
||||||
return IMPL.console_delete(context, console_id)
|
return IMPL.console_delete(context, console_id)
|
||||||
|
|
||||||
|
|
||||||
def console_get_by_pool_instance(context, pool_id, instance_id):
|
def console_get_by_pool_instance(context, pool_id, instance_id):
|
||||||
"""Get console entry for a given instance and pool."""
|
"""Get console entry for a given instance and pool."""
|
||||||
return IMPL.console_get_by_pool_instance(context, pool_id, instance_id)
|
return IMPL.console_get_by_pool_instance(context, pool_id, instance_id)
|
||||||
|
|
||||||
|
|
||||||
def console_get_all_by_instance(context, instance_id):
|
def console_get_all_by_instance(context, instance_id):
|
||||||
"""Get consoles for a given instance."""
|
"""Get consoles for a given instance."""
|
||||||
return IMPL.console_get_all_by_instance(context, instance_id)
|
return IMPL.console_get_all_by_instance(context, instance_id)
|
||||||
|
|
||||||
|
|
||||||
def console_get(context, console_id, instance_id=None):
|
def console_get(context, console_id, instance_id=None):
|
||||||
"""Get a specific console (possibly on a given instance)."""
|
"""Get a specific console (possibly on a given instance)."""
|
||||||
return IMPL.console_get(context, console_id, instance_id)
|
return IMPL.console_get(context, console_id, instance_id)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1835,10 +1835,12 @@ def console_pool_get(context, pool_id):
|
|||||||
filter_by(id=pool_id).\
|
filter_by(id=pool_id).\
|
||||||
first()
|
first()
|
||||||
if not result:
|
if not result:
|
||||||
raise exception.NotFound(_("No console pool with id %(pool_id)s") % {'pool_id': pool_id})
|
raise exception.NotFound(_("No console pool with id %(pool_id)s") %
|
||||||
|
{'pool_id': pool_id})
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def console_pool_get_by_host_type(context, compute_host, host,
|
def console_pool_get_by_host_type(context, compute_host, host,
|
||||||
console_type):
|
console_type):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
@@ -1875,6 +1877,7 @@ def console_create(context, values):
|
|||||||
console.save()
|
console.save()
|
||||||
return console
|
return console
|
||||||
|
|
||||||
|
|
||||||
def console_delete(context, console_id):
|
def console_delete(context, console_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
with session.begin():
|
with session.begin():
|
||||||
@@ -1882,6 +1885,7 @@ def console_delete(context, console_id):
|
|||||||
session.execute('delete from consoles '
|
session.execute('delete from consoles '
|
||||||
'where id=:id', {'id': console_id})
|
'where id=:id', {'id': console_id})
|
||||||
|
|
||||||
|
|
||||||
def console_get_by_pool_instance(context, pool_id, instance_id):
|
def console_get_by_pool_instance(context, pool_id, instance_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
result = session.query(models.Console).\
|
result = session.query(models.Console).\
|
||||||
@@ -1896,6 +1900,7 @@ def console_get_by_pool_instance(context, pool_id, instance_id):
|
|||||||
'pool_id': pool_id})
|
'pool_id': pool_id})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def console_get_all_by_instance(context, instance_id):
|
def console_get_all_by_instance(context, instance_id):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
results = session.query(models.Console).\
|
results = session.query(models.Console).\
|
||||||
@@ -1904,6 +1909,7 @@ def console_get_all_by_instance(context, instance_id):
|
|||||||
all()
|
all()
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
def console_get(context, console_id, instance_id=None):
|
def console_get(context, console_id, instance_id=None):
|
||||||
session = get_session()
|
session = get_session()
|
||||||
query = session.query(models.Console).\
|
query = session.query(models.Console).\
|
||||||
@@ -1916,5 +1922,3 @@ def console_get(context, console_id, instance_id=None):
|
|||||||
raise exception.NotFound(_("No console with id %(instance)s") %
|
raise exception.NotFound(_("No console with id %(instance)s") %
|
||||||
{'instance': idesc})
|
{'instance': idesc})
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -537,6 +537,7 @@ class FloatingIp(BASE, NovaBase):
|
|||||||
project_id = Column(String(255))
|
project_id = Column(String(255))
|
||||||
host = Column(String(255)) # , ForeignKey('hosts.id'))
|
host = Column(String(255)) # , ForeignKey('hosts.id'))
|
||||||
|
|
||||||
|
|
||||||
class ConsolePool(BASE, NovaBase):
|
class ConsolePool(BASE, NovaBase):
|
||||||
"""Represents pool of consoles on the same physical node."""
|
"""Represents pool of consoles on the same physical node."""
|
||||||
__tablename__ = 'console_pools'
|
__tablename__ = 'console_pools'
|
||||||
@@ -548,6 +549,7 @@ class ConsolePool(BASE, NovaBase):
|
|||||||
host = Column(String(255))
|
host = Column(String(255))
|
||||||
compute_host = Column(String(255))
|
compute_host = Column(String(255))
|
||||||
|
|
||||||
|
|
||||||
class Console(BASE, NovaBase):
|
class Console(BASE, NovaBase):
|
||||||
"""Represents a console session for an instance."""
|
"""Represents a console session for an instance."""
|
||||||
__tablename__ = 'consoles'
|
__tablename__ = 'consoles'
|
||||||
@@ -559,6 +561,7 @@ class Console(BASE, NovaBase):
|
|||||||
pool_id = Column(Integer, ForeignKey('console_pools.id'))
|
pool_id = Column(Integer, ForeignKey('console_pools.id'))
|
||||||
pool = relationship(ConsolePool, backref=backref('consoles'))
|
pool = relationship(ConsolePool, backref=backref('consoles'))
|
||||||
|
|
||||||
|
|
||||||
def register_models():
|
def register_models():
|
||||||
"""Register Models and create metadata.
|
"""Register Models and create metadata.
|
||||||
|
|
||||||
|
|||||||
@@ -218,7 +218,8 @@ DEFINE_integer('s3_port', 3333, 's3 port')
|
|||||||
DEFINE_string('s3_host', utils.get_my_ip(), 's3 host (for infrastructure)')
|
DEFINE_string('s3_host', utils.get_my_ip(), 's3 host (for infrastructure)')
|
||||||
DEFINE_string('s3_dmz', utils.get_my_ip(), 's3 dmz ip (for instances)')
|
DEFINE_string('s3_dmz', utils.get_my_ip(), 's3 dmz ip (for instances)')
|
||||||
DEFINE_string('compute_topic', 'compute', 'the topic compute nodes listen on')
|
DEFINE_string('compute_topic', 'compute', 'the topic compute nodes listen on')
|
||||||
DEFINE_string('console_topic', 'console', 'the topic console proxy nodes listen on')
|
DEFINE_string('console_topic', 'console',
|
||||||
|
'the topic console proxy nodes listen on')
|
||||||
DEFINE_string('scheduler_topic', 'scheduler',
|
DEFINE_string('scheduler_topic', 'scheduler',
|
||||||
'the topic scheduler nodes listen on')
|
'the topic scheduler nodes listen on')
|
||||||
DEFINE_string('volume_topic', 'volume', 'the topic volume nodes listen on')
|
DEFINE_string('volume_topic', 'volume', 'the topic volume nodes listen on')
|
||||||
|
|||||||
@@ -127,4 +127,3 @@ class ConsoleTestCase(test.TestCase):
|
|||||||
db.console_get,
|
db.console_get,
|
||||||
self.context,
|
self.context,
|
||||||
console_id)
|
console_id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user