From 5794dd7f8c0e565d16cfcb5bf6d81a2b3c33dc6c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 22 Aug 2019 16:15:01 -0400 Subject: [PATCH] Add CP storage to discovery --- confluent_server/confluent/discovery/core.py | 3 ++- .../confluent/discovery/handlers/bmc.py | 18 ++++++++-------- .../confluent/discovery/handlers/cpstorage.py | 21 +++++++++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 confluent_server/confluent/discovery/handlers/cpstorage.py diff --git a/confluent_server/confluent/discovery/core.py b/confluent_server/confluent/discovery/core.py index 005a57f7..0e6c5501 100644 --- a/confluent_server/confluent/discovery/core.py +++ b/confluent_server/confluent/discovery/core.py @@ -68,6 +68,7 @@ import confluent.discovery.protocols.pxe as pxe #import confluent.discovery.protocols.ssdp as ssdp import confluent.discovery.protocols.slp as slp import confluent.discovery.handlers.imm as imm +import confluent.discovery.handlers.cpstorage as cpstorage import confluent.discovery.handlers.pxe as pxeh import confluent.discovery.handlers.smm as smm import confluent.discovery.handlers.xcc as xcc @@ -101,7 +102,7 @@ nodehandlers = { 'service:management-hardware.IBM:integrated-management-module2': imm, 'pxe-client': pxeh, 'service:io-device.Lenovo:management-module': None, - 'service:thinkagile-storage': None, + 'service:thinkagile-storage': cpstorage, } servicenames = { diff --git a/confluent_server/confluent/discovery/handlers/bmc.py b/confluent_server/confluent/discovery/handlers/bmc.py index 4985f795..dacce06c 100644 --- a/confluent_server/confluent/discovery/handlers/bmc.py +++ b/confluent_server/confluent/discovery/handlers/bmc.py @@ -26,11 +26,11 @@ ipmicommand.session.threading = eventlet.green.threading ipmicommand.session.socket.getaddrinfo = eventlet.support.greendns.getaddrinfo getaddrinfo = eventlet.support.greendns.getaddrinfo -DEFAULT_USER = 'USERID' -DEFAULT_PASS = 'PASSW0RD' class NodeHandler(generic.NodeHandler): + DEFAULT_USER = 'USERID' + DEFAULT_PASS = 'PASSW0RD' def _get_ipmicmd(self, user=None, password=None): priv = None @@ -39,9 +39,9 @@ class NodeHandler(generic.NodeHandler): raise pygexc.IpmiException() priv = 4 # manually indicate priv to avoid double-attempt if user is None: - user = DEFAULT_USER + user = self.DEFAULT_USER if password is None: - password = DEFAULT_PASS + password = self.DEFAULT_PASS return ipmicommand.Command(self.ipaddr, user, password, privlevel=priv, keepalive=False) @@ -70,17 +70,17 @@ class NodeHandler(generic.NodeHandler): 'secret.hardwaremanagementpassword', {}).get('value', None) try: ic = self._get_ipmicmd() - passwd = DEFAULT_PASS + passwd = self.DEFAULT_PASS except pygexc.IpmiException as pi: havecustomcreds = False - if user is not None and user != DEFAULT_USER: + if user is not None and user != self.DEFAULT_USER: havecustomcreds = True else: - user = DEFAULT_USER - if passwd is not None and passwd != DEFAULT_PASS: + user = self.DEFAULT_USER + if passwd is not None and passwd != self.DEFAULT_PASS: havecustomcreds = True else: - passwd = DEFAULT_PASS + passwd = self.DEFAULT_PASS if havecustomcreds: ic = self._get_ipmicmd(user, passwd) else: diff --git a/confluent_server/confluent/discovery/handlers/cpstorage.py b/confluent_server/confluent/discovery/handlers/cpstorage.py new file mode 100644 index 00000000..4aaee102 --- /dev/null +++ b/confluent_server/confluent/discovery/handlers/cpstorage.py @@ -0,0 +1,21 @@ +# Copyright 2019 Lenovo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import confluent.discovery.handlers.bmc as bmchandler + +class NodeHandler(bmchandler.NodeHandler): + DEFAULT_USER = 'admin' + DEFAULT_PASS = 'admin' + devname = 'BMC' + maxmacs = 2