2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 19:10:10 +00:00

Recognize expressions at node/nodegroup creation time

This commit is contained in:
Jarrod Johnson 2014-02-22 18:12:21 -05:00
parent 56ae101366
commit 896159da4c
4 changed files with 25 additions and 10 deletions

View File

@ -37,6 +37,7 @@ import sys
import termios
import tty
exitcode = 0
consoleonly = False
target = "/"
path = os.path.dirname(os.path.realpath(__file__))
@ -156,9 +157,11 @@ def send_request(operation, path, server):
result = tlvdata.recv_tlvdata(server)
def do_command(command, server):
global exitcode
global target
global currconsole
global currchildren
exitcode = 0
command = command.lower()
argv = parse_command(command)
if len(argv) == 0:
@ -166,14 +169,16 @@ def do_command(command, server):
if argv[0] == "exit":
server.close()
sys.exit(0)
if argv[0] == "cd":
elif argv[0] == "cd":
otarget = target
target = fullpath_target(argv[1], forcepath=True)
for res in send_request('retrieve', target, server):
if 'errorcode' in res:
exitcode = res['errorcode']
if 'error' in res:
print target + ': ' + res['error']
sys.stderr.write(target + ': ' + res['error'] + '\n')
target = otarget
if argv[0] in ('cat', 'show', 'ls', 'dir'):
elif argv[0] in ('cat', 'show', 'ls', 'dir'):
if len(argv) > 1:
targpath = fullpath_target(argv[1])
else:
@ -196,17 +201,21 @@ def do_command(command, server):
print "%s=********" % key
else:
print "%s=" % key
if argv[0] == 'start':
elif argv[0] == 'start':
targpath = fullpath_target(argv[1])
currconsole = targpath
tlvdata.send_tlvdata(server, {'operation': 'start', 'path': targpath})
status = tlvdata.recv_tlvdata(server)
if 'error' in status:
print 'Error: ' + status['error']
if 'errorcode' in status:
exitcode = status['errorcode']
sys.stderr.write('Error: ' + status['error'] + '\n')
return
print '[console session started]'
startconsole()
return
else:
sys.stderr.write("%s: command not found...\n" % argv[0])
def fullpath_target(path, forcepath=False):

View File

@ -643,6 +643,7 @@ class ConfigManager(object):
# TODO(jbjohnso): multi mgr support, here if we have peers,
# pickle the arguments and fire them off in eventlet
# flows to peers, all should have the same result
exprmgr = None
for node in attribmap.iterkeys():
if node not in self._cfgstore['nodes']:
self._cfgstore['nodes'][node] = {}

View File

@ -138,7 +138,7 @@ def get_input_message(path, operation, inputdata, nodes=None):
if path[0] == 'power' and path[1] == 'state' and operation != 'retrieve':
return InputPowerMessage(path, nodes, inputdata)
elif path[0] == 'attributes' and operation != 'retrieve':
return InputAttributes(path, nodes, inputdata)
return InputAttributes(path, inputdata, nodes)
elif path == ['boot', 'device'] and operation != 'retrieve':
return InputBootDevice(path, nodes, inputdata)
elif inputdata:
@ -147,7 +147,10 @@ def get_input_message(path, operation, inputdata, nodes=None):
class InputAttributes(ConfluentMessage):
def __init__(self, path, nodes, inputdata):
def __init__(self, path, inputdata, nodes=None):
print "DEBUG: making input attributes "
print repr(nodes)
print repr(inputdata)
self.nodeattribs = {}
nestedmode = False
if not inputdata:

View File

@ -163,7 +163,7 @@ def create_group(inputdata, configmanager):
del inputdata['name']
attribmap = {groupname: inputdata}
except KeyError:
raise exc.InvalidArgumenTException()
raise exc.InvalidArgumentException()
configmanager.set_group_attributes(attribmap)
@ -202,7 +202,8 @@ def handle_path(path, operation, configmanager, inputdata=None):
group = pathcomponents[1]
except IndexError:
if operation == "create":
create_group(inputdata, configmanager)
inputdata = msg.InputAttributes(pathcomponents, inputdata)
create_group(inputdata.attribs, configmanager)
return iterate_collections(configmanager.get_groups())
if iscollection:
if operation == "delete":
@ -231,7 +232,8 @@ def handle_path(path, operation, configmanager, inputdata=None):
if operation == "delete":
raise exc.InvalidArgumentException()
if operation == "create":
create_node(inputdata, configmanager)
inputdata = msg.InputAttributes(pathcomponents, inputdata)
create_node(inputdata.attribs, configmanager)
return iterate_collections(configmanager.get_nodes())
if iscollection:
if operation == "delete":