diff options
author | evasquez <eric.vasquez@calxeda.com> | 2013-06-13 13:44:58 -0500 |
---|---|---|
committer | evasquez <eric.vasquez@calxeda.com> | 2013-06-13 13:44:58 -0500 |
commit | 1df4df675dbf81358880f529a49db01d40c0a248 (patch) | |
tree | 8235f0edbf67c5efb06325c2b51f265782e3da9d | |
parent | 530ff68d7fe9eecec3381ca47ba4c2c6e0ed92c3 (diff) | |
download | cxmanage-1df4df675dbf81358880f529a49db01d40c0a248.tar.gz |
AIT:Added a refresh() function for Fabrics.
Sometimes when tests power on/off systems or MC_RESET node IPs change.
We want the ability to get the new ips for the current fabric object
without a complete re-init.
-rw-r--r-- | cxmanage_api/fabric.py | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/cxmanage_api/fabric.py b/cxmanage_api/fabric.py index 34f435e..6159c47 100644 --- a/cxmanage_api/fabric.py +++ b/cxmanage_api/fabric.py @@ -137,7 +137,8 @@ class Fabric(object): """ if not self._nodes: - self._discover_nodes(self.ip_address) + self.refresh() + return self._nodes @property @@ -154,6 +155,23 @@ class Fabric(object): """ return self.nodes[0] + def refresh(self): + """Gets the nodes of this fabric by pulling IP info from a BMC.""" + self._nodes = {} + node = self.node(ip_address=self.ip_address, username=self.username, + password=self.password, tftp=self.tftp, + ecme_tftp_port=self.ecme_tftp_port, + verbose=self.verbose) + ipinfo = node.get_fabric_ipinfo() + for node_id, node_address in ipinfo.iteritems(): + self._nodes[node_id] = self.node(ip_address=node_address, + username=self.username, + password=self.password, + tftp=self.tftp, + ecme_tftp_port=self.ecme_tftp_port, + verbose=self.verbose) + self._nodes[node_id].node_id = node_id + def get_mac_addresses(self): """Gets MAC addresses from all nodes. @@ -884,21 +902,5 @@ class Fabric(object): raise CommandFailedError(results, errors) return results - def _discover_nodes(self, ip_address, username="admin", password="admin"): - """Gets the nodes of this fabric by pulling IP info from a BMC.""" - node = self.node(ip_address=ip_address, username=username, - password=password, tftp=self.tftp, - ecme_tftp_port=self.ecme_tftp_port, - verbose=self.verbose) - ipinfo = node.get_fabric_ipinfo() - for node_id, node_address in ipinfo.iteritems(): - self._nodes[node_id] = self.node(ip_address=node_address, - username=username, - password=password, - tftp=self.tftp, - ecme_tftp_port=self.ecme_tftp_port, - verbose=self.verbose) - self._nodes[node_id].node_id = node_id - # End of file: ./fabric.py |