-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add email capability, unattended option, general tidyup
- Loading branch information
Showing
7 changed files
with
253 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,11 @@ logging: | |
dir: /var/log/sat6-scripts (Directory to use for logging) | ||
debug: [True|False] | ||
email: | ||
mailout: True | ||
mailfrom: Satellite 6 <[email protected]> | ||
mailto: [email protected] | ||
export: | ||
dir: /var/sat-export (Directory to export content to - Connected Satellite) | ||
|
@@ -199,6 +204,7 @@ optional arguments: | |
-l, --last Display time of last export | ||
-L, --list List all successfully completed exports | ||
--nogpg Skip GPG checking | ||
-u, --unattended Answer any prompts safely, allowing automated usage | ||
-r, --repodata Include repodata for repos with no incremental content | ||
-p, --puppetforge Include puppet-forge-server format Puppet Forge repo | ||
--notar Do not archive the extracted content | ||
|
@@ -271,6 +277,7 @@ optional arguments: | |
-L, --list List all successfully completed imports | ||
-c, --count Display all package counts after import | ||
-f, --force Force import of data if it has previously been done | ||
-u, --unattended Answer any prompts safely, allowing automated usage | ||
--fixhistory Force import history to match export history | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,11 @@ logging: | |
dir: /var/log/satellite | ||
debug: False | ||
|
||
email: | ||
mailout: True | ||
mailfrom: Satellite 6 <[email protected]> | ||
mailto: [email protected] | ||
|
||
export: | ||
dir: /var/sat-export | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys, os, glob | ||
import subprocess | ||
import argparse | ||
import helpers | ||
|
||
|
||
def run_imports(dryrun): | ||
print "Processing Imports..." | ||
|
||
# Find any sha256 files in the import dir | ||
infiles = glob.glob(helpers.IMPORTDIR + '/*.sha256') | ||
|
||
# Extract the dataset timestamp/name from the filename and add to a new list | ||
# Assumes naming standard sat6_export_YYYYMMDD-HHMM_NAME.sha256 | ||
# 'sorted' function should result in imports being done in correct order by filename | ||
tslist = [] | ||
for f in sorted(infiles): | ||
dstime = f.split('_')[-2] | ||
dsname = (f.split('_')[-1]).split('.')[-2] | ||
tslist.append(dstime + '_' + dsname) | ||
|
||
if tslist: | ||
msg = 'Found import datasets on disk...\n' + '\n'.join(tslist) | ||
else: | ||
msg = 'No import datasets to process' | ||
helpers.log_msg(msg, 'INFO') | ||
print msg | ||
|
||
# Now for each import file in the list, run the import script in unattended mode:-) | ||
if tslist: | ||
if not dryrun: | ||
for dataset in tslist: | ||
rc = subprocess.call(['/usr/local/bin/sat_import', '-u', '-r', '-d', dataset]) | ||
print rc | ||
else: | ||
msg = "Dry run - not actually performing import" | ||
helpers.log_msg(msg, 'WARNING') | ||
|
||
|
||
def main(args): | ||
|
||
### Run import/publish on scheduled day | ||
|
||
# Check for sane input | ||
parser = argparse.ArgumentParser( | ||
description='Imports, Publishes and Promotes content views.') | ||
parser.add_argument('-d', '--dryrun', help='Dry Run - Only show what will be done', | ||
required=False, action="store_true") | ||
|
||
args = parser.parse_args() | ||
|
||
if args.dryrun: | ||
dryrun = True | ||
else: | ||
dryrun = False | ||
|
||
|
||
# Check if there are any imports in our input dir and import them | ||
run_imports(dryrun) | ||
|
||
# If all imports successful run publish | ||
|
||
|
||
### Run promote on scheduled display | ||
|
||
|
||
|
||
### Run cleanup on scheduled day | ||
|
||
|
||
|
||
|
||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
main(sys.argv[1:]) | ||
except KeyboardInterrupt, e: | ||
print >> sys.stderr, ("\n\nExiting on user cancel.") | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.