summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthew.hodgins <matthew.hodgins@calxeda.com>2013-12-10 16:39:33 -0600
committermatthew.hodgins <matthew.hodgins@calxeda.com>2013-12-11 10:38:12 -0600
commit38d387ce6634a072c15467c46b0776c214aad387 (patch)
tree1d4966b31e9717172e796ba89c93ca36b96977a0
parent4e47314d27e579d2310de0b6a6a8a9715acb0c42 (diff)
downloadcxmanage-38d387ce6634a072c15467c46b0776c214aad387.tar.gz
CXMAN-258 expose get networks/uplinks +CRCXMANAGE
Signed-off-by: matthew.hodgins <matthew.hodgins@calxeda.com>
-rw-r--r--cxmanage_api/fabric.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/cxmanage_api/fabric.py b/cxmanage_api/fabric.py
index 6063ed8..f06f700 100644
--- a/cxmanage_api/fabric.py
+++ b/cxmanage_api/fabric.py
@@ -33,6 +33,7 @@
# DAMAGE.
import time
+import re
from cxmanage_api.tasks import DEFAULT_TASK_QUEUE
from cxmanage_api.tftp import InternalTftp
@@ -310,6 +311,55 @@ class Fabric(object):
"""
self.primary_node.bmc.fabric_config_set_uplink_mode(uplink_mode)
+ def get_networks(self):
+ """Gets the fabric networks
+
+ >>> fabric.get_networks()
+ {
+ 'default_eth0': False,
+ 'default_eth1': False,
+ 'default_mgmt': False
+ }
+
+ :return: A dict mapping network to whether or not its private
+ :rtype: dict
+
+ """
+ results = {}
+ filename = self.primary_node._run_fabric_command(
+ 'fabric_config_get_networks'
+ )
+ regex = re.compile('\d+ Network (\w+), private=(\d)')
+ for line in open(filename, 'r').readlines():
+ name, private = regex.findall(line)[0]
+ results[name] = (int(private) != 0)
+
+ return results
+
+ def get_uplinks(self):
+ """Gets the fabric uplinks
+
+ >>> fabric.get_uplinks()
+ {0: ['default_eth0', 'default_eth1', 'default_mgmt']}
+
+ :return: A dict mapping uplink to networks
+ :rtype: dict
+
+ """
+ results = {}
+ filename = self.primary_node._run_fabric_command(
+ 'fabric_config_get_uplinks'
+ )
+ current_uplink = None
+ for line in open(filename, 'r').readlines():
+ if('Uplink' in line):
+ current_uplink = int(line.split('Uplink ')[1].replace(':', ''))
+ results[current_uplink] = []
+ else:
+ results[current_uplink].append(line.strip())
+
+ return results
+
def get_uplink_speed(self, async=False):
"""Gets the uplink speed of every node in the fabric.