Skip to content

Commit

Permalink
Force meta (#35)
Browse files Browse the repository at this point in the history
* Add force metadata regen option
* Add missing options
* Add metadata option to promote scripts
* Set forcemeta as default in auto_content
  • Loading branch information
ggatward authored Feb 25, 2018
1 parent b5045ef commit b8fca57
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Option to tag a published content view with a custom comment
- Option to clean versions taking into account published versions
- Option to force metadata regeneration during publish and promote

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


## [1.2.1] - 2017-12-11
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ these warnings.

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


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

By default the repository metadata is not rebuilt. In some scenarios it may be required
to force a rebuild of the metadata, in which case the (-m) option can be used to trigger this.

The defaults are configured in the main config.yml file in a YAML block like this:
```
publish:
Expand All @@ -433,7 +436,7 @@ once, to aid in performance tuning.


```
usage: publish_content_view.py [-h] [-o ORG] [-a] [-d] [-c COMMENT] [-q]
usage: publish_content_view.py [-h] [-o ORG] [-a] [-d] [-c COMMENT] [-m] [-q] [-l]
Publishes content views for specified organization.
Expand All @@ -445,6 +448,7 @@ optional arguments:
-l, --last Display last promotions
-c, --comment Add a custom description
-q, --quiet Suppress progress output updates
-m, --forcemeta Force metadata regeneration
```

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

By default the repository metadata is not rebuilt. In some scenarios it may be required
to force a rebuild of the metadata, in which case the (-m) option can be used to trigger this.

The defaults are configured in the main config.yml file in a YAML block like this:
```
promotion:
Expand All @@ -499,7 +506,7 @@ The batch: parameter can be used to limit the number of content views that will
once, to aid in performance tuning.

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

### Examples
Expand Down
8 changes: 4 additions & 4 deletions auto_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ def publish_cv(dryrun):
good_publish = False

if not dryrun:
rc = subprocess.call(['/usr/local/bin/publish_content_views', '-q', '-a'])
rc = subprocess.call(['/usr/local/bin/publish_content_views', '-q', '-a', '-m'])
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'])
rc = subprocess.call(['/usr/local/bin/publish_content_views', '-q', '-a', '-m', '-d'])

if rc == 0:
good_publish = True
Expand All @@ -98,11 +98,11 @@ def promote_cv(dryrun, lifecycle):
good_promote = False

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

if rc == 0:
good_promote = True
Expand Down
5 changes: 5 additions & 0 deletions man/promote_content_views.8
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ This option can be used to verify that the correct configuration options have be
Do not display refreshing progress bars during the operation.
This option can be used when including this script in automated tasks, for example from cron.
.RE
.PP
.BR "-m", " --forcemeta"
.RS 3
Force the regeneration of repository metadata during the publish.
.RE


.SH EXAMPLES
Expand Down
5 changes: 5 additions & 0 deletions man/publish_content_views.8
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ By default a comment indicating the content view was published via the API by th
Do not display refreshing progress bars during the operation.
This option can be used when including this script in automated tasks, for example from cron.
.RE
.PP
.BR "-m", " --forcemeta"
.RS 3
Force the regeneration of repository metadata during the publish.
.RE


.SH EXAMPLES
Expand Down
10 changes: 7 additions & 3 deletions promote_content_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_cv(org_id, target_env, env_list, prior_list, promote_list):


# Promote a content view version
def promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list, dry_run, quiet):
def promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list, dry_run, quiet, forcemeta):
"""Promote Content View"""
target_env_id = env_list[target_env]
source_env_id = prior_list[target_env_id]
Expand Down Expand Up @@ -163,7 +163,8 @@ def promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list,
helpers.KATELLO_API + "content_view_versions/" + str(ver_list[cvid]) +\
"/promote/", json.dumps(
{
"environment_id": target_env_id
"environment_id": target_env_id,
"force_yum_metadata_regeneration": str(forcemeta)
}
))["id"]
except Warning:
Expand Down Expand Up @@ -219,6 +220,8 @@ def main(args):
action="store_true")
parser.add_argument('-q', '--quiet', help="Suppress progress output updates", required=False,
action="store_true")
parser.add_argument('-m', '--forcemeta', help="Force metadata regeneration", required=False,
action="store_true")

args = parser.parse_args()

Expand Down Expand Up @@ -287,7 +290,8 @@ def main(args):
promote_list)

# Promote to the given environment. Returns a list of task IDs.
promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list, dry_run, args.quiet)
promote(target_env, ver_list, ver_descr, ver_version, env_list, prior_list, dry_run,
args.quiet, args.forcemeta)

# Add/Update the promotion history dictionary so we can check when we last promoted
phistory[target_env] = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d')
Expand Down
10 changes: 7 additions & 3 deletions publish_content_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_cv(org_id, publish_list):
return ver_list, ver_descr, ver_version


def publish(ver_list, ver_descr, ver_version, dry_run, runuser, description, quiet):
def publish(ver_list, ver_descr, ver_version, dry_run, runuser, description, quiet, forcemeta):
"""Publish Content View"""

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

args = parser.parse_args()

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

# Publish the content views. Returns a list of task IDs.
publish(ver_list, ver_descr, ver_version, dry_run, runuser, description, args.quiet)
publish(ver_list, ver_descr, ver_version, dry_run, runuser, description, args.quiet,
args.forcemeta)

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

0 comments on commit b8fca57

Please sign in to comment.