summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-11-15 10:21:03 +0000
committerGerrit Code Review <review@openstack.org>2017-11-15 10:21:03 +0000
commit4be116f70ec19030f8521353d4b9412a6213ff1c (patch)
treebbea99d9efe50070340aac5cbab62e3176587361
parent2db023fdd1485f7dad6d07d469ca805119727933 (diff)
parentc8755c58ea5314cd42fb064640467e2422acf426 (diff)
Merge "Add port group mode to manageable servers"
-rw-r--r--api-ref/source/v1/samples/manageable_servers/manageable-servers-list-resp.json1
-rw-r--r--mogan/baremetal/ironic/driver.py33
2 files changed, 22 insertions, 12 deletions
diff --git a/api-ref/source/v1/samples/manageable_servers/manageable-servers-list-resp.json b/api-ref/source/v1/samples/manageable_servers/manageable-servers-list-resp.json
index b754613..2bd7bff 100644
--- a/api-ref/source/v1/samples/manageable_servers/manageable-servers-list-resp.json
+++ b/api-ref/source/v1/samples/manageable_servers/manageable-servers-list-resp.json
@@ -17,6 +17,7 @@
17 { 17 {
18 "address": "a4:dc:be:0e:82:a6", 18 "address": "a4:dc:be:0e:82:a6",
19 "uuid": "1ec01153-685a-49b5-a6d3-45a4e7dddf54", 19 "uuid": "1ec01153-685a-49b5-a6d3-45a4e7dddf54",
20 "mode": "active-backup",
20 "neutron_port_id": "a9b94592-1d8e-46bb-836b-c7ba935b0137" 21 "neutron_port_id": "a9b94592-1d8e-46bb-836b-c7ba935b0137"
21 } 22 }
22 ], 23 ],
diff --git a/mogan/baremetal/ironic/driver.py b/mogan/baremetal/ironic/driver.py
index fd9a6ea..5034181 100644
--- a/mogan/baremetal/ironic/driver.py
+++ b/mogan/baremetal/ironic/driver.py
@@ -128,18 +128,27 @@ class IronicDriver(base_driver.BaseEngineDriver):
128 128
129 return dic 129 return dic
130 130
131 def _port_or_group_resource(self, port_or_pg): 131 def _port_resource(self, port):
132 """Helper method to create resource dict from port or portgroup 132 """Helper method to create resource dict from port stats."""
133 133
134 stats. 134 neutron_port_id = (port.internal_info.get(TENANT_VIF_KEY) or
135 port.extra.get(VIF_KEY))
136 dic = {
137 'address': port.address,
138 'uuid': port.uuid,
139 'neutron_port_id': neutron_port_id,
140 }
141 return dic
135 142
136 """ 143 def _portgroup_resource(self, portgroup):
144 """Helper method to create resource dict from portgroup stats. """
137 145
138 neutron_port_id = (port_or_pg.internal_info.get(TENANT_VIF_KEY) or 146 neutron_port_id = (portgroup.internal_info.get(TENANT_VIF_KEY) or
139 port_or_pg.extra.get(VIF_KEY)) 147 portgroup.extra.get(VIF_KEY))
140 dic = { 148 dic = {
141 'address': port_or_pg.address, 149 'address': portgroup.address,
142 'uuid': port_or_pg.uuid, 150 'uuid': portgroup.uuid,
151 'mode': portgroup.mode,
143 'neutron_port_id': neutron_port_id, 152 'neutron_port_id': neutron_port_id,
144 } 153 }
145 return dic 154 return dic
@@ -465,11 +474,11 @@ class IronicDriver(base_driver.BaseEngineDriver):
465 if node.resource_class is None: 474 if node.resource_class is None:
466 continue 475 continue
467 # Add ports to the associated node 476 # Add ports to the associated node
468 node.ports = [self._port_or_group_resource(port) 477 node.ports = [self._port_resource(port)
469 for port in port_list 478 for port in port_list
470 if node.uuid == port.node_uuid] 479 if node.uuid == port.node_uuid]
471 # Add portgroups to the associated node 480 # Add portgroups to the associated node
472 node.portgroups = [self._port_or_group_resource(portgroup) 481 node.portgroups = [self._portgroup_resource(portgroup)
473 for portgroup in portgroup_list 482 for portgroup in portgroup_list
474 if node.uuid == portgroup.node_uuid] 483 if node.uuid == portgroup.node_uuid]
475 node_resources[node.uuid] = self._node_resource(node) 484 node_resources[node.uuid] = self._node_resource(node)
@@ -815,11 +824,11 @@ class IronicDriver(base_driver.BaseEngineDriver):
815 portgroup_list = self.ironicclient.call("portgroup.list", **params) 824 portgroup_list = self.ironicclient.call("portgroup.list", **params)
816 825
817 # Add ports to the associated node 826 # Add ports to the associated node
818 node.ports = [self._port_or_group_resource(port) 827 node.ports = [self._port_resource(port)
819 for port in port_list 828 for port in port_list
820 if node.uuid == port.node_uuid] 829 if node.uuid == port.node_uuid]
821 # Add portgroups to the associated node 830 # Add portgroups to the associated node
822 node.portgroups = [self._port_or_group_resource(portgroup) 831 node.portgroups = [self._portgroup_resource(portgroup)
823 for portgroup in portgroup_list 832 for portgroup in portgroup_list
824 if node.uuid == portgroup.node_uuid] 833 if node.uuid == portgroup.node_uuid]
825 node.power_state = map_power_state(node.power_state) 834 node.power_state = map_power_state(node.power_state)