From 22385cbde0cbc20ad00a6fbd1fe3933709f53f65 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Thu, 1 Nov 2012 19:52:36 +0000 Subject: [PATCH] Cells: Add cells commands to nova-manage Add commands to nova-manage for configuring cells in the DB. Implements blueprint nova-compute-cells DocImpact Change-Id: Ic1a950181d5ce191780647838c5d06e5410676f7 --- bin/nova-manage | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/bin/nova-manage b/bin/nova-manage index 5d7e8d67..45002cfd 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -1016,9 +1016,73 @@ class GetLogCommands(object): print _('No nova entries in syslog!') +class CellCommands(object): + """Commands for managing cells.""" + + @args('--name', dest='name', metavar='', + help='Name for the new cell') + @args('--cell_type', dest='cell_type', metavar='', + help='Whether the cell is a parent or child') + @args('--username', dest='username', metavar='', + help='Username for the message broker in this cell') + @args('--password', dest='password', metavar='', + help='Password for the message broker in this cell') + @args('--hostname', dest='hostname', metavar='', + help='Address of the message broker in this cell') + @args('--port', dest='port', metavar='', + help='Port number of the message broker in this cell') + @args('--virtual_host', dest='virtual_host', metavar='', + help='The virtual host of the message broker in this cell') + @args('--woffset', dest='woffset', metavar='') + @args('--wscale', dest='wscale', metavar='') + def create(self, name, cell_type='child', username=None, password=None, + hostname=None, port=None, virtual_host=None, + woffset=None, wscale=None): + + if cell_type not in ['parent', 'child']: + print "Error: cell type must be 'parent' or 'child'" + sys.exit(2) + + is_parent = cell_type == 'parent' + values = {'name': name, + 'is_parent': is_parent, + 'username': username, + 'password': password, + 'rpc_host': hostname, + 'rpc_port': int(port), + 'rpc_virtual_host': virtual_host, + 'weight_offset': float(woffset), + 'weight_scale': float(wscale)} + ctxt = context.get_admin_context() + db.cell_create(ctxt, values) + + @args('--cell_id', dest='cell_id', metavar='', + help='ID of the cell to delete') + def delete(self, cell_id): + ctxt = context.get_admin_context() + db.cell_delete(ctxt, cell_id) + + def list(self): + ctxt = context.get_admin_context() + cells = db.cell_get_all(ctxt) + fmt = "%3s %-10s %-6s %-10s %-15s %-5s %-10s" + print fmt % ('Id', 'Name', 'Type', 'Username', 'Hostname', + 'Port', 'VHost') + print fmt % ('-' * 3, '-' * 10, '-' * 6, '-' * 10, '-' * 15, + '-' * 5, '-' * 10) + for cell in cells: + print fmt % (cell.id, cell.name, + 'parent' if cell.is_parent else 'child', + cell.username, cell.rpc_host, + cell.rpc_port, cell.rpc_virtual_host) + print fmt % ('-' * 3, '-' * 10, '-' * 6, '-' * 10, '-' * 15, + '-' * 5, '-' * 10) + + CATEGORIES = { 'account': AccountCommands, 'agent': AgentBuildCommands, + 'cell': CellCommands, 'db': DbCommands, 'fixed': FixedIpCommands, 'flavor': InstanceTypeCommands,