Skip to content

Commit b8fca57

Browse files
authored
Force meta (#35)
* Add force metadata regen option * Add missing options * Add metadata option to promote scripts * Set forcemeta as default in auto_content
1 parent b5045ef commit b8fca57

7 files changed

Lines changed: 42 additions & 14 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
### Added
88
- Option to tag a published content view with a custom comment
99
- Option to clean versions taking into account published versions
10+
- Option to force metadata regeneration during publish and promote
1011

1112
### Fixed
1213
- Fix unreferenced var in check_disk_space function
1314
- Various minor README corrections
1415
- auto_content did not publish CV if the satellite is internet connected
1516
- publish_content_views KeyError exception if API returns null value
17+
- Fix handling empty lists for used and unused versions in clean_content_views
1618

1719

1820
## [1.2.1] - 2017-12-11

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ these warnings.
264264

265265
### Help Output
266266
```
267-
usage: sat_import.py [-h] [-o ORG] -d DATE [-n] [-r] [-l] [-L] [-c] [-f] [--fixhistory]
267+
usage: sat_import.py [-h] [-o ORG] -d DATE [-n] [-r] [-l] [-L] [-c] [-f] [--fixhistory] [-u]
268268
269269
Performs Import of Default Content View.
270270
@@ -375,7 +375,7 @@ specified number of versions beyond the oldest in-use.
375375

376376

377377
```
378-
usage: clean_content_views.py [-h] [-o ORG] [-a] [-c] [-d]
378+
usage: clean_content_views.py [-h] [-o ORG] [-a] [-c] [-d] [-i]
379379
380380
Cleans content views for specified organization.
381381
@@ -417,6 +417,9 @@ the last publish/promote date can be viewed with the (-l) option. Note that this
417417
datestamp is only updated by this script - it does NOT record publish/promote via
418418
the WebUI or Hammer CLI.
419419

420+
By default the repository metadata is not rebuilt. In some scenarios it may be required
421+
to force a rebuild of the metadata, in which case the (-m) option can be used to trigger this.
422+
420423
The defaults are configured in the main config.yml file in a YAML block like this:
421424
```
422425
publish:
@@ -433,7 +436,7 @@ once, to aid in performance tuning.
433436

434437

435438
```
436-
usage: publish_content_view.py [-h] [-o ORG] [-a] [-d] [-c COMMENT] [-q]
439+
usage: publish_content_view.py [-h] [-o ORG] [-a] [-d] [-c COMMENT] [-m] [-q] [-l]
437440
438441
Publishes content views for specified organization.
439442
@@ -445,6 +448,7 @@ optional arguments:
445448
-l, --last Display last promotions
446449
-c, --comment Add a custom description
447450
-q, --quiet Suppress progress output updates
451+
-m, --forcemeta Force metadata regeneration
448452
```
449453

450454
### Examples
@@ -475,6 +479,9 @@ the last publish/promote date can be viewed with the (-l) option. Note that this
475479
datestamp is only updated by this script - it does NOT record publish/promote via
476480
the WebUI or Hammer CLI.
477481

482+
By default the repository metadata is not rebuilt. In some scenarios it may be required
483+
to force a rebuild of the metadata, in which case the (-m) option can be used to trigger this.
484+
478485
The defaults are configured in the main config.yml file in a YAML block like this:
479486
```
480487
promotion:
@@ -499,7 +506,7 @@ The batch: parameter can be used to limit the number of content views that will
499506
once, to aid in performance tuning.
500507

501508
```
502-
usage: promote_content_view.py [-h] -e ENV [-o ORG] [-a] [-d] [-q]
509+
usage: promote_content_view.py [-h] -e ENV [-o ORG] [-a] [-d] [-m] [-q] [-l]
503510
504511
Promotes content views for specified organization to the target environment.
505512
@@ -512,6 +519,7 @@ optional arguments:
512519
-d, --dryrun Dry Run - Only show what will be promoted
513520
-l, --last Display last promotions
514521
-q, --quiet Suppress progress output updates
522+
-m, --forcemeta Force metadata regeneration
515523
```
516524

517525
### Examples

auto_content.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ def publish_cv(dryrun):
7979
good_publish = False
8080

8181
if not dryrun:
82-
rc = subprocess.call(['/usr/local/bin/publish_content_views', '-q', '-a'])
82+
rc = subprocess.call(['/usr/local/bin/publish_content_views', '-q', '-a', '-m'])
8383
else:
8484
msg = "Dry run - not actually performing publish"
8585
helpers.log_msg(msg, 'WARNING')
86-
rc = subprocess.call(['/usr/local/bin/publish_content_views', '-q', '-a', '-d'])
86+
rc = subprocess.call(['/usr/local/bin/publish_content_views', '-q', '-a', '-m', '-d'])
8787

8888
if rc == 0:
8989
good_publish = True
@@ -98,11 +98,11 @@ def promote_cv(dryrun, lifecycle):
9898
good_promote = False
9999

100100
if not dryrun:
101-
rc = subprocess.call(['/usr/local/bin/promote_content_views', '-q', '-e', lifecycle])
101+
rc = subprocess.call(['/usr/local/bin/promote_content_views', '-q', '-m', '-e', lifecycle])
102102
else:
103103
msg = "Dry run - not actually performing promotion"
104104
helpers.log_msg(msg, 'WARNING')
105-
rc = subprocess.call(['/usr/local/bin/promote_content_views', '-q', '-d', '-e', lifecycle])
105+
rc = subprocess.call(['/usr/local/bin/promote_content_views', '-q', '-d', '-m', '-e', lifecycle])
106106

107107
if rc == 0:
108108
good_promote = True

man/promote_content_views.8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ This option can be used to verify that the correct configuration options have be
6868
Do not display refreshing progress bars during the operation.
6969
This option can be used when including this script in automated tasks, for example from cron.
7070
.RE
71+
.PP
72+
.BR "-m", " --forcemeta"
73+
.RS 3
74+
Force the regeneration of repository metadata during the publish.
75+
.RE
7176

7277

7378
.SH EXAMPLES

man/publish_content_views.8

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ By default a comment indicating the content view was published via the API by th
5959
Do not display refreshing progress bars during the operation.
6060
This option can be used when including this script in automated tasks, for example from cron.
6161
.RE
62+
.PP
63+
.BR "-m", " --forcemeta"
64+
.RS 3
65+
Force the regeneration of repository metadata during the publish.
66+
.RE
6267

6368

6469
.SH EXAMPLES

promote_content_views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def get_cv(org_id, target_env, env_list, prior_list, promote_list):
113113

114114

115115
# Promote a content view version
116-
def promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list, dry_run, quiet):
116+
def promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list, dry_run, quiet, forcemeta):
117117
"""Promote Content View"""
118118
target_env_id = env_list[target_env]
119119
source_env_id = prior_list[target_env_id]
@@ -163,7 +163,8 @@ def promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list,
163163
helpers.KATELLO_API + "content_view_versions/" + str(ver_list[cvid]) +\
164164
"/promote/", json.dumps(
165165
{
166-
"environment_id": target_env_id
166+
"environment_id": target_env_id,
167+
"force_yum_metadata_regeneration": str(forcemeta)
167168
}
168169
))["id"]
169170
except Warning:
@@ -219,6 +220,8 @@ def main(args):
219220
action="store_true")
220221
parser.add_argument('-q', '--quiet', help="Suppress progress output updates", required=False,
221222
action="store_true")
223+
parser.add_argument('-m', '--forcemeta', help="Force metadata regeneration", required=False,
224+
action="store_true")
222225

