From dc0c7270a4e3e08bb76cc609141bc96a41fa5853 Mon Sep 17 00:00:00 2001 From: Juliana Motira Date: Mon, 24 Aug 2015 14:43:38 -0300 Subject: [PATCH] Changing LEDs structure --- confluent_server/confluent/core.py | 4 ++-- confluent_server/confluent/messages.py | 10 ++++------ .../confluent/plugins/hardwaremanagement/ipmi.py | 14 +++++++++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index b403b68a..93de22db 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -208,11 +208,11 @@ noderesources = { }), }, 'led': { - 'all': PluginRoute({ + 'all': PluginCollection({ 'pluginattrs': ['hardwaremanagement.method'], 'default': 'ipmi', }) - } + }, }, } diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index bd65be7e..9d3f037d 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -829,12 +829,10 @@ class LEDStatus(ConfluentMessage): self.notnode = name is None self.desc = 'led status' - self.kvpairs = {} - for led_category in data: - self.kvpairs[led_category] = [data[led_category]] - - if not self.notnode: - self.kvpairs = {name: self.kvpairs} + if self.notnode: + self.kvpairs = {'leds':data} + else: + self.kvpairs = {name: {'leds':data}} class NetworkConfiguration(ConfluentMessage): diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index 1c5ef0ee..c04049d1 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -595,9 +595,15 @@ class IpmiHandler(object): raise Exception('Unsupported scenario...') def list_leds(self): - led_categories = {} - for category, leds in self.ipmicmd.get_leds(): - led_categories[category] = leds + self.output.put(msg.ChildCollection('all')) + for category, info in self.ipmicmd.get_leds(): + self.output.put(msg.ChildCollection(simplify_name(category))) + + def read_leds(self, component): + led_categories = [] + for category, info in self.ipmicmd.get_leds(): + if component == 'all' or component == simplify_name(category): + led_categories.append({category: info}) self.output.put(msg.LEDStatus(led_categories, self.node)) def read_inventory(self, component): @@ -639,6 +645,8 @@ class IpmiHandler(object): return self.list_sensors() elif len(self.element) == 3 and self.element[-2] == 'led': return self.list_leds() + elif len(self.element) == 4 and self.element[1] == 'led': + return self.read_leds(self.element[-1]) elif len(self.element) == 4: # resource requested return self.read_sensors(self.element[-1])