summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kraft <george.kraft@calxeda.com>2013-12-10 13:15:08 -0600
committerGeorge Kraft <george.kraft@calxeda.com>2013-12-10 13:15:08 -0600
commit96f0784603a60b385a3854bbe52f085e8ce7bfc9 (patch)
treea5fccd86a5336ba27358a3541940703c1b8277e3
parent7273e8cd03425cd53d5cbf7d71d1cc0f51fdfaf5 (diff)
downloadcxmanage-96f0784603a60b385a3854bbe52f085e8ce7bfc9.tar.gz
CXMAN-269: Allow node IDs to be strings
To support the "physical" management view, where node IDs can be 0.0, 0.1, etc. This is pretty much a bandaid fix, and I would expect to see some cases where things break when the "physical" view is enabled.
-rw-r--r--cxmanage_api/cli/__init__.py7
-rw-r--r--cxmanage_api/cli/commands/fabric.py8
-rw-r--r--cxmanage_api/cli/commands/tspackage.py33
-rw-r--r--cxmanage_api/node.py8
4 files changed, 29 insertions, 27 deletions
diff --git a/cxmanage_api/cli/__init__.py b/cxmanage_api/cli/__init__.py
index 6eb94f2..5acb0c9 100644
--- a/cxmanage_api/cli/__init__.py
+++ b/cxmanage_api/cli/__init__.py
@@ -158,11 +158,8 @@ def get_nodes(args, tftp, verify_prompt=False):
def get_node_strings(args, nodes, justify=False):
""" Get string representations for the nodes. """
- # Use the private _node_id instead of node_id. Strange choice,
- # but we want to avoid accidentally polling the BMC.
- # pylint: disable=W0212
- if args.ids and all(x._node_id != None for x in nodes):
- strings = ["Node %i (%s)" % (x._node_id, x.ip_address) for x in nodes]
+ if args.ids:
+ strings = [str(x) for x in nodes]
else:
strings = [x.ip_address for x in nodes]
diff --git a/cxmanage_api/cli/commands/fabric.py b/cxmanage_api/cli/commands/fabric.py
index 0ee7805..b42f797 100644
--- a/cxmanage_api/cli/commands/fabric.py
+++ b/cxmanage_api/cli/commands/fabric.py
@@ -49,8 +49,8 @@ def ipinfo_command(args):
for node in nodes:
if node in results:
print 'IP info from %s' % node.ip_address
- for node_id, node_address in results[node].iteritems():
- print 'Node %i: %s' % (node_id, node_address)
+ for node_id, node_address in sorted(results[node].items()):
+ print 'Node %s: %s' % (node_id, node_address)
print
return 0
@@ -70,10 +70,10 @@ def macaddrs_command(args):
for node in nodes:
if node in results:
print "MAC addresses from %s" % node.ip_address
- for node_id in results[node]:
+ for node_id in sorted(results[node]):
for port in results[node][node_id]:
for mac_address in results[node][node_id][port]:
- print "Node %i, Port %i: %s" % (node_id, port,
+ print "Node %s, Port %i: %s" % (node_id, port,
mac_address)
print
diff --git a/cxmanage_api/cli/commands/tspackage.py b/cxmanage_api/cli/commands/tspackage.py
index a51f750..0a4beb3 100644
--- a/cxmanage_api/cli/commands/tspackage.py
+++ b/cxmanage_api/cli/commands/tspackage.py
@@ -174,7 +174,7 @@ def write_version_info(args, nodes):
for node in nodes:
lines = [
- "[ Version Info for Node %d ]" % node.node_id,
+ "[ Version Info for Node %s ]" % node.node_id,
"ECME IP Address : %s" % node.ip_address
]
@@ -211,15 +211,16 @@ def write_mac_addrs(args, nodes):
for node in nodes:
lines = [] # Lines of text to write to file
# \n is used here to give a blank line before this section
- lines.append("\n[ MAC Addresses for Node %d ]" % node.node_id)
+ lines.append("\n[ MAC Addresses for Node %s ]" % node.node_id)
if node in mac_addr_results:
- for port in mac_addr_results[node][node.node_id]:
- for mac_address in mac_addr_results[node][node.node_id][port]:
- lines.append(
- "Node %i, Port %i: %s" %
- (node.node_id, port, mac_address)
- )
+ for node_id in mac_addr_results[node]:
+ for port in mac_addr_results[node][node_id]:
+ for mac_address in mac_addr_results[node][node_id][port]:
+ lines.append(
+ "Node %s, Port %i: %s" %
+ (node.node_id, port, mac_address)
+ )
else:
lines.append("\nWARNING: No MAC addresses found!")
@@ -234,7 +235,7 @@ def write_sensor_info(args, nodes):
args.sensor_name)
for node in nodes:
- lines = ["\n[ Sensors for Node %d ]" % node.node_id]
+ lines = ["\n[ Sensors for Node %s ]" % node.node_id]
justify_length = max(len(x) for x in results[node]) + 1
@@ -256,7 +257,7 @@ def write_fwinfo(args, nodes):
for node in nodes:
lines = [] # Lines of text to write to file
# \n is used here to give a blank line before this section
- lines.append("\n[ Firmware Info for Node %d ]" % node.node_id)
+ lines.append("\n[ Firmware Info for Node %s ]" % node.node_id)
if node in results:
first_partition = True # The first partiton doesn't need \n
@@ -287,7 +288,7 @@ def write_boot_order(args, nodes):
for node in nodes:
lines = [] # Lines of text to write to file
# \n is used here to give a blank line before this section
- lines.append("\n[ Boot Order for Node %d ]" % node.node_id)
+ lines.append("\n[ Boot Order for Node %s ]" % node.node_id)
if node in results:
lines.append(", ".join(results[node]))
@@ -304,7 +305,7 @@ def write_sel(args, nodes):
for node in nodes:
lines = [] # Lines of text to write to file
# \n is used here to give a blank line before this section
- lines.append("\n[ System Event Log for Node %d ]" % node.node_id)
+ lines.append("\n[ System Event Log for Node %s ]" % node.node_id)
try:
if node in results:
@@ -327,7 +328,7 @@ def write_depth_chart(args, nodes):
for node in nodes:
lines = [] # Lines of text to write to file
# \n is used here to give a blank line before this section
- lines.append("\n[ Depth Chart for Node %d ]" % node.node_id)
+ lines.append("\n[ Depth Chart for Node %s ]" % node.node_id)
if node in depth_results:
depth_chart = depth_results[node]
@@ -363,7 +364,7 @@ def write_routing_table(args, nodes):
for node in nodes:
lines = [] # Lines of text to write to file
# \n is used here to give a blank line before this section
- lines.append("\n[ Routing Table for Node %d ]" % node.node_id)
+ lines.append("\n[ Routing Table for Node %s ]" % node.node_id)
if node in routing_results:
table = routing_results[node]
@@ -379,7 +380,7 @@ def write_serial_log(args, nodes):
"""Write the serial log for each node"""
results, errors = run_command(args, nodes, "read_fru", 98)
for node in nodes:
- lines = ["\n[ Serial log for Node %d ]" % node.node_id]
+ lines = ["\n[ Serial log for Node %s ]" % node.node_id]
if node in results:
lines.append(results[node].strip())
else:
@@ -391,7 +392,7 @@ def write_crash_log(args, nodes):
"""Write the crash log for each node"""
results, errors = run_command(args, nodes, "read_fru", 99)
for node in nodes:
- lines = ["\n[ Crash log for Node %d ]" % node.node_id]
+ lines = ["\n[ Crash log for Node %s ]" % node.node_id]
if node in results:
lines.append(results[node].strip())
else:
diff --git a/cxmanage_api/node.py b/cxmanage_api/node.py
index fe99fdb..a7f8460 100644
--- a/cxmanage_api/node.py
+++ b/cxmanage_api/node.py
@@ -123,7 +123,7 @@ class Node(object):
return hash(self.ip_address)
def __str__(self):
- return 'Node %i (%s)' % (self.node_id, self.ip_address)
+ return 'Node %s (%s)' % (self.node_id, self.ip_address)
@property
def tftp_address(self):
@@ -1180,7 +1180,11 @@ communication.
for line in open(filename):
if line.strip():
elements = line.split()
- node_id = int(elements[1].rstrip(":"))
+ node_id = elements[1].rstrip(":")
+ try:
+ node_id = int(node_id)
+ except ValueError:
+ pass
ip_address = elements[2]
# IP validity check