diff options
author | George Kraft <george.kraft@calxeda.com> | 2013-12-11 12:51:38 -0600 |
---|---|---|
committer | George Kraft <george.kraft@calxeda.com> | 2013-12-11 12:51:38 -0600 |
commit | d309e3bdba4ef33c3582b81c59d97f917dc675e9 (patch) | |
tree | 2d1bb8aed105f7fdb37d6fcd8da0d8b5b7f54c95 | |
parent | d9712bb4070d6b86b5a6be97ce346d72d72acb35 (diff) | |
download | cxmanage-d309e3bdba4ef33c3582b81c59d97f917dc675e9.tar.gz |
CXMAN-261: Update CLI to use Fabric/Node credentials arguments
One noteworthy change here: the -U and -P arguments to cxmanage
are now global options, and no longer specific to ipdiscover.
-rw-r--r-- | cxmanage_api/cli/__init__.py | 26 | ||||
-rw-r--r-- | cxmanage_api/cli/commands/ipdiscover.py | 5 | ||||
-rwxr-xr-x | scripts/cxmanage | 9 | ||||
-rwxr-xr-x | scripts/cxmux | 5 |
4 files changed, 29 insertions, 16 deletions
diff --git a/cxmanage_api/cli/__init__.py b/cxmanage_api/cli/__init__.py index 5acb0c9..033edec 100644 --- a/cxmanage_api/cli/__init__.py +++ b/cxmanage_api/cli/__init__.py @@ -100,9 +100,20 @@ def get_nodes(args, tftp, verify_prompt=False): for entry in args.hostname.split(','): hosts.extend(parse_host_entry(entry)) - nodes = [Node(ip_address=x, username=args.user, password=args.password, - tftp=tftp, ecme_tftp_port=args.ecme_tftp_port, - verbose=args.verbose) for x in hosts] + credentials = { + "ecme_username": args.user, + "ecme_password": args.password, + "linux_username": args.linux_username, + "linux_password": args.linux_password + } + + nodes = [ + Node( + ip_address=x, credentials=credentials, tftp=tftp, + ecme_tftp_port=args.ecme_tftp_port, verbose=args.verbose + ) + for x in hosts + ] if args.all_nodes: if not args.quiet: @@ -116,10 +127,11 @@ def get_nodes(args, tftp, verify_prompt=False): for node in nodes: if node in results: for node_id, ip_address in sorted(results[node].iteritems()): - new_node = Node(ip_address=ip_address, username=args.user, - password=args.password, tftp=tftp, - ecme_tftp_port=args.ecme_tftp_port, - verbose=args.verbose) + new_node = Node( + ip_address=ip_address, credentials=credentials, + tftp=tftp, ecme_tftp_port=args.ecme_tftp_port, + verbose=args.verbose + ) new_node.node_id = node_id if not new_node in all_nodes: all_nodes.append(new_node) diff --git a/cxmanage_api/cli/commands/ipdiscover.py b/cxmanage_api/cli/commands/ipdiscover.py index fd21546..98a0155 100644 --- a/cxmanage_api/cli/commands/ipdiscover.py +++ b/cxmanage_api/cli/commands/ipdiscover.py @@ -42,8 +42,9 @@ def ipdiscover_command(args): if not args.quiet: print 'Getting server-side IP addresses...' - results, errors = run_command(args, nodes, 'get_server_ip', args.interface, - args.ipv6, args.server_user, args.server_password, args.aggressive) + results, errors = run_command( + args, nodes, 'get_server_ip', args.interface, args.ipv6, args.aggressive + ) if results: node_strings = get_node_strings(args, results, justify=True) diff --git a/scripts/cxmanage b/scripts/cxmanage index 66c6269..072e03f 100755 --- a/scripts/cxmanage +++ b/scripts/cxmanage @@ -107,6 +107,10 @@ def build_parser(): help='Username for login') parser.add_argument('-p', '--password', default='admin', help='Password for login') + parser.add_argument('-U', '--linux-username', type=str, default='user1', + metavar='USER', help='Server-side Linux username') + parser.add_argument('-P', '--linux-password', type=str, default='1Password', + metavar='PASSWORD', help='Server-side Linux password') parser.add_argument('-a', '--all-nodes', action='store_true', help='Send command to all nodes reported by fabric') parser.add_argument('--threads', type=int, metavar='THREAD_COUNT', @@ -300,11 +304,6 @@ def build_parser(): help='discover server-side IP addresses') ipdiscover.add_argument('-A', '--aggressive', action='store_true', help='discover IPs aggressively') - ipdiscover.add_argument('-U', '--server-user', type=str, default='user1', - metavar='USER', help='Server-side Linux username') - ipdiscover.add_argument('-P', '--server-password', type=str, - default='1Password', metavar='PASSWORD', - help='Server-side Linux password') ipdiscover.add_argument('-6', '--ipv6', action='store_true', help='Discover IPv6 addresses') ipdiscover.add_argument('-I', '--interface', type=str, default=None, diff --git a/scripts/cxmux b/scripts/cxmux index 2b595eb..67f2d51 100755 --- a/scripts/cxmux +++ b/scripts/cxmux @@ -85,8 +85,9 @@ def main(): fabric = cxmanage_api.fabric.Fabric( ip_address=args.ecmeip, - username=args.user, - password=args.password + credentials={ + "ecme_username": args.user, "ecme_password": args.password + } ) ips = [node.ip_address for node in fabric.nodes.values()] if args.ssh: |