From c20f0dc2ae0c9bafa15914f89dc02d09f833ff45 Mon Sep 17 00:00:00 2001 From: Juliana Motira Date: Thu, 27 Aug 2015 08:38:23 -0300 Subject: [PATCH] Implement reset command Added a reset bmc command in nodes//configuration/management_controller/reset --- confluent_server/confluent/core.py | 4 ++++ confluent_server/confluent/messages.py | 19 +++++++++++++++++++ .../plugins/hardwaremanagement/ipmi.py | 11 +++++++++++ 3 files changed, 34 insertions(+) diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index 93de22db..e3c80213 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -135,6 +135,10 @@ noderesources = { 'pluginattrs': ['hardwaremanagement.method'], 'default': 'ipmi', }), + 'reset': PluginRoute({ + 'pluginattrs': ['hardwaremanagement.method'], + 'default': 'ipmi', + }), } }, '_console': { diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 9d3f037d..0e92c815 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -328,6 +328,9 @@ def get_input_message(path, operation, inputdata, nodes=None, multinode=False): elif (path[:3] == ['configuration', 'management_controller', 'users'] and operation not in ('retrieve', 'delete') and path[-1] != 'all'): return InputCredential(path, inputdata, nodes) + elif (path[:3] == ['configuration', 'management_controller', 'reset'] + and operation != 'retrieve'): + return InputBMCReset(path, nodes, inputdata) elif inputdata: raise exc.InvalidArgumentException() @@ -542,6 +545,15 @@ class InputPowerMessage(ConfluentInputMessage): return self.inputbynode[node] +class InputBMCReset(ConfluentInputMessage): + valid_values = set([ + 'reset', + ]) + + def state(self, node): + return self.inputbynode[node] + + class BootDevice(ConfluentChoiceMessage): valid_values = set([ 'network', @@ -642,6 +654,13 @@ class PowerState(ConfluentChoiceMessage): keyname = 'state' +class BMCReset(ConfluentChoiceMessage): + valid_values = set([ + 'reset', + ]) + keyname = 'state' + + class EventCollection(ConfluentMessage): """A collection of events diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index c04049d1..3258f71b 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -367,6 +367,8 @@ class IpmiHandler(object): return self.handle_users() elif self.element[1:3] == ['management_controller', 'net_interfaces']: return self.handle_nets() + elif self.element[1:3] == ['management_controller', 'reset']: + return self.handle_reset() raise Exception('Not implemented') def decode_alert(self): @@ -739,6 +741,15 @@ class IpmiHandler(object): state=power['powerstate'])) return + def handle_reset(self): + if 'read' == self.op: + self.output.put(msg.BMCReset(node=self.node, + state='reset')) + return + elif 'update' == self.op: + self.ipmicmd.reset_bmc() + return + def _str_health(health): if health == 'unknown':