Add support for network_interface attribute

For the nework_interface attribute the user can:
- select a value for network_interface as part of enrolling a node
- update its value as part of editing a node,
- see its value in the node-details/overview page

Change-Id: I6bdbd9e6596de3f7da3bbcf75b511e5bc54b781a
Closes-Bug: #1648566
This commit is contained in:
Peter Piela 2017-02-11 09:24:54 -05:00 committed by Julia Kreger
parent d6e5ab2ecb
commit d97d4b4fa2
5 changed files with 50 additions and 26 deletions

View File

@ -24,7 +24,7 @@ from horizon.utils.memoized import memoized # noqa
from openstack_dashboard.api import base
DEFAULT_IRONIC_API_VERSION = '1.19'
DEFAULT_IRONIC_API_VERSION = '1.20'
DEFAULT_INSECURE = False
DEFAULT_CACERT = None
@ -141,14 +141,8 @@ def node_create(request, params):
"""
node_manager = ironicclient(request).node
node = node_manager.create(**params)
field_list = ['chassis_uuid',
'driver',
'driver_info',
'properties',
'extra',
'uuid',
'name']
return dict([(f, getattr(node, f, '')) for f in field_list])
return dict([(f, getattr(node, f, ''))
for f in res_fields.NODE_DETAILED_RESOURCE.fields])
def node_delete(request, node_id):
@ -173,7 +167,9 @@ def node_update(request, node_id, patch):
http://docs.openstack.org/developer/python-ironicclient/api/ironicclient.v1.node.html#ironicclient.v1.node.NodeManager.update
"""
ironicclient(request).node.update(node_id, patch)
node = ironicclient(request).node.update(node_id, patch)
return dict([(f, getattr(node, f, ''))
for f in res_fields.NODE_DETAILED_RESOURCE.fields])
def node_validate(request, node_id):

View File

@ -76,7 +76,8 @@
driver: null,
driver_info: {},
properties: {},
extra: {}
extra: {},
network_interface: null
};
/**

View File

@ -53,6 +53,29 @@
placeholder="{$ ::'A unique node name. Optional.' | translate $}"/>
</div>
</div>
<!--network interface-->
<div class="form-group">
<label for="network_interface"
class="control-label"
translate>
Network Interface
<span class="help-icon"
data-container="body"
title=""
data-toggle="tooltip"
data-original-title="{$ ::'Network interface used for switching between provisioning, tenant, and cleaning networks.' | translate $}">
<span class="fa fa-question-circle"></span>
</span>
</label>
<div>
<div class="btn-group">
<label class="btn btn-default"
ng-repeat="opt in ['noop', 'flat', 'neutron']"
ng-model="ctrl.node.network_interface"
uib-btn-radio="opt">{$ opt $}</label>
</div>
</div>
</div>
<!--node driver-->
<div class="form-group required">
<label for="driver"

View File

@ -78,6 +78,7 @@
ctrl.baseNode = node;
ctrl.node.name = node.name;
ctrl.node.network_interface = node.network_interface;
for (var i = 0; i < ctrl.drivers.length; i++) {
if (ctrl.drivers[i].name === node.driver) {
ctrl.selectedDriver = ctrl.drivers[i];
@ -110,21 +111,22 @@
*/
function buildPatch(sourceNode, targetNode) {
var patcher = new updatePatchService.UpdatePatch();
patcher.buildPatch(sourceNode.name, targetNode.name, "/name");
patcher.buildPatch(sourceNode.driver, targetNode.driver, "/driver");
patcher.buildPatch(sourceNode.properties,
targetNode.properties,
"/properties");
patcher.buildPatch(sourceNode.extra,
targetNode.extra,
"/extra");
patcher.buildPatch(sourceNode.driver_info,
targetNode.driver_info,
"/driver_info");
patcher.buildPatch(sourceNode.instance_info,
targetNode.instance_info,
"/instance_info");
var PatchItem = function PatchItem(id, path) {
this.id = id;
this.path = path;
};
angular.forEach([new PatchItem("name", "/name"),
new PatchItem("network_interface", "/network_interface"),
new PatchItem("driver", "/driver"),
new PatchItem("properties", "/properties"),
new PatchItem("extra", "/extra"),
new PatchItem("driver_info", "/driver_info"),
new PatchItem("instance_info", "/instance_info")],
function(item) {
patcher.buildPatch(sourceNode[item.id],
targetNode[item.id],
item.path);
});
return patcher.getPatch();
}

View File

@ -7,6 +7,8 @@
<dl class="dl-horizontal">
<dt translate>Name</dt>
<dd>{$ ctrl.node.name | noValue $}</dd>
<dt translate>Network Interface</dt>
<dd>{$ ctrl.node.network_interface $}</dd>
<dt translate>Maintenance</dt>
<dd>{$ ctrl.node.maintenance | yesno $}</dd>
<dt translate>Maintenance Reason</dt>