From 2936c7e8fd808cfe581beee4fb27b5d266123de2 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 24 Apr 2020 09:39:31 -0400 Subject: [PATCH 1/4] Add a utility to select disks Use python to enable a bit more flexibility and still be readable. --- misc/getinstalldisk | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 misc/getinstalldisk diff --git a/misc/getinstalldisk b/misc/getinstalldisk new file mode 100644 index 00000000..71a63381 --- /dev/null +++ b/misc/getinstalldisk @@ -0,0 +1,86 @@ +import subprocess +import os + +class DiskInfo(object): + def __init__(self, devname): + self.name = devname + self.wwn = None + self.path = None + self.model = None + self.size = 0 + self.driver = None + devnode = '/dev/{0}'.format(devname) + qprop = subprocess.check_output( + ['udevadm', 'info', '--query=property', devnode]) + if not isinstance(qprop, str): + qprop = qprop.decode('utf8') + for prop in qprop.split('\n'): + if '=' not in prop: + continue + k, v = prop.split('=', 1) + if k == 'DEVTYPE' and v != 'disk': + raise Exception('Not a disk') + elif k == 'DM_NAME': + raise Exception('Device Mapper') + elif k == 'ID_MODEL': + self.model = v + elif k == 'DEVPATH': + self.path = v + elif k == 'ID_WWN': + self.wwn = v + attrs = subprocess.check_output(['udevadm', 'info', '-a', devnode]) + if not isinstance(attrs, str): + attrs = attrs.decode('utf8') + for attr in attrs.split('\n'): + if '==' not in attr: + continue + k, v = attr.split('==', 1) + k = k.strip() + if k == 'ATTRS{size}': + self.size = v.replace('"', '') + elif (k == 'DRIVERS' and not self.driver + and v not in ('"sd"', '""')): + self.driver = v.replace('"', '') + if not self.driver: + raise Exception("No driver detected") + + @property + def priority(self): + if self.model and self.model.lower() in ('thinksystem_m.2_vd', 'thinksystem m.2'): + return 0 + # TODO: RSTe, which would be a 1 + if self.driver == 'ahci': + return 2 + if self.driver.startswith('megaraid'): + return 3 + if self.driver.startswith('mpt'): + return 4 + return 99 + + def __repr__(self): + return repr({ + 'name': self.name, + 'path': self.path, + 'wwn': self.wwn, + 'driver': self.driver, + 'size': self.size, + 'model': self.model, + }) + + +def main(): + disks = [] + for disk in sorted(os.listdir('/sys/class/block')): + try: + disk = DiskInfo(disk) + disks.append(disk) + except Exception as e: + print("Skipping {0}: {1}".format(disk, str(e))) + nd = [x.name for x in sorted(disks, key=lambda x: x.priority)] + if nd: + open('/tmp/installdisk', 'w').write(nd[0]) + +if __name__ == '__main__': + main() + + From 501ab64e18141bf9bd7e6ebc34af6b7f437eb580 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 27 Apr 2020 17:37:21 -0400 Subject: [PATCH 2/4] Revert "Add a utility to select disks" This reverts commit 2936c7e8fd808cfe581beee4fb27b5d266123de2. --- misc/getinstalldisk | 86 --------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 misc/getinstalldisk diff --git a/misc/getinstalldisk b/misc/getinstalldisk deleted file mode 100644 index 71a63381..00000000 --- a/misc/getinstalldisk +++ /dev/null @@ -1,86 +0,0 @@ -import subprocess -import os - -class DiskInfo(object): - def __init__(self, devname): - self.name = devname - self.wwn = None - self.path = None - self.model = None - self.size = 0 - self.driver = None - devnode = '/dev/{0}'.format(devname) - qprop = subprocess.check_output( - ['udevadm', 'info', '--query=property', devnode]) - if not isinstance(qprop, str): - qprop = qprop.decode('utf8') - for prop in qprop.split('\n'): - if '=' not in prop: - continue - k, v = prop.split('=', 1) - if k == 'DEVTYPE' and v != 'disk': - raise Exception('Not a disk') - elif k == 'DM_NAME': - raise Exception('Device Mapper') - elif k == 'ID_MODEL': - self.model = v - elif k == 'DEVPATH': - self.path = v - elif k == 'ID_WWN': - self.wwn = v - attrs = subprocess.check_output(['udevadm', 'info', '-a', devnode]) - if not isinstance(attrs, str): - attrs = attrs.decode('utf8') - for attr in attrs.split('\n'): - if '==' not in attr: - continue - k, v = attr.split('==', 1) - k = k.strip() - if k == 'ATTRS{size}': - self.size = v.replace('"', '') - elif (k == 'DRIVERS' and not self.driver - and v not in ('"sd"', '""')): - self.driver = v.replace('"', '') - if not self.driver: - raise Exception("No driver detected") - - @property - def priority(self): - if self.model and self.model.lower() in ('thinksystem_m.2_vd', 'thinksystem m.2'): - return 0 - # TODO: RSTe, which would be a 1 - if self.driver == 'ahci': - return 2 - if self.driver.startswith('megaraid'): - return 3 - if self.driver.startswith('mpt'): - return 4 - return 99 - - def __repr__(self): - return repr({ - 'name': self.name, - 'path': self.path, - 'wwn': self.wwn, - 'driver': self.driver, - 'size': self.size, - 'model': self.model, - }) - - -def main(): - disks = [] - for disk in sorted(os.listdir('/sys/class/block')): - try: - disk = DiskInfo(disk) - disks.append(disk) - except Exception as e: - print("Skipping {0}: {1}".format(disk, str(e))) - nd = [x.name for x in sorted(disks, key=lambda x: x.priority)] - if nd: - open('/tmp/installdisk', 'w').write(nd[0]) - -if __name__ == '__main__': - main() - - From 598ec4a29472f759eda846c7bd71b8fd8213de10 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 28 Apr 2020 11:29:41 -0400 Subject: [PATCH 3/4] Change ubuntu package names --- confluent_server/builddeb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/confluent_server/builddeb b/confluent_server/builddeb index 418e6620..47fa7f32 100755 --- a/confluent_server/builddeb +++ b/confluent_server/builddeb @@ -44,6 +44,9 @@ if [ "$OPKGNAME" = "confluent-server" ]; then echo 'confluent_client confluent-client' >> debian/pydist-overrides fi fi +if ! grep wheezy /etc/os-release; then + sed -i 's/^Package: python3-/Package: /' debian/control +fi head -n -1 debian/control > debian/control1 mv debian/control1 debian/control echo 'export PYBUILD_INSTALL_ARGS=--install-lib=/opt/confluent/lib/python' >> debian/rules From 3f53c55a6698c39019da9287ce2e660ad97a1990 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 7 May 2020 08:27:16 -0400 Subject: [PATCH 4/4] Add custom port to nodeshell Permit use of an alternative port in nodeshell. --- confluent_client/bin/nodeshell | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/confluent_client/bin/nodeshell b/confluent_client/bin/nodeshell index 8899a013..4621be31 100755 --- a/confluent_client/bin/nodeshell +++ b/confluent_client/bin/nodeshell @@ -46,6 +46,8 @@ def run(): help='Number of commands to run at a time') argparser.add_option('-n', '--nonodeprefix', action='store_true', help='Do not prefix output with node names') + argparser.add_option('-p', '--port', type='int', default=0, + help='Specify a custom port for ssh') argparser.add_option('-m', '--maxnodes', type='int', help='Specify a maximum number of ' 'nodes to run remote ssh command to, ' @@ -59,7 +61,7 @@ def run(): sys.exit(1) client.check_globbing(args[0]) concurrentprocs = options.count - c = client.Command() + c = client.Command() cmdstr = " ".join(args[1:]) currprocs = 0 @@ -79,7 +81,10 @@ def run(): cmd = ex[node]['value'] if not isinstance(cmd, str) and not isinstance(cmd, bytes): cmd = cmd.encode('utf-8') - cmdv = ['ssh', node, cmd] + if options.port: + cmdv = ['ssh', '-p', '{0}'.format(options.port), node, cmd] + else: + cmdv = ['ssh', node, cmd] if currprocs < concurrentprocs: currprocs += 1 run_cmdv(node, cmdv, all, pipedesc)