Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add log-level param for buildextend subcommands #777

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/cmd-aws-replicate
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ parser.add_argument("--build", help="Build ID",
parser.add_argument("--name-suffix", help="Suffix for name")
parser.add_argument("--regions", help="EC2 regions",
default=default_all_regions, nargs='+')
parser.add_argument("--log-level", help="ore log level")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ore log level

Related to this is #692. E.g. ideally we'd log way less to the terminal, and then --log-level here would allow bumping that up (in addition to passing it along to ore).

args = parser.parse_args()

builds = Builds()
Expand Down Expand Up @@ -57,8 +58,10 @@ def run_ore():

source_image = buildmeta['amis'][0]['hvm']
source_region = buildmeta['amis'][0]['name']
ore_args = ['ore', 'aws', 'copy-image',
'--image', source_image, '--region', source_region]
ore_args = ['ore']
if args.log_level:
ore_args.extend(['--log-level', args.log_level])
ore_args.extend(['aws', 'copy-image', '--image', source_image, '--region', source_region])
ore_args.extend(region_list)
print("+ {}".format(subprocess.list2cmdline(ore_args)))
ore_data = json.loads(subprocess.check_output(ore_args))
Expand Down
24 changes: 14 additions & 10 deletions src/cmd-buildextend-aws
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ parser.add_argument("--bucket", help="S3 Bucket",
parser.add_argument("--name-suffix", help="Suffix for name")
parser.add_argument("--grant-user", help="Grant user launch permission",
nargs="*", default=[])
parser.add_argument("--log-level", help="ore log level")
args = parser.parse_args()

builds = Builds()
Expand Down Expand Up @@ -57,16 +58,19 @@ def generate_aws_vmdk():

def run_ore():
tmp_img_aws_vmdk = generate_aws_vmdk()
ore_args = ['ore', 'aws', 'upload',
'--region', args.region,
'--bucket', args.bucket,
'--ami-name', ami_name_version,
'--name', ami_name_version,
'--ami-description', f"{buildmeta['summary']} {args.build}",
'--file', tmp_img_aws_vmdk,
'--disk-size-inspect',
'--delete-object',
'--force']
ore_args = ['ore']
if args.log_level:
ore_args.extend(['--log-level', args.log_level])
ore_args.extend(['aws', 'upload',
'--region', args.region,
'--bucket', args.bucket,
'--ami-name', ami_name_version,
'--name', ami_name_version,
'--ami-description', f"{buildmeta['summary']} {args.build}",
'--file', tmp_img_aws_vmdk,
'--disk-size-inspect',
'--delete-object',
'--force'])
for user in args.grant_user:
ore_args.extend(['--grant-user', user])
print("+ {}".format(subprocess.list2cmdline(ore_args)))
Expand Down
8 changes: 6 additions & 2 deletions src/cmd-buildextend-azure
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def cli():
parser.add_argument(
'--storage-account', help='Storage account', required=True,
default=os.environ.get('AZURE_STORAGE_ACCOUNT'))
parser.add_argument("--log-level", help="ore log level")
args = parser.parse_args()

# Argument checks for environment strings that are required
Expand Down Expand Up @@ -166,8 +167,11 @@ def run_ore(args, build):
:type build: Build
"""
azure_vhd_path = os.path.join(build.build_dir, build.azure_vhd_name)
ore_upload_args = [
'ore', 'azure', 'upload-blob-arm',
ore_upload_args = ['ore']
if args.log_level:
ore_upload_args.extend(['--log-level', args.log_level])
ore_upload_args.extend([
'azure', 'upload-blob-arm',
'--azure-auth', args.auth,
'--azure-location', args.location,
'--azure-profile', args.profile,
Expand Down
27 changes: 16 additions & 11 deletions src/cmd-buildextend-gcp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ parser.add_argument("--name-suffix", help="Append suffix to name",
required=False)
parser.add_argument("--project", help="GCP Project name",
default=os.environ.get("GCP_PROJECT_NAME"))
parser.add_argument("--log-level", help="ore log level")
args = parser.parse_args()

# Argument checks for environment strings that are required
Expand Down Expand Up @@ -95,17 +96,21 @@ def run_ore():
""" Execute ore to upload the tarball and register the image """
build_tarball = f"{builddir}/{gcp_tarball_name}"
tmp_img_gcp_tarball = generate_gcp_tar()
ore_args = ['ore', 'gcloud',
'--project', args.project,
'--basename', base_name,
'upload',
'--force', # We want to support restarting the pipeline
'--board=""',
'--bucket', f'gs://{args.bucket}/{base_name}',
'--json-key', args.json_key,
'--name', f'{args.build}',
'--file', tmp_img_gcp_tarball
]
ore_args = ['ore']
if args.log_level:
ore_args.extend(['--log-level', args.log_level])
ore_args.extend([
'gcloud',
'--project', args.project,
'--basename', base_name,
'upload',
'--force', # We want to support restarting the pipeline
'--board=""',
'--bucket', f'gs://{args.bucket}/{base_name}',
'--json-key', args.json_key,
'--name', f'{args.build}',
'--file', tmp_img_gcp_tarball
])

run_verbose(ore_args)
os.rename(tmp_img_gcp_tarball, build_tarball)
Expand Down