mirror of
https://github.com/xcat2/confluent.git
synced 2026-09-29 08:41:00 +00:00
Compare commits
277 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7cb6b1ac35 | |||
| 315d1d9b5e | |||
| d382bd5182 | |||
| fca0119331 | |||
| a7c338786e | |||
| c892af5a1e | |||
| 870cee5ed8 | |||
| 76a66a46e1 | |||
| df354c2f7d | |||
| 5b1492fed8 | |||
| ca3a53fde4 | |||
| 5ab16851ec | |||
| febccf4d5e | |||
| d0ae7b46ae | |||
| 57ada3728c | |||
| 89437ee761 | |||
| bfadc284b0 | |||
| fbea510fc1 | |||
| 5be99d995a | |||
| b3ffd632a5 | |||
| 62988117f1 | |||
| 71f5ce2b29 | |||
| 0c0cac140d | |||
| 5cc70846fd | |||
| 71f75dbc31 | |||
| f797ede15f | |||
| 9b3c8e185d | |||
| 9fa5278204 | |||
| fd4c2686a4 | |||
| d4d9b015b8 | |||
| 0b5be68586 | |||
| 80bf0c9bfa | |||
| f89cc5863f | |||
| 6552c90e4d | |||
| 0e8a6038dc | |||
| 797b5fc478 | |||
| 4c90d431b6 | |||
| 5e87b3ff48 | |||
| 2370cb0b0a | |||
| 20b4f46699 | |||
| 74355e5220 | |||
| 3b46ccb5b1 | |||
| 85249ae71b | |||
| 0bdcaecf82 | |||
| b4ef1b484a | |||
| 9f51e256ce | |||
| 1e1b7871cb | |||
| 1553af0f41 | |||
| 0c8799f4dd | |||
| 52b0ae179e | |||
| 690980c064 | |||
| 977d272c56 | |||
| b5540dd395 | |||
| af1659dafd | |||
| a69113222f | |||
| 05ffc9da10 | |||
| bfdd6a56f6 | |||
| 94af42031e | |||
| 0cfdfbdfa4 | |||
| 999a9c3acf | |||
| 082a20f776 | |||
| 69240ef492 | |||
| 656dea0929 | |||
| e46b4ede6d | |||
| 9823ffc12d | |||
| e5da8c01a9 | |||
| a138bef551 | |||
| e27f07ac36 | |||
| f11473c736 | |||
| 35e3ca1f1f | |||
| 6d1da85991 | |||
| 507e6fa9ac | |||
| e9372a4d34 | |||
| 49ac3487c2 | |||
| 1ec08336e6 | |||
| 90f4a2a062 | |||
| 1985525cc0 | |||
| 9174ad651f | |||
| ddf9244514 | |||
| 5e72a8b3c0 | |||
| 66265d170a | |||
| 2e60ca13b7 | |||
| 9744e0d1b0 | |||
| 7001f0d827 | |||
| a6afbeebe0 | |||
| 699efd2f4f | |||
| 5d60a6a427 | |||
| 672bc73756 | |||
| 0e3543c4aa | |||
| 43d9fe09cf | |||
| 9cc3c96f6a | |||
| b3b852a9e1 | |||
| 71ddbb88fc | |||
| 5df6f9adbf | |||
| 799fff10ff | |||
| bf03d8dc82 | |||
| 65760bb678 | |||
| 9980414160 | |||
| 5f7a5b18bf | |||
| 53760ac576 | |||
| 1fa2baacb7 | |||
| b1ba1720b9 | |||
| b21d8b75e0 | |||
| df6818a3cc | |||
| 98add92a20 | |||
| 85b19acf5f | |||
| e5f588d2b7 | |||
| c8ed877fda | |||
| b665365178 | |||
| 48921c4ef0 | |||
| df2c6a4e18 | |||
| 92ac49b561 | |||
| 2514507b87 | |||
| 7419dbcf71 | |||
| 659f87877d | |||
| 586261ddca | |||
| fc0cc41b90 | |||
| b596de93a0 | |||
| ce5c1c925e | |||
| 72c030995f | |||
| 4677f2c806 | |||
| 401ac50730 | |||
| 249ed5d9be | |||
| c29c9d5c47 | |||
| 62e081cd72 | |||
| 1cf2a5339a | |||
| 5ab02c31ee | |||
| 21f4d2e5c2 | |||
| fae266bf61 | |||
| 84881cc6be | |||
| 24e419568a | |||
| e375c956ed | |||
| f6e9691b7f | |||
| 5fb04126e6 | |||
| 02bd26e7d2 | |||
| 3a9b75839b | |||
| 29915acaeb | |||
| ef68259745 | |||
| e25b3acd98 | |||
| 1e463367fe | |||
| 7d83a920a2 | |||
| 6402861f4c | |||
| 0205f70d5a | |||
| 58608016c4 | |||
| 7d7baf0f77 | |||
| 9123d2f2e0 | |||
| 9cecaab055 | |||
| 9136341bda | |||
| d2011261ab | |||
| 060b81e205 | |||
| 1f97a5e67d | |||
| 13a6493100 | |||
| 28c929aec6 | |||
| b4b011663e | |||
| defd41488e | |||
| 95952b5231 | |||
| 857854a6e9 | |||
| e5b1b5d3a0 | |||
| c26936a2d7 | |||
| 80ea0b3e91 | |||
| 1bfad11ee5 | |||
| 7b4063a42f | |||
| 2bc347fc2a | |||
| f458c15677 | |||
| 02ec40092e | |||
| cea87d012c | |||
| c73352a293 | |||
| f06d9a81e7 | |||
| 0d4da78f05 | |||
| 44a30686cb | |||
| 596dca5d48 | |||
| 75a0f44a36 | |||
| bde03f4595 | |||
| f62c0db678 | |||
| 132824ede5 | |||
| a595abe9e6 | |||
| 11d63a4b5c | |||
| 67bacc9934 | |||
| 3a3f3a961d | |||
| 5fda02b9e0 | |||
| 825cacde0e | |||
| e87d6652ca | |||
| 76d4556501 | |||
| 543a42edd6 | |||
| 82fe75e457 | |||
| 9b59c2fadb | |||
| 52497d7d95 | |||
| 2fcfbe9774 | |||
| 564e136dc5 | |||
| b9f4051396 | |||
| e901559644 | |||
| e536789c9d | |||
| 7493cc5d48 | |||
| 0fadb00acf | |||
| b89ae4d74a | |||
| 79d5a637a7 | |||
| 67aaee3b4e | |||
| e3d70f351d | |||
| 2f33aa5d83 | |||
| d4fbd021ad | |||
| 24f0ff5221 | |||
| fb8675ddc5 | |||
| cdfb76de57 | |||
| 32bc5afe03 | |||
| e2bb72cc14 | |||
| 0cae0fe06e | |||
| cd2509c485 | |||
| 8e0bc43008 | |||
| ddd97388a6 | |||
| 2c9b526de4 | |||
| 5d6a935bec | |||
| 23cb1fa8ab | |||
| 5f90aa4f69 | |||
| 64895c9f95 | |||
| 8bdabdc962 | |||
| 3fa6b47995 | |||
| f1f433041c | |||
| ebecc9c844 | |||
| ff523a0d5c | |||
| efda4b4ef7 | |||
| 8e89c8f622 | |||
| a0ffc11d6f | |||
| 9c589e8352 | |||
| f88e9ecebf | |||
| 2f3a8619e8 | |||
| 5df30881f8 | |||
| b1f8cf8f12 | |||
| d8c633a7d5 | |||
| 523d5920bc | |||
| 9b6204db4f | |||
| a298ef8d74 | |||
| 008c1308b4 | |||
| b46a1e14a3 | |||
| a46bcfa2b5 | |||
| 773cab8189 | |||
| ab0f48f351 | |||
| b99e4c94a0 | |||
| 3560415668 | |||
| 81b57d5db6 | |||
| b05b36484b | |||
| 3a0218c421 | |||
| 84c119ce3d | |||
| 910af18a00 | |||
| 3ad53a3aac | |||
| 2fa56f4a38 | |||
| 7793de39b4 | |||
| a3212d7603 | |||
| ed2a8b6f9d | |||
| 71a83ac39c | |||
| a8df3692b6 | |||
| 65ae52782e | |||
| 936153490a | |||
| f19234419d | |||
| 787e8b95c0 | |||
| 9bce0de93d | |||
| dbfb800c1b | |||
| 942bbd1c69 | |||
| bd37b1746d | |||
| 5609d4fe4b | |||
| c2abe7c4cd | |||
| 78dc6e31d7 | |||
| bbc032056e | |||
| 304d0b5dce | |||
| d553ab864b | |||
| db381d377b | |||
| 7da3944b2b | |||
| 8704afcee5 | |||
| 0fb19ce263 | |||
| c048439849 | |||
| f8715f4cb1 | |||
| d17d5341f1 | |||
| fa940579f1 | |||
| c678510b02 | |||
| 0016d940e3 | |||
| b3f32eb805 | |||
| 901f633848 | |||
| 820d255a1a |
@@ -14,11 +14,16 @@ import shutil
|
||||
|
||||
shutil.copyfile('doc/man/nodeattrib.ronn.tmpl', 'doc/man/nodeattrib.ronn')
|
||||
shutil.copyfile('doc/man/nodegroupattrib.ronn.tmpl', 'doc/man/nodegroupattrib.ronn')
|
||||
with open('doc/man/nodeattrib.ronn', 'a') as outf:
|
||||
for field in sorted(attr.node):
|
||||
outf.write('\n* `{0}`:\n {1}\n'.format(field, attr.node[field]['description']))
|
||||
with open('doc/man/nodegroupattrib.ronn', 'a') as outf:
|
||||
for field in sorted(attr.node):
|
||||
outf.write('\n* `{0}`:\n {1}\n'.format(field, attr.node[field]['description']))
|
||||
|
||||
def append_attributes(filename):
|
||||
with open(filename, 'a') as outf:
|
||||
for field in sorted(attr.node):
|
||||
outf.write('\n* `{0}`:\n {1}\n'.format(field, attr.node[field]['description']))
|
||||
# Optionally write valid values if they exist
|
||||
for key, values in attr.node[field].items():
|
||||
if key.startswith('valid'):
|
||||
values_formatted = ', '.join("'{0}'".format(v) for v in values)
|
||||
outf.write(f'\n Valid values: {values_formatted}\n')
|
||||
|
||||
append_attributes('doc/man/nodeattrib.ronn')
|
||||
append_attributes('doc/man/nodegroupattrib.ronn')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python2
|
||||
#!/usr/bin/python3
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2014 IBM Corporation
|
||||
@@ -654,13 +654,17 @@ def quitconfetty(code=0, fullexit=False, fixterm=True):
|
||||
def get_session_node(shellargs):
|
||||
# straight to node console
|
||||
if len(shellargs) == 1 and ' ' not in shellargs[0]:
|
||||
return shellargs[0]
|
||||
targ = "/nodes/%s/console/session" % shellargs[0]
|
||||
return targ, shellargs[0]
|
||||
if len(shellargs) == 2 and shellargs[0] == 'start':
|
||||
args = [s for s in shellargs[1].split('/') if s]
|
||||
if len(args) == 4 and args[0] == 'nodes' and args[2] == 'console' and \
|
||||
args[3] == 'session':
|
||||
return args[1]
|
||||
return None
|
||||
return shellargs[1], args[1]
|
||||
if len(args) == 5 and args[0] == 'nodes' and args[2] == 'shell' and \
|
||||
args[3] == 'sessions':
|
||||
return shellargs[1], args[1]
|
||||
return None, None
|
||||
|
||||
|
||||
def run_inline_command(path, arg, completion, **kwargs):
|
||||
@@ -917,10 +921,10 @@ def main():
|
||||
doexit = False
|
||||
inconsole = False
|
||||
pendingcommand = ""
|
||||
session_node = get_session_node(shellargs)
|
||||
targ, session_node = get_session_node(shellargs)
|
||||
if session_node is not None:
|
||||
consoleonly = True
|
||||
do_command("start /nodes/%s/console/session" % session_node, netserver)
|
||||
do_command("start %s" % targ, netserver)
|
||||
doexit = True
|
||||
elif shellargs:
|
||||
do_command(shellargs, netserver)
|
||||
@@ -948,8 +952,9 @@ def main():
|
||||
except IOError:
|
||||
pass
|
||||
if powerstate is None or powertime < time.time() - 10: # Check powerstate every 10 seconds
|
||||
if powerstate == None:
|
||||
powerstate = True
|
||||
powertime = time.time()
|
||||
powerstate = True
|
||||
check_power_state()
|
||||
else:
|
||||
currcommand = prompt()
|
||||
|
||||
@@ -118,6 +118,7 @@ def main():
|
||||
ap.add_argument('-a', '--attrib', help='Pull ip addresses and hostnames from attribute database', action='store_true')
|
||||
ap.add_argument('-i', '--ip', help='Expression to generate addresses (e.g. 172.16.1.{n1} or fd2b:246f:8a50::{n1:x})')
|
||||
ap.add_argument('-n', '--name', help='Expression for name to add ({node}-compute, etc). If unspecified, "{node} {node}.{dns.domain}" will be used', action='append')
|
||||
ap.add_argument('-f', '--fqdn-first', help='Put the FQDN first in the hosts entries', action='store_true')
|
||||
args = ap.parse_args()
|
||||
c = client.Command()
|
||||
if args.name:
|
||||
@@ -173,7 +174,13 @@ def main():
|
||||
break
|
||||
else:
|
||||
for name in list(names):
|
||||
names.append('{0}.{1}'.format(name, mydomain))
|
||||
fqdn = '{0}.{1}'.format(name, mydomain)
|
||||
if args.fqdn_first:
|
||||
# Insert FQDN at the beginning if --fqdn-first flag is set
|
||||
names.insert(0, fqdn)
|
||||
else:
|
||||
# Otherwise, append FQDN at the end (original behavior)
|
||||
names.append(fqdn)
|
||||
names = ' '.join(names)
|
||||
merger.add_entry(ipdb[node][currnet], names)
|
||||
merger.write_out('/etc/whatnowhosts')
|
||||
|
||||
@@ -8,30 +8,35 @@ import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
def create_image(directory, image, label=None):
|
||||
ents = 0
|
||||
datasz = 512
|
||||
for dir in os.walk(sys.argv[1]):
|
||||
ents += 1
|
||||
for filen in dir[2]:
|
||||
def create_image(directory, image, label=None, esize=0, totalsize=None):
|
||||
|
||||
if totalsize:
|
||||
datasz = totalsize * 1048576
|
||||
else:
|
||||
ents = 0
|
||||
datasz = 512 + (esize * 1048576)
|
||||
for dir in os.walk(sys.argv[1]):
|
||||
ents += 1
|
||||
filename = os.path.join(dir[0], filen)
|
||||
currsz = os.path.getsize(filename)
|
||||
# assuming up to 65k cluster
|
||||
currsz = (currsz // 512 +1) * 512
|
||||
datasz += currsz
|
||||
datasz += ents * 32768
|
||||
datasz = datasz // 16384 + 1
|
||||
for filen in dir[2]:
|
||||
ents += 1
|
||||
filename = os.path.join(dir[0], filen)
|
||||
currsz = os.path.getsize(filename)
|
||||
# assuming up to 65k cluster
|
||||
currsz = (currsz // 512 + 1) * 512
|
||||
datasz += currsz
|
||||
datasz += ents * 32768
|
||||
datasz = datasz // 65536 + 1
|
||||
with open(image, 'wb') as imgfile:
|
||||
imgfile.seek(datasz * 16384 - 1)
|
||||
imgfile.seek(datasz * 65536 - 1)
|
||||
imgfile.write(b'\x00')
|
||||
if label:
|
||||
# 4 heads, 32 sectors, means 65k per track
|
||||
subprocess.check_call(['mformat', '-i', image, '-v', label,
|
||||
'-r', '16', '-d', '1', '-t', str(datasz),
|
||||
'-s', '16','-h', '2', '::'])
|
||||
'-s', '32','-h', '4', '::'])
|
||||
else:
|
||||
subprocess.check_call(['mformat', '-i', image, '-r', '16', '-d', '1', '-t',
|
||||
str(datasz), '-s', '16','-h', '2', '::'])
|
||||
str(datasz), '-s', '32','-h', '4', '::'])
|
||||
# Some clustered filesystems will have the lock from mformat
|
||||
# linger after close (mformat doesn't unlock)
|
||||
# do a blocking wait for shared lock and then explicitly
|
||||
@@ -56,6 +61,21 @@ if __name__ == '__main__':
|
||||
sys.argv[0]))
|
||||
sys.exit(1)
|
||||
label = None
|
||||
if len(sys.argv) > 3:
|
||||
label = sys.argv[3]
|
||||
create_image(sys.argv[1], sys.argv[2], label)
|
||||
args = sys.argv
|
||||
esize = 0
|
||||
try:
|
||||
earg = args.index('-e')
|
||||
esize = int(args[earg + 1])
|
||||
args = args[:earg] + args[earg +2:]
|
||||
except ValueError:
|
||||
pass
|
||||
totsize = None
|
||||
try:
|
||||
earg = args.index('-s')
|
||||
totsize = int(args[earg + 1])
|
||||
args = args[:earg] + args[earg +2:]
|
||||
except ValueError:
|
||||
pass
|
||||
if len(args) > 3:
|
||||
label = args[3]
|
||||
create_image(args[1], args[2], label, esize, totsize)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import base64
|
||||
import optparse
|
||||
import os
|
||||
import subprocess
|
||||
@@ -28,8 +29,31 @@ import confluent.client as client
|
||||
import confluent.sortutil as sortutil
|
||||
import confluent.logreader as logreader
|
||||
import time
|
||||
import select
|
||||
import signal
|
||||
import socket
|
||||
import re
|
||||
import tty
|
||||
import termios
|
||||
import fcntl
|
||||
import confluent.screensqueeze as sq
|
||||
try:
|
||||
from PIL import Image, ImageDraw
|
||||
except ImportError:
|
||||
Image = None
|
||||
|
||||
try:
|
||||
# sixel is optional, attempt to import but stub out if unavailable
|
||||
import io
|
||||
import sixel
|
||||
|
||||
class DumbWriter(sixel.SixelWriter):
|
||||
def restore_position(self, output):
|
||||
return
|
||||
except ImportError:
|
||||
class DumbWriter():
|
||||
def draw(self, imgfile):
|
||||
sys.stderr.write("PySixel not detected, Sixel format display not supported\n")
|
||||
|
||||
confettypath = os.path.join(os.path.dirname(sys.argv[0]), 'confetty')
|
||||
argparser = optparse.OptionParser(
|
||||
@@ -46,6 +70,11 @@ argparser.add_option('-l', '--log', action='store_true', default=False,
|
||||
argparser.add_option('-T', '--Timestamp', action='store_true', default=False,
|
||||
help= 'Dump log in stdout with timestamps')
|
||||
|
||||
argparser.add_option('-s', '--screenshot', action='store_true', default=False,
|
||||
help='Attempt to grab screenshot and render using kitty image protocol')
|
||||
argparser.add_option('-i', '--interval', type='float',
|
||||
help='Interval in seconds to redraw the screenshot. Currently only '
|
||||
'works for one node')
|
||||
argparser.add_option('-w','--windowed', action='store_true', default=False,
|
||||
help='Open terminal windows for each node. The '
|
||||
'environment variable NODECONSOLE_WINDOWED_COMMAND '
|
||||
@@ -69,6 +98,209 @@ argparser.add_option('-w','--windowed', action='store_true', default=False,
|
||||
|
||||
(options, args) = argparser.parse_args()
|
||||
|
||||
oldtcattr = None
|
||||
oldfl = None
|
||||
|
||||
def get_coords():
|
||||
sys.stdout.write('\x1b[6n') #
|
||||
sys.stdout.flush()
|
||||
gotreply = select.select([sys.stdin,], [], [], 0.250)[0]
|
||||
if gotreply:
|
||||
response = ''
|
||||
while select.select([sys.stdin,], [], [], 0.1)[0] and 'R' not in response:
|
||||
response += sys.stdin.read()
|
||||
coords = response.replace('R', '').split('[')[1].split(';')
|
||||
#sys.stdout.write('\x1b[{}:{}H'.format(*coords))
|
||||
|
||||
def direct_console():
|
||||
global oldtcattr
|
||||
global oldfl
|
||||
oldtcattr = termios.tcgetattr(sys.stdin.fileno())
|
||||
oldfl = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL)
|
||||
tty.setraw(sys.stdin.fileno())
|
||||
fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, oldfl | os.O_NONBLOCK)
|
||||
|
||||
def indirect_console():
|
||||
fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, oldfl & ~os.O_NONBLOCK)
|
||||
termios.tcsetattr(sys.stdin.fileno(), termios.TCSANOW, oldtcattr)
|
||||
|
||||
def determine_tile_size(numnodes):
|
||||
# for now, smash everything to a common aspect ratio. 16:11
|
||||
# is pretty much wrong for everything, making 4:3 a bit too wide
|
||||
# and 16:9 significantly too narrow, but it is serviceable
|
||||
# An improvement could come with us owning the scaling
|
||||
# instead of delegating to Kitty, which says if we specify both,
|
||||
# we get stretching. In theory we should be able to get aspect correct
|
||||
# from kitty by omitting, but:
|
||||
# then we don't know how much to move the cursor left after draw_image
|
||||
# Konsole won't scale at all with only partial scaling specified
|
||||
cheight, cwidth, pixwidth, pixheight = sq.get_screengeom()
|
||||
# 16:12 is to roughly account for the 'titles' of the tiles
|
||||
ratio = (pixwidth / 16) / (pixheight / 12)
|
||||
bestdeviation = None
|
||||
bestdims = []
|
||||
for i in range(1, numnodes + 1):
|
||||
number = numnodes
|
||||
while number % i != 0:
|
||||
number += 1
|
||||
columns = i
|
||||
rows = number // i
|
||||
deviation = abs(ratio - (columns / rows))
|
||||
if bestdeviation is None:
|
||||
bestdeviation = deviation
|
||||
bestdims = [columns, rows]
|
||||
elif deviation < bestdeviation:
|
||||
bestdeviation = deviation
|
||||
bestdims = [columns, rows]
|
||||
# ok, the above algorithm can still pick things like
|
||||
# 1 2 3
|
||||
# 4
|
||||
# So we will let it pick the number of rows, and
|
||||
# then see if we can chop columns and still fit
|
||||
while (bestdims[0] - 1) * bestdims[1] >= numnodes:
|
||||
bestdims[0] = bestdims[0] - 1
|
||||
cellswide = cwidth // bestdims[0]
|
||||
cellshigh = cheight // bestdims[1]
|
||||
tilewidth = cellswide * pixwidth / cwidth
|
||||
tileheight = cellshigh * pixheight / cheight
|
||||
if tilewidth > (tileheight * 16 / 11):
|
||||
tilewidth = tileheight * 16 / 11
|
||||
cellswide = int(tilewidth // (pixwidth / cwidth))
|
||||
if tileheight > (tilewidth * 11 /16):
|
||||
tileheight = tilewidth * 11 / 16
|
||||
cellshigh = int(tileheight // (pixheight / cheight))
|
||||
bestdims = bestdims + [cellswide, cellshigh, cellshigh * bestdims[1]]
|
||||
# incur any scrolling we might get. This allows us to accurately
|
||||
# save/restore cursor or even get coordinates without scrolling fouling
|
||||
# the desired target
|
||||
sys.stdout.write('\n' * bestdims[4])
|
||||
sys.stdout.flush()
|
||||
cursor_up(bestdims[4])
|
||||
return bestdims
|
||||
|
||||
cursor_saved = False
|
||||
def sticky_cursor():
|
||||
global cursor_saved
|
||||
# get cursor restore_position
|
||||
if sys.stdin.isatty() and not cursor_saved:
|
||||
try:
|
||||
direct_console()
|
||||
sys.stdout.write('\x1b7')
|
||||
cursor_saved = True
|
||||
finally:
|
||||
indirect_console()
|
||||
elif cursor_saved:
|
||||
try:
|
||||
direct_console()
|
||||
sys.stdout.write('\x1b8')
|
||||
finally:
|
||||
indirect_console()
|
||||
|
||||
def cursor_up(count=1):
|
||||
sys.stdout.write(f'\x1b[{count}A')
|
||||
def cursor_down(count=1):
|
||||
sys.stdout.write(f'\x1b[{count}B')
|
||||
def cursor_right(count=1):
|
||||
sys.stdout.write(f'\x1b[{count}C')
|
||||
def cursor_left(count=1):
|
||||
sys.stdout.write(f'\x1b[{count}D')
|
||||
def cursor_save():
|
||||
sys.stdout.write('\x1b7')
|
||||
def cursor_restore():
|
||||
sys.stdout.write('\x1b8')
|
||||
def cursor_hide():
|
||||
sys.stdout.write('\x1b[?25l')
|
||||
def cursor_show():
|
||||
sys.stdout.write('\x1b[?25h')
|
||||
|
||||
def draw_text(text, width, height):
|
||||
if Image:
|
||||
maxfntsize = 256
|
||||
nerr = Image.new(mode='RGB', size=(1024,768), color='green')
|
||||
nd = ImageDraw.Draw(nerr)
|
||||
for txtpiece in text.split('\n'):
|
||||
fntsize = 8
|
||||
while nd.textlength(txtpiece, font_size=fntsize) < 896:
|
||||
fntsize += 1
|
||||
fntsize -= 1
|
||||
if fntsize < maxfntsize:
|
||||
maxfntsize = fntsize
|
||||
nd.text((64, 64), text, font_size=maxfntsize)
|
||||
outfile = io.BytesIO()
|
||||
nerr.save(outfile, format='PNG')
|
||||
data = base64.b64encode(outfile.getbuffer())
|
||||
draw_image(data, width, height)
|
||||
else:
|
||||
sys.stdout.write(text)
|
||||
cursor_left(len(txt))
|
||||
|
||||
def draw_image(data, width, height):
|
||||
imageformat = os.environ.get('CONFLUENT_IMAGE_PROTOCOL', 'kitty')
|
||||
if imageformat == 'sixel':
|
||||
sixel_draw(data)
|
||||
elif imageformat == 'iterm':
|
||||
iterm_draw(data, width, height)
|
||||
else:
|
||||
kitty_draw(data, width, height)
|
||||
|
||||
|
||||
def sixel_draw(data):
|
||||
bindata = base64.b64decode(data)
|
||||
binfile = io.BytesIO()
|
||||
binfile.write(bindata)
|
||||
binfile.seek(0)
|
||||
DumbWriter().draw(binfile)
|
||||
|
||||
def iterm_draw(data, width, height):
|
||||
if not height:
|
||||
height = 'auto'
|
||||
if not width:
|
||||
width = 'auto'
|
||||
bindata = base64.b64decode(data)
|
||||
datalen = len(bindata)
|
||||
sys.stdout.write(
|
||||
'\x1b]1337;File=inline=1;width={};height={};size={}:'.format(width,height,datalen))
|
||||
sys.stdout.write(data.decode('utf8'))
|
||||
sys.stdout.write('\a')
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
def kitty_draw(data, width, height):
|
||||
if Image:
|
||||
bindata = base64.b64decode(data)
|
||||
binfile = io.BytesIO()
|
||||
binfile.write(bindata)
|
||||
binfile.seek(0)
|
||||
try:
|
||||
img = Image.open(binfile)
|
||||
except Exception as e:
|
||||
errstr = 'Error rendering image:\n' + str(e)
|
||||
return draw_text(errstr, width, height)
|
||||
nimg = Image.new(mode='RGB', size=(img.width + 4, img.height + 4), color='black')
|
||||
nd = ImageDraw.Draw(nimg)
|
||||
nd.rectangle((0, 0, nimg.width - 1, nimg.height -1), outline='white', width=1)
|
||||
nimg.paste(img, box=(2, 2))
|
||||
outfile = io.BytesIO()
|
||||
nimg.save(outfile, format='PNG')
|
||||
data = base64.b64encode(outfile.getbuffer())
|
||||
preamble = '\x1b_Ga=T,f=100'
|
||||
if height:
|
||||
preamble += f',r={height},c={width}'
|
||||
#sys.stdout.write(repr(preamble))
|
||||
#sys.stdout.write('\xb[{}D'.format(len(repr(preamble))))
|
||||
#return
|
||||
first = True
|
||||
while data:
|
||||
chunk, data = data[:4096], data[4096:]
|
||||
m = 1 if data else 0
|
||||
if first:
|
||||
sys.stdout.write('{},m={};'.format(preamble, m))
|
||||
else:
|
||||
sys.stdout.write('\x1b_Gm={};'.format(m))
|
||||
sys.stdout.write(chunk.decode('utf8'))
|
||||
sys.stdout.write('\x1b\\')
|
||||
sys.stdout.flush()
|
||||
|
||||
pass_through_args = []
|
||||
killcon = False
|
||||
try:
|
||||
@@ -106,6 +338,143 @@ if options.Timestamp:
|
||||
logreader.dump_to_console(logname)
|
||||
sys.exit(0)
|
||||
|
||||
def prep_node_tile(node):
|
||||
currcolcell, currrowcell = nodepositions[node]
|
||||
if currcolcell:
|
||||
cursor_right(currcolcell)
|
||||
if currrowcell:
|
||||
cursor_down(currrowcell)
|
||||
sys.stdout.write('▏' + node)
|
||||
cursor_left(len(node) + 1)
|
||||
cursor_down()
|
||||
|
||||
def reset_cursor(node):
|
||||
currcolcell, currrowcell = nodepositions[node]
|
||||
if currcolcell:
|
||||
cursor_left(currcolcell)
|
||||
cursor_up(currrowcell + 1)
|
||||
|
||||
nodepositions = {}
|
||||
numrows = 0
|
||||
cwidth = 0
|
||||
cheight = 0
|
||||
imagedatabynode = {}
|
||||
|
||||
def redraw():
|
||||
for node in imagedatabynode:
|
||||
imgdata = imagedatabynode[node]
|
||||
if node in nodepositions:
|
||||
prep_node_tile(node)
|
||||
cursor_save()
|
||||
else:
|
||||
if options.interval is not None:
|
||||
if node != firstnodename:
|
||||
sys.stderr.write('Multiple nodes not supported for interval')
|
||||
sys.exit(1)
|
||||
sticky_cursor()
|
||||
sys.stdout.write('{}: '.format(node))
|
||||
# one row is used by our own name, so cheight - 1 for that allowance
|
||||
draw_image(imgdata.encode(), cwidth, cheight - 1 if cheight else cheight)
|
||||
if node in nodepositions:
|
||||
cursor_restore()
|
||||
reset_cursor(node)
|
||||
else:
|
||||
sys.stdout.write('\n')
|
||||
sys.stdout.flush()
|
||||
|
||||
def do_screenshot():
|
||||
global numrows
|
||||
sess = client.Command()
|
||||
if options.tile:
|
||||
imageformat = os.environ.get('CONFLUENT_IMAGE_PROTOCOL', 'kitty')
|
||||
if imageformat not in ('kitty', 'iterm'):
|
||||
sys.stderr.write('Tiled screenshots only supported with kitty or iterm protocol')
|
||||
sys.exit(1)
|
||||
allnodes = []
|
||||
numnodes = 0
|
||||
for res in sess.read('/noderange/{}/nodes/'.format(args[0])):
|
||||
allnodes.append(res['item']['href'].replace('/', ''))
|
||||
numnodes += 1
|
||||
def do_resize(a=None, b=None):
|
||||
if a:
|
||||
# on a window resize, clear the old stuff
|
||||
# ideally we'd retain the images and redraw them
|
||||
sys.stdout.write('\x1bc')
|
||||
global numrows
|
||||
global cwidth
|
||||
global cheight
|
||||
cols, rows, cwidth, cheight, numrows = determine_tile_size(numnodes)
|
||||
currcol = 1
|
||||
currcolcell = 0
|
||||
currrowcell = 0
|
||||
for node in allnodes:
|
||||
nodepositions[node] = currcolcell, currrowcell
|
||||
if currcol < cols:
|
||||
currcol += 1
|
||||
currcolcell += cwidth
|
||||
else:
|
||||
currcol = 1
|
||||
currcolcell = 0
|
||||
currrowcell += cheight
|
||||
if a:
|
||||
redraw()
|
||||
do_resize()
|
||||
signal.signal(signal.SIGWINCH, do_resize)
|
||||
elif options.interval is not None:
|
||||
sys.stdout.write('\x1bc')
|
||||
firstnodename = None
|
||||
dorefresh = True
|
||||
while dorefresh:
|
||||
for res in sess.read('/noderange/{}/console/ikvm_screenshot'.format(args[0])):
|
||||
for node in res.get('databynode', {}):
|
||||
if not firstnodename:
|
||||
firstnodename = node
|
||||
imgdata = res['databynode'][node].get('image', {}).get('imgdata', None)
|
||||
if imgdata:
|
||||
errorstr = ''
|
||||
if len(imgdata) < 32: # We were subjected to error
|
||||
errorstr = f'Unable to get screenshot'
|
||||
imagedatabynode[node] = imgdata
|
||||
if node in nodepositions:
|
||||
prep_node_tile(node)
|
||||
cursor_save()
|
||||
else:
|
||||
if options.interval is not None:
|
||||
if node != firstnodename:
|
||||
sys.stderr.write('Multiple nodes not supported for interval')
|
||||
sys.exit(1)
|
||||
sticky_cursor()
|
||||
sys.stdout.write('{}: '.format(node))
|
||||
# one row is used by our own name, so cheight - 1 for that allowance
|
||||
if errorstr:
|
||||
draw_text(errorstr, cwidth, cheight -1 if cheight else cheight)
|
||||
else:
|
||||
draw_image(imgdata.encode(), cwidth, cheight - 1 if cheight else cheight)
|
||||
if node in nodepositions:
|
||||
cursor_restore()
|
||||
reset_cursor(node)
|
||||
else:
|
||||
sys.stdout.write('\n')
|
||||
sys.stdout.flush()
|
||||
if options.interval is None:
|
||||
dorefresh = False
|
||||
else:
|
||||
dorefresh = True
|
||||
time.sleep(options.interval)
|
||||
sys.exit(0)
|
||||
|
||||
if options.screenshot:
|
||||
try:
|
||||
cursor_hide()
|
||||
do_screenshot()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
cursor_show()
|
||||
cursor_down(numrows)
|
||||
sys.stdout.write('\n')
|
||||
sys.exit(0)
|
||||
|
||||
def kill(noderange):
|
||||
sess = client.Command()
|
||||
envstring=os.environ.get('NODECONSOLE_WINDOWED_COMMAND')
|
||||
@@ -113,29 +482,23 @@ def kill(noderange):
|
||||
envstring = 'xterm'
|
||||
|
||||
nodes = []
|
||||
for res in sess.read('/noderange/{0}/nodes/'.format(args[0])):
|
||||
for res in sess.read('/noderange/{0}/nodes/'.format(noderange)):
|
||||
node = res.get('item', {}).get('href', '/').replace('/', '')
|
||||
if not node:
|
||||
sys.stderr.write(res.get('error', repr(res)) + '\n')
|
||||
sys.exit(1)
|
||||
nodes.append(node)
|
||||
|
||||
for node in nodes:
|
||||
s=socket.socket(socket.AF_UNIX)
|
||||
winid=None
|
||||
for node in nodes:
|
||||
command = "ps auxww | grep {0} | grep console | egrep '\\b{1}\\b' | grep -v grep | awk '{{print $2}}'".format(envstring, node)
|
||||
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
try:
|
||||
win=subprocess.Popen(['xwininfo', '-tree', '-root'], stdout=subprocess.PIPE)
|
||||
wintr=win.communicate()[0]
|
||||
for line in wintr.decode('utf-8').split('\n'):
|
||||
if 'console: {0}'.format(node) in line or 'confetty' in line:
|
||||
win_obj = [ele for ele in line.split(' ') if ele.strip()]
|
||||
winid = win_obj[0]
|
||||
except:
|
||||
print("Error: cannot retrieve window id of node {}".format(node))
|
||||
|
||||
if winid:
|
||||
ps_data=subprocess.Popen(['xkill', '-id', winid ], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
process_id = stdout.decode('utf-8').split()[0]
|
||||
except IndexError:
|
||||
sys.stderr.write(node + ": console window not found \n")
|
||||
continue
|
||||
subprocess.Popen(["kill", process_id], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
sys.exit(0)
|
||||
|
||||
def handle_geometry(envlist, sizegeometry, side_pad=0, top_pad=0, first=False):
|
||||
|
||||
@@ -117,6 +117,16 @@ def main(args):
|
||||
else:
|
||||
sys.stderr.write('No deployment profiles available, try osdeploy import or imgutil capture\n')
|
||||
sys.exit(1)
|
||||
lockednodes = []
|
||||
for lockinfo in c.read('/noderange/{0}/deployment/lock'.format(args.noderange)):
|
||||
for node in lockinfo.get('databynode', {}):
|
||||
lockstate = lockinfo['databynode'][node]['lock']['value']
|
||||
if lockstate == 'locked':
|
||||
lockednodes.append(node)
|
||||
if lockednodes:
|
||||
sys.stderr.write('Requested noderange has nodes with locked deployment: ' + ','.join(lockednodes))
|
||||
sys.stderr.write('\n')
|
||||
sys.exit(1)
|
||||
armonce(args.noderange, c)
|
||||
setpending(args.noderange, args.profile, c)
|
||||
else:
|
||||
|
||||
@@ -78,8 +78,11 @@ exitcode = 0
|
||||
def format_event(evt):
|
||||
retparts = []
|
||||
if 'timestamp' in evt and evt['timestamp'] is not None:
|
||||
display = dt.strptime(evt['timestamp'], '%Y-%m-%dT%H:%M:%S')
|
||||
retparts.append(display.strftime('%m/%d/%Y %H:%M:%S'))
|
||||
try:
|
||||
display = dt.strptime(evt['timestamp'], '%Y-%m-%dT%H:%M:%S')
|
||||
retparts.append(display.strftime('%m/%d/%Y %H:%M:%S'))
|
||||
except ValueError:
|
||||
display = ''
|
||||
dscparts = []
|
||||
if evt.get('log_id', None):
|
||||
retparts.append(evt['log_id'] + ':')
|
||||
|
||||
@@ -56,7 +56,7 @@ components = ['all']
|
||||
|
||||
argparser = optparse.OptionParser(
|
||||
usage="Usage: "
|
||||
"%prog <noderange> [list][update [--backup <file>]]|[<components>]")
|
||||
"%prog <noderange> [list][updatestatus][update [--backup <file>]]|[<components>]")
|
||||
argparser.add_option('-b', '--backup', action='store_true',
|
||||
help='Target a backup bank rather than primary')
|
||||
argparser.add_option('-m', '--maxnodes', type='int',
|
||||
@@ -65,14 +65,18 @@ argparser.add_option('-m', '--maxnodes', type='int',
|
||||
|
||||
(options, args) = argparser.parse_args()
|
||||
upfile = None
|
||||
querystatus = False
|
||||
try:
|
||||
noderange = args[0]
|
||||
if len(args) > 1:
|
||||
if args[1] == 'update':
|
||||
upfile = args[2]
|
||||
else:
|
||||
comps = []
|
||||
if args[1] == 'list':
|
||||
comps = args[2:]
|
||||
elif args[1] == 'updatestatus':
|
||||
querystatus = True
|
||||
else:
|
||||
comps = args[1:]
|
||||
components = []
|
||||
@@ -171,7 +175,16 @@ def show_firmware(session):
|
||||
|
||||
try:
|
||||
session = client.Command()
|
||||
if upfile is None:
|
||||
if querystatus:
|
||||
for res in session.read(
|
||||
'/noderange/{0}/inventory/firmware/updatestatus'.format(noderange)):
|
||||
for node in res.get('databynode', {}):
|
||||
currstat = res['databynode'][node].get('status', None)
|
||||
if currstat:
|
||||
print('{}: {}'.format(node, currstat))
|
||||
else:
|
||||
print(repr(res))
|
||||
elif upfile is None:
|
||||
show_firmware(session)
|
||||
else:
|
||||
update_firmware(session, upfile)
|
||||
|
||||
@@ -61,7 +61,10 @@ def get_neighbors(switch):
|
||||
switch_neigbors = []
|
||||
url = '/networking/neighbors/by-switch/{0}/by-peername/'.format(switch)
|
||||
for neighbor in session.read(url):
|
||||
switch = neighbor['item']['href'].strip('/')
|
||||
try:
|
||||
switch = neighbor['item']['href'].strip('/')
|
||||
except:
|
||||
continue
|
||||
if switch in all_switches:
|
||||
switch_neigbors.append(switch)
|
||||
return switch_neigbors
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/python2
|
||||
#!/usr/bin/python3
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2016-2017 Lenovo
|
||||
@@ -42,6 +42,8 @@ def run():
|
||||
usage="Usage: %prog [options] noderange")
|
||||
argparser.add_option('-f', '-c', '--count', type='int', default=168,
|
||||
help='Number of commands to run at a time')
|
||||
argparser.add_option('-o', '--origname', action='store_true',
|
||||
help='Use original nodename in print out even if substituted')
|
||||
argparser.add_option('-s', '--substitutename',
|
||||
help='Use a different name other than the nodename for ping, with {}, it is the entire name evaluated as an expression, otherwise it is used as a suffix')
|
||||
# among other things, FD_SETSIZE limits. Besides, spawning too many
|
||||
@@ -83,7 +85,10 @@ def run():
|
||||
cmdv = ['ping', '-c', '1', '-W', '1', pingnode]
|
||||
if currprocs < concurrentprocs:
|
||||
currprocs += 1
|
||||
run_cmdv(pingnode, cmdv, all, pipedesc)
|
||||
if options.origname:
|
||||
run_cmdv(node, cmdv, all, pipedesc)
|
||||
else:
|
||||
run_cmdv(pingnode, cmdv, all, pipedesc)
|
||||
else:
|
||||
pendingexecs.append((pingnode, cmdv))
|
||||
if not all or exitcode:
|
||||
|
||||
@@ -67,7 +67,7 @@ argparser.add_option('-n', '--numreadings', type='int',
|
||||
argparser.add_option('-c', '--csv', action='store_true',
|
||||
help='Output in CSV format')
|
||||
argparser.add_option('-s', '--skipnumberless', action='store_true',
|
||||
help='Output in CSV format')
|
||||
help='Do not show non-numeric sensors')
|
||||
(options, args) = argparser.parse_args()
|
||||
repeatmode = False
|
||||
if options.interval:
|
||||
|
||||
@@ -72,6 +72,8 @@ def plot(gui, output, plotdata, bins, fmt):
|
||||
tdata = io.BytesIO()
|
||||
plt.savefig(tdata)
|
||||
if not gui and not output:
|
||||
if fmt == 'environment':
|
||||
fmt = os.environ.get('CONFLUENT_IMAGE_PROTOCOL', 'kitty')
|
||||
if fmt == 'sixel':
|
||||
writer = DumbWriter()
|
||||
writer.draw(tdata)
|
||||
@@ -108,7 +110,7 @@ aparser = argparse.ArgumentParser(description='Quick access to common statistics
|
||||
aparser.add_argument('-c', type=int, default=0, help='Column number to analyze (default is last column)')
|
||||
aparser.add_argument('-d', default=None, help='Value used to separate columns')
|
||||
aparser.add_argument('-x', default=False, action='store_true', help='Output histogram in graphical format')
|
||||
aparser.add_argument('-f', default='sixel', help='Format for histogram output (sixel/iterm/kitty)')
|
||||
aparser.add_argument('-f', default='environment', help='Format for histogram output (sixel/iterm/kitty)')
|
||||
aparser.add_argument('-s', default=0, help='Number of header lines to skip before processing')
|
||||
aparser.add_argument('-g', default=False, action='store_true', help='Open histogram in separate graphical window')
|
||||
aparser.add_argument('-o', default=None, help='Output histogram to the specified filename in PNG format')
|
||||
|
||||
@@ -18,8 +18,9 @@ import struct
|
||||
import termios
|
||||
|
||||
def get_screengeom():
|
||||
return struct.unpack('hh', fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ,
|
||||
b'....'))
|
||||
# returns height in cells, width in cells, width in pixels, height in pixels
|
||||
return struct.unpack('hhhh', fcntl.ioctl(sys.stdout, termios.TIOCGWINSZ,
|
||||
b'........'))
|
||||
class ScreenPrinter(object):
|
||||
|
||||
def __init__(self, noderange, client, textlen=4):
|
||||
@@ -58,7 +59,7 @@ class ScreenPrinter(object):
|
||||
|
||||
def drawscreen(self, node=None):
|
||||
if self.squeeze:
|
||||
currheight, currwidth = get_screengeom()
|
||||
currheight, currwidth, _, _ = get_screengeom()
|
||||
currheight -= 2
|
||||
if currheight < 1:
|
||||
currheight = 1
|
||||
@@ -120,6 +121,7 @@ if __name__ == '__main__':
|
||||
c = client.Command()
|
||||
p = ScreenPrinter('d1-d12', c)
|
||||
p.set_output('d3', 'Upload: 67%')
|
||||
p.set_output('d7', 'Upload: 67%')
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -171,7 +171,9 @@ class GroupedData(object):
|
||||
self.byoutput[outdata])))
|
||||
currout += '\n====================================\n'
|
||||
currout += outdata
|
||||
currout += '\n\n'
|
||||
if currout[-1] != '\n':
|
||||
currout += '\n'
|
||||
currout += '\n'
|
||||
output.write(currout)
|
||||
output.flush()
|
||||
|
||||
@@ -211,7 +213,9 @@ class GroupedData(object):
|
||||
else:
|
||||
currout += '\n'.join(colordiff(modaloutput.split('\n'),
|
||||
outdata.split('\n')))
|
||||
currout += '\n\n'
|
||||
if currout[-1] != '\n':
|
||||
currout += '\n'
|
||||
currout += '\n'
|
||||
if reverse:
|
||||
revoutput.append(currout)
|
||||
else:
|
||||
|
||||
@@ -13,7 +13,7 @@ noderange. There are two general approaches.
|
||||
|
||||
It can be used ad-hoc, using -i and -n to specify the address and name portions respectively. This accepts the standard confluent expression syntax, allowing for things like 172.30.1.{n1} or {node}.{dns.domain} or {bmc}.
|
||||
|
||||
It can also read from the confluent db, using `-a`. In this mode, each net.<value>.<attribute> group is pulled together into hosts lines. ipv4_address and ipv6_address fields are associated with the corresponding hostname attributes.
|
||||
It can also read from the confluent db, using `-a`. In this mode, each net.<value>.<attribute> group is pulled together into hosts lines. ipv4_address and ipv6_address fields are associated with the corresponding hostname attributes. You can use `-f` to put the FQDN first.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
|
||||
@@ -38,5 +38,8 @@ the json files (password protected, removed from the files, or unprotected).
|
||||
keys do not change and as such they do not require
|
||||
incremental backup.
|
||||
|
||||
* `-y`, `--yaml
|
||||
Use YAML instead of JSON as file format
|
||||
|
||||
* `-h`, `--help`:
|
||||
Show help message and exit
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
l2traceroute(8) -- returns the layer 2 route through an Ethernet network managed by confluent given 2 end points.
|
||||
==============================
|
||||
## SYNOPSIS
|
||||
`l2traceroute [options] <start_node> <end_noderange>`
|
||||
|
||||
## DESCRIPTION
|
||||
**l2traceroute** is a command that returns the layer 2 route for the configered interfaces in nodeattrib.
|
||||
It can also be used with the -i and -e options to check against specific interfaces on the endpoints.
|
||||
|
||||
|
||||
## PREREQUISITES
|
||||
**l2traceroute** the net.<interface>.switch attributes have to be set on the end points if endpoint is not a switch
|
||||
|
||||
|
||||
## OPTIONS
|
||||
* ` -e` EFACE, --eface=INTERFACE
|
||||
interface to check against for the second end point
|
||||
* ` -i` INTERFACE, --interface=INTERFACE
|
||||
interface to check against for the first end point
|
||||
* ` -c` CUMULUS, --cumulus=CUMULUS
|
||||
return layer 2 route through cumulus switches only
|
||||
* `-h`, `--help`:
|
||||
Show help message and exit
|
||||
|
||||
|
||||
## EXAMPLES
|
||||
* Checking route between two nodes:
|
||||
`# l2traceroute_client n244 n1851`
|
||||
`n244 to n1851: ['switch114']`
|
||||
|
||||
* Checking route from one node to multiple nodes:
|
||||
`# l2traceroute_client n244 n1833,n1851`
|
||||
`n244 to n1833: ['switch114', 'switch7', 'switch32', 'switch253', 'switch85', 'switch72', 'switch21', 'switch2', 'switch96', 'switch103', 'switch115']
|
||||
n244 to n1851: ['switch114']`
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,9 +21,15 @@ console process which will result in the console window closing.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
* `-i N`, `--interval`:
|
||||
For screenshot mode, fetch new screenshots and overwrite old screenshots every N seconds.
|
||||
For example, `nodeconsole r3u[21:24] -tsi 3` will tile screenshots of r3u21 through r3u24 and
|
||||
refresh them every 3 seconds.
|
||||
|
||||
* `-t`, `--tile`:
|
||||
Use tmux to arrange consoles of the given noderange into a tiled layout on
|
||||
the terminal screen
|
||||
For text consoles, use tmux to arrange consoles of the given noderange into a tiled layout on
|
||||
the terminal screen. If using 'screenshot' mode, divide the terminal and display the images
|
||||
in a grid.
|
||||
|
||||
* `-l`, `--log`:
|
||||
Perform a log reply on the current, local log in /var/log/confluent/consoles.
|
||||
@@ -34,6 +40,14 @@ console process which will result in the console window closing.
|
||||
Dump the log with Timpstamps on the current, local log in /var/log/confluent/consoles.
|
||||
If in collective mode, this only makes sense to use on the current collective
|
||||
manager at this time.
|
||||
|
||||
* `-s`, `--screenshot`:
|
||||
Attempt to grab screenshot(s) and render using a terminal
|
||||
image protocol. The image protocol defaults to kitty, and
|
||||
can be selected by CONFLUENT_IMAGE_PROTOCOL environment variable.
|
||||
Supported protocols are kitty, iterm, and, sixel (sixel only
|
||||
if PySixel is installed). This only presents screenshots, there
|
||||
is no input supported to graphical consoles from a terminal.
|
||||
|
||||
* `-w`, `--windowed`:
|
||||
Open terminal windows for each node. The
|
||||
|
||||
@@ -3,7 +3,7 @@ nodefirmware(8) -- Report firmware information on confluent nodes
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
`nodefirmware <noderange> [list][update [--backup <file>]]|[<components>]`
|
||||
`nodefirmware <noderange> [list][updatestatus][update [--backup <file>]]|[<components>]`
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
@@ -17,6 +17,9 @@ not be relevant to redfish. Additionally, the Lenovo XCC makes certain
|
||||
information available over IPMI that is not otherwise available (for example
|
||||
the FPGA version where applicable).
|
||||
|
||||
The updatestatus argument will describe the state of firmware updates on the
|
||||
nodes.
|
||||
|
||||
In the update form, it accepts a single file and attempts to update it using
|
||||
the out of band facilities. Firmware updates can end in one of three states:
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
nodel2traceroute(8) -- returns the layer 2 route through an Ethernet network managed by confluent given 2 end points.
|
||||
==============================
|
||||
## SYNOPSIS
|
||||
`nodel2traceroute [options] <start_node> <end_noderange>`
|
||||
|
||||
## DESCRIPTION
|
||||
**nodel2traceroute** is a command that returns the layer 2 route for the configered interfaces in nodeattrib.
|
||||
It can also be used with the -i and -e options to check against specific interfaces on the endpoints. If the
|
||||
--interface or --eface option are not used then the command will check for routes against all the defined
|
||||
interfaces in nodeattrib (net.*.switch) for the nodes.
|
||||
|
||||
|
||||
|
||||
## PREREQUISITES
|
||||
**nodel2traceroute** the net.<interface>.switch attributes have to be set on the end points if endpoint is not a switch
|
||||
|
||||
|
||||
## OPTIONS
|
||||
* ` -e` EFACE, --eface=INTERFACE
|
||||
interface to check against for the second end point or end points if using checking against multiple nodes
|
||||
* ` -i` INTERFACE, --interface=INTERFACE
|
||||
interface to check against for the first end point
|
||||
* ` -c` CUMULUS, --cumulus=CUMULUS
|
||||
return layer 2 route through cumulus switches only
|
||||
* `-h`, `--help`:
|
||||
Show help message and exit
|
||||
|
||||
|
||||
## EXAMPLES
|
||||
* Checking route between two nodes:
|
||||
`# nodel2traceroute n244 n1851`
|
||||
`n244 to n1851: ['switch114']`
|
||||
|
||||
* Checking route from one node to multiple nodes:
|
||||
`# nodel2traceroute n244 n1833,n1851`
|
||||
`n244 to n1833: ['switch114', 'switch7', 'switch32', 'switch253', 'switch85', 'switch72', 'switch21', 'switch2', 'switch96', 'switch103', 'switch115']
|
||||
n244 to n1851: ['switch114']`
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import ssl
|
||||
import sys
|
||||
import struct
|
||||
import time
|
||||
import re
|
||||
import json
|
||||
|
||||
class InvalidApiKey(Exception):
|
||||
pass
|
||||
@@ -89,8 +91,11 @@ def scan_confluents():
|
||||
confluentuuid = line.split(': ')[1]
|
||||
msg += '/confluentuuid=' + confluentuuid
|
||||
break
|
||||
with open('/sys/devices/virtual/dmi/id/product_uuid') as uuidin:
|
||||
msg += '/uuid=' + uuidin.read().strip()
|
||||
try:
|
||||
with open('/sys/devices/virtual/dmi/id/product_uuid') as uuidin:
|
||||
msg += '/uuid=' + uuidin.read().strip()
|
||||
except Exception:
|
||||
pass
|
||||
for addrf in glob.glob('/sys/class/net/*/address'):
|
||||
with open(addrf) as addrin:
|
||||
hwaddr = addrin.read().strip()
|
||||
@@ -228,6 +233,7 @@ def get_apikey(nodename, hosts, errout=None):
|
||||
|
||||
class HTTPSClient(client.HTTPConnection, object):
|
||||
def __init__(self, usejson=False, port=443, host=None, errout=None, phmac=None, checkonly=False):
|
||||
self.ignorehosts = set([])
|
||||
self.phmac = phmac
|
||||
self.errout = None
|
||||
if errout:
|
||||
@@ -315,6 +321,8 @@ class HTTPSClient(client.HTTPConnection, object):
|
||||
ctx.check_hostname = True
|
||||
for timeo in (0.1, 5):
|
||||
for host in hosts:
|
||||
if host in self.ignorehosts:
|
||||
continue
|
||||
try:
|
||||
addrinf = socket.getaddrinfo(host, self.port)[0]
|
||||
psock = socket.socket(addrinf[0])
|
||||
@@ -410,10 +418,100 @@ class HTTPSClient(client.HTTPConnection, object):
|
||||
akfile.write('')
|
||||
self.stdheaders['CONFLUENT_APIKEY'] = get_apikey(
|
||||
self.node, [self.host], errout=self.errout)
|
||||
if rsp.status == 503: # confluent is down, but the server running confluent is otherwise up
|
||||
authed = False
|
||||
self.ignorehosts.add(self.host)
|
||||
host = self.check_connections()
|
||||
client.HTTPConnection.__init__(self, host, self.port)
|
||||
|
||||
raise Exception(rsp.read())
|
||||
|
||||
def get_current_vmnic_vswitch():
|
||||
uplinkmatch = re.compile(r'^\s*Uplinks:\s*(.*)')
|
||||
switchmatch = re.compile(r'^\s*Name:\s*(.*)')
|
||||
|
||||
vswinfo = subprocess.check_output(['localcli', 'network', 'vswitch', 'standard', 'list']).decode()
|
||||
|
||||
vmnic = None
|
||||
vswitch_name = None
|
||||
|
||||
for info in vswinfo.split('\n'):
|
||||
name_match = switchmatch.match(info)
|
||||
if name_match:
|
||||
vswitch_name = name_match.group(1).strip()
|
||||
|
||||
upinfo = uplinkmatch.match(info)
|
||||
if upinfo:
|
||||
vmnic = upinfo.group(1).strip()
|
||||
if vmnic and 'vusb0' not in vmnic:
|
||||
return vswitch_name, vmnic
|
||||
|
||||
return vswitch_name, vmnic
|
||||
|
||||
def get_available_nics():
|
||||
nicinfo = subprocess.check_output(['localcli', 'network', 'nic', 'list']).decode('utf8').split('\n')
|
||||
available_nics = {}
|
||||
|
||||
# Skip headers and separators
|
||||
parsing_started = False
|
||||
for line in nicinfo:
|
||||
if re.match(r'^-+', line):
|
||||
parsing_started = True
|
||||
continue
|
||||
if not parsing_started or not line.strip():
|
||||
continue
|
||||
|
||||
parts = re.split(r'\s{2,}', line.strip())
|
||||
if len(parts) >= 5:
|
||||
nic_name = parts[0]
|
||||
nic_status = parts[4] # "Link Status" este al 5-lea câmp
|
||||
available_nics[nic_name] = nic_status
|
||||
|
||||
return available_nics
|
||||
|
||||
def is_esxi():
|
||||
return os.path.isdir("/etc/vmware")
|
||||
|
||||
def fix_vswitch():
|
||||
if is_esxi():
|
||||
start_time = time.time()
|
||||
while True:
|
||||
|
||||
current_vswitch, current_vmnic = get_current_vmnic_vswitch()
|
||||
if current_vswitch is None:
|
||||
raise RuntimeError("Panic: current vswitch is None")
|
||||
if current_vmnic is None:
|
||||
raise RuntimeError("Panic: current vmnic is None")
|
||||
|
||||
available_nics = get_available_nics()
|
||||
|
||||
if current_vmnic and available_nics.get(current_vmnic) == 'Up':
|
||||
break
|
||||
|
||||
new_vmnic = next((nic for nic, status in available_nics.items() if status == 'Up'), None)
|
||||
|
||||
if new_vmnic and new_vmnic != current_vmnic:
|
||||
subprocess.check_call(['localcli', 'network', 'vswitch', 'standard', 'uplink', 'remove',
|
||||
'--uplink-name', current_vmnic, '--vswitch-name', current_vswitch])
|
||||
subprocess.check_call(['localcli', 'network', 'vswitch', 'standard', 'uplink', 'add',
|
||||
'--uplink-name', new_vmnic, '--vswitch-name', current_vswitch])
|
||||
elif not new_vmnic:
|
||||
if time.time() - start_time > 300:
|
||||
break
|
||||
time.sleep(5)
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
if __name__ == '__main__':
|
||||
data = None
|
||||
|
||||
if '-f' in sys.argv:
|
||||
try:
|
||||
fix_vswitch()
|
||||
except Exception as e:
|
||||
print(f"fix_vswitch() error: {e}")
|
||||
sys.argv.remove('-f')
|
||||
sys.exit(0)
|
||||
usejson = False
|
||||
if '-j' in sys.argv:
|
||||
usejson = True
|
||||
@@ -468,13 +566,14 @@ if __name__ == '__main__':
|
||||
outf.write(chunk)
|
||||
chunk = reader.read(16384)
|
||||
sys.exit(0)
|
||||
client = HTTPSClient(usejson, errout=errout, phmac=phmac, checkonly=checkonly)
|
||||
|
||||
mclient = HTTPSClient(usejson, errout=errout, phmac=phmac, checkonly=checkonly)
|
||||
if waitfor:
|
||||
status = 201
|
||||
while status != waitfor:
|
||||
status, rsp = client.grab_url_with_status(sys.argv[1], data)
|
||||
status, rsp = mclient.grab_url_with_status(sys.argv[1], data)
|
||||
sys.stdout.write(rsp.decode())
|
||||
elif checkonly:
|
||||
sys.stdout.write(client.check_connections())
|
||||
sys.stdout.write(mclient.check_connections())
|
||||
else:
|
||||
sys.stdout.write(client.grab_url(sys.argv[1], data).decode())
|
||||
sys.stdout.write(mclient.grab_url(sys.argv[1], data).decode())
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# This script evaluates whether firmware redirection is likely. It uses three cues:
|
||||
# - Does the system offer up SPCR? This would indicate that the firmware is doing serial output.
|
||||
# Otherwise, there's no indication that the firmware cares about serial console.
|
||||
# - Is the system EFI? BIOS implementations may not intercept text draw calls after POST exit,
|
||||
# thus even when BIOS tells us serial port is in use, it may not be doing anything when
|
||||
# grub would be running
|
||||
# - Is the serial port connected? In the event that firmware indicates serial port, but
|
||||
# serial port is not reporting DCD, then it doesn't look like a comfortable enough scenario
|
||||
|
||||
import fcntl
|
||||
import os
|
||||
import os.path
|
||||
import struct
|
||||
import subprocess
|
||||
import termios
|
||||
|
||||
|
||||
addrtoname = {
|
||||
0x3f8: '/dev/ttyS0',
|
||||
0x2f8: '/dev/ttyS1',
|
||||
0x3e8: '/dev/ttyS2',
|
||||
0x2e8: '/dev/ttyS3',
|
||||
}
|
||||
speedmap = {
|
||||
0: None,
|
||||
3: 9600,
|
||||
4: 19200,
|
||||
6: 57600,
|
||||
7: 115200,
|
||||
}
|
||||
|
||||
termiobaud = {
|
||||
9600: termios.B9600,
|
||||
19200: termios.B19200,
|
||||
57600: termios.B57600,
|
||||
115200: termios.B115200,
|
||||
}
|
||||
|
||||
|
||||
def deserialize_grub_rh():
|
||||
if 'console=ttyS' in open('/proc/cmdline').read():
|
||||
return None # User manually indicated serial config
|
||||
# they own the grub behavior too for now
|
||||
grublines = []
|
||||
with open('/etc/default/grub') as grubin:
|
||||
grublines = grubin.read().split('\n')
|
||||
with open('/etc/default/grub', 'w') as grubout:
|
||||
for grubline in grublines:
|
||||
if grubline.startswith('GRUB_TERMINAL'):
|
||||
grubline = grubline.replace('serial ', '')
|
||||
grubout.write(grubline + '\n')
|
||||
subprocess.check_call(['grub2-mkconfig', '-o', '/boot/grub2/grub.cfg'])
|
||||
|
||||
def fixup_ubuntu_grub_serial():
|
||||
# Ubuntu aggressively tries to graphics up
|
||||
# grub. We will counter that for serial
|
||||
# They also aggressively hide UI and
|
||||
# block ability to interject. We will
|
||||
# compromise and lean on nodeboot <node> setup
|
||||
# as a means to give someone reasonable shot at
|
||||
# the short timeout
|
||||
with open('/etc/default/grub') as grubin:
|
||||
grublines = grubin.read().split('\n')
|
||||
with open('/etc/default/grub', 'w') as grubout:
|
||||
for grubline in grublines:
|
||||
if grubline.startswith('GRUB_TIMEOUT_STYLE=hidden'):
|
||||
grubline = 'GRUB_TIMEOUT_STYLE=menu'
|
||||
elif grubline.startswith('GRUB_TIMEOUT=0'):
|
||||
grubline = 'GRUB_TIMEOUT=2'
|
||||
elif grubline.startswith('#GRUB_TERMINAL=console'):
|
||||
grubline = grubline.replace('#', '')
|
||||
grubout.write(grubline + '\n')
|
||||
subprocess.check_call(['update-grub'])
|
||||
|
||||
def get_serial_config():
|
||||
if not os.path.exists('/sys/firmware/efi'):
|
||||
return None
|
||||
if not os.path.exists('/sys/firmware/acpi/tables/SPCR'):
|
||||
return None
|
||||
spcr = open("/sys/firmware/acpi/tables/SPCR", "rb")
|
||||
spcr = bytearray(spcr.read())
|
||||
if spcr[8] != 2 or spcr[36] != 0 or spcr[40] != 1:
|
||||
return None
|
||||
address = struct.unpack('<Q', spcr[44:52])[0]
|
||||
tty = None
|
||||
try:
|
||||
tty = addrtoname[address]
|
||||
except KeyError:
|
||||
return None
|
||||
retval = { 'tty': tty }
|
||||
try:
|
||||
retval['speed'] = speedmap[spcr[58]]
|
||||
except KeyError:
|
||||
return None
|
||||
if retval['speed']:
|
||||
ttyf = os.open(tty, os.O_RDWR | os.O_NOCTTY)
|
||||
currattr = termios.tcgetattr(ttyf)
|
||||
currattr[4:6] = [0, termiobaud[retval['speed']]]
|
||||
termios.tcsetattr(ttyf, termios.TCSANOW, currattr)
|
||||
retval['connected'] = bool(struct.unpack('<I', fcntl.ioctl(
|
||||
ttyf, termios.TIOCMGET, '\x00\x00\x00\x00'))[0] & termios.TIOCM_CAR)
|
||||
os.close(ttyf)
|
||||
return retval
|
||||
|
||||
def main():
|
||||
autoconscfg = get_serial_config()
|
||||
if not autoconscfg or not autoconscfg['connected']:
|
||||
return
|
||||
if os.path.exists('/etc/redhat-release'): # redhat family
|
||||
deserialize_grub_rh()
|
||||
elif os.path.exists('/etc/os-release'):
|
||||
with open('/etc/os-release') as osr:
|
||||
if 'Ubuntu' in osr.read():
|
||||
fixup_ubuntu_grub_serial()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -226,7 +226,11 @@ class WickedManager(object):
|
||||
self.cfgbydev[devname] = currcfg
|
||||
for cfg in open(ifcfg).read().splitlines():
|
||||
cfg = cfg.split('#', 1)[0]
|
||||
kv = ' '.join(shlex.split(cfg)).split('=', 1)
|
||||
try:
|
||||
kv = ' '.join(shlex.split(cfg)).split('=', 1)
|
||||
except Exception:
|
||||
# unparseable line, likely having something we can't handle
|
||||
del self.cfgbydev[devname]
|
||||
if len(kv) != 2:
|
||||
continue
|
||||
k, v = kv
|
||||
@@ -297,6 +301,12 @@ class WickedManager(object):
|
||||
|
||||
|
||||
class NetworkManager(object):
|
||||
bondtypes = {
|
||||
'lacp': '802.3ad',
|
||||
'loadbalance': 'balance-alb',
|
||||
'roundrobin': 'balance-rr',
|
||||
'activebackup': 'active-backup',
|
||||
}
|
||||
def __init__(self, devtypes, deploycfg):
|
||||
self.deploycfg = deploycfg
|
||||
self.connections = {}
|
||||
@@ -348,7 +358,8 @@ class NetworkManager(object):
|
||||
bondcfg[stg] = deats[stg]
|
||||
if member in self.uuidbyname:
|
||||
subprocess.check_call(['nmcli', 'c', 'del', self.uuidbyname[member]])
|
||||
subprocess.check_call(['nmcli', 'c', 'add', 'type', 'bond-slave', 'master', team, 'con-name', member, 'connection.interface-name', member])
|
||||
devtype = self.devtypes.get(member, 'bond-slave')
|
||||
subprocess.check_call(['nmcli', 'c', 'add', 'type', devtype, 'master', team, 'con-name', member, 'connection.interface-name', member])
|
||||
if bondcfg:
|
||||
args = []
|
||||
for parm in bondcfg:
|
||||
@@ -356,7 +367,7 @@ class NetworkManager(object):
|
||||
args.append(bondcfg[parm])
|
||||
subprocess.check_call(['nmcli', 'c', 'm', team] + args)
|
||||
|
||||
def apply_configuration(self, cfg):
|
||||
def apply_configuration(self, cfg, lastchance=False):
|
||||
cmdargs = {}
|
||||
cmdargs['connection.autoconnect'] = 'yes'
|
||||
stgs = cfg['settings']
|
||||
@@ -396,9 +407,9 @@ class NetworkManager(object):
|
||||
for arg in cmdargs:
|
||||
cargs.append(arg)
|
||||
cargs.append(cmdargs[arg])
|
||||
if stgs['team_mode'] == 'lacp':
|
||||
stgs['team_mode'] = '802.3ad'
|
||||
subprocess.check_call(['nmcli', 'c', 'add', 'type', 'bond', 'con-name', cname, 'connection.interface-name', cname, 'bond.options', 'mode={}'.format(stgs['team_mode'])] + cargs)
|
||||
if stgs['team_mode'] in self.bondtypes:
|
||||
stgs['team_mode'] = self.bondtypes[stgs['team_mode']]
|
||||
subprocess.check_call(['nmcli', 'c', 'add', 'type', 'bond', 'con-name', cname, 'connection.interface-name', cname, 'bond.options', 'miimon=100,mode={}'.format(stgs['team_mode'])] + cargs)
|
||||
for iface in cfg['interfaces']:
|
||||
self.add_team_member(cname, iface)
|
||||
subprocess.check_call(['nmcli', 'c', 'u', cname])
|
||||
@@ -407,8 +418,9 @@ class NetworkManager(object):
|
||||
iname = list(cfg['interfaces'])[0]
|
||||
ctype = self.devtypes.get(iname, None)
|
||||
if not ctype:
|
||||
sys.stderr.write("Warning, no device found for interface_name ({0}), skipping setup\n".format(iname))
|
||||
return
|
||||
if lastchance:
|
||||
sys.stderr.write("Warning, no device found for interface_name ({0}), skipping setup\n".format(iname))
|
||||
return 1
|
||||
if stgs.get('vlan_id', None):
|
||||
vlan = stgs['vlan_id']
|
||||
if ctype == 'infiniband':
|
||||
@@ -532,8 +544,21 @@ if __name__ == '__main__':
|
||||
nm = NetworkManager(devtypes, dc)
|
||||
elif os.path.exists('/usr/sbin/wicked'):
|
||||
nm = WickedManager()
|
||||
retrynics = []
|
||||
for netn in netname_to_interfaces:
|
||||
nm.apply_configuration(netname_to_interfaces[netn])
|
||||
redo = nm.apply_configuration(netname_to_interfaces[netn])
|
||||
if redo == 1:
|
||||
retrynics.append(netn)
|
||||
if retrynics:
|
||||
idxmap, devtypes = map_idx_to_name()
|
||||
if os.path.exists('/usr/sbin/netplan'):
|
||||
nm = NetplanManager(dc)
|
||||
if os.path.exists('/usr/bin/nmcli'):
|
||||
nm = NetworkManager(devtypes, dc)
|
||||
elif os.path.exists('/usr/sbin/wicked'):
|
||||
nm = WickedManager()
|
||||
for netn in retrynics:
|
||||
nm.apply_configuration(netname_to_interfaces[netn], lastchance=True)
|
||||
if havefirewall:
|
||||
subprocess.check_call(['systemctl', 'start', 'firewalld'])
|
||||
await_tentative()
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
is_suse=false
|
||||
is_rhel=false
|
||||
|
||||
if test -f /boot/efi/EFI/redhat/grub.cfg; then
|
||||
grubcfg="/boot/efi/EFI/redhat/grub.cfg"
|
||||
grub2-mkconfig -o $grubcfg
|
||||
is_rhel=true
|
||||
elif test -f /boot/efi/EFI/sle_hpc/grub.cfg; then
|
||||
grubcfg="/boot/efi/EFI/sle_hpc/grub.cfg"
|
||||
grub2-mkconfig -o $grubcfg
|
||||
is_suse=true
|
||||
else
|
||||
echo "Expected File missing: Check if os sle_hpc or redhat"
|
||||
exit
|
||||
fi
|
||||
|
||||
# working on SUSE
|
||||
if $is_suse; then
|
||||
start=false
|
||||
num_line=0
|
||||
lines_to_edit=()
|
||||
while read line; do
|
||||
((num_line++))
|
||||
if [[ $line == *"grub_platform"* ]]; then
|
||||
start=true
|
||||
fi
|
||||
if $start; then
|
||||
if [[ $line != "#"* ]];then
|
||||
lines_to_edit+=($num_line)
|
||||
fi
|
||||
fi
|
||||
if [[ ${#line} -eq 2 && $line == *"fi" ]]; then
|
||||
if $start; then
|
||||
start=false
|
||||
fi
|
||||
fi
|
||||
done < grub_cnf.cfg
|
||||
|
||||
for line_num in "${lines_to_edit[@]}"; do
|
||||
line_num+="s"
|
||||
sed -i "${line_num},^,#," $grubcfg
|
||||
done
|
||||
sed -i 's,^terminal,#terminal,' $grubcfg
|
||||
fi
|
||||
|
||||
# Working on Redhat
|
||||
if $is_rhel; then
|
||||
sed -i 's,^serial,#serial, ; s,^terminal,#terminal,' $grubcfg
|
||||
fi
|
||||
@@ -10,6 +10,15 @@ for pubkey in /etc/ssh/ssh_host*key.pub; do
|
||||
rm $certfile
|
||||
confluentpython $confapiclient /confluent-api/self/sshcert $pubkey -o $certfile
|
||||
done
|
||||
if [ -d /etc/ssh/sshd_config.d/ -a ! -e /etc/ssh/sshd_config.d/90-confluent.conf ]; then
|
||||
for cert in /etc/ssh/ssh*-cert.pub; do
|
||||
echo HostCertificate $cert >> /etc/ssh/sshd_config.d/90-confluent.conf
|
||||
done
|
||||
echo HostbasedAuthentication yes >> /etc/ssh/sshd_config.d/90-confluent.conf
|
||||
echo HostbasedUsesNameFromPacketOnly yes >> /etc/ssh/sshd_config.d/90-confluent.conf
|
||||
echo IgnoreRhosts no >> /etc/ssh/sshd_config.d/90-confluent.conf
|
||||
fi
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
cd $TMPDIR
|
||||
confluentpython $confapiclient /confluent-public/site/initramfs.tgz -o initramfs.tgz
|
||||
|
||||
@@ -28,11 +28,15 @@ This contains support utilities for enabling deployment of x86_64 architecture s
|
||||
#cp start_root urlmount ../stateless-bin/
|
||||
#cd ..
|
||||
ln -s el8 el9
|
||||
for os in rhvh4 el7 genesis el8 suse15 ubuntu18.04 ubuntu20.04 ubuntu22.04 ubuntu24.04 coreos el9; do
|
||||
cp -a el8 el10
|
||||
mv el10/initramfs/usr el10/initramfs/var
|
||||
for os in rhvh4 el7 genesis el8 suse15 debian ubuntu18.04 ubuntu20.04 ubuntu22.04 ubuntu24.04 coreos el9 el10; do
|
||||
mkdir ${os}out
|
||||
cd ${os}out
|
||||
if [ -d ../${os}bin ]; then
|
||||
cp -a ../${os}bin/opt .
|
||||
elif [ $os = el10 ]; then
|
||||
cp -a ../el9bin/opt .
|
||||
else
|
||||
cp -a ../el8bin/opt .
|
||||
fi
|
||||
@@ -73,12 +77,14 @@ cd ..
|
||||
cp -a esxi7out esxi6out
|
||||
cp -a esxi7 esxi6
|
||||
cp -a esxi7out esxi8out
|
||||
cp -a esxi7out esxi9out
|
||||
cp -a esxi7 esxi8
|
||||
cp -a esxi7 esxi9
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}/opt/confluent/share/licenses/confluent_osdeploy/
|
||||
cp LICENSE %{buildroot}/opt/confluent/share/licenses/confluent_osdeploy/
|
||||
for os in rhvh4 el7 el8 el9 genesis suse15 ubuntu20.04 ubuntu18.04 ubuntu22.04 ubuntu24.04 esxi6 esxi7 esxi8 coreos; do
|
||||
for os in rhvh4 el7 el8 el9 el10 genesis suse15 ubuntu20.04 debian ubuntu18.04 ubuntu22.04 ubuntu24.04 esxi6 esxi7 esxi8 esxi9 coreos; do
|
||||
mkdir -p %{buildroot}/opt/confluent/lib/osdeploy/$os/initramfs
|
||||
mkdir -p %{buildroot}/opt/confluent/lib/osdeploy/$os/profiles
|
||||
cp ${os}out/addons.* %{buildroot}/opt/confluent/lib/osdeploy/$os/initramfs
|
||||
|
||||
+163
-51
@@ -14,65 +14,127 @@ setdebopt() {
|
||||
echo d-i $1 $3 $2 >> /preseed.cfg
|
||||
}
|
||||
|
||||
dhuuid=$(reverse_uuid $(cat /sys/devices/virtual/dmi/id/product_uuid))
|
||||
dhcpid=$(mktemp)
|
||||
mkdir -p /etc/confluent
|
||||
cp /tls/* /etc/ssl/certs/
|
||||
for nic in $(ip link | grep mtu|grep -v LOOPBACK|cut -d: -f 2|sed -e 's/ //'); do
|
||||
ip link set $nic up
|
||||
for i in /sys/class/net/*; do
|
||||
ip link set $(basename $i) up
|
||||
done
|
||||
for nic in $(ip link | grep mtu|grep -v LOOPBACK|grep LOWER_UP|cut -d: -f 2|sed -e 's/ //'); do
|
||||
if udhcpc -i $nic -p $dhcpid -t 2 -T 2 -n -x 93:0007 -x 97:00$dhuuid -q; then
|
||||
/opt/confluent/bin/copernicus > /etc/confluent/confluent.info
|
||||
if grep ^MANAGER:.*\\. /etc/confluent/confluent.info ; then
|
||||
break
|
||||
fi
|
||||
TRIES=5
|
||||
while [ ! -e /dev/disk ] && [ $TRIES -gt 0 ]; do
|
||||
sleep 2
|
||||
TRIES=$((TRIES - 1))
|
||||
done
|
||||
for i in /sys/class/net/*; do
|
||||
ip link set $(basename $i) down
|
||||
udevadm info $i | grep ID_NET_DRIVER=cdc_ether > /dev/null && continue
|
||||
ip link set $(basename $i) up
|
||||
done
|
||||
cp -a /tls/* /etc/ssl/certs/
|
||||
mkdir -p /etc/confluent
|
||||
if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then
|
||||
tmnt=$(mktemp -d)
|
||||
tcfg=$(mktemp)
|
||||
mount /dev/disk/by-label/CNFLNT_IDNT $tmnt
|
||||
cd $tmnt
|
||||
deploysrvs=$(sed -n '/^deploy_servers:/,/^[^-]/p' cnflnt.yml |grep ^-|sed -e 's/^- //'|grep -v :)
|
||||
nodename=$(grep ^nodename: cnflnt.yml|cut -f 2 -d ' ')
|
||||
echo NODENAME: $nodename > /etc/confluent/confluent.info
|
||||
sed -n '/^net_cfgs:/,/^[^- ]/{/^[^- ]/!p}' cnflnt.yml |sed -n '/^-/,/^-/{/^-/!p}'| sed -e 's/^[- ]*//'> $tcfg
|
||||
autoconfigmethod=$(grep ^ipv4_method: $tcfg)
|
||||
autoconfigmethod=${autoconfigmethod#ipv4_method: }
|
||||
if [ "$autoconfigmethod" = "static" ]; then
|
||||
setdebopt netcfg/disable_dhcp true boolean
|
||||
v4addr=$(grep ^ipv4_address: $tcfg|cut -d: -f 2|sed -e 's/ //')
|
||||
v4gw=$(grep ^ipv4_gateway: $tcfg|cut -d: -f 2| sed -e 's/ //')
|
||||
if [ "$v4gw" = "null" ]; then
|
||||
v4gw=""
|
||||
fi
|
||||
v4nm=$(grep ^ipv4_netmask: $tcfg|cut -d: -f 2|sed -e 's/ //')
|
||||
setdebopt netcfg/get_netmask $v4nm string
|
||||
setdebopt netcfg/get_ipaddress ${v4addr%/*} string
|
||||
setdebopt netcfg/confirm_static true boolean
|
||||
if [ ! -z "$v4gw" ]; then
|
||||
setdebopt netcfg/get_gateway $v4gw string
|
||||
fi
|
||||
NIC=""
|
||||
while [ -z "$NIC" ]; do
|
||||
for NICGUESS in $(ip link|grep LOWER_UP|grep -v LOOPBACK|cut -d ' ' -f 2 | sed -e 's/:$//'); do
|
||||
ip addr add dev $NICGUESS $v4addr
|
||||
if [ ! -z "$v4gw" ]; then
|
||||
ip route add default via $v4gw
|
||||
fi
|
||||
for dsrv in $deploysrvs; do
|
||||
if wget https://$dsrv/confluent-public/ --tries=1 --timeout=1 -O /dev/null > /dev/null 2>&1; then
|
||||
deploysrvs=$dsrv
|
||||
NIC=$NICGUESS
|
||||
setdebopt netcfg/choose_interface $NIC select
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$NIC" ]; then
|
||||
ip -4 a flush dev $NICGUESS
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
#TODO: nameservers
|
||||
elif [ "$v4cfgmeth" = "dhcp" ]; then
|
||||
setdebopt netcfg/disable_dhcp false boolean
|
||||
setdebopt netcfg/confirm_static false boolean
|
||||
for NICGUESS in $(ip link|grep LOWER_UP|grep -v LOOPBACK|cut -d ' ' -f 2 | sed -e 's/:$//'); do
|
||||
udhcpc $NICGUESS
|
||||
done
|
||||
for dsrv in $deploysrvs; do
|
||||
if wget https://$dsrv/confluent-public/ --tries=1 --timeout=1 -O /dev/null > /dev/null 2>&1; then
|
||||
deploysrvs=$dsrv
|
||||
fi
|
||||
done
|
||||
fi
|
||||
ip -4 flush dev $nic
|
||||
done
|
||||
mgr=$(grep ^MANAGER:.*\\. /etc/confluent/confluent.info|head -n 1|cut -d: -f 2|sed -e 's/ //')
|
||||
nodename=$(grep ^NODENAME: /etc/confluent/confluent.info|head -n 1|cut -d: -f 2|sed -e 's/ //')
|
||||
/opt/confluent/bin/clortho $nodename $mgr > /etc/confluent/confluent.apikey
|
||||
mgr=$deploysrvs
|
||||
ln -s /opt/confluent/bin/clortho /opt/confluent/bin/genpasshmac
|
||||
hmackeyfile=/tmp/cnflnthmackeytmp
|
||||
passfile=/tmp/cnflnttmppassfile
|
||||
passcrypt=/tmp/cnflntcryptfile
|
||||
hmacfile=/tmp/cnflnthmacfile
|
||||
echo -n $(grep ^apitoken: cnflnt.yml|cut -d ' ' -f 2) > $hmackeyfile
|
||||
/opt/confluent/bin/genpasshmac $passfile $passcrypt $hmacfile $hmackeyfile
|
||||
wget --header="CONFLUENT_NODENAME: $nodename" --header="CONFLUENT_CRYPTHMAC: $(cat $hmacfile)" --post-file=$passcrypt https://$mgr/confluent-api/self/registerapikey -O - --quiet
|
||||
cp $passfile /etc/confluent/confluent.apikey
|
||||
nic=$NIC
|
||||
else
|
||||
dhuuid=$(reverse_uuid $(cat /sys/devices/virtual/dmi/id/product_uuid))
|
||||
dhcpid=$(mktemp)
|
||||
mkdir -p /etc/confluent
|
||||
cp /tls/* /etc/ssl/certs/
|
||||
cat /tls/*.pem >> /etc/confluent/ca.pem
|
||||
for nic in $(ip link | grep mtu|grep -v LOOPBACK|cut -d: -f 2|sed -e 's/ //'); do
|
||||
ip link set $nic up
|
||||
done
|
||||
for nic in $(ip link | grep mtu|grep -v LOOPBACK|grep LOWER_UP|cut -d: -f 2|sed -e 's/ //'); do
|
||||
if udhcpc -i $nic -p $dhcpid -t 2 -T 2 -n -x 93:0007 -x 97:00$dhuuid -q; then
|
||||
/opt/confluent/bin/copernicus > /etc/confluent/confluent.info
|
||||
if grep ^MANAGER:.*\\. /etc/confluent/confluent.info ; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
ip -4 flush dev $nic
|
||||
done
|
||||
mgr=$(grep ^MANAGER:.*\\. /etc/confluent/confluent.info|head -n 1|cut -d: -f 2|sed -e 's/ //')
|
||||
nodename=$(grep ^NODENAME: /etc/confluent/confluent.info|head -n 1|cut -d: -f 2|sed -e 's/ //')
|
||||
/opt/confluent/bin/clortho $nodename $mgr > /etc/confluent/confluent.apikey
|
||||
fi
|
||||
apikey=$(cat /etc/confluent/confluent.apikey)
|
||||
cd /etc/confluent
|
||||
wget --header="CONFLUENT_NODENAME: $nodename" --header="CONFLUENT_APIKEY: $apikey" https://$mgr/confluent-api/self/deploycfg
|
||||
cd -
|
||||
predir=$(mktemp -d)
|
||||
cd $predir
|
||||
cp /etc/confluent/deploycfg /etc/confluent/confluent.deploycfg
|
||||
profile=$(grep ^profile: /etc/confluent/deploycfg|cut -d ' ' -f 2)
|
||||
wget https://$mgr/confluent-public/os/$profile/scripts/pre.sh
|
||||
chmod u+x pre.sh
|
||||
wget https://$mgr/confluent-public/os/$profile/preseed.cfg
|
||||
mv preseed.cfg /
|
||||
setdebopt auto-install/enable true boolean
|
||||
setdebopt partman/early_command $predir/pre.sh string
|
||||
cd -
|
||||
ip -4 a flush dev $nic
|
||||
setdebopt netcfg/choose_interface $nic select
|
||||
setdebopt netcfg/get_hostname $nodename string
|
||||
v4cfgmeth=$(grep ipv4_method: /etc/confluent/deploycfg |cut -d: -f 2|sed -e 's/ //')
|
||||
if [ "$v4cfgmeth" = "static" ]; then
|
||||
setdebopt netcfg/disable_dhcp true boolean
|
||||
v4addr=$(grep ^ipv4_address: /etc/confluent/deploycfg|cut -d: -f 2|sed -e 's/ //')
|
||||
v4gw=$(grep ^ipv4_gateway: /etc/confluent/deploycfg|cut -d: -f 2| sed -e 's/ //')
|
||||
if [ "$v4gw" = "null" ]; then
|
||||
v4gw=""
|
||||
fi
|
||||
v4nm=$(grep ^ipv4_netmask: /etc/confluent/deploycfg|cut -d: -f 2|sed -e 's/ //')
|
||||
setdebopt netcfg/get_netmask $v4nm string
|
||||
setdebopt netcfg/get_ipaddress $v4addr string
|
||||
setdebopt netcfg/confirm_static true boolean
|
||||
if [ ! -z "$v4gw" ]; then
|
||||
setdebopt netcfg/get_gateway $v4gw string
|
||||
fi
|
||||
namesrvs=$(sed -n '/^nameservers:/,/^[^-]/p' /etc/confluent/deploycfg|grep ^- | cut -d ' ' -f 2|sed -e 's/ //')
|
||||
for namesrv in "$namesrvs"; do
|
||||
setdebopt netcfg/get_nameservers $namesrv string
|
||||
done
|
||||
elif [ "$v4cfgmeth" = "dhcp" ]; then
|
||||
setdebopt netcfg/disable_dhcp false boolean
|
||||
setdebopt netcfg/confirm_static false boolean
|
||||
fi
|
||||
namesrvs=$(sed -n '/^nameservers:/,/^[^-]/p' /etc/confluent/deploycfg|grep ^- | cut -d ' ' -f 2|sed -e 's/ //')
|
||||
for namesrv in "$namesrvs"; do
|
||||
setdebopt netcfg/get_nameservers $namesrv string
|
||||
done
|
||||
rootpass=$(grep ^rootpassword: /etc/confluent/deploycfg|cut -d ' ' -f 2|sed -e 's/ //')
|
||||
if [ "$rootpass" = null ] || [ -z "$rootpass" ]; then
|
||||
setdebopt passwd/root-login false boolean
|
||||
@@ -84,9 +146,8 @@ setdebopt time/zone $(grep ^timezone: /etc/confluent/deploycfg|cut -d ' ' -f 2|s
|
||||
ntpsrvs=$(sed -n '/^ntpservers:/,/^[^-]/p' /etc/confluent/deploycfg|grep ^- | cut -d ' ' -f 2|sed -e 's/ //')
|
||||
for ntpsrv in "$ntpsrvs"; do
|
||||
setdebopt clock-setup/ntp true boolean
|
||||
setdebopt clock-setup/ntep-server $ntpsrv string
|
||||
setdebopt clock-setup/ntp-server $ntpsrv string
|
||||
done
|
||||
#setdebopt console-setup/layoutcode $(grep ^keymap: /etc/confluent/deploycfg|cut -d ' ' -f 2) string
|
||||
setdebopt debian-installer/locale $(grep ^locale: /etc/confluent/deploycfg|cut -d ' ' -f 2) select
|
||||
domainname=$(grep ^dnsdomain: /etc/confluent/deploycfg|cut -d ' ' -f 2)
|
||||
if [ ! -z "$domainname" ] && [ "$domainname" != "null" ]; then
|
||||
@@ -95,3 +156,54 @@ fi
|
||||
|
||||
|
||||
|
||||
|
||||
wget https://$mgr/confluent-public/os/$profile/scripts/pre.sh
|
||||
chmod u+x pre.sh
|
||||
wget https://$mgr/confluent-public/os/$profile/scripts/prechroot.sh
|
||||
chmod u+x prechroot.sh
|
||||
wget https://$mgr/confluent-public/os/$profile/scripts/post.sh
|
||||
chmod u+x post.sh
|
||||
wget https://$mgr/confluent-public/os/$profile/preseed.cfg
|
||||
cat preseed.cfg >> /preseed.cfg
|
||||
echo $mgr > /etc/confluent/deployer
|
||||
setdebopt auto-install/enable true boolean
|
||||
setdebopt partman/early_command $predir/pre.sh string
|
||||
setdebopt preseed/late_command $predir/prechroot.sh string
|
||||
mv $predir/post.sh /tmp/
|
||||
cd -
|
||||
ip -4 a flush dev $nic
|
||||
setdebopt netcfg/choose_interface $nic select
|
||||
setdebopt netcfg/get_hostname $nodename string
|
||||
setdebopt netcfg/hostname $nodename string
|
||||
setdebopt mirror/protocol https string
|
||||
setdebopt mirror/country manual string
|
||||
setdebopt mirror/https/hostname deb.debian.org string
|
||||
setdebopt mirror/https/directory /debian/ string
|
||||
setdebopt mirror/protocol https string
|
||||
setdebopt mirror/https/proxy "" string
|
||||
#setdebopt apt-setup/security_host $mgr string
|
||||
if [ ! -e /dev/disk/by-label/CNFLNT_IDNT ]; then
|
||||
v4cfgmeth=$(grep ipv4_method: /etc/confluent/deploycfg |cut -d: -f 2|sed -e 's/ //')
|
||||
if [ "$v4cfgmeth" = "static" ]; then
|
||||
setdebopt netcfg/disable_dhcp true boolean
|
||||
v4addr=$(grep ^ipv4_address: /etc/confluent/deploycfg|cut -d: -f 2|sed -e 's/ //')
|
||||
v4gw=$(grep ^ipv4_gateway: /etc/confluent/deploycfg|cut -d: -f 2| sed -e 's/ //')
|
||||
if [ "$v4gw" = "null" ]; then
|
||||
v4gw=""
|
||||
fi
|
||||
v4nm=$(grep ^ipv4_netmask: /etc/confluent/deploycfg|cut -d: -f 2|sed -e 's/ //')
|
||||
setdebopt netcfg/get_netmask $v4nm string
|
||||
setdebopt netcfg/get_ipaddress $v4addr string
|
||||
setdebopt netcfg/confirm_static true boolean
|
||||
if [ ! -z "$v4gw" ]; then
|
||||
setdebopt netcfg/get_gateway $v4gw string
|
||||
fi
|
||||
namesrvs=$(sed -n '/^nameservers:/,/^[^-]/p' /etc/confluent/deploycfg|grep ^- | cut -d ' ' -f 2|sed -e 's/ //')
|
||||
for namesrv in "$namesrvs"; do
|
||||
setdebopt netcfg/get_nameservers $namesrv string
|
||||
done
|
||||
elif [ "$vpcfgmeth" = "dhcp" ]; then
|
||||
setdebopt netcfg/disable_dhcp false boolean
|
||||
setdebopt netcfg/confirm_static false boolean
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
sed -i 's/label: debian/label: Debian/' $2/profile.yaml && \
|
||||
ln -s $1/linux $2/boot/kernel && \
|
||||
ln -s $1/initrd.gz $2/boot/initramfs/distribution && \
|
||||
mkdir -p $2/boot/efi/boot && \
|
||||
rm $2/distribution && \
|
||||
mcopy -i $1/boot/grub/efi.img ::/efi/boot/* $2/boot/efi/boot
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
d-i anna/choose_modules string openssh-server-udeb
|
||||
d-i partman-auto/method string regular
|
||||
d-i partman-lvm/device_remove_lvm boolean true
|
||||
d-i partman-md/device_remove_md boolean true
|
||||
d-i partman-auto/expert_recipe_file string /tmp/partitionfile
|
||||
d-i partman/confirm_write_new_label boolean true
|
||||
d-i partman/choose_partition select finish
|
||||
d-i partman/confirm boolean true
|
||||
d-i partman/confirm_nooverwrite boolean true
|
||||
d-i passwd/make-user boolean false
|
||||
d-i clock-setup/utc boolean true
|
||||
d-i apt-setup/multiverse boolean false
|
||||
d-i apt-setup/universe boolean false
|
||||
d-i apt-setup/backports boolean false
|
||||
d-i apt-setup/updates boolean false
|
||||
d-i grub-installer/only_debian boolean true
|
||||
tasksel tasksel/first multiselect standard
|
||||
d-i pkgsel/include string openssh-server curl
|
||||
d-i pkgsel/update-policy select none
|
||||
d-i pkgsel/updatedb boolean false
|
||||
d-i finish-install/reboot_in_progress note
|
||||
popularity-contest popularity-contest/participate boolean false
|
||||
d-i partman-auto/method string lvm
|
||||
d-i partman-auto/choose_recipe select atomic
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||
d-i partman-auto-lvm/guided_size string max
|
||||
@@ -0,0 +1,3 @@
|
||||
label: %%DISTRO%% %%VERSION%% %%ARCH%% (Default Profile)
|
||||
kernelargs: quiet osprofile=%%PROFILE%%
|
||||
#installedargs: example # These arguments would be added to the installed system
|
||||
@@ -0,0 +1,565 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import shlex
|
||||
import subprocess
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
pass
|
||||
try:
|
||||
from importlib.machinery import SourceFileLoader
|
||||
def load_source(mod, path):
|
||||
return SourceFileLoader(mod, path).load_module()
|
||||
except ImportError:
|
||||
from imp import load_source
|
||||
|
||||
try:
|
||||
apiclient = load_source('apiclient', '/opt/confluent/bin/apiclient')
|
||||
except IOError:
|
||||
apiclient = load_source('apiclient', '/etc/confluent/apiclient')
|
||||
|
||||
def add_lla(iface, mac):
|
||||
pieces = mac.split(':')
|
||||
initbyte = int(pieces[0], 16) ^ 2
|
||||
lla = 'fe80::{0:x}{1}:{2}ff:fe{3}:{4}{5}/64'.format(initbyte, pieces[1], pieces[2], pieces[3], pieces[4], pieces[5])
|
||||
try:
|
||||
with open('/proc/sys/net/ipv6/conf/{0}/disable_ipv6'.format(iface), 'w') as setin:
|
||||
setin.write('0')
|
||||
subprocess.check_call(['ip', 'addr', 'add', 'dev', iface, lla, 'scope', 'link'])
|
||||
except Exception:
|
||||
return None
|
||||
return lla
|
||||
|
||||
#cli = apiclient.HTTPSClient(json=True)
|
||||
#c = cli.grab_url_with_status('/confluent-api/self/netcfg')
|
||||
def add_missing_llas():
|
||||
#NetworkManager goes out of its way to suppress ipv6 lla, so will just add some
|
||||
added = {}
|
||||
linkinfo = subprocess.check_output(['ip', '-br', 'l']).decode('utf8')
|
||||
ifaces = {}
|
||||
for line in linkinfo.split('\n'):
|
||||
line = line.strip().split()
|
||||
if not line or 'LOOPBACK' in line[-1] or 'NO-CARRIER' in line[-1]:
|
||||
continue
|
||||
if 'UP' not in line[-1]:
|
||||
subprocess.call(['ip', 'link', 'set', line[0], 'up'])
|
||||
ifaces[line[0]] = line[2]
|
||||
ips = {}
|
||||
ipinfo = subprocess.check_output(['ip', '-br', '-6', 'a']).decode('utf8')
|
||||
for line in ipinfo.split('\n'):
|
||||
line = line.strip().split(None, 2)
|
||||
if not line:
|
||||
continue
|
||||
ips[line[0]] = line[2]
|
||||
for iface in ifaces:
|
||||
for addr in ips.get(iface, '').split():
|
||||
if addr.startswith('fe80::'):
|
||||
break
|
||||
else:
|
||||
newlla = add_lla(iface, ifaces[iface])
|
||||
if newlla:
|
||||
added[iface] = newlla
|
||||
return added
|
||||
|
||||
def rm_tmp_llas(tmpllas):
|
||||
for iface in tmpllas:
|
||||
subprocess.check_call(['ip', 'addr', 'del', 'dev', iface, tmpllas[iface]])
|
||||
|
||||
def await_tentative():
|
||||
maxwait = 10
|
||||
while b'tentative' in subprocess.check_output(['ip', 'a']):
|
||||
if maxwait == 0:
|
||||
break
|
||||
maxwait -= 1
|
||||
time.sleep(1)
|
||||
|
||||
def map_idx_to_name():
|
||||
map = {}
|
||||
devtype = {}
|
||||
prevdev = None
|
||||
for line in subprocess.check_output(['ip', 'l']).decode('utf8').splitlines():
|
||||
if line.startswith(' ') and 'link/' in line:
|
||||
typ = line.split()[0].split('/')[1]
|
||||
devtype[prevdev] = typ if typ != 'ether' else 'ethernet'
|
||||
if line.startswith(' '):
|
||||
continue
|
||||
idx, iface, rst = line.split(':', 2)
|
||||
prevdev = iface.strip()
|
||||
rst = rst.split()
|
||||
try:
|
||||
midx = rst.index('master')
|
||||
continue
|
||||
except ValueError:
|
||||
pass
|
||||
idx = int(idx)
|
||||
iface = iface.strip()
|
||||
map[idx] = iface
|
||||
return map, devtype
|
||||
|
||||
|
||||
def get_interface_name(iname, settings):
|
||||
explicitname = settings.get('interface_names', None)
|
||||
if explicitname:
|
||||
return explicitname
|
||||
if settings.get('current_nic', False):
|
||||
return iname
|
||||
return None
|
||||
|
||||
class NetplanManager(object):
|
||||
def __init__(self, deploycfg):
|
||||
self.cfgbydev = {}
|
||||
self.read_connections()
|
||||
self.deploycfg = deploycfg
|
||||
|
||||
def read_connections(self):
|
||||
for plan in glob.glob('/etc/netplan/*.y*ml'):
|
||||
with open(plan) as planfile:
|
||||
planinfo = yaml.safe_load(planfile)
|
||||
if not planinfo:
|
||||
continue
|
||||
nicinfo = planinfo.get('network', {}).get('ethernets', {})
|
||||
for devname in nicinfo:
|
||||
if devname == 'lo':
|
||||
continue
|
||||
if 'gateway4' in nicinfo[devname]:
|
||||
# normalize deprecated syntax on read in
|
||||
gw4 = nicinfo[devname]['gateway4']
|
||||
del nicinfo[devname]['gateway4']
|
||||
routeinfo = nicinfo[devname].get('routes', [])
|
||||
for ri in routeinfo:
|
||||
if ri.get('via', None) == gw4 and ri.get('to', None) in ('default', '0.0.0.0/0', '0/0'):
|
||||
break
|
||||
else:
|
||||
routeinfo.append({
|
||||
'to': 'default',
|
||||
'via': gw4
|
||||
})
|
||||
nicinfo[devname]['routes'] = routeinfo
|
||||
self.cfgbydev[devname] = nicinfo[devname]
|
||||
|
||||
def apply_configuration(self, cfg):
|
||||
devnames = cfg['interfaces']
|
||||
if len(devnames) != 1:
|
||||
raise Exception('Multi-nic team/bonds not yet supported')
|
||||
stgs = cfg['settings']
|
||||
needcfgapply = False
|
||||
for devname in devnames:
|
||||
needcfgwrite = False
|
||||
# ipv6_method missing at uconn...
|
||||
if stgs.get('ipv6_method', None) == 'static':
|
||||
curraddr = stgs['ipv6_address']
|
||||
currips = self.getcfgarrpath([devname, 'addresses'])
|
||||
if curraddr not in currips:
|
||||
needcfgwrite = True
|
||||
currips.append(curraddr)
|
||||
if stgs.get('ipv4_method', None) == 'static':
|
||||
curraddr = stgs['ipv4_address']
|
||||
currips = self.getcfgarrpath([devname, 'addresses'])
|
||||
if curraddr not in currips:
|
||||
needcfgwrite = True
|
||||
currips.append(curraddr)
|
||||
gws = []
|
||||
gws.append(stgs.get('ipv4_gateway', None))
|
||||
gws.append(stgs.get('ipv6_gateway', None))
|
||||
for gwaddr in gws:
|
||||
if gwaddr:
|
||||
cfgroutes = self.getcfgarrpath([devname, 'routes'])
|
||||
for rinfo in cfgroutes:
|
||||
if rinfo.get('via', None) == gwaddr:
|
||||
break
|
||||
else:
|
||||
needcfgwrite = True
|
||||
cfgroutes.append({'via': gwaddr, 'to': 'default'})
|
||||
dnsips = self.deploycfg.get('nameservers', [])
|
||||
dnsdomain = self.deploycfg.get('dnsdomain', '')
|
||||
if dnsips:
|
||||
currdnsips = self.getcfgarrpath([devname, 'nameservers', 'addresses'])
|
||||
for dnsip in dnsips:
|
||||
if dnsip and dnsip not in currdnsips:
|
||||
needcfgwrite = True
|
||||
currdnsips.append(dnsip)
|
||||
if dnsdomain:
|
||||
currdnsdomain = self.getcfgarrpath([devname, 'nameservers', 'search'])
|
||||
if dnsdomain not in currdnsdomain:
|
||||
needcfgwrite = True
|
||||
currdnsdomain.append(dnsdomain)
|
||||
if needcfgwrite:
|
||||
needcfgapply = True
|
||||
newcfg = {'network': {'version': 2, 'ethernets': {devname: self.cfgbydev[devname]}}}
|
||||
oumask = os.umask(0o77)
|
||||
with open('/etc/netplan/{0}-confluentcfg.yaml'.format(devname), 'w') as planout:
|
||||
planout.write(yaml.dump(newcfg))
|
||||
os.umask(oumask)
|
||||
if needcfgapply:
|
||||
subprocess.call(['netplan', 'apply'])
|
||||
|
||||
def getcfgarrpath(self, devpath):
|
||||
currptr = self.cfgbydev
|
||||
for k in devpath[:-1]:
|
||||
if k not in currptr:
|
||||
currptr[k] = {}
|
||||
currptr = currptr[k]
|
||||
if devpath[-1] not in currptr:
|
||||
currptr[devpath[-1]] = []
|
||||
return currptr[devpath[-1]]
|
||||
|
||||
|
||||
|
||||
class WickedManager(object):
|
||||
def __init__(self):
|
||||
self.teamidx = 0
|
||||
self.read_connections()
|
||||
|
||||
def read_connections(self):
|
||||
self.cfgbydev = {}
|
||||
for ifcfg in glob.glob('/etc/sysconfig/network/ifcfg-*'):
|
||||
devname = ifcfg.replace('/etc/sysconfig/network/ifcfg-', '')
|
||||
if devname == 'lo':
|
||||
continue
|
||||
currcfg = {}
|
||||
self.cfgbydev[devname] = currcfg
|
||||
for cfg in open(ifcfg).read().splitlines():
|
||||
cfg = cfg.split('#', 1)[0]
|
||||
try:
|
||||
kv = ' '.join(shlex.split(cfg)).split('=', 1)
|
||||
except Exception:
|
||||
# unparseable line, likely having something we can't handle
|
||||
del self.cfgbydev[devname]
|
||||
if len(kv) != 2:
|
||||
continue
|
||||
k, v = kv
|
||||
k = k.strip()
|
||||
v = v.strip()
|
||||
currcfg[k] = v
|
||||
|
||||
def apply_configuration(self, cfg):
|
||||
stgs = cfg['settings']
|
||||
ipcfg = 'STARTMODE=auto\n'
|
||||
routecfg = ''
|
||||
bootproto4 = stgs.get('ipv4_method', 'none')
|
||||
bootproto6 = stgs.get('ipv6_method', 'none')
|
||||
if bootproto4 == 'dhcp' and bootproto6 == 'dhcp':
|
||||
ipcfg += 'BOOTPROTO=dhcp\n'
|
||||
elif bootproto4 == 'dhcp':
|
||||
ipcfg += 'BOOTPROTO=dhcp4\n'
|
||||
elif bootproto6 == 'dhcp':
|
||||
ipcfg += 'BOOTPROTO=dhcp6\n'
|
||||
else:
|
||||
ipcfg += 'BOOTPROTO=static\n'
|
||||
if stgs.get('ipv4_address', None):
|
||||
ipcfg += 'IPADDR=' + stgs['ipv4_address'] + '\n'
|
||||
v4gw = stgs.get('ipv4_gateway', None)
|
||||
if stgs.get('ipv6_address', None):
|
||||
ipcfg += 'IPADDR_V6=' + stgs['ipv6_address'] + '\n'
|
||||
v6gw = stgs.get('ipv6_gateway', None)
|
||||
cname = None
|
||||
if len(cfg['interfaces']) > 1: # creating new team
|
||||
if not stgs.get('team_mode', None):
|
||||
sys.stderr.write("Warning, multiple interfaces ({0}) without a team_mode, skipping setup\n".format(','.join(cfg['interfaces'])))
|
||||
return
|
||||
if not stgs.get('connection_name', None):
|
||||
stgs['connection_name'] = 'bond{0}'.format(self.teamidx)
|
||||
self.teamidx += 1
|
||||
cname = stgs['connection_name']
|
||||
with open('/etc/sysconfig/network/ifcfg-{0}'.format(cname), 'w') as teamout:
|
||||
teamout.write(ipcfg)
|
||||
if stgs['team_mode'] == 'lacp':
|
||||
stgs['team_mode'] = '802.3ad'
|
||||
teamout.write("BONDING_MODULE_OPTS='mode={0} miimon=100'\nBONDING_MASTER=yes\n".format(stgs['team_mode']))
|
||||
idx = 1
|
||||
for iface in cfg['interfaces']:
|
||||
subprocess.call(['wicked', 'ifdown', iface])
|
||||
try:
|
||||
os.remove('/etc/sysconfig/network/ifcfg-{0}'.format(iface))
|
||||
os.remove('/etc/sysconfig/network/ifroute-{0}'.format(iface))
|
||||
except OSError:
|
||||
pass
|
||||
teamout.write('BONDING_SLAVE{0}={1}\n'.format(idx, iface))
|
||||
idx += 1
|
||||
else:
|
||||
cname = list(cfg['interfaces'])[0]
|
||||
priorcfg = self.cfgbydev.get(cname, {})
|
||||
for cf in priorcfg:
|
||||
if cf.startswith('TEAM_'):
|
||||
ipcfg += '{0}={1}\n'.format(cf, priorcfg[cf])
|
||||
with open('/etc/sysconfig/network/ifcfg-{0}'.format(cname), 'w') as iout:
|
||||
iout.write(ipcfg)
|
||||
if v4gw:
|
||||
routecfg += 'default {0} - {1}\n'.format(v4gw, cname)
|
||||
if v6gw:
|
||||
routecfg += 'default {0} - {1}\n'.format(v6gw, cname)
|
||||
if routecfg:
|
||||
with open('/etc/sysconfig/network/ifroute-{0}'.format(cname), 'w') as routeout:
|
||||
routeout.write(routecfg)
|
||||
subprocess.call(['wicked', 'ifup', cname])
|
||||
|
||||
|
||||
class NetworkManager(object):
|
||||
bondtypes = {
|
||||
'lacp': '802.3ad',
|
||||
'loadbalance': 'balance-alb',
|
||||
'roundrobin': 'balance-rr',
|
||||
'activebackup': 'active-backup',
|
||||
}
|
||||
def __init__(self, devtypes, deploycfg):
|
||||
self.deploycfg = deploycfg
|
||||
self.connections = {}
|
||||
self.uuidbyname = {}
|
||||
self.uuidbydev = {}
|
||||
self.connectiondetail = {}
|
||||
self.read_connections()
|
||||
self.teamidx = 0
|
||||
self.devtypes = devtypes
|
||||
|
||||
def read_connections(self):
|
||||
self.connections = {}
|
||||
self.uuidbyname = {}
|
||||
self.uuidbydev = {}
|
||||
self.connectiondetail = {}
|
||||
ci = subprocess.check_output(['nmcli', '-t', 'c']).decode('utf8')
|
||||
for inf in ci.splitlines():
|
||||
n, u, t, dev = inf.split(':')
|
||||
if n == 'NAME':
|
||||
continue
|
||||
if dev == '--':
|
||||
dev = None
|
||||
self.uuidbyname[n] = u
|
||||
if dev:
|
||||
self.uuidbydev[dev] = u
|
||||
self.connections[u] = {'name': n, 'uuid': u, 'type': t, 'dev': dev}
|
||||
deats = {}
|
||||
for deat in subprocess.check_output(['nmcli', 'c', 's', u]).decode('utf8').splitlines():
|
||||
k, v = deat.split(':', 1)
|
||||
v = v.strip()
|
||||
if v == '--':
|
||||
continue
|
||||
if '(default)' in v:
|
||||
continue
|
||||
deats[k] = v
|
||||
self.connectiondetail[u] = deats
|
||||
|
||||
|
||||
def add_team_member(self, team, member):
|
||||
bondcfg = {}
|
||||
if member in self.uuidbydev:
|
||||
myuuid = self.uuidbydev[member]
|
||||
deats = self.connectiondetail[myuuid]
|
||||
currteam = deats.get('connection.master', None)
|
||||
if currteam == team:
|
||||
return
|
||||
for stg in ('ipv4.dhcp-hostname', 'ipv4.dns', 'ipv6.dns', 'ipv6.dhcp-hostname'):
|
||||
if deats.get(stg, None):
|
||||
bondcfg[stg] = deats[stg]
|
||||
if member in self.uuidbyname:
|
||||
subprocess.check_call(['nmcli', 'c', 'del', self.uuidbyname[member]])
|
||||
devtype = self.devtypes.get(member, 'bond-slave')
|
||||
subprocess.check_call(['nmcli', 'c', 'add', 'type', devtype, 'master', team, 'con-name', member, 'connection.interface-name', member])
|
||||
if bondcfg:
|
||||
args = []
|
||||
for parm in bondcfg:
|
||||
args.append(parm)
|
||||
args.append(bondcfg[parm])
|
||||
subprocess.check_call(['nmcli', 'c', 'm', team] + args)
|
||||
|
||||
def apply_configuration(self, cfg, lastchance=False):
|
||||
cmdargs = {}
|
||||
cmdargs['connection.autoconnect'] = 'yes'
|
||||
stgs = cfg['settings']
|
||||
cmdargs['ipv6.method'] = stgs.get('ipv6_method', 'link-local')
|
||||
if stgs.get('ipv6_address', None):
|
||||
cmdargs['ipv6.addresses'] = stgs['ipv6_address']
|
||||
cmdargs['ipv4.method'] = stgs.get('ipv4_method', 'disabled')
|
||||
if stgs.get('ipv4_address', None):
|
||||
cmdargs['ipv4.addresses'] = stgs['ipv4_address']
|
||||
if stgs.get('ipv4_gateway', None):
|
||||
cmdargs['ipv4.gateway'] = stgs['ipv4_gateway']
|
||||
if stgs.get('ipv6_gateway', None):
|
||||
cmdargs['ipv6.gateway'] = stgs['ipv6_gateway']
|
||||
dnsips = self.deploycfg.get('nameservers', [])
|
||||
if not dnsips:
|
||||
dnsips = []
|
||||
dns4 = []
|
||||
dns6 = []
|
||||
for dnsip in dnsips:
|
||||
if '.' in dnsip:
|
||||
dns4.append(dnsip)
|
||||
elif ':' in dnsip:
|
||||
dns6.append(dnsip)
|
||||
if dns4:
|
||||
cmdargs['ipv4.dns'] = ','.join(dns4)
|
||||
if dns6:
|
||||
cmdargs['ipv6.dns'] = ','.join(dns6)
|
||||
if len(cfg['interfaces']) > 1: # team time.. should be..
|
||||
if not cfg['settings'].get('team_mode', None):
|
||||
sys.stderr.write("Warning, multiple interfaces ({0}) without a team_mode, skipping setup\n".format(','.join(cfg['interfaces'])))
|
||||
return
|
||||
if not cfg['settings'].get('connection_name', None):
|
||||
cfg['settings']['connection_name'] = 'team{0}'.format(self.teamidx)
|
||||
self.teamidx += 1
|
||||
cname = cfg['settings']['connection_name']
|
||||
cargs = []
|
||||
for arg in cmdargs:
|
||||
cargs.append(arg)
|
||||
cargs.append(cmdargs[arg])
|
||||
if stgs['team_mode'] in self.bondtypes:
|
||||
stgs['team_mode'] = self.bondtypes[stgs['team_mode']]
|
||||
subprocess.check_call(['nmcli', 'c', 'add', 'type', 'bond', 'con-name', cname, 'connection.interface-name', cname, 'bond.options', 'mode={}'.format(stgs['team_mode'])] + cargs)
|
||||
for iface in cfg['interfaces']:
|
||||
self.add_team_member(cname, iface)
|
||||
subprocess.check_call(['nmcli', 'c', 'u', cname])
|
||||
else:
|
||||
cname = stgs.get('connection_name', None)
|
||||
iname = list(cfg['interfaces'])[0]
|
||||
ctype = self.devtypes.get(iname, None)
|
||||
if not ctype:
|
||||
if lastchance:
|
||||
sys.stderr.write("Warning, no device found for interface_name ({0}), skipping setup\n".format(iname))
|
||||
return 1
|
||||
if stgs.get('vlan_id', None):
|
||||
vlan = stgs['vlan_id']
|
||||
if ctype == 'infiniband':
|
||||
vlan = '0x{0}'.format(vlan) if not vlan.startswith('0x') else vlan
|
||||
cmdargs['infiniband.parent'] = iname
|
||||
cmdargs['infiniband.p-key'] = vlan
|
||||
iname = '{0}.{1}'.format(iname, vlan[2:])
|
||||
elif ctype == 'ethernet':
|
||||
ctype = 'vlan'
|
||||
cmdargs['vlan.parent'] = iname
|
||||
cmdargs['vlan.id'] = vlan
|
||||
iname = '{0}.{1}'.format(iname, vlan)
|
||||
else:
|
||||
sys.stderr.write("Warning, unknown interface_name ({0}) device type ({1}) for VLAN/PKEY, skipping setup\n".format(iname, ctype))
|
||||
return
|
||||
cname = iname if not cname else cname
|
||||
u = self.uuidbyname.get(cname, None)
|
||||
cargs = []
|
||||
for arg in cmdargs:
|
||||
cargs.append(arg)
|
||||
cargs.append(cmdargs[arg])
|
||||
if u:
|
||||
subprocess.check_call(['nmcli', 'c', 'm', u, 'connection.interface-name', iname] + cargs)
|
||||
subprocess.check_call(['nmcli', 'c', 'u', u])
|
||||
else:
|
||||
subprocess.check_call(['nmcli', 'c', 'add', 'type', ctype, 'con-name', cname, 'connection.interface-name', iname] + cargs)
|
||||
self.read_connections()
|
||||
u = self.uuidbyname.get(cname, None)
|
||||
if u:
|
||||
subprocess.check_call(['nmcli', 'c', 'u', u])
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
havefirewall = subprocess.call(['systemctl', 'status', 'firewalld'])
|
||||
havefirewall = havefirewall == 0
|
||||
if havefirewall:
|
||||
subprocess.check_call(['systemctl', 'stop', 'firewalld'])
|
||||
tmpllas = add_missing_llas()
|
||||
await_tentative()
|
||||
idxmap, devtypes = map_idx_to_name()
|
||||
netname_to_interfaces = {}
|
||||
myaddrs = apiclient.get_my_addresses()
|
||||
srvs, _ = apiclient.scan_confluents()
|
||||
doneidxs = set([])
|
||||
dc = None
|
||||
if not srvs: # the multicast scan failed, fallback to deploycfg cfg file
|
||||
with open('/etc/confluent/confluent.deploycfg', 'r') as dci:
|
||||
for cfgline in dci.read().split('\n'):
|
||||
if cfgline.startswith('deploy_server:'):
|
||||
srvs = [cfgline.split()[1]]
|
||||
break
|
||||
for srv in srvs:
|
||||
try:
|
||||
s = socket.create_connection((srv, 443))
|
||||
except socket.error:
|
||||
continue
|
||||
myname = s.getsockname()
|
||||
s.close()
|
||||
if len(myname) == 4:
|
||||
curridx = myname[-1]
|
||||
else:
|
||||
myname = myname[0]
|
||||
myname = socket.inet_pton(socket.AF_INET, myname)
|
||||
for addr in myaddrs:
|
||||
if myname == addr[1].tobytes():
|
||||
curridx = addr[-1]
|
||||
if curridx in doneidxs:
|
||||
continue
|
||||
for tries in (1, 2, 3):
|
||||
try:
|
||||
status, nc = apiclient.HTTPSClient(usejson=True, host=srv).grab_url_with_status('/confluent-api/self/netcfg')
|
||||
break
|
||||
except Exception:
|
||||
if tries == 3:
|
||||
raise
|
||||
time.sleep(1)
|
||||
continue
|
||||
nc = json.loads(nc)
|
||||
if not dc:
|
||||
for tries in (1, 2, 3):
|
||||
try:
|
||||
status, dc = apiclient.HTTPSClient(usejson=True, host=srv).grab_url_with_status('/confluent-api/self/deploycfg2')
|
||||
break
|
||||
except Exception:
|
||||
if tries == 3:
|
||||
raise
|
||||
time.sleep(1)
|
||||
continue
|
||||
dc = json.loads(dc)
|
||||
iname = get_interface_name(idxmap[curridx], nc.get('default', {}))
|
||||
if iname:
|
||||
for iname in iname.split(','):
|
||||
if 'default' in netname_to_interfaces:
|
||||
netname_to_interfaces['default']['interfaces'].add(iname)
|
||||
else:
|
||||
netname_to_interfaces['default'] = {'interfaces': set([iname]), 'settings': nc['default']}
|
||||
for netname in nc.get('extranets', {}):
|
||||
uname = '_' + netname
|
||||
iname = get_interface_name(idxmap[curridx], nc['extranets'][netname])
|
||||
if iname:
|
||||
for iname in iname.split(','):
|
||||
if uname in netname_to_interfaces:
|
||||
netname_to_interfaces[uname]['interfaces'].add(iname)
|
||||
else:
|
||||
netname_to_interfaces[uname] = {'interfaces': set([iname]), 'settings': nc['extranets'][netname]}
|
||||
doneidxs.add(curridx)
|
||||
if 'default' in netname_to_interfaces:
|
||||
for netn in netname_to_interfaces:
|
||||
if netn == 'default':
|
||||
continue
|
||||
netname_to_interfaces['default']['interfaces'] -= netname_to_interfaces[netn]['interfaces']
|
||||
if not netname_to_interfaces['default']['interfaces']:
|
||||
del netname_to_interfaces['default']
|
||||
# Make sure VLAN/PKEY connections are created last
|
||||
netname_to_interfaces = dict(sorted(netname_to_interfaces.items(), key=lambda item: 'vlan_id' in item[1]['settings']))
|
||||
rm_tmp_llas(tmpllas)
|
||||
if os.path.exists('/usr/sbin/netplan'):
|
||||
nm = NetplanManager(dc)
|
||||
if os.path.exists('/usr/bin/nmcli'):
|
||||
nm = NetworkManager(devtypes, dc)
|
||||
elif os.path.exists('/usr/sbin/wicked'):
|
||||
nm = WickedManager()
|
||||
retrynics = []
|
||||
for netn in netname_to_interfaces:
|
||||
redo = nm.apply_configuration(netname_to_interfaces[netn])
|
||||
if redo == 1:
|
||||
retrynics.append(netn)
|
||||
if retrynics:
|
||||
idxmap, devtypes = map_idx_to_name()
|
||||
if os.path.exists('/usr/sbin/netplan'):
|
||||
nm = NetplanManager(dc)
|
||||
if os.path.exists('/usr/bin/nmcli'):
|
||||
nm = NetworkManager(devtypes, dc)
|
||||
elif os.path.exists('/usr/sbin/wicked'):
|
||||
nm = WickedManager()
|
||||
for netn in retrynics:
|
||||
nm.apply_configuration(netname_to_interfaces[netn], lastchance=True)
|
||||
if havefirewall:
|
||||
subprocess.check_call(['systemctl', 'start', 'firewalld'])
|
||||
await_tentative()
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=First Boot Process
|
||||
Requires=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/opt/confluent/bin/firstboot.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
echo "Confluent first boot is running"
|
||||
HOME=$(getent passwd $(whoami)|cut -d: -f 6)
|
||||
export HOME
|
||||
#cp -a /etc/confluent/ssh/* /etc/ssh/
|
||||
#systemctl restart sshd
|
||||
rootpw=$(grep ^rootpassword: /etc/confluent/confluent.deploycfg |awk '{print $2}')
|
||||
if [ ! -z "$rootpw" -a "$rootpw" != "null" ]; then
|
||||
echo root:$rootpw | chpasswd -e
|
||||
fi
|
||||
nodename=$(grep ^NODENAME: /etc/confluent/confluent.info | awk '{print $2}')
|
||||
confluent_apikey=$(cat /etc/confluent/confluent.apikey)
|
||||
confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg |awk '{print $2}')
|
||||
while ! ping -c 1 $confluent_mgr >& /dev/null; do
|
||||
sleep 1
|
||||
done
|
||||
source /etc/confluent/functions
|
||||
|
||||
run_remote_parts firstboot.d
|
||||
run_remote_config firstboot.d
|
||||
systemctl disable firstboot
|
||||
curl -f -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" -X POST -d "status: complete" https://$confluent_mgr/confluent-api/self/updatestatus
|
||||
@@ -0,0 +1,209 @@
|
||||
#!/bin/bash
|
||||
function test_mgr() {
|
||||
whost=$1
|
||||
if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then
|
||||
whost="[$whost]"
|
||||
fi
|
||||
if curl -gs https://${whost}/confluent-api/ > /dev/null; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function confluentpython() {
|
||||
if [ -x /usr/libexec/platform-python ]; then
|
||||
/usr/libexec/platform-python $*
|
||||
elif [ -x /usr/bin/python3 ]; then
|
||||
/usr/bin/python3 $*
|
||||
elif [ -x /usr/bin/python ]; then
|
||||
/usr/bin/python $*
|
||||
elif [ -x /usr/bin/python2 ]; then
|
||||
/usr/bin/python2 $*
|
||||
fi
|
||||
}
|
||||
|
||||
function set_confluent_vars() {
|
||||
if [ -z "$nodename" ]; then
|
||||
nodename=$(grep ^NODENAME: /etc/confluent/confluent.info | awk '{print $2}')
|
||||
fi
|
||||
if [[ "$confluent_mgr" == *"%"* ]]; then
|
||||
confluent_mgr=""
|
||||
fi
|
||||
if [ -z "$confluent_mgr" ]; then
|
||||
confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
if ! test_mgr $confluent_mgr; then
|
||||
confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
if [[ "$confluent_mgr" = *":"* ]]; then
|
||||
confluent_mgr="[$confluent_mgr]"
|
||||
fi
|
||||
fi
|
||||
if ! test_mgr $confluent_mgr; then
|
||||
BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//')
|
||||
OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//')
|
||||
for confluent_mgr in $BESTMGRS $OKMGRS; do
|
||||
if [[ $confluent_mgr == *":"* ]]; then
|
||||
confluent_mgr="[$confluent_mgr]"
|
||||
fi
|
||||
if test_mgr $confluent_mgr; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
curlargs=""
|
||||
if [ -f /etc/confluent/ca.pem ]; then
|
||||
curlargs=" --cacert /etc/confluent/ca.pem"
|
||||
fi
|
||||
set_confluent_vars
|
||||
mkdir -p $(dirname $1)
|
||||
whost=$confluent_mgr
|
||||
if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then
|
||||
whost="[$whost]"
|
||||
fi
|
||||
curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1
|
||||
if [ $? != 0 ]; then echo $1 failed to download; return 1; fi
|
||||
}
|
||||
|
||||
source_remote_parts() {
|
||||
confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX)
|
||||
apiclient=/opt/confluent/bin/apiclient
|
||||
if [ -f /etc/confluent/apiclient ]; then
|
||||
apiclient=/etc/confluent/apiclient
|
||||
fi
|
||||
scriptlist=$(confluentpython $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //')
|
||||
for script in $scriptlist; do
|
||||
source_remote $1/$script
|
||||
done
|
||||
rm -rf $confluentscripttmpdir
|
||||
unset confluentscripttmpdir
|
||||
}
|
||||
|
||||
run_remote_parts() {
|
||||
confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX)
|
||||
apiclient=/opt/confluent/bin/apiclient
|
||||
if [ -f /etc/confluent/apiclient ]; then
|
||||
apiclient=/etc/confluent/apiclient
|
||||
fi
|
||||
scriptlist=$(confluentpython $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //')
|
||||
for script in $scriptlist; do
|
||||
run_remote $1/$script
|
||||
done
|
||||
rm -rf $confluentscripttmpdir
|
||||
unset confluentscripttmpdir
|
||||
}
|
||||
|
||||
source_remote() {
|
||||
set_confluent_vars
|
||||
unsettmpdir=0
|
||||
echo
|
||||
echo '---------------------------------------------------------------------------'
|
||||
echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
|
||||
if [ -z "$confluentscripttmpdir" ]; then
|
||||
confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX)
|
||||
unsettmpdir=1
|
||||
fi
|
||||
echo Sourcing from $confluentscripttmpdir
|
||||
cd $confluentscripttmpdir
|
||||
fetch_remote $1
|
||||
if [ $? != 0 ]; then echo $1 failed to download; return 1; fi
|
||||
chmod +x $1
|
||||
cmd=$1
|
||||
shift
|
||||
source ./$cmd
|
||||
cd - > /dev/null
|
||||
if [ "$unsettmpdir" = 1 ]; then
|
||||
rm -rf $confluentscripttmpdir
|
||||
unset confluentscripttmpdir
|
||||
unsettmpdir=0
|
||||
fi
|
||||
rm -rf $confluentscripttmpdir
|
||||
return $retcode
|
||||
}
|
||||
|
||||
run_remote() {
|
||||
requestedcmd="'$*'"
|
||||
unsettmpdir=0
|
||||
set_confluent_vars
|
||||
echo
|
||||
echo '---------------------------------------------------------------------------'
|
||||
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
|
||||
if [ -z "$confluentscripttmpdir" ]; then
|
||||
confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX)
|
||||
unsettmpdir=1
|
||||
fi
|
||||
echo Executing in $confluentscripttmpdir
|
||||
cd $confluentscripttmpdir
|
||||
fetch_remote $1
|
||||
if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi
|
||||
chmod +x $1
|
||||
cmd=$1
|
||||
if [ -x /usr/bin/chcon ]; then
|
||||
chcon system_u:object_r:bin_t:s0 $cmd
|
||||
fi
|
||||
shift
|
||||
./$cmd $*
|
||||
retcode=$?
|
||||
if [ $retcode -ne 0 ]; then
|
||||
echo "$requestedcmd exited with code $retcode"
|
||||
fi
|
||||
cd - > /dev/null
|
||||
if [ "$unsettmpdir" = 1 ]; then
|
||||
rm -rf $confluentscripttmpdir
|
||||
unset confluentscripttmpdir
|
||||
unsettmpdir=0
|
||||
fi
|
||||
return $retcode
|
||||
}
|
||||
|
||||
run_remote_python() {
|
||||
echo
|
||||
set_confluent_vars
|
||||
if [ -f /etc/confluent/ca.pem ]; then
|
||||
curlargs=" --cacert /etc/confluent/ca.pem"
|
||||
fi
|
||||
echo '---------------------------------------------------------------------------'
|
||||
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
|
||||
confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX)
|
||||
echo Executing in $confluentscripttmpdir
|
||||
cd $confluentscripttmpdir
|
||||
mkdir -p $(dirname $1)
|
||||
whost=$confluent_mgr
|
||||
if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then
|
||||
whost="[$whost]"
|
||||
fi
|
||||
curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1
|
||||
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
|
||||
confluentpython $*
|
||||
retcode=$?
|
||||
echo "'$*' exited with code $retcode"
|
||||
cd - > /dev/null
|
||||
rm -rf $confluentscripttmpdir
|
||||
unset confluentscripttmpdir
|
||||
return $retcode
|
||||
}
|
||||
|
||||
run_remote_config() {
|
||||
echo
|
||||
set_confluent_vars
|
||||
apiclient=/opt/confluent/bin/apiclient
|
||||
if [ -f /etc/confluent/apiclient ]; then
|
||||
apiclient=/etc/confluent/apiclient
|
||||
fi
|
||||
echo '---------------------------------------------------------------------------'
|
||||
echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile
|
||||
confluentpython $apiclient /confluent-api/self/remoteconfig/"$*" -d {}
|
||||
confluentpython $apiclient /confluent-api/self/remoteconfig/status -w 204
|
||||
echo
|
||||
echo 'Completed remote configuration'
|
||||
echo '---------------------------------------------------------------------------'
|
||||
return
|
||||
}
|
||||
#If invoked as a command, use the arguments to actually run a function
|
||||
(return 0 2>/dev/null) || $1 "${@:2}"
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
mkdir -p /run/sshd
|
||||
mkdir -p /root/.ssh
|
||||
cat /tmp/ssh/*pubkey >> /root/.ssh/authorized_keys
|
||||
cat /tmp/ssh/*.ca | sed -e s/^/'@cert-authority * '/ >> /etc/ssh/ssh_known_hosts
|
||||
chmod 700 /etc/confluent
|
||||
chmod go-rwx /etc/confluent/*
|
||||
sshconf=/etc/ssh/ssh_config
|
||||
if [ -d /etc/ssh/ssh_config.d/ ]; then
|
||||
sshconf=/etc/ssh/ssh_config.d/01-confluent.conf
|
||||
fi
|
||||
echo 'Host *' >> $sshconf
|
||||
echo ' HostbasedAuthentication yes' >> $sshconf
|
||||
echo ' EnableSSHKeysign yes' >> $sshconf
|
||||
echo ' HostbasedKeyTypes *ed25519*' >> $sshconf
|
||||
/usr/sbin/sshd
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | awk '{print $2}')
|
||||
mkdir -p /opt/confluent/bin
|
||||
python3 /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/scripts/firstboot.sh > /opt/confluent/bin/firstboot.sh
|
||||
chmod +x /opt/confluent/bin/firstboot.sh
|
||||
python3 /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/scripts/firstboot.service > /etc/systemd/system/firstboot.service
|
||||
systemctl enable firstboot
|
||||
python3 /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/scripts/functions > /etc/confluent/functions
|
||||
source /etc/confluent/functions
|
||||
python3 /opt/confluent/bin/apiclient /confluent-api/self/nodelist | sed -e s/'^- //' > /tmp/allnodes
|
||||
cp /tmp/allnodes /root/.shosts
|
||||
cp /tmp/allnodes /etc/ssh/shosts.equiv
|
||||
if grep ^ntpservers: /etc/confluent/confluent.deploycfg > /dev/null; then
|
||||
ntps=$(sed -n '/^ntpservers:/,/^[^-]/p' /etc/confluent/confluent.deploycfg|sed 1d|sed '$d' | sed -e 's/^- //' | paste -sd ' ')
|
||||
sed -i "s/#NTP=/NTP=$ntps/" /etc/systemd/timesyncd.conf
|
||||
fi
|
||||
textcons=$(grep ^textconsole: /etc/confluent/confluent.deploycfg |awk '{print $2}')
|
||||
updategrub=0
|
||||
if [ "$textcons" = "true" ] && ! grep console= /proc/cmdline > /dev/null; then
|
||||
cons=""
|
||||
if [ -f /tmp/autocons.info ]; then
|
||||
cons=$(cat /tmp/autocons.info)
|
||||
fi
|
||||
if [ ! -z "$cons" ]; then
|
||||
sed -i 's/GRUB_CMDLINE_LINUX="\([^"]*\)"/GRUB_CMDLINE_LINUX="\1 console='${cons#/dev/}'"/' /etc/default/grub
|
||||
updategrub=1
|
||||
fi
|
||||
fi
|
||||
kargs=$(python3 /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/profile.yaml | grep ^installedargs: | sed -e 's/#.*//')
|
||||
if [ ! -z "$kargs" ]; then
|
||||
sed -i 's/GRUB_CMDLINE_LINUX="\([^"]*\)"/GRUB_CMDLINE_LINUX="\1 '"${kargs}"'"/' /etc/default/grub
|
||||
fi
|
||||
|
||||
if [ 1 = $updategrub ]; then
|
||||
update-grub
|
||||
fi
|
||||
|
||||
if [ -e /sys/firmware/efi ]; then
|
||||
bootnum=$(efibootmgr | grep ubuntu | sed -e 's/ .*//' -e 's/\*//' -e s/Boot//)
|
||||
if [ ! -z "$bootnum" ]; then
|
||||
currboot=$(efibootmgr | grep ^BootOrder: | awk '{print $2}')
|
||||
nextboot=$(echo $currboot| awk -F, '{print $1}')
|
||||
[ "$nextboot" = "$bootnum" ] || efibootmgr -o $bootnum,$currboot
|
||||
efibootmgr -D
|
||||
fi
|
||||
fi
|
||||
run_remote_python syncfileclient
|
||||
run_remote_parts post.d
|
||||
run_remote_config post
|
||||
|
||||
python3 /opt/confluent/bin/apiclient /confluent-api/self/updatestatus -d 'status: staged'
|
||||
|
||||
Regular → Executable
+81
-11
@@ -1,18 +1,88 @@
|
||||
anna-install openssh-server-udeb
|
||||
mkdir -p ~/.ssh/
|
||||
cat /ssh/*pubkey > ~/.ssh/authorized_keys
|
||||
ssh-keygen -A
|
||||
mgr=$(grep ^MANAGER:.*\\. /etc/confluent/confluent.info|head -n 1|cut -d: -f 2|sed -e 's/ //')
|
||||
nodename=$(grep ^NODENAME: /etc/confluent/confluent.info|head -n 1|cut -d: -f 2|sed -e 's/ //')
|
||||
#!/bin/sh
|
||||
## Use the following option to add additional boot parameters for the
|
||||
## installed system (if supported by the bootloader installer).
|
||||
## Note: options passed to the installer will be added automatically.
|
||||
#d-i debian-installer/add-kernel-opts string [from profile.yaml]
|
||||
deploycfg=/etc/confluent/confluent.deploycfg
|
||||
mgr=$(cat /etc/confluent/deployer)
|
||||
|
||||
cryptboot=$(grep encryptboot: $deploycfg|sed -e 's/^encryptboot: //')
|
||||
if [ "$cryptboot" != "" ] && [ "$cryptboot" != "none" ] && [ "$cryptboot" != "null" ]; then
|
||||
echo "****Encrypted boot requested, but not implemented for this OS, halting install" > /dev/console
|
||||
[ -f '/tmp/autoconsdev' ] && (echo "****Encryptod boot requested, but not implemented for this OS,halting install" >> $(cat /tmp/autoconsdev))
|
||||
while :; do sleep 86400; done
|
||||
fi
|
||||
cat > /usr/lib/live-installer.d/confluent-certs << EOF
|
||||
#!/bin/sh
|
||||
cp /tls/* /target/etc/ssl/certs/
|
||||
cat /tls/*.pem >> /target/etc/ssl/certs/ca-certificates.crt
|
||||
EOF
|
||||
chmod a+x /usr/lib/live-installer.d/confluent-certs
|
||||
mkdir -p /.ssh/
|
||||
cat /ssh/*pubkey > /.ssh/authorized_keys
|
||||
mkdir -p /etc/ssh
|
||||
nodename=$(grep ^NODENAME: /etc/confluent/confluent.info|cut -d ' ' -f 2)
|
||||
apikey=$(cat /etc/confluent/confluent.apikey)
|
||||
ssh-keygen -A
|
||||
for pubkey in /etc/ssh/ssh_host*key.pub; do
|
||||
certfile=${pubkey%.pub}-cert.pub
|
||||
certfile=$(echo $pubkey | sed -e s/.pub/-cert.pub/)
|
||||
keyfile=${pubkey%.pub}
|
||||
wget --post-file=$pubkey --header='CONFLUENT_NODENAME: '$nodename --header="CONFLUENT_APIKEY: $apikey" https://$mgr/confluent-api/self/sshcert -O $certfile
|
||||
wget --header="CONFLUENT_NODENAME: $nodename" --header="CONFLUENT_APIKEY: $apikey" --post-file=$pubkey https://$mgr/confluent-api/self/sshcert -O $certfile --quiet
|
||||
echo HostKey $keyfile >> /etc/ssh/sshd_config
|
||||
echo HostCertificate $certfile >> /etc/ssh/sshd_config
|
||||
done
|
||||
|
||||
echo sshd:x:939:939::/: >> /etc/passwd
|
||||
if [ -e /tmp/installdisk ]; then
|
||||
instdisk=$(cat /tmp/installdisk)
|
||||
else
|
||||
for blockdev in $(ls /sys/class/block/); do
|
||||
shortname=$(basename $blockdev)
|
||||
if [ "$shortname" != "${shortname%loop*}" ]; then
|
||||
continue
|
||||
fi
|
||||
udevadm info --query=property /dev/$shortname |grep DEVTYPE=disk > /dev/null || continue # ignore partitions
|
||||
udevadm info --query=property /dev/$shortname |grep DM_NAME > /dev/null && continue # not a real disk
|
||||
sz=$(cat /sys/block/$shortname/size 2> /dev/null)
|
||||
[ -z "$sz" ] && continue
|
||||
[ $sz -lt 1048576 ] && continue # Too small
|
||||
[ -z "$firstdisk" ] && firstdisk=$shortname
|
||||
if udevadm info --query=property /dev/$shortname|grep ID_MODEL=| sed -e s/' '/_/g | grep -iE '(thinksystem_m.2|m.2_nvme_2-bay_raid_kit)' > /dev/null; then
|
||||
instdisk=$shortname
|
||||
break
|
||||
fi
|
||||
if udevadm info --query=property /dev/$shortname|grep MD_CONTAINER=imsm; then
|
||||
sraid=$sortname
|
||||
else
|
||||
drv=$(udevadm info -a /dev/sdb|grep DRIVERS==|grep -Ev '""|"sd"' | sed -e s/.*=// -e s/'"'//g)
|
||||
if [ "ahci" = "$drv" -a -z "$onbdisk" ]; then
|
||||
onbdisk=$shortname
|
||||
elif [ "megaraid" = "$drv" -a -z "$rdisk" ]; then
|
||||
rdisk=$shortname
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ -z "$instdisk" ]; then
|
||||
if [ ! -z "$sraid"]; then
|
||||
instdisk=$sraid
|
||||
elif [ ! -z "$onbdisk" ]; then
|
||||
instdisk=$onbdisk
|
||||
elif [ ! -z "$rdisk" ]; then
|
||||
instdisk=$rdisk
|
||||
else
|
||||
instdisk=$firstdisk
|
||||
fi
|
||||
fi
|
||||
if [ ! -z "$instdisk" ]; then
|
||||
debconf-set partman-auto/disk /dev/$instdisk
|
||||
debconf-set grub-installer/bootdev /dev/$instdisk
|
||||
fi
|
||||
echo HostbasedAuthentication yes >> /etc/ssh/sshd_config
|
||||
echo HostbasedUsesNameFromPacketOnly yes >> /etc/ssh/sshd_config
|
||||
echo IgnoreRhosts no >> /etc/ssh/sshd_config
|
||||
echo sshd:x:1:1::/run/sshd:/bin/false >> /etc/passwd
|
||||
/usr/sbin/sshd
|
||||
|
||||
wget --header="CONFLUENT_NODENAME: $nodename" --header="CONFLUENT_APIKEY: $apikey" https://$mgr/confluent-api/self/nodelist -O /tmp/allnodes --quiet
|
||||
#kill -HUP $(ps | grep -v grep | grep /usr/sbin/sshd | sed -e 's/^ *//'|cut -d ' ' -f 1)
|
||||
#curl -f https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/getinstalldisk > /tmp/getinstalldisk
|
||||
#python3 /tmp/getinstalldisk
|
||||
#sed -i s!%%INSTALLDISK%%!/dev/$(cat /tmp/installdisk)! /autoinstall.yaml
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
mount -o bind /sys /target/sys
|
||||
mount -o bind /dev /target/dev
|
||||
mount -o bind /dev/pts /target/dev/pts
|
||||
mount -o bind /proc /target/proc
|
||||
mount -o bind /dev/pts /target/dev/pts
|
||||
mount -o bind /run /target/run
|
||||
cp -a /etc/confluent /target/etc/confluent
|
||||
cp -a /opt/confluent /target/opt/confluent
|
||||
mv /tmp/post.sh /target/tmp/
|
||||
cp -a /ssh /tls /target/tmp
|
||||
cat /tls/*.pem >> /target/etc/confluent/ca.pem
|
||||
cp -a /etc/ssh/ssh_host_* /target/etc/ssh/
|
||||
grep HostCertificate /etc/ssh/sshd_config >> /target/etc/ssh/sshd_config
|
||||
echo Port 2222 >> /etc/ssh/sshd_config
|
||||
kill -HUP $(ps |grep -v grep|grep sshd|grep /usr|sed -e s/' root.*//')
|
||||
cp /tls/* /target/etc/ssl/certs/
|
||||
cat /tls/*.pem >> /target/etc/ssl/certs/ca-certificates.crt
|
||||
chroot /target bash /tmp/post.sh
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Add this to firstboot.d
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get -y install proxmox-ve postfix open-iscsi chrony < /dev/null
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# This script would run in post.d
|
||||
#
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
echo "deb [arch=amd64] http://download.proxmox.com/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list
|
||||
wget https://enterprise.proxmox.com/debian/proxmox-release-bookworm.gpg -O /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg
|
||||
sum=$(sha512sum /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg)
|
||||
if [ "$sum" -ne "7da6fe34168adc6e479327ba517796d4702fa2f8b4f0a9833f5ea6e6b48f6507a6da403a274fe201595edc86a84463d50383d07f64bdde2e3658108db7d6dc87" ]; then
|
||||
echo "Mismatch in fingerprint!"
|
||||
rm /etc/apt/trusted.gpg.d/proxmox-release-bookworm.gpg
|
||||
exit 1
|
||||
fi
|
||||
apt-get update && apt-get -y full-upgrade < /dev/null
|
||||
|
||||
apt-get -y install proxmox-default-kernel < /dev/null
|
||||
apt-get -y remove linux-image-amd64 'linux-image-6.1*' < /dev/null
|
||||
update-grub
|
||||
apt-get -y remove os-prober < /dev/null
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
[ -f /lib/confluent/functions ] && . /lib/confluent/functions
|
||||
[ -f /etc/confluent/functions ] && . /etc/confluent/functions
|
||||
[ -f /opt/confluent/bin/apiclient ] && confapiclient=/opt/confluent/bin/apiclient
|
||||
[ -f /etc/confluent/apiclient ] && confapiclient=/etc/confluent/apiclient
|
||||
for pubkey in /etc/ssh/ssh_host*key.pub; do
|
||||
if [ "$pubkey" = /etc/ssh/ssh_host_key.pub ]; then
|
||||
continue
|
||||
fi
|
||||
certfile=${pubkey/.pub/-cert.pub}
|
||||
rm $certfile
|
||||
confluentpython $confapiclient /confluent-api/self/sshcert $pubkey -o $certfile
|
||||
done
|
||||
if [ -d /etc/ssh/sshd_config.d/ -a ! -e /etc/ssh/sshd_config.d/90-confluent.conf ]; then
|
||||
for cert in /etc/ssh/ssh*-cert.pub; do
|
||||
echo HostCertificate $cert >> /etc/ssh/sshd_config.d/90-confluent.conf
|
||||
done
|
||||
echo HostbasedAuthentication yes >> /etc/ssh/sshd_config.d/90-confluent.conf
|
||||
echo HostbasedUsesNameFromPacketOnly yes >> /etc/ssh/sshd_config.d/90-confluent.conf
|
||||
echo IgnoreRhosts no >> /etc/ssh/sshd_config.d/90-confluent.conf
|
||||
fi
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
cd $TMPDIR
|
||||
confluentpython $confapiclient /confluent-public/site/initramfs.tgz -o initramfs.tgz
|
||||
tar xf initramfs.tgz
|
||||
for ca in ssh/*.ca; do
|
||||
LINE=$(cat $ca)
|
||||
cp -af /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts.new
|
||||
grep -v "$LINE" /etc/ssh/ssh_known_hosts > /etc/ssh/ssh_known_hosts.new
|
||||
echo '@cert-authority *' $LINE >> /etc/ssh/ssh_known_hosts.new
|
||||
mv /etc/ssh/ssh_known_hosts.new /etc/ssh/ssh_known_hosts
|
||||
done
|
||||
for pubkey in ssh/*.*pubkey; do
|
||||
LINE=$(cat $pubkey)
|
||||
cp -af /root/.ssh/authorized_keys /root/.ssh/authorized_keys.new
|
||||
grep -v "$LINE" /root/.ssh/authorized_keys > /root/.ssh/authorized_keys.new
|
||||
echo "$LINE" >> /root/.ssh/authorized_keys.new
|
||||
mv /root/.ssh/authorized_keys.new /root/.ssh/authorized_keys
|
||||
done
|
||||
confluentpython $confapiclient /confluent-api/self/nodelist | sed -e 's/^- //' > /etc/ssh/shosts.equiv
|
||||
cat /etc/ssh/shosts.equiv > /root/.shosts
|
||||
cd -
|
||||
rm -rf $TMPDIR
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -5,11 +5,37 @@
|
||||
# noted below so custom commands are executed before
|
||||
# the script notifies confluent that install is fully complete.
|
||||
|
||||
|
||||
ntpsrvs=""
|
||||
nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}')
|
||||
confluent_apikey=$(cat /etc/confluent/confluent.apikey)
|
||||
confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
timedatectl set-timezone $(grep ^timezone: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
|
||||
|
||||
if grep ^ntpservers: /etc/confluent/confluent.deploycfg > /dev/null; then
|
||||
for ntpsrv in $(sed -n '/^ntpservers:/,/^[^-]/p' /etc/confluent/confluent.deploycfg|sed 1d|sed '$d' | sed -e 's/^- //'); do
|
||||
echo "server ${ntpsrv} iburst " >> /tmp/timeservers
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -f /tmp/timeservers ]; then
|
||||
|
||||
ntpsrvs=$(cat /tmp/timeservers)
|
||||
|
||||
sed -i "1,/^pool * /c\\
|
||||
|
||||
${ntpsrvs//$'\n'/\\$'\n'}" /etc/chrony.conf
|
||||
|
||||
|
||||
systemctl restart chronyd
|
||||
|
||||
rm -f /tmp/timeservers
|
||||
fi
|
||||
|
||||
|
||||
|
||||
export nodename confluent_mgr confluent_profile
|
||||
. /etc/confluent/functions
|
||||
mkdir -p /var/log/confluent
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# noted below so custom commands are executed before
|
||||
# the script notifies confluent that install is fully complete.
|
||||
|
||||
ntpsrvs=""
|
||||
nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}')
|
||||
confluent_apikey=$(cat /etc/confluent/confluent.apikey)
|
||||
v4meth=$(grep ^ipv4_method: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
@@ -17,6 +18,33 @@ fi
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
timedatectl set-timezone $(grep ^timezone: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
hostnamectl set-hostname $nodename
|
||||
|
||||
|
||||
if grep ^ntpservers: /etc/confluent/confluent.deploycfg > /dev/null; then
|
||||
for ntpsrv in $(sed -n '/^ntpservers:/,/^[^-]/p' /etc/confluent/confluent.deploycfg|sed 1d|sed '$d' | sed -e 's/^- //'); do
|
||||
echo "server ${ntpsrv} iburst " >> /tmp/timeservers
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -f /tmp/timeservers ]; then
|
||||
|
||||
ntpsrvs=$(cat /tmp/timeservers)
|
||||
|
||||
sed -i "1,/^pool * /c\\
|
||||
${ntpsrvs//$'\n'/\\$'\n'}" /etc/chrony.conf
|
||||
|
||||
|
||||
systemctl restart chronyd
|
||||
|
||||
rm -f /tmp/timeservers
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export nodename confluent_mgr confluent_profile
|
||||
. /etc/confluent/functions
|
||||
mkdir -p /var/log/confluent
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#!/bin/bash
|
||||
echo -n "" >> /tmp/net.ifaces
|
||||
echo -n "" > /tmp/01-autocons.devnode
|
||||
cat /tls/*.0 >> /etc/pki/tls/certs/ca-bundle.crt
|
||||
BUNDLENAME=/etc/pki/tls/certs/ca-bundle.crt
|
||||
if [ ! -e "$BUNDLENAME" ]; then
|
||||
BUNDLENAME=/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
|
||||
mkdir -p /etc/pki/tls/certs
|
||||
ln -s $BUNDLENAME /etc/pki/tls/certs/ca-bundle.crt
|
||||
fi
|
||||
cat /tls/*.0 >> $BUNDLENAME
|
||||
if ! grep console= /proc/cmdline >& /dev/null; then
|
||||
autocons=$(/opt/confluent/bin/autocons)
|
||||
if [ -n "$autocons" ]; then
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
BUNDLENAME=/sysroot/etc/pki/tls/certs/ca-bundle.crt
|
||||
if [ ! -e "$BUNDLENAME" ]; then
|
||||
BUNDLENAME=/sysroot/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
|
||||
fi
|
||||
while [ -h $BUNDLENAME ]; do
|
||||
BUNDLENAME=/sysroot/$(readlink $BUNDLENAME)
|
||||
done
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#!/bin/sh
|
||||
sed -i 's/centos/CentOS/; s/rhel/Red Hat Enterprise Linux/; s/oraclelinux/Oracle Linux/; s/alma/AlmaLinux/' $2/profile.yaml
|
||||
sed -i 's/centos/CentOS/; s/rhel/Red Hat Enterprise Linux/; s/oraclelinux/Oracle Linux/; s/alma/AlmaLinux/;s/fedora/Fedora Linux/' $2/profile.yaml
|
||||
if grep Fedora $2/profile.yaml > /dev/null; then
|
||||
sed -i 's/@^minimal-environment/#/' $2/packagelist
|
||||
fi
|
||||
ln -s $1/images/pxeboot/vmlinuz $2/boot/kernel && \
|
||||
ln -s $1/images/pxeboot/initrd.img $2/boot/initramfs/distribution
|
||||
mkdir -p $2/boot/efi/boot
|
||||
|
||||
@@ -6,6 +6,7 @@ except ImportError:
|
||||
import importlib.util
|
||||
import importlib.machinery
|
||||
import sys
|
||||
import glob
|
||||
modloader = importlib.machinery.SourceFileLoader('apiclient', '/opt/confluent/bin/apiclient')
|
||||
modspec = importlib.util.spec_from_file_location('apiclient', '/opt/confluent/bin/apiclient', loader=modloader)
|
||||
apiclient = importlib.util.module_from_spec(modspec)
|
||||
@@ -41,6 +42,7 @@ try:
|
||||
except AttributeError:
|
||||
f = cStringIO.StringIO(cfgdata)
|
||||
c.readfp(f)
|
||||
gpgkeys = glob.glob('/etc/pki/rpm-gpg/RPM-GPG-KEY-*')
|
||||
for sec in c.sections():
|
||||
if sec.startswith('variant-'):
|
||||
try:
|
||||
@@ -56,3 +58,6 @@ for sec in c.sections():
|
||||
repopath = repopath[1:]
|
||||
repout.write('baseurl=https://{}/confluent-public/os/{}/distribution/{}\n'.format(server, profile, repopath))
|
||||
repout.write('enabled=1\n')
|
||||
if gpgkeys:
|
||||
gpgkeyvals = ['file://{}'.format(x) for x in gpgkeys]
|
||||
repout.write('gpgkey=' + ' '.join(gpgkeyvals) + '\n')
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -34,6 +34,11 @@ run_remote_python add_local_repositories
|
||||
# run_remote_python will use the appropriate python interpreter path to run the specified script
|
||||
# A post.custom is provided to more conveniently hold customizations, see the post.custom file.
|
||||
|
||||
# This will do some serial console fixup for bad grub configuration when serial is firmware
|
||||
# managed. See script for details
|
||||
run_remote_python autoconsole
|
||||
|
||||
|
||||
# This will induce server side processing of the syncfile contents if
|
||||
# present
|
||||
run_remote_python syncfileclient
|
||||
|
||||
+1
-1
@@ -292,7 +292,7 @@ if [[ $confluent_websrv == *:* ]] && [[ $confluent_websrv != "["* ]]; then
|
||||
confluent_websrv="[$confluent_websrv]"
|
||||
fi
|
||||
echo -n "Initializing ssh..."
|
||||
ssh-keygen -A
|
||||
ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -C '' -N ''
|
||||
for pubkey in /etc/ssh/ssh_host*key.pub; do
|
||||
certfile=${pubkey/.pub/-cert.pub}
|
||||
privfile=${pubkey%.pub}
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -65,7 +65,11 @@ def get_image_metadata(imgpath):
|
||||
continue
|
||||
yield md
|
||||
else:
|
||||
raise Exception('Installation from single part image not supported')
|
||||
# plausible filesystem structure to apply to a nominally "diskless" image
|
||||
yield {'mount': '/', 'filesystem': 'xfs', 'minsize': 39513563136, 'initsize': 954128662528, 'flags': 'rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota', 'device': '/dev/mapper/root', 'compressed_size': 27022069760}
|
||||
yield {'mount': '/boot', 'filesystem': 'xfs', 'minsize': 232316928, 'initsize': 1006632960, 'flags': 'rw,seclabel,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota', 'device': '/dev/nvme1n1p2', 'compressed_size': 171462656}
|
||||
yield {'mount': '/boot/efi', 'filesystem': 'vfat', 'minsize': 7835648, 'initsize': 627900416, 'flags': 'rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro', 'device': '/dev/nvme1n1p1', 'compressed_size': 1576960}
|
||||
#raise Exception('Installation from single part image not supported')
|
||||
|
||||
class PartedRunner():
|
||||
def __init__(self, disk):
|
||||
@@ -84,8 +88,17 @@ def fixup(rootdir, vols):
|
||||
for vol in vols:
|
||||
devbymount[vol['mount']] = vol['targetdisk']
|
||||
fstabfile = os.path.join(rootdir, 'etc/fstab')
|
||||
with open(fstabfile) as tfile:
|
||||
fstab = tfile.read().split('\n')
|
||||
if os.path.exists(fstabfile):
|
||||
with open(fstabfile) as tfile:
|
||||
fstab = tfile.read().split('\n')
|
||||
else:
|
||||
#diskless image, need to invent fstab
|
||||
fstab = [
|
||||
"#ORIGFSTAB#/dev/mapper/root# / xfs defaults 0 0",
|
||||
"#ORIGFSTAB#UUID=aaf9e0f9-aa4d-4d74-9e75-3537620cfe23# /boot xfs defaults 0 0",
|
||||
"#ORIGFSTAB#UUID=C21D-B881# /boot/efi vfat umask=0077,shortname=winnt 0 2",
|
||||
"#ORIGFSTAB#/dev/mapper/swap# none swap defaults 0 0",
|
||||
]
|
||||
while not fstab[0]:
|
||||
fstab = fstab[1:]
|
||||
if os.path.exists(os.path.join(rootdir, '.autorelabel')):
|
||||
@@ -135,8 +148,10 @@ def fixup(rootdir, vols):
|
||||
newcfg = ifcfg.split('/')[-1]
|
||||
newcfg = os.path.join(rootdir, 'etc/NetworkManager/system-connections/{0}'.format(newcfg))
|
||||
shutil.copy2(ifcfg, newcfg)
|
||||
shutil.rmtree(os.path.join(rootdir, 'etc/confluent/'))
|
||||
shutil.copytree('/etc/confluent', os.path.join(rootdir, 'etc/confluent'))
|
||||
rootconfluentdir = os.path.join(rootdir, 'etc/confluent/')
|
||||
if os.path.exists(rootconfluentdir):
|
||||
shutil.rmtree(rootconfluentdir)
|
||||
shutil.copytree('/etc/confluent', rootconfluentdir)
|
||||
if policy:
|
||||
sys.stdout.write('Applying SELinux labeling...')
|
||||
sys.stdout.flush()
|
||||
@@ -191,8 +206,24 @@ def fixup(rootdir, vols):
|
||||
else:
|
||||
newcfgparts.append(cfgpart)
|
||||
loadentout.write(' '.join(newcfgparts) + '\n')
|
||||
with open(grubsyscfg) as defgrubin:
|
||||
defgrub = defgrubin.read().split('\n')
|
||||
if os.path.exists(grubsyscfg):
|
||||
with open(grubsyscfg) as defgrubin:
|
||||
defgrub = defgrubin.read().split('\n')
|
||||
else:
|
||||
defgrub = [
|
||||
'GRUB_TIMEOUT=5',
|
||||
'GRUB_DISTRIBUTOR="$(sed ' + "'s, release .*$,,g'" + ' /etc/system-release)"',
|
||||
'GRUB_DEFAULT=saved',
|
||||
'GRUB_DISABLE_SUBMENU=true',
|
||||
'GRUB_TERMINAL=""',
|
||||
'GRUB_SERIAL_COMMAND=""',
|
||||
'GRUB_CMDLINE_LINUX="crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M rd.lvm.lv=vg/root rd.lvm.lv=vg/swap"',
|
||||
'GRUB_DISABLE_RECOVERY="true"',
|
||||
'GRUB_ENABLE_BLSCFG=true',
|
||||
]
|
||||
if not os.path.exists(os.path.join(rootdir, "etc/kernel/cmdline")):
|
||||
with open(os.path.join(rootdir, "etc/kernel/cmdline"), "w") as cmdlineout:
|
||||
cmdlineout.write("root=/dev/mapper/localstorage-root rd.lvm.lv=localstorage/root")
|
||||
with open(grubsyscfg, 'w') as defgrubout:
|
||||
for gline in defgrub:
|
||||
gline = gline.split()
|
||||
@@ -217,6 +248,12 @@ def fixup(rootdir, vols):
|
||||
grubcfg = grubcfg[:-1]
|
||||
if len(grubcfg) == 1:
|
||||
grubcfg = grubcfg[0]
|
||||
elif not grubcfg:
|
||||
grubcfg = '/boot/grub2/grub.cfg'
|
||||
paths = glob.glob(os.path.join(rootdir, 'boot/efi/EFI/*'))
|
||||
for path in paths:
|
||||
with open(os.path.join(path, 'grub.cfg'), 'w') as stubgrubout:
|
||||
stubgrubout.write("search --no-floppy --root-dev-only --fs-uuid --set=dev " + bootuuid + "\nset prefix=($dev)/grub2\nexport $prefix\nconfigfile $prefix/grub.cfg\n")
|
||||
else:
|
||||
for gcfg in grubcfg:
|
||||
rgcfg = os.path.join(rootdir, gcfg[1:]) # gcfg has a leading / to get rid of
|
||||
@@ -272,10 +309,19 @@ def fixup(rootdir, vols):
|
||||
shimpath = subprocess.check_output(['find', os.path.join(rootdir, 'boot/efi'), '-name', 'shimx64.efi']).decode('utf8').strip()
|
||||
shimpath = shimpath.replace(rootdir, '/').replace('/boot/efi', '').replace('//', '/').replace('/', '\\')
|
||||
subprocess.check_call(['efibootmgr', '-c', '-d', targblock, '-l', shimpath, '--part', partnum])
|
||||
|
||||
try:
|
||||
os.makedirs(os.path.join(rootdir, 'opt/confluent/bin'))
|
||||
except Exception:
|
||||
pass
|
||||
shutil.copy2('/opt/confluent/bin/apiclient', os.path.join(rootdir, 'opt/confluent/bin/apiclient'))
|
||||
#other network interfaces
|
||||
|
||||
|
||||
def had_swap():
|
||||
if not os.path.exists('/etc/fstab'):
|
||||
# diskless source, assume swap
|
||||
return True
|
||||
with open('/etc/fstab') as tabfile:
|
||||
tabs = tabfile.read().split('\n')
|
||||
for tab in tabs:
|
||||
@@ -440,6 +486,8 @@ def install_to_disk(imgpath):
|
||||
subprocess.check_call(['mount', vol['targetdisk'], '/run/imginst/targ'])
|
||||
source = vol['mount'].replace('/', '_')
|
||||
source = '/run/imginst/sources/' + source
|
||||
if not os.path.exists(source):
|
||||
source = '/run/imginst/sources/_' + vol['mount']
|
||||
blankfsstat = os.statvfs('/run/imginst/targ')
|
||||
blankused = (blankfsstat.f_blocks - blankfsstat.f_bfree) * blankfsstat.f_bsize
|
||||
sys.stdout.write('\nWriting {0}: '.format(vol['mount']))
|
||||
|
||||
@@ -41,6 +41,8 @@ echo "Port 22" >> /etc/ssh/sshd_config
|
||||
echo 'Match LocalPort 22' >> /etc/ssh/sshd_config
|
||||
echo ' ChrootDirectory /sysroot/run/imginst/targ' >> /etc/ssh/sshd_config
|
||||
kill -HUP $(cat /run/sshd.pid)
|
||||
cp /sysroot/etc/pki/ca-trust/source/anchors/* /sysroot/run/imginst/targ/etc/pki/ca-trust/source/anchors/
|
||||
chroot /sysroot/run/imginst/targ update-ca-trust
|
||||
|
||||
chroot /sysroot/run/imginst/targ bash -c "source /etc/confluent/functions; run_remote post.sh"
|
||||
chroot /sysroot bash -c "umount \$(tac /proc/mounts|awk '{print \$2}'|grep ^/run/imginst/targ)"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# completed. It is best to edit the middle of the file as
|
||||
# noted below so custom commands are executed before
|
||||
# the script notifies confluent that install is fully complete.
|
||||
|
||||
ntpsrvs=""
|
||||
nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}')
|
||||
confluent_apikey=$(cat /etc/confluent/confluent.apikey)
|
||||
v4meth=$(grep ^ipv4_method: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
@@ -17,6 +17,28 @@ fi
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
timedatectl set-timezone $(grep ^timezone: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
hostnamectl set-hostname $nodename
|
||||
|
||||
|
||||
if grep ^ntpservers: /etc/confluent/confluent.deploycfg > /dev/null; then
|
||||
for ntpsrv in $(sed -n '/^ntpservers:/,/^[^-]/p' /etc/confluent/confluent.deploycfg|sed 1d|sed '$d' | sed -e 's/^- //'); do
|
||||
echo "server ${ntpsrv} iburst " >> /tmp/timeservers
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -f /tmp/timeservers ]; then
|
||||
|
||||
ntpsrvs=$(cat /tmp/timeservers)
|
||||
|
||||
sed -i "1,/^pool * /c\\
|
||||
|
||||
${ntpsrvs//$'\n'/\\$'\n'}" /etc/chrony.conf
|
||||
|
||||
|
||||
systemctl restart chronyd
|
||||
|
||||
rm -f /tmp/timeservers
|
||||
fi
|
||||
|
||||
export nodename confluent_mgr confluent_profile
|
||||
. /etc/confluent/functions
|
||||
mkdir -p /var/log/confluent
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
|
||||
# This script is executed 'chrooted' into a cloned disk target before rebooting
|
||||
#
|
||||
|
||||
if [ -f /etc/dracut.conf.d/diskless.conf ]; then
|
||||
rm /etc/dracut.conf.d/diskless.conf
|
||||
fi
|
||||
for kver in /lib/modules/*; do kver=$(basename $kver); kernel-install add $kver /boot/vmlinuz-$kver; done
|
||||
nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}')
|
||||
confluent_apikey=$(cat /etc/confluent/confluent.apikey)
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
||||
@@ -16,6 +19,7 @@ if [[ "$confluent_mgr" == *:* ]]; then
|
||||
fi
|
||||
export nodename confluent_mgr confluent_profile confluent_websrv
|
||||
. /etc/confluent/functions
|
||||
run_remote setupssh
|
||||
mkdir -p /var/log/confluent
|
||||
chmod 700 /var/log/confluent
|
||||
exec >> /var/log/confluent/confluent-post.log
|
||||
@@ -40,6 +44,9 @@ run_remote_parts post.d
|
||||
# Induce execution of remote configuration, e.g. ansible plays in ansible/post.d/
|
||||
run_remote_config post.d
|
||||
|
||||
# rebuild initrd, pick up new drivers if needed
|
||||
dracut -f /boot/initramfs-$(uname -r).img $(uname -r)
|
||||
|
||||
curl -sf -X POST -d 'status: staged' -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_websrv/confluent-api/self/updatestatus
|
||||
|
||||
kill $logshowpid
|
||||
|
||||
@@ -6,6 +6,7 @@ if [ ! -f /var/run/vmware/show-esx-shell-login ]; then
|
||||
chvt 2
|
||||
/etc/init.d/ESXShell start
|
||||
fi
|
||||
/opt/confluent/bin/apiclient -f
|
||||
uuid=$(vsish -e get /hardware/bios/dmiInfo|grep -A15 UUID|sed -e 's/.*://'|sed -e ':a;N;$!ba;s/\n//g' | sed -e 's/ *0x//g')
|
||||
uuid=${uuid:0:8}-${uuid:8:4}-${uuid:12:4}-${uuid:16:4}-${uuid:20:12}
|
||||
kargs=$(vsish -e get /system/bootCmdLine|grep "command line:")
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
label: Confluent installation of VMware ESXi %%VERSION%% Hypervisor
|
||||
label: VMware ESXi %%VERSION%% Hypervisor
|
||||
ostype: esxi
|
||||
kernelargs: runweasel
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
#!/bin/bash
|
||||
mkdir -p /usr/libexec /run/sshd
|
||||
if [ ! -x /usr/libexec/platform-python ]; then
|
||||
ln -s /usr/bin/python3 /usr/libexec/platform-python
|
||||
fi
|
||||
export LANG=en_US.utf8
|
||||
|
||||
(while :; do TERM=linux tmux a <> /dev/tty1 >&0 2>&1; done) &
|
||||
|
||||
|
||||
|
||||
mkdir -p /etc/confluent
|
||||
if ! grep console= /proc/cmdline >& /dev/null; then
|
||||
autocons=$(/opt/confluent/bin/autocons)
|
||||
@@ -9,13 +18,9 @@ if ! grep console= /proc/cmdline >& /dev/null; then
|
||||
if [ ! -z "$autocons" ]; then
|
||||
echo "Using $(cat /tmp/01-autocons.conf)"
|
||||
(while :; do TERM=xterm-256color tmux a <> $autocons >&0 2>&1; done) &
|
||||
(while :; do TERM=linux tmux a <> /dev/tty1 >&0 2>&1; done) &
|
||||
else
|
||||
(while :; do TERM=linux tmux a <> /dev/console >&0 2>&1; done) &
|
||||
fi
|
||||
else
|
||||
(while :; do TERM=xterm-256color tmux a <> /dev/console >&0 2>&1; done) &
|
||||
(while :; do TERM=linux tmux a <> /dev/tty1 >&0 2>&1; done) &
|
||||
fi
|
||||
(while :; do TERM=linux tmux <> /dev/tty2 >&0 2>&1; done) &
|
||||
echo -n "udevd: "
|
||||
@@ -29,6 +34,13 @@ modprobe ib_umad
|
||||
modprobe hfi1
|
||||
modprobe mlx5_ib
|
||||
echo "done"
|
||||
if [ -x /usr/bin/seatd-launch -a -x /usr/bin/sway ]; then
|
||||
export XDG_RUNTIME_DIR=/run/users/0
|
||||
mkdir -p $XDG_RUNTIME_DIR
|
||||
sed -i '/^output /d' /etc/sway/config
|
||||
echo 'exec foot -t xterm -T Terminal tmux a' > /etc/sway/config.d/genesis
|
||||
(while :; do seatd-launch sway <> /dev/tty1 >& /dev/null; done) &
|
||||
fi
|
||||
cat > /etc/ssh/sshd_config << EOF
|
||||
Port 22
|
||||
Port 3389
|
||||
@@ -43,23 +55,48 @@ mkdir -p /etc/pki/tls/certs
|
||||
cat /tls/*.pem > /etc/pki/tls/certs/ca-bundle.crt
|
||||
TRIES=0
|
||||
touch /etc/confluent/confluent.info
|
||||
TRIES=5
|
||||
echo -n "Waitiing for disks..."
|
||||
while [ ! -e /dev/disk/by-label ] && [ $TRIES -gt 0 ]; do
|
||||
sleep 1
|
||||
TRIES=$((TRIES - 1))
|
||||
done
|
||||
echo "Done"
|
||||
if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then
|
||||
mkdir -p /media/ident
|
||||
mount /dev/disk/by-label/CNFLNT_IDNT /media/ident
|
||||
if [ -e /media/ident/genesis_bootstrap.sh ]; then
|
||||
exec sh /media/ident/genesis_bootstrap.sh
|
||||
exec bash /media/ident/genesis_bootstrap.sh
|
||||
fi
|
||||
fi
|
||||
if [ -e /dev/disk/by-label/GENESIS-X86 ]; then
|
||||
mkdir -p /media/genesis
|
||||
mount /dev/disk/by-label/GENESIS-X86 /media/genesis
|
||||
if [ -e /media/genesis/genesis_bootstrap.sh ]; then
|
||||
exec sh /media/genesis/genesis_bootstrap.sh
|
||||
exec bash /media/genesis/genesis_bootstrap.sh
|
||||
fi
|
||||
fi
|
||||
cd /sys/class/net
|
||||
echo -n "Scanning for network configuration..."
|
||||
while ! grep ^EXTMGRINFO: /etc/confluent/confluent.info | awk -F'|' '{print $3}' | grep 1 >& /dev/null && [ "$TRIES" -lt 30 ]; do
|
||||
if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then
|
||||
echo ""
|
||||
echo "Media bootstrap detected, switching to media based boot"
|
||||
mkdir -p /media/ident
|
||||
mount /dev/disk/by-label/CNFLNT_IDNT /media/ident
|
||||
if [ -e /media/ident/genesis_bootstrap.sh ]; then
|
||||
exec bash /media/ident/genesis_bootstrap.sh
|
||||
fi
|
||||
fi
|
||||
if [ -e /dev/disk/by-label/GENESIS-X86 ]; then
|
||||
echo ""
|
||||
echo "Media bootstrap detected, switching to media based boot"
|
||||
mkdir -p /media/genesis
|
||||
mount /dev/disk/by-label/GENESIS-X86 /media/genesis
|
||||
if [ -e /media/genesis/genesis_bootstrap.sh ]; then
|
||||
exec bash /media/genesis/genesis_bootstrap.sh
|
||||
fi
|
||||
fi
|
||||
TRIES=$((TRIES + 1))
|
||||
for i in *; do
|
||||
ip link set $i up
|
||||
|
||||
@@ -2,15 +2,17 @@ root=1
|
||||
rootok=1
|
||||
netroot=genesis
|
||||
clear
|
||||
mount -t cgroup2 cgroup2 /sys/fs/cgroup
|
||||
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
|
||||
echo PS1="'"'[genesis running on \H \w]$ '"'" >> ~/.bashrc
|
||||
echo PS1="'"'[genesis running on \H \w]$ '"'" >> ~/.bash_profile
|
||||
mkdir -p /etc/ssh
|
||||
mkdir -p /var/tmp/
|
||||
mkdir -p /var/empty/sshd
|
||||
sed -i '/^root:x/d' /etc/passwd
|
||||
sed -i '/^root:/d' /etc/passwd
|
||||
echo root:x:0:0::/:/bin/bash >> /etc/passwd
|
||||
echo sshd:x:30:30:SSH User:/var/empty/sshd:/sbin/nologin >> /etc/passwd
|
||||
tmux new-session -d sh /opt/confluent/bin/rungenesis
|
||||
tmux new-session -d bash /opt/confluent/bin/rungenesis
|
||||
while :; do
|
||||
sleep 86400
|
||||
done
|
||||
|
||||
@@ -210,16 +210,28 @@ def set_port_tsm(s, port, model):
|
||||
|
||||
|
||||
def set_port_xcc(s, port, model):
|
||||
if '_' in port:
|
||||
port_type = port.split('_')[0]
|
||||
port_number = port.split('_')[1] # this could be the number or the form sfp28 || rj45
|
||||
port = port_type
|
||||
oport = port
|
||||
if port.lower() == 'dedicated':
|
||||
port = b'\x01'
|
||||
elif port.lower() in ('ml2', 'ocp'):
|
||||
port = b'\x02\x00'
|
||||
elif port.lower() == 'lom':
|
||||
if model == '7x58':
|
||||
port = b'\x00\x02'
|
||||
elif port.lower() == 'lom': # potentially have to change to port_form.lower() == 'sfp28 || or rj45 // if it is two port sfp28 it is usually the first port that is ncsi enabled'
|
||||
if port_number == '1' or port_number.lower() == 'sfp28':
|
||||
port = b'\x05\x00'
|
||||
elif port_number == '3' or port_number.lower() == 'rj45':
|
||||
if model == '7x58':
|
||||
port = b'\x00\x02'
|
||||
else:
|
||||
port = b'\x00\x00'
|
||||
else:
|
||||
port = b'\x00\x00'
|
||||
if model == '7x58':
|
||||
port = b'\x00\x02'
|
||||
else:
|
||||
port = b'\x00\x00'
|
||||
else:
|
||||
port = port.split(' ')
|
||||
port = bytes(bytearray([int(x) for x in port]))
|
||||
|
||||
@@ -23,6 +23,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export nodename confluent_mgr confluent_profile
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
# present
|
||||
run_remote_python syncfileclient
|
||||
|
||||
run_remote_parts onboot.d
|
||||
|
||||
|
||||
# Induce execution of remote configuration, e.g. ansible plays in ansible/onboot.d/
|
||||
run_remote_config onboot
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -140,4 +140,5 @@ mv /lib/modules/$(uname -r) /lib/modules/$(uname -r)-ramfs
|
||||
ln -s /sysroot/lib/modules/$(uname -r) /lib/modules/
|
||||
mv /lib/firmware /lib/firmware-ramfs
|
||||
ln -s /sysroot/lib/firmware /lib/firmware
|
||||
chroot /sysroot chkstat --system --set --noheader > /dev/null
|
||||
exec /opt/confluent/bin/start_root
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
+19
-16
@@ -55,25 +55,28 @@ if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then
|
||||
if [ ! -z "$v4gw" ]; then
|
||||
setdebopt netcfg/get_gateway $v4gw string
|
||||
fi
|
||||
for NICGUESS in $(ip link|grep LOWER_UP|grep -v LOOPBACK|cut -d ' ' -f 2 | sed -e 's/:$//'); do
|
||||
ip addr add dev $NICGUESS $v4addr
|
||||
if [ ! -z "$v4gw" ]; then
|
||||
ip route add default via $v4gw
|
||||
fi
|
||||
for dsrv in $deploysrvs; do
|
||||
if wget https://$dsrv/confluent-public/ --tries=1 --timeout=1 -O /dev/null > /dev/null 2>&1; then
|
||||
deploysrvs=$dsrv
|
||||
NIC=$NICGUESS
|
||||
setdebopt netcfg/choose_interface $NIC select
|
||||
NIC=""
|
||||
while [ -z "$NIC" ]; do
|
||||
for NICGUESS in $(ip link|grep LOWER_UP|grep -v LOOPBACK|cut -d ' ' -f 2 | sed -e 's/:$//'); do
|
||||
ip addr add dev $NICGUESS $v4addr
|
||||
if [ ! -z "$v4gw" ]; then
|
||||
ip route add default via $v4gw
|
||||
fi
|
||||
for dsrv in $deploysrvs; do
|
||||
if wget https://$dsrv/confluent-public/ --tries=1 --timeout=1 -O /dev/null > /dev/null 2>&1; then
|
||||
deploysrvs=$dsrv
|
||||
NIC=$NICGUESS
|
||||
setdebopt netcfg/choose_interface $NIC select
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$NIC" ]; then
|
||||
ip -4 a flush dev $NICGUESS
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$NIC" ]; then
|
||||
ip -4 a flush dev $NICGUESS
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
#TODO: nameservers
|
||||
elif [ "$v4cfgmeth" = "dhcp" ]; then
|
||||
setdebopt netcfg/disable_dhcp false boolean
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -85,3 +85,4 @@ wget --header="CONFLUENT_NODENAME: $nodename" --header="CONFLUENT_APIKEY: $apike
|
||||
#curl -f https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/getinstalldisk > /tmp/getinstalldisk
|
||||
#python3 /tmp/getinstalldisk
|
||||
#sed -i s!%%INSTALLDISK%%!/dev/$(cat /tmp/installdisk)! /autoinstall.yaml
|
||||
umount /media
|
||||
|
||||
@@ -50,6 +50,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_mgr confluent_profile nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -1,72 +1,79 @@
|
||||
cd /sys/class/net
|
||||
cp /tls/* /etc/ssl/certs/
|
||||
for nic in *; do
|
||||
ip link set $nic up
|
||||
done
|
||||
mkdir -p /custom-installation
|
||||
cp -a /opt/confluent /custom-installation
|
||||
touch /custom-installation/confluent/confluent.info
|
||||
TRIES=5
|
||||
while [ ! -e /dev/disk/by-label ] && [ $TRIES -gt 0 ]; do
|
||||
sleep 2
|
||||
TRIES=$((TRIES - 1))
|
||||
done
|
||||
if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then
|
||||
tmnt=/tmp/idntmnt
|
||||
mkdir -p /tmp/identdata/
|
||||
mkdir -p $tmnt
|
||||
tcfg=/tmp/idnttmp
|
||||
mount /dev/disk/by-label/CNFLNT_IDNT $tmnt
|
||||
cp -a $tmnt/* /tmp/identdata/
|
||||
cd $tmnt
|
||||
deploysrvs=$(sed -n '/^deploy_servers:/,/^[^-]/p' cnflnt.yml |grep ^-|sed -e 's/^- //'|grep -v :)
|
||||
sed -n '/^net_cfgs:/,/^[^- ]/{/^[^- ]/!p}' cnflnt.yml |sed -n '/^-/,/^-/{/^-/!p}'| sed -e 's/^[- ]*//'> $tcfg
|
||||
autoconfigmethod=$(grep ^ipv4_method: $tcfg)
|
||||
autoconfigmethod=${autoconfigmethod#ipv4_method: }
|
||||
. /scripts/functions
|
||||
if [ "$autoconfigmethod" = "static" ]; then
|
||||
MYIP=$(grep ^ipv4_address: $tcfg | awk '{print $2}'|sed -e s'!/.*!!')
|
||||
v4addr=$(grep ^ipv4_address: $tcfg|cut -d: -f 2|sed -e 's/ //')
|
||||
MYGW=$(grep ^ipv4_gateway: $tcfg | awk '{print $2}')
|
||||
if [ "$MYGW" = "null" ]; then
|
||||
MYGW=""
|
||||
fi
|
||||
MYNM=$(grep ^ipv4_netmask: $tcfg | awk '{print $2}')
|
||||
for NICGUESS in $(ip link|grep LOWER_UP|grep -v LOOPBACK|cut -d ' ' -f 2 | sed -e 's/:$//'); do
|
||||
ip addr add dev $NICGUESS $v4addr
|
||||
if [ ! -z "$MYGW" ]; then
|
||||
ip route add default via $MYGW
|
||||
while ! grep NODENAME /custom-installation/confluent/confluent.info; do
|
||||
if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then
|
||||
tmnt=/tmp/idntmnt
|
||||
mkdir -p /tmp/identdata/
|
||||
mkdir -p $tmnt
|
||||
tcfg=/tmp/idnttmp
|
||||
mount /dev/disk/by-label/CNFLNT_IDNT $tmnt
|
||||
cp -a $tmnt/* /tmp/identdata/
|
||||
cd $tmnt
|
||||
deploysrvs=$(sed -n '/^deploy_servers:/,/^[^-]/p' cnflnt.yml |grep ^-|sed -e 's/^- //'|grep -v :)
|
||||
sed -n '/^net_cfgs:/,/^[^- ]/{/^[^- ]/!p}' cnflnt.yml |sed -n '/^-/,/^-/{/^-/!p}'| sed -e 's/^[- ]*//'> $tcfg
|
||||
autoconfigmethod=$(grep ^ipv4_method: $tcfg)
|
||||
autoconfigmethod=${autoconfigmethod#ipv4_method: }
|
||||
. /scripts/functions
|
||||
if [ "$autoconfigmethod" = "static" ]; then
|
||||
MYIP=$(grep ^ipv4_address: $tcfg | awk '{print $2}'|sed -e s'!/.*!!')
|
||||
v4addr=$(grep ^ipv4_address: $tcfg|cut -d: -f 2|sed -e 's/ //')
|
||||
MYGW=$(grep ^ipv4_gateway: $tcfg | awk '{print $2}')
|
||||
if [ "$MYGW" = "null" ]; then
|
||||
MYGW=""
|
||||
fi
|
||||
MYNM=$(grep ^ipv4_netmask: $tcfg | awk '{print $2}')
|
||||
NIC=""
|
||||
while [ -z "$NIC" ]; do
|
||||
for NICGUESS in $(ip link|grep LOWER_UP|grep -v LOOPBACK|cut -d ' ' -f 2 | sed -e 's/:$//'); do
|
||||
ip addr add dev $NICGUESS $v4addr
|
||||
if [ ! -z "$MYGW" ]; then
|
||||
ip route add default via $MYGW
|
||||
fi
|
||||
for dsrv in $deploysrvs; do
|
||||
if openssl s_client -connect $dsrv:443 > /dev/null 2>&1; then
|
||||
deploysrvs=$dsrv
|
||||
NIC=$NICGUESS
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$NIC" ]; then
|
||||
ip -4 a flush dev $NICGUESS
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
ipconfig -d $MYIP::$MYGW:$MYNM::$NIC
|
||||
echo $NIC > /tmp/autodetectnic
|
||||
else
|
||||
configure_networking
|
||||
for dsrv in $deploysrvs; do
|
||||
if openssl s_client -connect $dsrv:443 > /dev/null 2>&1; then
|
||||
deploysrvs=$dsrv
|
||||
NIC=$NICGUESS
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$NIC" ]; then
|
||||
ip -4 a flush dev $NICGUESS
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
ipconfig -d $MYIP::$MYGW:$MYNM::$NIC
|
||||
echo $NIC > /tmp/autodetectnic
|
||||
fi
|
||||
MGR=$deploysrvs
|
||||
NODENAME=$(grep ^nodename: /tmp/idntmnt/cnflnt.yml | awk '{print $2}')
|
||||
echo "NODENAME: $NODENAME" >> /custom-installation/confluent/confluent.info
|
||||
echo "MANAGER: $MGR" >> /custom-installation/confluent/confluent.info
|
||||
echo "EXTMGRINFO: $MGR||1" >> /custom-installation/confluent/confluent.info
|
||||
hmackeyfile=/tmp/cnflnthmackeytmp
|
||||
echo -n $(grep ^apitoken: cnflnt.yml|awk '{print $2}') > $hmackeyfile
|
||||
cd -
|
||||
umount $tmnt
|
||||
else
|
||||
configure_networking
|
||||
fi
|
||||
MGR=$deploysrvs
|
||||
NODENAME=$(grep ^nodename: /tmp/idntmnt/cnflnt.yml | awk '{print $2}')
|
||||
echo "NODENAME: $NODENAME" >> /custom-installation/confluent/confluent.info
|
||||
echo "MANAGER: $MGR" >> /custom-installation/confluent/confluent.info
|
||||
echo "EXTMGRINFO: $MGR||1" >> /custom-installation/confluent/confluent.info
|
||||
hmackeyfile=/tmp/cnflnthmackeytmp
|
||||
echo -n $(grep ^apitoken: cnflnt.yml|awk '{print $2}') > $hmackeyfile
|
||||
cd -
|
||||
umount $tmnt
|
||||
else
|
||||
while ! grep NODENAME /custom-installation/confluent/confluent.info; do
|
||||
/opt/confluent/bin/copernicus -t > /custom-installation/confluent/confluent.info
|
||||
done
|
||||
fi
|
||||
done
|
||||
if [ -z "$MGR" ]; then
|
||||
MGR="[$(grep MANAGER: /custom-installation/confluent/confluent.info | head -n 1 | awk '{print $2}')]"
|
||||
fi
|
||||
osprofile=$(sed -e 's/.*osprofile=//' -e 's/ .*//' /proc/cmdline)
|
||||
@@ -79,8 +86,25 @@ if [ ! -z "$cons" ]; then
|
||||
fi
|
||||
echo "Preparing to deploy $osprofile from $MGR"
|
||||
echo $osprofile > /custom-installation/confluent/osprofile
|
||||
echo URL=http://${MGR}/confluent-public/os/$osprofile/distribution/install.iso >> /conf/param.conf
|
||||
fcmdline="$(cat /custom-installation/confluent/cmdline.orig) url=http://${MGR}/confluent-public/os/$osprofile/distribution/install.iso"
|
||||
mv /usr/bin/openssl /usr/bin/ossl
|
||||
cat > /usr/bin/openssl << 'EOF'
|
||||
#!/bin/sh
|
||||
AMENDARGS=0
|
||||
nargs=""
|
||||
for arg in $*; do
|
||||
if [ "$arg" == "-servername" -o "$arg" == "-verify" ]; then
|
||||
AMENDARGS=1
|
||||
fi
|
||||
if [ "$AMENDARGS" == "1" ]; then
|
||||
arg=$(echo $arg|sed -e 's/:443$//' -e 's/\[//' -e 's/\]//' -e 's/%.*//')
|
||||
fi
|
||||
nargs="$nargs $arg"
|
||||
done
|
||||
exec /usr/bin/ossl $nargs
|
||||
EOF
|
||||
chmod +x /usr/bin/openssl
|
||||
echo URL=https://${MGR}:443/confluent-public/os/$osprofile/distribution/install.iso >> /conf/param.conf
|
||||
fcmdline="$(cat /custom-installation/confluent/cmdline.orig) url=https://${MGR}:443/confluent-public/os/$osprofile/distribution/install.iso"
|
||||
if [ ! -z "$cons" ]; then
|
||||
fcmdline="$fcmdline console=${cons#/dev/}"
|
||||
fi
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -28,7 +28,15 @@ if [ -e /tmp/cnflnthmackeytmp ]; then
|
||||
DEVICE=$(cat /tmp/autodetectnic)
|
||||
IP=done
|
||||
else
|
||||
APIKEY=
|
||||
chroot . custom-installation/confluent/bin/clortho $NODENAME $MGR > /root/custom-installation/confluent/confluent.apikey
|
||||
APIKEY=$(cat /root/custom-installation/confluent/confluent.apikey)
|
||||
while [ -z "$APIKEY" ]; do
|
||||
echo "Failure trying to get confluent node token registered, check nodedeploy status, retrying in 5 seconds..."
|
||||
sleep 5
|
||||
chroot . custom-installation/confluent/bin/clortho $NODENAME $MGR > /root/custom-installation/confluent/confluent.apikey
|
||||
APIKEY=$(cat /root/custom-installation/confluent/confluent.apikey)
|
||||
done
|
||||
MGR=[$MGR]
|
||||
nic=$(grep ^MANAGER /custom-installation/confluent/confluent.info|grep fe80::|sed -e s/.*%//|head -n 1)
|
||||
nic=$(ip link |grep ^$nic:|awk '{print $2}')
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
cp /tls/* /etc/ssl/certs/
|
||||
cd /sys/class/net
|
||||
for nic in *; do
|
||||
ip link set $nic up
|
||||
@@ -5,68 +6,75 @@ done
|
||||
mkdir -p /custom-installation
|
||||
cp -a /opt/confluent /custom-installation
|
||||
touch /custom-installation/confluent/confluent.info
|
||||
TRIES=5
|
||||
while [ ! -e /dev/disk/by-label ] && [ $TRIES -gt 0 ]; do
|
||||
sleep 2
|
||||
TRIES=$((TRIES - 1))
|
||||
done
|
||||
if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then
|
||||
tmnt=/tmp/idntmnt
|
||||
mkdir -p /tmp/identdata/
|
||||
mkdir -p $tmnt
|
||||
tcfg=/tmp/idnttmp
|
||||
mount /dev/disk/by-label/CNFLNT_IDNT $tmnt
|
||||
cp -a $tmnt/* /tmp/identdata/
|
||||
cd $tmnt
|
||||
deploysrvs=$(sed -n '/^deploy_servers:/,/^[^-]/p' cnflnt.yml |grep ^-|sed -e 's/^- //'|grep -v :)
|
||||
sed -n '/^net_cfgs:/,/^[^- ]/{/^[^- ]/!p}' cnflnt.yml |sed -n '/^-/,/^-/{/^-/!p}'| sed -e 's/^[- ]*//'> $tcfg
|
||||
autoconfigmethod=$(grep ^ipv4_method: $tcfg)
|
||||
autoconfigmethod=${autoconfigmethod#ipv4_method: }
|
||||
. /scripts/functions
|
||||
if [ "$autoconfigmethod" = "static" ]; then
|
||||
MYIP=$(grep ^ipv4_address: $tcfg | awk '{print $2}'|sed -e s'!/.*!!')
|
||||
v4addr=$(grep ^ipv4_address: $tcfg|cut -d: -f 2|sed -e 's/ //')
|
||||
MYGW=$(grep ^ipv4_gateway: $tcfg | awk '{print $2}')
|
||||
if [ "$MYGW" = "null" ]; then
|
||||
MYGW=""
|
||||
fi
|
||||
MYNM=$(grep ^ipv4_netmask: $tcfg | awk '{print $2}')
|
||||
for NICGUESS in $(ip link|grep LOWER_UP|grep -v LOOPBACK|cut -d ' ' -f 2 | sed -e 's/:$//'); do
|
||||
ip addr add dev $NICGUESS $v4addr
|
||||
if [ ! -z "$MYGW" ]; then
|
||||
ip route add default via $MYGW
|
||||
MGR=""
|
||||
while ! grep NODENAME /custom-installation/confluent/confluent.info; do
|
||||
if [ -e /dev/disk/by-label/CNFLNT_IDNT ]; then
|
||||
tmnt=/tmp/idntmnt
|
||||
mkdir -p /tmp/identdata/
|
||||
mkdir -p $tmnt
|
||||
tcfg=/tmp/idnttmp
|
||||
mount /dev/disk/by-label/CNFLNT_IDNT $tmnt
|
||||
cp -a $tmnt/* /tmp/identdata/
|
||||
cd $tmnt
|
||||
deploysrvs=$(sed -n '/^deploy_servers:/,/^[^-]/p' cnflnt.yml |grep ^-|sed -e 's/^- //'|grep -v :)
|
||||
sed -n '/^net_cfgs:/,/^[^- ]/{/^[^- ]/!p}' cnflnt.yml |sed -n '/^-/,/^-/{/^-/!p}'| sed -e 's/^[- ]*//'> $tcfg
|
||||
autoconfigmethod=$(grep ^ipv4_method: $tcfg)
|
||||
autoconfigmethod=${autoconfigmethod#ipv4_method: }
|
||||
. /scripts/functions
|
||||
if [ "$autoconfigmethod" = "static" ]; then
|
||||
MYIP=$(grep ^ipv4_address: $tcfg | awk '{print $2}'|sed -e s'!/.*!!')
|
||||
v4addr=$(grep ^ipv4_address: $tcfg|cut -d: -f 2|sed -e 's/ //')
|
||||
MYGW=$(grep ^ipv4_gateway: $tcfg | awk '{print $2}')
|
||||
if [ "$MYGW" = "null" ]; then
|
||||
MYGW=""
|
||||
fi
|
||||
MYNM=$(grep ^ipv4_netmask: $tcfg | awk '{print $2}')
|
||||
NIC=""
|
||||
while [ -z "$NIC" ]; do
|
||||
for NICGUESS in $(ip link|grep LOWER_UP|grep -v LOOPBACK|cut -d ' ' -f 2 | sed -e 's/:$//'); do
|
||||
ip addr add dev $NICGUESS $v4addr
|
||||
if [ ! -z "$MYGW" ]; then
|
||||
ip route add default via $MYGW
|
||||
fi
|
||||
for dsrv in $deploysrvs; do
|
||||
if openssl s_client -connect $dsrv:443 > /dev/null 2>&1; then
|
||||
deploysrvs=$dsrv
|
||||
NIC=$NICGUESS
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$NIC" ]; then
|
||||
ip -4 a flush dev $NICGUESS
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
done
|
||||
ipconfig -d $MYIP::$MYGW:$MYNM::$NIC
|
||||
echo $NIC > /tmp/autodetectnic
|
||||
else
|
||||
configure_networking
|
||||
for dsrv in $deploysrvs; do
|
||||
if openssl s_client -connect $dsrv:443 > /dev/null 2>&1; then
|
||||
deploysrvs=$dsrv
|
||||
NIC=$NICGUESS
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$NIC" ]; then
|
||||
ip -4 a flush dev $NICGUESS
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
ipconfig -d $MYIP::$MYGW:$MYNM::$NIC
|
||||
echo $NIC > /tmp/autodetectnic
|
||||
fi
|
||||
MGR=$deploysrvs
|
||||
NODENAME=$(grep ^nodename: /tmp/idntmnt/cnflnt.yml | awk '{print $2}')
|
||||
echo "NODENAME: $NODENAME" >> /custom-installation/confluent/confluent.info
|
||||
echo "MANAGER: $MGR" >> /custom-installation/confluent/confluent.info
|
||||
echo "EXTMGRINFO: $MGR||1" >> /custom-installation/confluent/confluent.info
|
||||
hmackeyfile=/tmp/cnflnthmackeytmp
|
||||
echo -n $(grep ^apitoken: cnflnt.yml|awk '{print $2}') > $hmackeyfile
|
||||
cd -
|
||||
umount $tmnt
|
||||
else
|
||||
configure_networking
|
||||
fi
|
||||
MGR=$deploysrvs
|
||||
NODENAME=$(grep ^nodename: /tmp/idntmnt/cnflnt.yml | awk '{print $2}')
|
||||
echo "NODENAME: $NODENAME" >> /custom-installation/confluent/confluent.info
|
||||
echo "MANAGER: $MGR" >> /custom-installation/confluent/confluent.info
|
||||
echo "EXTMGRINFO: $MGR||1" >> /custom-installation/confluent/confluent.info
|
||||
hmackeyfile=/tmp/cnflnthmackeytmp
|
||||
echo -n $(grep ^apitoken: cnflnt.yml|awk '{print $2}') > $hmackeyfile
|
||||
cd -
|
||||
umount $tmnt
|
||||
else
|
||||
while ! grep NODENAME /custom-installation/confluent/confluent.info; do
|
||||
/opt/confluent/bin/copernicus -t > /custom-installation/confluent/confluent.info
|
||||
done
|
||||
fi
|
||||
done
|
||||
if [ -z "$MGR" ]; then
|
||||
MGR="[$(grep MANAGER: /custom-installation/confluent/confluent.info | head -n 1 | awk '{print $2}')]"
|
||||
fi
|
||||
osprofile=$(sed -e 's/.*osprofile=//' -e 's/ .*//' /proc/cmdline)
|
||||
@@ -82,8 +90,25 @@ echo $osprofile > /custom-installation/confluent/osprofile
|
||||
. /etc/os-release
|
||||
DIRECTISO=$(blkid -t TYPE=iso9660 |grep -Ei ' LABEL="Ubuntu-Server '$VERSION_ID)
|
||||
if [ -z "$DIRECTISO" ]; then
|
||||
echo URL=http://${MGR}/confluent-public/os/$osprofile/distribution/install.iso >> /conf/param.conf
|
||||
fcmdline="$(cat /custom-installation/confluent/cmdline.orig) url=http://${MGR}/confluent-public/os/$osprofile/distribution/install.iso"
|
||||
mv /usr/bin/openssl /usr/bin/ossl
|
||||
cat > /usr/bin/openssl << 'EOF'
|
||||
#!/bin/sh
|
||||
AMENDARGS=0
|
||||
nargs=""
|
||||
for arg in $*; do
|
||||
if [ "$arg" == "-servername" -o "$arg" == "-verify" ]; then
|
||||
AMENDARGS=1
|
||||
fi
|
||||
if [ "$AMENDARGS" == "1" ]; then
|
||||
arg=$(echo $arg|sed -e 's/:443$//' -e 's/\[//' -e 's/\]//' -e 's/%.*//')
|
||||
fi
|
||||
nargs="$nargs $arg"
|
||||
done
|
||||
exec /usr/bin/ossl $nargs
|
||||
EOF
|
||||
chmod +x /usr/bin/openssl
|
||||
echo URL=https://${MGR}:443/confluent-public/os/$osprofile/distribution/install.iso >> /conf/param.conf
|
||||
fcmdline="$(cat /custom-installation/confluent/cmdline.orig) url=https://${MGR}:443/confluent-public/os/$osprofile/distribution/install.iso"
|
||||
fi
|
||||
if [ ! -z "$cons" ]; then
|
||||
fcmdline="$fcmdline console=${cons#/dev/}"
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
#cloud-config
|
||||
autoinstall:
|
||||
# The following can help an Ubuntu system skip install-time updates
|
||||
# Only uncomment if you know you really want to do this or plan to manage the updates
|
||||
# a different way.
|
||||
#
|
||||
# updates: security
|
||||
# apt:
|
||||
# disable_suites: [security]
|
||||
# fallback: offline-install
|
||||
version: 1
|
||||
early-commands:
|
||||
- /custom-installation/pre.sh
|
||||
|
||||
@@ -53,6 +53,7 @@ function set_confluent_vars() {
|
||||
if [ -z "$confluent_profile" ]; then
|
||||
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
||||
fi
|
||||
export confluent_profile confluent_mgr nodename
|
||||
}
|
||||
|
||||
fetch_remote() {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#!/usr/bin/python3
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
@@ -10,8 +11,9 @@ class DiskInfo(object):
|
||||
self.path = None
|
||||
self.model = ''
|
||||
self.size = 0
|
||||
self.driver = None
|
||||
self.driver = ''
|
||||
self.mdcontainer = ''
|
||||
self.subsystype = ''
|
||||
devnode = '/dev/{0}'.format(devname)
|
||||
qprop = subprocess.check_output(
|
||||
['udevadm', 'info', '--query=property', devnode])
|
||||
@@ -46,7 +48,9 @@ class DiskInfo(object):
|
||||
elif (k == 'DRIVERS' and not self.driver
|
||||
and v not in ('"sd"', '""')):
|
||||
self.driver = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer:
|
||||
elif k == 'ATTRS{subsystype}':
|
||||
self.subsystype = v.replace('"', '')
|
||||
if not self.driver and 'imsm' not in self.mdcontainer and self.subsystype != 'nvm':
|
||||
raise Exception("No driver detected")
|
||||
if os.path.exists('/sys/block/{0}/size'.format(self.name)):
|
||||
with open('/sys/block/{0}/size'.format(self.name), 'r') as sizesrc:
|
||||
|
||||
@@ -84,6 +84,10 @@ cat /target/etc/confluent/tls/*.pem > /target/etc/confluent/ca.pem
|
||||
cat /target/etc/confluent/tls/*.pem > /target/usr/local/share/ca-certificates/confluent.crt
|
||||
cat /target/etc/confluent/tls/*.pem > /etc/confluent/ca.pem
|
||||
chroot /target update-ca-certificates
|
||||
|
||||
# Ubuntu mangles grub function for serial users, undo that mangling
|
||||
chroot /target bash -c "source /etc/confluent/functions; run_remote_python autoconsole"
|
||||
|
||||
chroot /target bash -c "source /etc/confluent/functions; run_remote_python syncfileclient"
|
||||
chroot /target bash -c "source /etc/confluent/functions; run_remote_python confignet"
|
||||
chroot /target bash -c "source /etc/confluent/functions; run_remote_parts post.d"
|
||||
|
||||
@@ -246,6 +246,6 @@ int main(int argc, char* argv[]) {
|
||||
buffer[0] = 255;
|
||||
ret = read(sock, buffer, 2);
|
||||
}
|
||||
fprintf(stderr, "Password was not accepted\n");
|
||||
fprintf(stderr, "Confluent API token grant denied by server\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
all: confusebox
|
||||
|
||||
confusebox: *.go
|
||||
go build -ldflags "-w -s" -gcflags=all="-l" -trimpath
|
||||
upx --brute confusebox
|
||||
|
||||
clean:
|
||||
rm confusebox
|
||||
@@ -0,0 +1,134 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"net/http"
|
||||
"crypto/x509"
|
||||
"crypto/tls"
|
||||
"strings"
|
||||
"errors"
|
||||
)
|
||||
type ApiClient struct {
|
||||
server string
|
||||
urlserver string
|
||||
apikey string
|
||||
nodename string
|
||||
webclient *http.Client
|
||||
}
|
||||
|
||||
func NewApiClient(cafile string, keyfile string, nodename string, server string) (*ApiClient, error) {
|
||||
currcacerts, err := os.ReadFile(cafile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cacerts := x509.NewCertPool()
|
||||
cacerts.AppendCertsFromPEM(currcacerts)
|
||||
apikey := []byte("")
|
||||
if keyfile != "" {
|
||||
apikey, err = os.ReadFile(keyfile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if apikey[len(apikey) - 1] == 0xa {
|
||||
apikey = apikey[:len(apikey)-1]
|
||||
}
|
||||
}
|
||||
if nodename == "" {
|
||||
cinfo, err := os.ReadFile("/etc/confluent/confliuent.info")
|
||||
if err != nil {
|
||||
nodename, err = os.Hostname()
|
||||
if err != nil { return nil, err }
|
||||
}
|
||||
cinfolines := bytes.Split(cinfo, []byte("\n"))
|
||||
if bytes.Contains(cinfolines[0], []byte("NODENAME")) {
|
||||
cnodebytes := bytes.Split(cinfolines[0], []byte(" "))
|
||||
nodename = string(cnodebytes[0])
|
||||
}
|
||||
}
|
||||
urlserver := server
|
||||
if strings.Contains(server, ":") {
|
||||
if strings.Contains(server, "%") && !strings.Contains(server, "%25") {
|
||||
server = strings.Replace(server, "%", "%25", 1)
|
||||
}
|
||||
urlserver = fmt.Sprintf("[%s]", server)
|
||||
if strings.Contains(server, "%") {
|
||||
server = server[:strings.Index(server, "%")]
|
||||
}
|
||||
}
|
||||
webclient := &http.Client{
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
RootCAs: cacerts,
|
||||
ServerName: server,
|
||||
},
|
||||
},
|
||||
}
|
||||
vc := ApiClient{server, urlserver, string(apikey), nodename, webclient}
|
||||
return &vc, nil
|
||||
}
|
||||
|
||||
func (apiclient *ApiClient) RegisterKey(crypted string, hmac string) (error) {
|
||||
cryptbytes := []byte(crypted)
|
||||
cryptbuffer := bytes.NewBuffer(cryptbytes)
|
||||
_, err := apiclient.request("/confluent-api/self/registerapikey", "", cryptbuffer, "", hmac)
|
||||
return err
|
||||
}
|
||||
|
||||
func (apiclient *ApiClient) Fetch(url string, outputfile string, mime string, body io.Reader) (error) {
|
||||
outp, err := os.Create(outputfile)
|
||||
if err != nil { return err }
|
||||
defer outp.Close()
|
||||
rsp, err := apiclient.request(url, mime, body, "", "")
|
||||
if err != nil { return err }
|
||||
_, err = io.Copy(outp, rsp)
|
||||
return err
|
||||
}
|
||||
|
||||
func (apiclient *ApiClient) GrabText(url string, mime string, body io.Reader) (string, error){
|
||||
rsp, err := apiclient.request(url, mime, body, "", "")
|
||||
if err != nil { return "", err }
|
||||
rspdata, err := io.ReadAll(rsp)
|
||||
if err != nil { return "", err }
|
||||
rsptxt := string(rspdata)
|
||||
return rsptxt, nil
|
||||
}
|
||||
|
||||
func (apiclient *ApiClient) request(url string, mime string, body io.Reader, method string, hmac string) (io.ReadCloser, error) {
|
||||
if ! strings.Contains(url, "https://") {
|
||||
url = fmt.Sprintf("https://%s%s", apiclient.urlserver, url)
|
||||
}
|
||||
if method == "" {
|
||||
if body != nil {
|
||||
method = http.MethodPost
|
||||
} else {
|
||||
method = http.MethodGet
|
||||
}
|
||||
}
|
||||
var err error
|
||||
var rq *http.Request
|
||||
if body == nil {
|
||||
rq, err = http.NewRequest(method, url, nil)
|
||||
} else {
|
||||
rq, err = http.NewRequest(method, url, body)
|
||||
}
|
||||
if err != nil { return nil, err }
|
||||
if (mime != "") { rq.Header.Set("Accept", mime) }
|
||||
rq.Header.Set("CONFLUENT_NODENAME", apiclient.nodename)
|
||||
if len(hmac) > 0 {
|
||||
rq.Header.Set("CONFLUENT_CRYPTHMAC", hmac)
|
||||
} else {
|
||||
|
||||
rq.Header.Set("CONFLUENT_APIKEY", apiclient.apikey)
|
||||
}
|
||||
rsp, err := apiclient.webclient.Do(rq)
|
||||
if err != nil { return nil, err }
|
||||
if rsp.StatusCode >= 300 {
|
||||
err = errors.New(rsp.Status)
|
||||
return nil, err
|
||||
}
|
||||
return rsp.Body, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/go-crypt/crypt/algorithm/shacrypt"
|
||||
"os"
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
)
|
||||
|
||||
func genpasshmac(hmackeyfile string) (string, string, string, error) {
|
||||
randbytes := make([]byte, 36)
|
||||
_, err := rand.Read(randbytes)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
password := base64.StdEncoding.EncodeToString(randbytes)
|
||||
hasher, err := shacrypt.New(shacrypt.WithVariant(shacrypt.VariantSHA256), shacrypt.WithIterations(5000))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
digest, err := hasher.Hash(password)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cryptpass := digest.Encode()
|
||||
hmackey, err := os.ReadFile(hmackeyfile)
|
||||
if err != nil { return "", "", "", err }
|
||||
keylines := bytes.Split(hmackey, []byte("\n"))
|
||||
if bytes.Contains(keylines[0], []byte("apitoken:")) {
|
||||
keyparts := bytes.Split(keylines[0], []byte(" "))
|
||||
hmackey = keyparts[1]
|
||||
}
|
||||
|
||||
hmacer := hmac.New(sha256.New, hmackey)
|
||||
hmacer.Write([]byte(cryptpass))
|
||||
hmacresult := hmacer.Sum(nil)
|
||||
hmacout := base64.StdEncoding.EncodeToString(hmacresult)
|
||||
return password, cryptpass, hmacout, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
module confusebox
|
||||
|
||||
go 1.23.6
|
||||
|
||||
require github.com/go-crypt/crypt v0.3.3
|
||||
|
||||
require github.com/go-crypt/x v0.3.4 // indirect
|
||||
@@ -0,0 +1,4 @@
|
||||
github.com/go-crypt/crypt v0.3.3 h1:mBSh8U+vwDm3V+UHNMQqsxV0clzlvKbLcJXcafYFpCs=
|
||||
github.com/go-crypt/crypt v0.3.3/go.mod h1:ex5C1b58/tzCW6/rJfcdf5Y2TjgzmWVtX57sjpN3pUQ=
|
||||
github.com/go-crypt/x v0.3.4 h1:zgpaI55VOAbkkRup9+tLaZ02IWTV/xz63tohoY0t9+Y=
|
||||
github.com/go-crypt/x v0.3.4/go.mod h1:+uHWqfzD3S6YWxm18/Qp+4VcuBb0Le9dGUhX0zaWicU=
|
||||
@@ -0,0 +1,110 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"os"
|
||||
"io"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func get_confluent_server() (string, error) {
|
||||
var confluentsrv string
|
||||
dcfg, err := os.ReadFile("/etc/confluent/confluent.deploycfg")
|
||||
if err == nil {
|
||||
dcfglines := bytes.Split(dcfg, []byte("\n"))
|
||||
for _, dcfgline := range(dcfglines) {
|
||||
dkeyval := bytes.Split(dcfgline, []byte(" "))
|
||||
if bytes.Contains(dkeyval[0], []byte("deploy_server")) && (bytes.Contains(dkeyval[1], []byte(".")) || bytes.Contains(dkeyval[1], []byte(":"))) {
|
||||
confluentsrv = string(dkeyval[1])
|
||||
return confluentsrv, nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_, err := os.ReadFile("/etc/confluent/confluent.info")
|
||||
if err != nil {
|
||||
return "Unable to determine Confluent server", err
|
||||
}
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
func main() {
|
||||
var nodename string
|
||||
var cacerts string
|
||||
var apikey string
|
||||
var usejson bool
|
||||
var confluentsrv string
|
||||
hmacreg := flag.NewFlagSet("hmacregister", flag.ExitOnError)
|
||||
hmacreg.StringVar(&apikey, "k", "/etc/confluent/apikey", "Output file for the api key")
|
||||
hmacKey := hmacreg.String("i", "", "Identity yaml file")
|
||||
hmacreg.StringVar(&cacerts, "c", "/etc/confluent/ca.pem", "Certeficate authorities to use in PEM")
|
||||
hmacreg.StringVar(&nodename, "n", "", "Node name")
|
||||
hmacreg.StringVar(&confluentsrv, "s", "", "Confluent server to request from")
|
||||
|
||||
invokeapi := flag.NewFlagSet("invoke", flag.ExitOnError)
|
||||
invokeapi.StringVar(&nodename, "n", "", "Node name")
|
||||
|
||||
invokeapi.StringVar(&cacerts, "c", "/etc/confluent/ca.pem", "Certeficate authorities to use in PEM")
|
||||
invokeapi.StringVar(&apikey, "k", "/etc/confluent/confluent.apikey", "File containing Confluent API key")
|
||||
invokeapi.BoolVar(&usejson, "j", false, "Request JSON formatted reply")
|
||||
outputfile := invokeapi.String("o", "", "Filename to store download to")
|
||||
invokeapi.StringVar(&confluentsrv, "s", "", "Confluent server to request from")
|
||||
invokedata := invokeapi.String("d", "", "Data to submit")
|
||||
invokedatafile := invokeapi.String("i", "", "File containing data to submit")
|
||||
|
||||
|
||||
|
||||
if len(os.Args) < 2 {
|
||||
panic("Insufficient arguments, no subcommand")
|
||||
}
|
||||
switch os.Args[1] {
|
||||
case "hmacregister":
|
||||
var err error
|
||||
hmacreg.Parse(os.Args[2:])
|
||||
if confluentsrv == "" {
|
||||
confluentsrv, err = get_confluent_server()
|
||||
}
|
||||
password, crypted, hmac, err := genpasshmac(*hmacKey)
|
||||
if err != nil { panic(err) }
|
||||
//apiclient(cacerts, "/confluent-api/self/registerapikey", apikey, nodename, usejson)
|
||||
apiclient, err := NewApiClient(cacerts, "", nodename, confluentsrv)
|
||||
if err != nil { panic(err) }
|
||||
err = apiclient.RegisterKey(crypted, hmac)
|
||||
if err != nil { panic(err) }
|
||||
outp, err := os.Create(apikey)
|
||||
if err != nil { panic(err) }
|
||||
defer outp.Close()
|
||||
outp.Write([]byte(password))
|
||||
case "invoke":
|
||||
var err error
|
||||
var body io.Reader
|
||||
body = nil
|
||||
invokeapi.Parse(os.Args[2:])
|
||||
if *invokedata != "" {
|
||||
body = bytes.NewBuffer([]byte(*invokedata))
|
||||
}
|
||||
if *invokedatafile != "" {
|
||||
body, err = os.Open(*invokedatafile)
|
||||
if err != nil { panic(err) }
|
||||
}
|
||||
if confluentsrv == "" {
|
||||
confluentsrv, err = get_confluent_server()
|
||||
}
|
||||
apiclient, err := NewApiClient(cacerts, apikey, nodename, confluentsrv)
|
||||
if err != nil { panic(err) }
|
||||
mime := ""
|
||||
if usejson {
|
||||
mime = "application/json"
|
||||
}
|
||||
if *outputfile != "" {
|
||||
err := apiclient.Fetch(invokeapi.Arg(0), *outputfile, mime, body)
|
||||
if err != nil { panic(err) }
|
||||
} else {
|
||||
rsp, err := apiclient.GrabText(invokeapi.Arg(0), mime, body)
|
||||
if err != nil { panic(err) }
|
||||
fmt.Println(rsp)
|
||||
}
|
||||
default:
|
||||
panic("Unrecognized subcommand")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
module confluentapiclient
|
||||
|
||||
go 1.22
|
||||
|
||||
toolchain go1.23.6
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user