From 4dab5fc5273599e5ef6643dd71162b777f97d403 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 5 Aug 2019 16:16:42 -0400 Subject: [PATCH 1/4] Adapt to RHEL or Debian openssl config locations --- confluent_server/bin/confluentcertutil.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/confluent_server/bin/confluentcertutil.py b/confluent_server/bin/confluentcertutil.py index 3dab5306..c121224a 100644 --- a/confluent_server/bin/confluentcertutil.py +++ b/confluent_server/bin/confluentcertutil.py @@ -1,11 +1,16 @@ +from os.path import exists import shutil import socket import subprocess import tempfile def get_openssl_conf_location(): - # CentOS/RHAT - return '/etc/pki/tls/openssl.cnf' + if exists('/etc/pki/tls/openssl.cnf'): + return '/etc/pki/tls/openssl.cnf' + elif exists('/etc/ssl/openssl.cnf'); + return '/etc/ssl/openssl.cnf' + else: + raise Exception("Cannot find openssl config file") def get_ip_addresses(): lines = subprocess.check_output('ip addr'.split(' ')) @@ -47,4 +52,4 @@ def create_certificate(): ) if __name__ == '__main__': - create_certificate() \ No newline at end of file + create_certificate() From c3176ab86a5bcca1849b0347fb2b997a23ac2119 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 5 Aug 2019 16:22:50 -0400 Subject: [PATCH 2/4] Add blink and identify reporting to redfish --- confluent_client/bin/nodeidentify | 5 +---- confluent_client/confluent_env.sh | 2 +- confluent_client/doc/man/nodeidentify.ronn | 3 ++- confluent_server/confluent/messages.py | 1 + .../confluent/plugins/hardwaremanagement/ipmi.py | 3 +++ .../confluent/plugins/hardwaremanagement/redfish.py | 7 ++++--- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/confluent_client/bin/nodeidentify b/confluent_client/bin/nodeidentify index cc86ee32..32f7f82f 100755 --- a/confluent_client/bin/nodeidentify +++ b/confluent_client/bin/nodeidentify @@ -31,7 +31,7 @@ if path.startswith('/opt'): import confluent.client as client -argparser = optparse.OptionParser(usage="Usage: %prog [on|off]") +argparser = optparse.OptionParser(usage="Usage: %prog [on|off|blink]") (options, args) = argparser.parse_args() try: noderange = args[0] @@ -42,9 +42,6 @@ client.check_globbing(noderange) identifystate = None if len(sys.argv) > 2: identifystate = sys.argv[2] -else: - argparser.print_help() - sys.exit(1) session = client.Command() exitcode = 0 sys.exit( diff --git a/confluent_client/confluent_env.sh b/confluent_client/confluent_env.sh index 2cb8b6be..090b2fc9 100644 --- a/confluent_client/confluent_env.sh +++ b/confluent_client/confluent_env.sh @@ -84,7 +84,7 @@ function _confluent_generic_completion() } _confluent_nodeidentify_completion() { - COMP_CANDIDATES=("on,off -h") + COMP_CANDIDATES=("on,off,blink -h") _confluent_generic_completion } diff --git a/confluent_client/doc/man/nodeidentify.ronn b/confluent_client/doc/man/nodeidentify.ronn index 3a9cbe69..a0b08044 100644 --- a/confluent_client/doc/man/nodeidentify.ronn +++ b/confluent_client/doc/man/nodeidentify.ronn @@ -3,7 +3,7 @@ nodeidentify(8) -- Control the identify LED of confluent nodes ## SYNOPSIS -`nodidentify [on|off]` +`nodidentify [on|off|blink]` ## DESCRIPTION @@ -13,6 +13,7 @@ options are supported: * `on`: Turn on the identify LED * `off`: Turn off the identify LED +* `blink`: Set the identify LED to blink (when supported by the system) ## EXAMPLES: diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluent/messages.py index 36213d28..3590919e 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluent/messages.py @@ -822,6 +822,7 @@ class InputIdentifyMessage(ConfluentInputMessage): valid_values = set([ 'on', 'off', + 'blink', ]) keyname = 'identify' diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index a27fe007..400cb19e 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -1296,6 +1296,9 @@ class IpmiHandler(object): def identify(self): if 'update' == self.op: identifystate = self.inputdata.inputbynode[self.node] == 'on' + if self.inputdata.inputbynode[self.node] == 'blink': + raise exc.InvalidArgumentException( + '"blink" is not supported with ipmi') self.ipmicmd.set_identify(on=identifystate) self.output.put(msg.IdentifyState( node=self.node, state=self.inputdata.inputbynode[self.node])) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py index 4f893a27..e4506a91 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py @@ -1163,13 +1163,14 @@ class IpmiHandler(object): def identify(self): if 'update' == self.op: identifystate = self.inputdata.inputbynode[self.node] == 'on' - self.ipmicmd.set_identify(on=identifystate) + blinkstate = self.inputdata.inputbynode[self.node] == 'blink' + self.ipmicmd.set_identify(on=identifystate, blink=blinkstate) self.output.put(msg.IdentifyState( node=self.node, state=self.inputdata.inputbynode[self.node])) return elif 'read' == self.op: - # ipmi has identify as read-only for now - self.output.put(msg.IdentifyState(node=self.node, state='')) + identify = self.ipmicmd.get_identify().get('identifystate', '') + self.output.put(msg.IdentifyState(node=self.node, state=identify)) return def power(self): From 3f6e6d4c391c070ddc7be2e001fffc5400966c35 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 8 Aug 2019 15:02:26 -0400 Subject: [PATCH 3/4] Support unavailable sensors in redfish --- .../confluent/plugins/hardwaremanagement/redfish.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py index e4506a91..b58e2106 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py @@ -682,6 +682,10 @@ class IpmiHandler(object): try: reading = self.ipmicmd.get_sensor_reading( sensor['name']) + if reading.unavailable: + self.output.put(msg.SensorReadings([EmptySensor( + sensor['name'])], name=self.node)) + continue except pygexc.IpmiException as ie: if ie.ipmicode == 203: self.output.put(msg.SensorReadings([EmptySensor( @@ -702,6 +706,11 @@ class IpmiHandler(object): try: reading = self.ipmicmd.get_sensor_reading( self.sensormap[sensorname]) + if reading.unavailable: + self.output.put(msg.ConfluentResourceUnavailable( + self.node, 'Unavailable' + )) + return if hasattr(reading, 'health'): reading.health = _str_health(reading.health) self.output.put( From d95464df6f28ca4290a0d90f7fe45caca7a3ecf7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 8 Aug 2019 16:14:05 -0400 Subject: [PATCH 4/4] Add a non-ip network string xmit concept --- misc/clortho.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 misc/clortho.c diff --git a/misc/clortho.c b/misc/clortho.c new file mode 100644 index 00000000..bfe48d00 --- /dev/null +++ b/misc/clortho.c @@ -0,0 +1,85 @@ +/* Copyright 2019 Lenovo */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define OUI_ETHERTYPE 0x88b7 +#define MAXPACKET 1024 +#define CHDR "\xa4\x8c\xdb\x30\x01" + +int get_interface_index(int sock, char *interface) { + struct ifreq req; + memset(&req, 0, sizeof(req)); + strncpy(req.ifr_name, interface, IFNAMSIZ); + if (ioctl(sock, SIOCGIFINDEX, &req) < 0) { + return -1; + } + return req.ifr_ifindex; +} + +unsigned char* genpasswd() { + unsigned char * passwd; + int urandom; + passwd = calloc(33, sizeof(char)); + urandom = open("/dev/urandom", O_RDONLY); + read(urandom, passwd, 32); + close(urandom); + for (urandom = 0; urandom < 32; urandom++) { + passwd[urandom] = 0x30 + (passwd[urandom] >> 2); + } + return passwd; + +} + +int parse_macaddr(char* macaddr) { + unsigned char *curr; + unsigned char idx; + curr = strtok(macaddr, ":-"); + idx = 0; + + while (curr != NULL) { + macaddr[idx++] = strtoul(curr, NULL, 16); + curr = strtok(NULL, ":-"); + } + +} + +int main(int argc, char* argv[]) { + int sock; + int iface; + unsigned char* passwd; + unsigned char* macaddr; + + unsigned char buffer[MAXPACKET]; + + passwd = genpasswd(); + if (argc < 3) { + fprintf(stderr, "Missing interface name and target MAC\n"); + exit(1); + } + printf("%s\n", argv[2]); + parse_macaddr(argv[2]); + printf("%s\n", argv[2]); + sock = socket(AF_PACKET, SOCK_DGRAM, htons(OUI_ETHERTYPE)); + if (sock < 0) { + fprintf(stderr, "Unable to open socket (run as root?)\n"); + exit(1); + } + iface = get_interface_index(sock, argv[1]); + if (iface < 0) { + fprintf(stderr, "Unable to find specified interface '%s'\n", argv[1]); + exit(1); + } + + +} +