summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSumedh Sathaye <sumedh.sathaye@calxeda.com>2013-04-19 15:52:44 -0500
committerSumedh Sathaye <sumedh.sathaye@calxeda.com>2013-04-26 13:18:12 -0500
commit19a19b8e27ab660b71136f63ae625823c210db8a (patch)
treec41844f543a797620db9c89031ca61b66363787f
parent405302107d8de4b4992547c2fb5e03d82d106017 (diff)
downloadcxmanage-19a19b8e27ab660b71136f63ae625823c210db8a.tar.gz
Added support for add/rm mac address to a node/interface combo.
Added cxmanage_api tests in cxmanage_test/fabric.py for add_macaddr/rm_macaddr.
-rw-r--r--cxmanage_api/fabric.py34
-rw-r--r--cxmanage_api/node.py17
-rw-r--r--cxmanage_test/fabric_test.py30
3 files changed, 81 insertions, 0 deletions
diff --git a/cxmanage_api/fabric.py b/cxmanage_api/fabric.py
index 84e5a51..bea06fa 100644
--- a/cxmanage_api/fabric.py
+++ b/cxmanage_api/fabric.py
@@ -743,6 +743,40 @@ class Fabric(object):
# because we can just get the info from a primary node (fabric config).
self.primary_node.bmc.fabric_config_set_linkspeed(linkspeed)
+ def add_macaddr(self, nodeid, iface, macaddr):
+ """Add a new macaddr to a node/interface in the fabric.
+
+ >>> fabric.add_mac_address (3, 1, "66:55:44:33:22:11")
+
+ :param nodeid: Node id to which the macaddr is to be added
+ :type nodeid: integer
+ :param iface: interface on the node to which the macaddr is to be added
+ :type iface: integer
+ :param macaddr: mac address to be added
+ :type macaddr: string
+
+ """
+ # This command is a case where we should avoid using _run_command,
+ # because we can just add the macaddr using primary node
+ self.primary_node.bmc.fabric_add_macaddr(nodeid, iface, macaddr)
+
+ def rm_macaddr(self, nodeid, iface, macaddr):
+ """Remove a macaddr to a node/interface in the fabric.
+
+ >>> fabric.rm_mac_address (3, 1, "66:55:44:33:22:11")
+
+ :param nodeid: Node id from which the macaddr is to be remove
+ :type nodeid: integer
+ :param iface: interface on the node from which the macaddr is to be removed
+ :type iface: integer
+ :param macaddr: mac address to be removed
+ :type macaddr: string
+
+ """
+ # This command is a case where we should avoid using _run_command,
+ # because we can just add the macaddr using primary node
+ self.primary_node.bmc.fabric_rm_macaddr(nodeid, iface, macaddr)
+
def get_linkspeed_policy(self):
"""Get the global linkspeed policy for the fabric. In the partition
world this means the linkspeed for Configuration 0, Partition 0,
diff --git a/cxmanage_api/node.py b/cxmanage_api/node.py
index 4ca8eec..d051f04 100644
--- a/cxmanage_api/node.py
+++ b/cxmanage_api/node.py
@@ -174,6 +174,23 @@ class Node(object):
"""
return self.get_fabric_macaddrs()[self.node_id]
+ def get_interface_mac_address(self, interface):
+ """Return mac address for an interface
+
+ >>> node.get_interface_mac_address()
+ fc:2f:40:d8:e3:14
+
+ :return: The Node's current mac address for specified interface
+ :rtype: string
+
+ :raises IpmiError: If errors in the command occur with BMC communication.
+
+ """
+ try:
+ return self.bmc.get_node_interface_macaddr(interface)
+ except IpmiError as e:
+ raise IpmiError(self._parse_ipmierror(e))
+
def get_power(self):
"""Returns the power status for this node.
diff --git a/cxmanage_test/fabric_test.py b/cxmanage_test/fabric_test.py
index dcb5f85..46e7926 100644
--- a/cxmanage_test/fabric_test.py
+++ b/cxmanage_test/fabric_test.py
@@ -305,6 +305,36 @@ class FabricTest(unittest.TestCase):
# it's there to make sure the ipsrc_mode value gets passed to the bmc.
self.assertEqual(bmc.fabric_lu_factor, lu_factor)
+ def test_add_macaddr (self):
+ """Test the add_macaddr method"""
+
+ valid_nodeids = [0, 1, 2, 3]
+ t_nodeid = random.choice(valid_nodeids)
+
+ valid_ifaces = [0, 1, 2]
+ t_nodeid = random.choice(valid_ifaces)
+
+ t_macaddr = "66:55:44:33:22:11"
+
+ self.fabric.add_macaddr (t_nodeid, t_iface, t_macaddr)
+ bmc = self.fabric.primary_node.bmc
+ self.assertIn ('fabric_add_macaddr', bmc.executed)
+
+ def test_rm_macaddr (self):
+ """Test the rm_macaddr method"""
+
+ valid_nodeids = [0, 1, 2, 3]
+ t_nodeid = random.choice(valid_nodeids)
+
+ valid_ifaces = [0, 1, 2]
+ t_nodeid = random.choice(valid_ifaces)
+
+ t_macaddr = "66:55:44:33:22:11"
+
+ self.fabric.rm_macaddr (t_nodeid, t_iface, t_macaddr)
+ bmc = self.fabric.primary_node.bmc
+ self.assertIn ('fabric_rm_macaddr', bmc.executed)
+
class DummyNode(object):
""" Dummy node for the nodemanager tests """
def __init__(self, ip_address, username="admin", password="admin",