Skip to content

Commit 2814396

Browse files
author
Geoff Gatward
committed
Fix clean functionality, pre-release updates
1 parent dededcb commit 2814396

6 files changed

Lines changed: 65 additions & 33 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
55

66
## [Unreleased]
77
### Fixed
8+
9+
## [1.2.4] - 2018-11-25
10+
### Fixed
811
- clean_content_views raised an exception if a CV version was included in a composite view
912
- Default org view was assumed to be version 1.0. Correct version is now extracted (Issue #43)
1013
- Org name and label do not always match. Issue with mixed case and spaces in org name (Issue #42)
@@ -13,7 +16,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1316
- Tasks in 'planning' state were not being considered when checking for locks
1417
- foreman_tasks API returns action as 'Promote' instead of 'Promotion' in Sat 6.3
1518

16-
1719
### Added
1820
- Option to define the tar split size (Issue #44)
1921

@@ -97,7 +99,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
9799
## 0.6 - 2017-02-27
98100
- Last of a series of pre-release betas
99101

100-
[Unreleased]: https://github.com/RedHatSatellite/sat6_scripts/compare/1.2.3...HEAD
102+
[Unreleased]: https://github.com/RedHatSatellite/sat6_scripts/compare/1.2.4...HEAD
103+
[1.2.4]: https://github.com/RedHatSatellite/sat6_scripts/compare/1.2.3...1.2.4
101104
[1.2.3]: https://github.com/RedHatSatellite/sat6_scripts/compare/1.2.2...1.2.3
102105
[1.2.2]: https://github.com/RedHatSatellite/sat6_scripts/compare/1.2.1...1.2.2
103106
[1.2.1]: https://github.com/RedHatSatellite/sat6_scripts/compare/1.2.0...1.2.1

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# Overview
22

33
Importing content in a disconnected environment can be a challenge.
4-
These scripts make use of the Inter-Satellite Sync capability in Satellite 6.2 to
4+
These scripts make use of the Inter-Satellite Sync capability in Satellite 6 to
55
allow for full and incremental export/import of content between environments.
66

77
These scripts have been written and tested using Satellite 6.x on RHEL7. (RHEL6 not supported)
88
Export/Import testing has been performed on the following version combinations:
99
* 6.2 -> 6.2
1010
* 6.2 -> 6.3
11-
* 6.3 -> 6.2
1211
* 6.3 -> 6.3
12+
* 6.3 -> 6.2
13+
* 6.3 -> 6.4
14+
* 6.4 -> 6.4
15+
* 6.4 -> 6.3
16+
1317

1418
## Definitions
1519
Throughout these scripts the following references are used:

bin/auto_content

100644100755
File mode changed.

clean_content_views.py

100755100644
Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@ def get_cv(org_id, cleanup_list, keep):
6262

6363
return ver_list, ver_descr, ver_keep
6464

65-
# def get_content_view_version(cvid):
66-
# cvv = helpers.get_json(
67-
# helpers.KATELLO_API + "content_view_versions/" + str(cvid))
68-
#
69-
# return cvv
7065

7166
def get_content_view_info(cvid):
7267
"""
@@ -121,19 +116,22 @@ def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall, ignorefir
121116
sys.exit(1)
122117

123118
for cvid in ver_list.keys():
124-
# Check if there is a publish/promote already running on this content view
125-
locked = helpers.check_running_publish(ver_list[cvid], ver_descr[cvid])
126-
127119
msg = "Cleaning content view '" + str(ver_descr[cvid]) + "'"
128120
helpers.log_msg(msg, 'INFO')
129121
print helpers.HEADER + msg + helpers.ENDC
130122

123+
# Check if there is a publish/promote already running on this content view
124+
locked = helpers.check_running_publish(ver_list[cvid], ver_descr[cvid])
125+
if locked:
126+
continue
127+
131128
# For the given content view we need to find the orphaned versions
132129
cvinfo = get_content_view_info(cvid)
133130

134131
# Find the oldest published version
135132
version_list = []
136133
orphan_versions = []
134+
orphan_dict = {}
137135
all_versions = []
138136
ccv_versions = []
139137
for version in cvinfo['versions']:
@@ -150,8 +148,10 @@ def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall, ignorefir
150148
if not version['environment_ids']:
151149
# These are the versions that don't belong to an environment (i.e. orphans)
152150
# We also cross-check for versions that may be in a CCV here.
151+
# We add the version name and id into a dictionary so we can delete by id.
153152
if not version_in_use:
154153
orphan_versions.append(float(version['version']))
154+
orphan_dict[version['version']] = version['id']
155155
continue
156156
else:
157157
msg = "Found version " + str(version['version'])
@@ -210,6 +210,9 @@ def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall, ignorefir
210210
str(ver_descr[cvid]) + "'"
211211
helpers.log_msg(msg, 'DEBUG')
212212

213+
# Lookup the version_id from our orphan_dict
214+
delete_id = orphan_dict.get(str(version))
215+
213216
msg = "Removing version " + str(version)
214217
helpers.log_msg(msg, 'INFO')
215218
print helpers.HEADER + msg + helpers.ENDC
@@ -219,7 +222,7 @@ def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall, ignorefir
219222
elif version in orphan_versions:
220223
msg = "Skipping delete of version " + str(version) + " (due to keep value)"
221224
else:
222-
msg = "Skipping delete of version " + str(version)
225+
msg = "Skipping delete of version " + str(version) + " (in use)"
223226
helpers.log_msg(msg, 'INFO')
224227
print msg
225228
continue
@@ -236,7 +239,7 @@ def cleanup(ver_list, ver_descr, dry_run, runuser, ver_keep, cleanall, ignorefir
236239
json.dumps(
237240
{
238241
"id": cvid,
239-
"content_view_version_ids": version['id']
242+
"content_view_version_ids": delete_id
240243
}
241244
))['id']
242245

helpers.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -416,48 +416,67 @@ def check_running_publish(cvid, desc):
416416
for task_result in tasks['results']:
417417
if task_result['state'] == 'planning' and task_result['label'] != 'Actions::BulkAction':
418418
if task_result['humanized']['action'] == 'Publish':
419-
if task_result['input']['content_view']['id'] == cvid:
420-
msg = "Unable to start '" + desc + "': content view is locked by another task"
421-
log_msg(msg, 'WARNING')
422-
locked = True
423-
return locked
419+
msg = "Unable to start '" + desc + "': A publish task is in planning state, cannot determine if it is for this CV"
420+
log_msg(msg, 'WARNING')
421+
locked = True
422+
return locked
424423
if task_result['state'] == 'running' and task_result['label'] != 'Actions::BulkAction':
425424
if task_result['humanized']['action'] == 'Publish':
426425
if task_result['input']['content_view']['id'] == cvid:
427-
msg = "Unable to start '" + desc + "': content view is locked by another task"
426+
msg = "Unable to start '" + desc + "': content view is locked by a running Publish task"
428427
log_msg(msg, 'WARNING')
429428
locked = True
430429
return locked
431430
if task_result['state'] == 'paused' and task_result['label'] != 'Actions::BulkAction':
432431
if task_result['humanized']['action'] == 'Publish':
433432
if task_result['input']['content_view']['id'] == cvid:
434-
msg = "Unable to start '" + desc + "': content view is locked by a paused task"
433+
msg = "Unable to start '" + desc + "': content view is locked by a paused Publish task"
435434
log_msg(msg, 'WARNING')
436435
locked = True
437436
return locked
438437
if task_result['state'] == 'planning' and task_result['label'] != 'Actions::BulkAction':
438+
if task_result['humanized']['action'] == 'Promotion' or task_result['humanized']['action'] == 'Promote':
439+
msg = "Unable to start '" + desc + "': A promotion task is in planning state, cannot determine if it is for this CV"
440+
log_msg(msg, 'WARNING')
441+
locked = True
442+
return locked
443+
if task_result['state'] == 'running' and task_result['label'] != 'Actions::BulkAction':
439444
if task_result['humanized']['action'] == 'Promotion' or task_result['humanized']['action'] == 'Promote':
440445
if task_result['input']['content_view']['id'] == cvid:
441-
msg = "Unable to start '" + desc + "': content view is locked by another task"
446+
msg = "Unable to start '" + desc + "': content view is locked by a running Promotion task"
442447
log_msg(msg, 'WARNING')
443448
locked = True
444449
return locked
445-
if task_result['state'] == 'running' and task_result['label'] != 'Actions::BulkAction':
450+
if task_result['state'] == 'paused' and task_result['label'] != 'Actions::BulkAction':
446451
if task_result['humanized']['action'] == 'Promotion' or task_result['humanized']['action'] == 'Promote':
447452
if task_result['input']['content_view']['id'] == cvid:
448-
msg = "Unable to start '" + desc + "': content view is locked by another task"
453+
msg = "Unable to start '" + desc + "': content view is locked by a paused Promotion task"
454+
log_msg(msg, 'WARNING')
455+
locked = True
456+
return locked
457+
if task_result['state'] == 'planning' and task_result['label'] != 'Actions::BulkAction':
458+
if task_result['humanized']['action'] == 'Remove Versions and Associations':
459+
msg = "Unable to start '" + desc + "': A remove task is in planning state, cannot determine if it is for this CV"
460+
log_msg(msg, 'WARNING')
461+
locked = True
462+
return locked
463+
if task_result['state'] == 'running' and task_result['label'] != 'Actions::BulkAction':
464+
if task_result['humanized']['action'] == 'Remove Versions and Associations':
465+
if task_result['input']['content_view']['id'] == cvid:
466+
msg = "Unable to start '" + desc + "': content view is locked by a running CV deletion task"
449467
log_msg(msg, 'WARNING')
450468
locked = True
451469
return locked
452470
if task_result['state'] == 'paused' and task_result['label'] != 'Actions::BulkAction':
453-
if task_result['humanized']['action'] == 'Promotion' or task_result['humanized']['action'] == 'Promote':
471+
if task_result['humanized']['action'] == 'Remove Versions and Associations':
454472
if task_result['input']['content_view']['id'] == cvid:
455-
msg = "Unable to start '" + desc + "': content view is locked by a paused task"
473+
msg = "Unable to start '" + desc + "': content view is locked by a paused CV deletion task"
456474
log_msg(msg, 'WARNING')
457475
locked = True
458476
return locked
459477

460478

479+
461480
def query_yes_no(question, default="yes"):
462481
"""
463482
Ask a yes/no question via raw_input() and return their answer.

rel-eng/sat6_scripts.spec

100755100644
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Name: sat6_scripts
2-
Version: 1.2.3
2+
Version: 1.2.4
33
Release: 1%{?dist}
44
Summary: Scripts to automate Satellite 6 tasks
55

66
License: GPL
7-
URL: https://github.com/ggatward/sat6_scripts
8-
Source0: sat6_scripts-1.2.3.tar.gz
7+
URL: https://github.com/RedHatSatellite/sat6_scripts
8+
Source0: sat6_scripts-1.2.4.tar.gz
99

1010
Requires: python >= 2.7, PyYAML
1111

@@ -130,17 +130,20 @@ mandb -q
130130

131131

132132
%changelog
133+
* Sun Nov 25 2018 Geoff Gatward <ggatward@redhat.com> 1.2.4
134+
- Refer https://github.com/RedHatSatellite/sat6_scripts/blob/1.2.4/CHANGELOG.md
135+
133136
* Mon Mar 12 2018 Geoff Gatward <ggatward@redhat.com> 1.2.3
134-
- Refer https://github.com/ggatward/sat6_scripts/blob/1.2.3/CHANGELOG.md
137+
- Refer https://github.com/RedHatSatellite/sat6_scripts/blob/1.2.3/CHANGELOG.md
135138

136139
* Sun Feb 25 2018 Geoff Gatward <ggatward@redhat.com> 1.2.2
137-
- Refer https://github.com/ggatward/sat6_scripts/blob/1.2.2/CHANGELOG.md
140+
- Refer https://github.com/RedHatSatellite/sat6_scripts/blob/1.2.2/CHANGELOG.md
138141

139142
* Mon Dec 11 2017 Geoff Gatward <ggatward@redhat.com> 1.2.1
140-
- Refer https://github.com/ggatward/sat6_scripts/blob/1.2.1/CHANGELOG.md
143+
- Refer https://github.com/RedHatSatellite/sat6_scripts/blob/1.2.1/CHANGELOG.md
141144

142145
* Sun Dec 10 2017 Geoff Gatward <ggatward@redhat.com> 1.2.0
143-
- Refer https://github.com/ggatward/sat6_scripts/blob/1.2.0/CHANGELOG.md
146+
- Refer https://github.com/RedHatSatellite/sat6_scripts/blob/1.2.0/CHANGELOG.md
144147

145148
* Wed Oct 25 2017 Geoff Gatward <ggatward@redhat.com> 1.1.1
146149
- Refer https://github.com/ggatward/sat6_scripts/blob/1.1.1/CHANGELOG.md

0 commit comments

Comments
 (0)