Skip to content

Commit

Permalink
Update for auto_content scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ggatward committed Dec 8, 2017
1 parent 587cc03 commit f81adcd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
32 changes: 23 additions & 9 deletions import_auto.py → auto_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -65,16 +62,27 @@ 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:
msg = "Dry run - not actually performing publish"
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])
Expand All @@ -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..."
Expand Down Expand Up @@ -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()
Expand All @@ -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.
Expand All @@ -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:])
Expand Down
10 changes: 10 additions & 0 deletions bin/auto_content
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions rel-eng/sat6_scripts.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f81adcd

Please sign in to comment.