diff --git a/confluent_client/confluent_env.sh b/confluent_client/confluent_env.sh index e5e241fb..41a4ba2d 100644 --- a/confluent_client/confluent_env.sh +++ b/confluent_client/confluent_env.sh @@ -156,7 +156,7 @@ _confluent_osimage_completion() { _confluent_get_args if [ $NUMARGS == 2 ]; then - COMPREPLY=($(compgen -W "initialize import importcheck updateboot rebase fetch" -- ${COMP_WORDS[COMP_CWORD]})) + COMPREPLY=($(compgen -W "initialize export import importcheck updateboot rebase fetch" -- ${COMP_WORDS[COMP_CWORD]})) return elif [ ${CMPARGS[1]} == 'initialize' ]; then COMPREPLY=($(compgen -W "-h -a -g -u -s -k -t -p -i -l -r" -- ${COMP_WORDS[COMP_CWORD]})) @@ -175,7 +175,16 @@ _confluent_osimage_completion() elif [ ${CMPARGS[1]} == 'updateboot' -o ${CMPARGS[1]} == 'rebase' ]; then COMPREPLY=($(compgen -W "-n $(confetty show /deployment/profiles|sed -e 's/\///')" -- "${COMP_WORDS[COMP_CWORD]}")) return + elif [ ${CMPARGS[1]} == 'export' ]; then + if [ $NUMARGS == 3 ]; then + COMPREPLY=($(compgen -W "-n $(confetty show /deployment/profiles|sed -e 's/\///')" -- "${COMP_WORDS[COMP_CWORD]}")) + return + fi + compopt -o dirnames + COMPREPLY=() + return fi + } _confluent_imgutil_completion() diff --git a/confluent_client/doc/man/osdeploy.ronn b/confluent_client/doc/man/osdeploy.ronn index 71720a1e..1d65f042 100644 --- a/confluent_client/doc/man/osdeploy.ronn +++ b/confluent_client/doc/man/osdeploy.ronn @@ -4,9 +4,10 @@ osdeploy(8) --- Configure general OS deployment facilities of confluent ## SYNOPSIS `osdeploy import ` +`osdeploy export ` `osdeploy updateboot ` `osdeploy rebase ` -`osdeploy initialize [-h] [-g] [-u] [-s] [-k] [-t] [-p] [-i] [-l] [-a]` +`osdeploy initialize [-h] [-g] [-u] [-s] [-k] [-t] [-p] [-i] [-l] [-a] [-r]` ## DESCRIPTION @@ -16,4 +17,9 @@ changes in the specified update that need to be pushed into boot configuration a and ensure those needed changes are performed. `initialize` provides assistance in setting up the most commonly required facilities. `rebase` has confluent attempt to update profile content that came from /opt/confluent in an rpm update, if profile supports it. -Run `osdeploy initialize -h` for more detail on the options offered by `osdeploy initialize`. \ No newline at end of file +Run `osdeploy initialize -h` for more detail on the options offered by `osdeploy initialize`. + +`export` takes the profile specified and creates a file suitable for import to another confluent server. +Note that this will not include the targets of symbolic links that go outside of the public or private profile date. +An export will include any sensitive data embedded in the image and the requisite private keys. This is only intended for +diskless and captured images. \ No newline at end of file diff --git a/confluent_server/bin/osdeploy b/confluent_server/bin/osdeploy index f9d3a6d1..4f0381f2 100644 --- a/confluent_server/bin/osdeploy +++ b/confluent_server/bin/osdeploy @@ -57,9 +57,13 @@ async def main(args): osip = sp.add_parser('import', help='Import an OS image from an ISO image') osip.add_argument('imagefile', help='File to use for source of importing') osip.add_argument('-n', help='Specific a custom distribution name') + fetchargs = sp.add_parser('fetch', help='Fetch an OS image from a remote source') fetchargs.add_argument('distname', help='Distribution name to fetch') fetchargs.add_argument('destdir', help='Directory to save the fetched image in') + exportargs = sp.add_parser('export', help='Export a deployment profile') + exportargs.add_argument('profile', help='Profile name to export') + exportargs.add_argument('filename', help='Output filename') upb = sp.add_parser( 'updateboot', help='Push profile.yaml of the named profile data into boot assets as appropriate') @@ -77,6 +81,8 @@ async def main(args): return await oslist() if cmdset.command == 'fetch': return await download_image(cmdset.distname, cmdset.destdir) + if cmdset.command == 'export': + return await export_profile(cmdset.profile, cmdset.filename) if cmdset.command == 'import': return await osimport(cmdset.imagefile, custname=cmdset.n) if cmdset.command == 'importcheck': @@ -529,6 +535,28 @@ async def updateboot(profilename): print(repr(rsp)) +async def export_profile(profilename, filename): + c = client.Command() + profiles = [] + async for rsp in c.read('/deployment/profiles'): + if 'error' in rsp: + sys.stderr.write(rsp['error'] + '\n') + exitcode = 1 + else: + profiles.append(rsp['item']['href'].replace('/', '')) + if profilename not in profiles: + sys.stderr.write('Profile {0} not found\n'.format(profilename)) + return 1 + tarpaths = ['public/os/{0}'.format(profilename)] + privatepath = 'private/os/{0}'.format(profilename) + if os.path.isdir(os.path.join('/var/lib/confluent', privatepath)): + tarpaths.append(privatepath) + result = subprocess.run( + ['tar', 'cf', filename] + tarpaths, + cwd='/var/lib/confluent') + return result.returncode + + async def rebase(profilename): c = client.Command() async for rsp in c.update('/deployment/profiles/{0}'.format(profilename), {'rebase': 1}):