From 9b52e276ccf02f92db63261c282418810690cb6d Mon Sep 17 00:00:00 2001 From: Juliana Motira Date: Tue, 8 Sep 2015 12:33:36 -0300 Subject: [PATCH] Implement remote KVM command --- confluent_server/confluent/core.py | 4 ++++ confluent_server/confluent/messages.py | 15 +++++++++++++++ .../confluent/plugins/hardwaremanagement/ipmi.py | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index fd0e7544..d39b8e99 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -170,6 +170,10 @@ noderesources = { 'console': { # this is a dummy value, http or socket must handle special 'session': PluginRoute({}), + 'license': PluginRoute({ + 'pluginattrs': ['hardwaremanagement.method'], + 'default': 'ipmi', + }), }, 'events': { 'hardware': { diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index bc0b987b..a274b57b 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -1105,6 +1105,21 @@ class NTPServer(ConfluentMessage): self.kvpairs = {name: kv} +class License(ConfluentMessage): + readonly = True + + def __init__(self, name=None, kvm=None): + self.notnode = name is None + self.desc = 'License' + + kv = [] + kv.append({'kvm_availability': str(kvm)}) + if self.notnode: + self.kvpairs = {'License': kv} + else: + self.kvpairs = {name: {'License': kv}} + + class CryptedAttributes(Attributes): defaulttype = 'password' diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index 9ebd1ecc..565d01b5 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -357,6 +357,8 @@ class IpmiHandler(object): self.do_eventlog() elif self.element == ['events', 'hardware', 'decode']: self.decode_alert() + elif self.element == ['console', 'license']: + self.handle_license() else: raise Exception('Not Implemented') @@ -819,6 +821,11 @@ class IpmiHandler(object): self.ipmicmd.set_ntp_server(server, idx) return + def handle_license(self): + available = self.ipmicmd.get_remote_kvm_available() + self.output.put(msg.License(self.node, available)) + return + def _str_health(health): if health == 'unknown': return health