diff --git a/import_auto.py b/auto_content.py similarity index 87% rename from import_auto.py rename to auto_content.py index 8656605..9f85e32 100644 --- a/import_auto.py +++ b/auto_content.py @@ -52,9 +52,6 @@ def run_imports(dryrun): if rc == 0: good_imports = True - # Check the 'good import' state - this triggers publish if we are good here - print good_imports - else: msg = "Dry run - not actually performing import" helpers.log_msg(msg, 'WARNING') @@ -65,6 +62,9 @@ def run_imports(dryrun): def publish_cv(dryrun): print "Running Content View Publish..." + # Set the initial state + good_publish = False + if not dryrun: rc = subprocess.call(['/usr/local/bin/publish_content_views', '-q', '-a']) else: @@ -72,9 +72,17 @@ def publish_cv(dryrun): helpers.log_msg(msg, 'WARNING') rc = subprocess.call(['/usr/local/bin/publish_content_views', '-q', '-a', '-d']) + if rc == 0: + good_publish = True + + return good_publish + def promote_cv(dryrun, lifecycle): - print "Running Content View Promotion..." + print "Running Content View Promotion to " + lifecycle + "..." + + # Set the initial state + good_promote = False if not dryrun: rc = subprocess.call(['/usr/local/bin/promote_content_views', '-q', '-e', lifecycle]) @@ -83,6 +91,11 @@ def promote_cv(dryrun, lifecycle): helpers.log_msg(msg, 'WARNING') rc = subprocess.call(['/usr/local/bin/promote_content_views', '-q', '-d', '-e', lifecycle]) + if rc == 0: + good_promote = True + + return good_promote + def clean_cv(dryrun): print "Running Content View Cleanup..." @@ -114,6 +127,7 @@ def main(args): dryrun = False run_publish = False + run_promote = True # Determine the day of week and week of month for use in our scheduling (dayofweek, weekofmonth) = dates() @@ -122,10 +136,12 @@ def main(args): # Run promotion first - this ensures content consistency (QA->Prod, Library->QA) if dayofweek == 1: if weekofmonth == 4: - promote_cv(dryrun, 'Production') + run_promote = promote_cv(dryrun, 'Production') - if weekofmonth == 2: - promote_cv(dryrun, 'Quality') + # Run QA promotion on 2nd and 4th Monday. Conditional on Prod promotion success + if weekofmonth == 2 or weekofmonth == 4: + if run_promote: + run_promote = promote_cv(dryrun, 'Quality') # Every day, check if there are any imports in our input dir and import them. @@ -137,14 +153,12 @@ def main(args): publish_cv(dryrun) - ### Run cleanup on scheduled day if dayofweek == 3: if weekofmonth == 4: clean_cv(dryrun) - if __name__ == "__main__": try: main(sys.argv[1:]) diff --git a/bin/auto_content b/bin/auto_content new file mode 100644 index 0000000..4dbdffd --- /dev/null +++ b/bin/auto_content @@ -0,0 +1,10 @@ +#!/usr/bin/python +import sys + +sys.path.insert(0, '/usr/share/sat6_scripts') +try: + import auto_content + auto_content.main(sys.argv[1:]) +except KeyboardInterrupt, e: + print >> sys.stderr, "\n\nExiting on user cancel." + sys.exit(1) diff --git a/rel-eng/sat6_scripts.spec b/rel-eng/sat6_scripts.spec index 713e5ca..b046166 100755 --- a/rel-eng/sat6_scripts.spec +++ b/rel-eng/sat6_scripts.spec @@ -37,12 +37,14 @@ install -m 0644 config/exports.yml.example %{buildroot}/usr/share/sat6_scripts/c install -m 0755 bin/check_sync %{buildroot}/usr/local/bin/check_sync install -m 0755 bin/sat_export %{buildroot}/usr/local/bin/sat_export install -m 0755 bin/sat_import %{buildroot}/usr/local/bin/sat_import +install -m 0755 bin/auto_content %{buildroot}/usr/local/bin/auto_content install -m 0755 bin/clean_content_views %{buildroot}/usr/local/bin/clean_content_views install -m 0755 bin/publish_content_views %{buildroot}/usr/local/bin/publish_content_views install -m 0755 bin/promote_content_views %{buildroot}/usr/local/bin/promote_content_views install -m 0755 bin/download_manifest %{buildroot}/usr/local/bin/download_manifest install -m 0755 bin/push_puppetforge %{buildroot}/usr/local/bin/push_puppetforge install -m 0644 helpers.py %{buildroot}/usr/share/sat6_scripts/helpers.py +install -m 0644 auto_content.py %{buildroot}/usr/share/sat6_scripts/auto_content.py install -m 0644 check_sync.py %{buildroot}/usr/share/sat6_scripts/check_sync.py install -m 0644 sat_export.py %{buildroot}/usr/share/sat6_scripts/sat_export.py install -m 0644 sat_import.py %{buildroot}/usr/share/sat6_scripts/sat_import.py @@ -84,6 +86,7 @@ gzip -9c man/sat_import.8 > %{buildroot}/usr/local/share/man/man8/sat_import.8.g /usr/local/share/man/man8/sat_import.8.gz /usr/share/sat6_scripts/helpers.py +/usr/share/sat6_scripts/auto_content.py /usr/share/sat6_scripts/check_sync.py /usr/share/sat6_scripts/sat_export.py /usr/share/sat6_scripts/sat_import.py @@ -93,6 +96,7 @@ gzip -9c man/sat_import.8 > %{buildroot}/usr/local/share/man/man8/sat_import.8.g /usr/share/sat6_scripts/download_manifest.py /usr/share/sat6_scripts/push_puppetforge.py +/usr/local/bin/auto_content /usr/local/bin/check_sync /usr/local/bin/sat_export /usr/local/bin/sat_import