223226
args = parser.parse_args()
224227

@@ -287,7 +290,8 @@ def main(args):
287290
promote_list)
288291

289292
# Promote to the given environment. Returns a list of task IDs.
290-
promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list, dry_run, args.quiet)
293+
promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list, dry_run,
294+
args.quiet, args.forcemeta)
291295

292296
# Add/Update the promotion history dictionary so we can check when we last promoted
293297
phistory[target_env] = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d')

publish_content_views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def get_cv(org_id, publish_list):
5353
return ver_list, ver_descr, ver_version
5454

5555

56-
def publish(ver_list, ver_descr, ver_version, dry_run, runuser, description, quiet):
56+
def publish(ver_list, ver_descr, ver_version, dry_run, runuser, description, quiet, forcemeta):
5757
"""Publish Content View"""
5858

5959
# Set the task name to be displayed in the task monitoring stage
@@ -94,7 +94,8 @@ def publish(ver_list, ver_descr, ver_version, dry_run, runuser, description, qui
9494
helpers.KATELLO_API + "content_views/" + str(ver_list[cvid]) +\
9595
"/publish", json.dumps(
9696
{
97-
"description": description
97+
"description": description,
98+
"force_yum_metadata_regeneration": str(forcemeta)
9899
}
99100
))["id"]
100101
except Warning:
@@ -153,6 +154,8 @@ def main(args):
153154
parser.add_argument('-c', '--comment', help="Add a custom description", required=False)
154155
parser.add_argument('-q', '--quiet', help="Suppress progress output updates", required=False,
155156
action="store_true")
157+
parser.add_argument('-m', '--forcemeta', help="Force metadata regeneration", required=False,
158+
action="store_true")
156159

157160
args = parser.parse_args()
158161

@@ -216,7 +219,8 @@ def main(args):
216219
(ver_list, ver_descr, ver_version) = get_cv(org_id, publish_list)
217220

218221
# Publish the content views. Returns a list of task IDs.
219-
publish(ver_list, ver_descr, ver_version, dry_run, runuser, description, args.quiet)
222+
publish(ver_list, ver_descr, ver_version, dry_run, runuser, description, args.quiet,
223+
args.forcemeta)
220224

221225
# Add/Update the promotion history dictionary so we can check when we last promoted
222226
phistory['Library'] = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d')

0 commit comments

Comments
 (0)