Show boot device in Node Details/Configuration

Partial-Bug: #1671567
Change-Id: I3208dde3e47477e42f4ce59d8c65e8d5049d0c0e
This commit is contained in:
Miles Gould 2017-03-09 17:36:27 +00:00
parent a4c89967d8
commit 18e6379814
7 changed files with 92 additions and 0 deletions

View File

@ -190,6 +190,18 @@ def node_validate(request, node_id):
return result
def node_get_boot_device(request, node_id):
"""Get the boot device for a specified node.
:param request: HTTP request.
:param node_id: The id of the node.
:return: Dictionary with keys "boot_device" and "persistent"
http://docs.openstack.org/developer/python-ironicclient/api/ironicclient.v1.node.html#ironicclient.v1.node.NodeManager.get_boot_device
"""
return ironicclient(request).node.get_boot_device(node_id)
def driver_list(request):
"""Retrieve a list of drivers.

View File

@ -224,6 +224,22 @@ class Validate(generic.View):
return ironic.node_validate(request, node_id)
@urls.register
class BootDevice(generic.View):
url_regex = r'ironic/nodes/(?P<node_id>[0-9a-f-]+)/boot_device$'
@rest_utils.ajax()
def get(self, request, node_id):
"""Get the boot device for a specified node
:param request: HTTP request.
:param node_id: Node name or uuid
:return: Dictionary with keys "boot_device" and "persistent"
"""
return ironic.node_get_boot_device(request, node_id)
@urls.register
class Drivers(generic.View):

View File

@ -49,6 +49,7 @@
getNode: getNode,
getNodes: getNodes,
getPortsWithNode: getPortsWithNode,
getBootDevice: getBootDevice,
powerOffNode: powerOffNode,
powerOnNode: powerOnNode,
putNodeInMaintenanceMode: putNodeInMaintenanceMode,
@ -111,6 +112,28 @@
});
}
/**
* @description Retrieve the boot device for a node
* https://developer.openstack.org/api-ref/baremetal/#get-boot-device
*
* @param {string} uuid UUID or logical name of a node.
* @return {promise} Dictionary describing the current boot device
*/
function getBootDevice(uuid) {
return apiService.get('/api/ironic/nodes/' + uuid + '/boot_device')
.then(function(response) {
return response.data;
})
.catch(function(response) {
var msg = interpolate(
gettext('Unable to retrieve boot device for Ironic node. %s'),
[response.data],
false);
toastService.add('error', msg);
return $q.reject(msg);
});
}
/**
* @description Retrieve a list of ports associated with a node.
*

View File

@ -132,6 +132,7 @@
ctrl.nodeStateTransitions =
nodeStateTransitionService.getTransitions(ctrl.node.provision_state);
retrievePorts();
retrieveBootDevice();
validateNode();
});
}
@ -164,6 +165,19 @@
});
}
/**
* @name horizon.dashboard.admin.ironic.NodeDetailsController.retrieveBootDevice
* @description Retrieve the boot device associated with the current node,
* and store it in the controller instance.
*
* @return {void}
*/
function retrieveBootDevice() {
ironic.getBootDevice(ctrl.node.uuid).then(function (bootDevice) {
ctrl.node.bootDevice = bootDevice;
});
}
/**
* @name horizon.dashboard.admin.ironic.NodeDetailsController.validateNode
* @description Retrieve the ports associated with the current node,

View File

@ -22,6 +22,7 @@
var nodeUuid = "0123abcd-0123-4567-abcd-0123456789ab";
var nodeName = "herp";
var numPorts = 2;
var bootDevice = {boot_device: 'pxe', persistent: true};
function portUuid(nodeUuid, index) {
return '' + index + index + nodeUuid.substring(2);
@ -66,6 +67,10 @@
return $q.when(ports);
},
getBootDevice: function () {
return $q.when(bootDevice);
},
validateNode: function() {
return $q.when({});
}
@ -125,6 +130,7 @@
expect(ctrl.node).toBeDefined();
var node = createNode(nodeName, nodeUuid);
node.id = node.uuid;
node.bootDevice = bootDevice;
expect(ctrl.node).toEqual(node);
});
@ -170,5 +176,10 @@
expect(ctrl.nodeValidation).toBeDefined();
expect(ctrl.nodeValidation).toEqual([]);
});
it('should have a boot device', function () {
expect(ctrl.node.bootDevice).toBeDefined();
expect(ctrl.node.bootDevice).toEqual(bootDevice);
});
});
})();

View File

@ -267,6 +267,18 @@
</dl>
</div>
</div>
<!-- Boot Device -->
<div class="col-md-6 status detail">
<h4 translate>Boot Device</h4>
<hr class="header_rule">
<dl class="dl-horizontal">
<dt translate>Device</dt>
<dd>{$ ctrl.node.bootDevice.boot_device | noValue $}</dd>
<dt translate>Persistent</dt>
<dd>{$ ctrl.node.bootDevice.persistent | noValue $}</dd>
</dl>
</div>
</div>
<div class="row">

View File

@ -0,0 +1,4 @@
---
features:
- |
The Node Details/Configuration tab now shows the node's boot device.