2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00

Draft work to flesh out profile and pull back

Fingerprint the target and prepare for more effort.

Will have another imgutil primitive for post-capture prep to get the
initramfs, kernel, rootimg, and bootloader content ready for copy.
This commit is contained in:
Jarrod Johnson 2021-07-20 17:02:08 -04:00
parent 2257a67420
commit cd8a1dfe5e
2 changed files with 30 additions and 7 deletions

View File

@ -4,7 +4,7 @@ dracut_install tpm2_create tpm2_pcrread tpm2_createpolicy tpm2_createprimary
dracut_install tpm2_load tpm2_unseal tpm2_getcap tpm2_evictcontrol
dracut_install tpm2_pcrextend tpm2_policypcr tpm2_flushcontext tpm2_startauthsession
dracut_install curl openssl tar cpio gzip lsmod ethtool xz lsmod ethtool
dracut_install modprobe touch echo cut wc bash netstat uniq grep ip hostname
dracut_install modprobe touch echo cut wc bash uniq grep ip hostname
dracut_install awk egrep dirname expr sort
dracut_install ssh sshd reboot parted mkfs mkfs.ext4 mkfs.xfs xfs_db mkswap
dracut_install efibootmgr uuidgen
@ -23,7 +23,7 @@ dracut_install losetup # multipart support
#this would be nfs with lock, but not needed, go nolock
#dracut_install mount.nfs rpcbind rpc.statd /etc/netconfig sm-notify
dracut_install mount.nfs /etc/netconfig
#dracut_install mount.nfs /etc/netconfig
inst /usr/lib/dracut/modules.d/40network/net-lib.sh /lib/net-lib.sh

View File

@ -125,11 +125,6 @@ def capture_remote(opts, args):
outdir = args[1]
if '/' not in outdir:
outdir = os.path.join('/var/lib/confluent/public/os/', outdir)
mkdirp(os.path.join(outdir, 'boot/efi/boot'))
mkdirp(os.path.join(outdir, 'boot/initramfs/'))
profname = os.path.basename(outdir)
os.symlink('/var/lib/confluent/public/site/initramfs.cpio',
os.path.join(outdir, 'boot/initramfs/site.cpio'))
# need kernel, initramfs, shim, grub
# maybe break pack_image into three, one that is common to call
# with here locally,
@ -139,11 +134,32 @@ def capture_remote(opts, args):
utillib = os.path.join(utillib, 'el8/dracut/')
subprocess.check_call(['ssh', targ, 'mkdir', '-p', '/run/imgutil/capenv'])
subprocess.check_call(['rsync', __file__, '{0}:/run/imgutil/capenv/'.format(targ)])
finfo = subprocess.check_output(['ssh', targ, 'python3', '/run/imgutil/capenv/imgutil', 'getfingerprint']).decode('utf8')
finfo = json.loads(finfo)
if finfo['oscategory'] != 'el8':
raise Exception('Not yet supported for capture: ' + repr(finfo))
oscat = finfo['oscategory']
subprocess.check_call(['ssh', '-t', targ, 'python3', '/run/imgutil/capenv/imgutil', 'capturelocal'])
subprocess.check_call(['rsync', '-a', utillib, '{0}:/usr/lib/dracut/modules.d/97imgutil'.format(targ)])
subprocess.check_call(['ssh', targ, 'chmod', '755', '/usr/lib/dracut/modules.d/97imgutil/install*'])
kernfile = subprocess.check_output(['ssh', targ, 'ls', '/boot/vmlinuz-$(uname -r)'])
subprocess.check_call(['ssh', targ, 'dracut', '-N', '--xz', '-m', '"imgutil base terminfo"', '/run/imgutil/capout/initramfs'])
# prep to receive result of above
mkdirp(os.path.join(outdir, 'boot/efi/boot'))
mkdirp(os.path.join(outdir, 'boot/initramfs/'))
profname = os.path.basename(outdir)
os.symlink('/var/lib/confluent/public/site/initramfs.cpio',
os.path.join(outdir, 'boot/initramfs/site.cpio'))
confdir = '/opt/confluent/lib/osdeploy/{}-diskless'.format(oscat)
os.symlink('{}/initramfs/addons.cpio'.format(confdir),
os.path.join(outdir, 'boot/initramfs/addons.cpio'))
if os.path.exists('{}/profiles/default'.format(confdir)):
copy_tree('{}/profiles/default'.format(confdir), outdir)
# now we need kernel, initramfs, rootimg.sfs, grub, and shim...
label = '{0} {1} ({2})'.format(finfo['name'], finfo['version'], profname)
@ -267,6 +283,11 @@ class OsHandler(object):
self.sourcepath = None
self.osname = '{}-{}-{}'.format(name, version, arch)
def get_json(self):
info = {'oscategory': self.oscategory,
'version': self.version, 'arch': self.arch, 'name': self.name}
return json.dumps(info)
def list_packages(self):
with open(os.path.join(get_mydir(self.oscategory), 'pkglist'), 'r') as pkglist:
pkgs = pkglist.read()
@ -439,6 +460,8 @@ def main():
build_root(opts, args[1:])
elif args[0] == 'capture':
capture_remote(opts, args[1:])
elif args[0] == 'getfingerprint':
print(fingerprint_host().get_json())
elif args[0] == 'capturelocal':
capture_system()
elif args[0] == 'exec':