Skip to content

Commit d3ea6a7

Browse files
marmijodustymabe
authored andcommitted
cosalib/aws: don't require build artifact for AWS WinLI builds
The build artifact is not needed in the AWS WIndows License Included (WinLI) case because the image is built from an existing snapshot. To allow individual cloud providers to override this requirement, move the build artifact check to each provider's wrapper. Don't perform the check in the AWS wrapper if building a winli image. Also modify the AWS ore upload code to not require an upload file when a source snapshot is used, which allows the WinLI image to be built without the need for an upload file.
1 parent 0bc53dc commit d3ea6a7

File tree

7 files changed

+23
-6
lines changed

7 files changed

+23
-6
lines changed

mantle/cmd/ore/aws/upload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ func runUpload(cmd *cobra.Command, args []string) error {
144144
fmt.Fprintf(os.Stderr, "--disk-size-inspect cannot be used with --source-object or --source-snapshot.\n")
145145
os.Exit(2)
146146
}
147-
if uploadFile == "" {
148-
fmt.Fprintf(os.Stderr, "specify --file\n")
147+
if uploadFile == "" && uploadSourceSnapshot == "" {
148+
fmt.Fprintf(os.Stderr, "specify --file or --source-snapshot\n")
149149
os.Exit(2)
150150
}
151151
if uploadImageName == "" {

src/cmd-ore-wrapper

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ Each target has its own sub options. To access them us:
121121
build.ensure_built()
122122

123123
if args.upload:
124-
if not build.have_artifact:
125-
raise Exception(f"Missing build artifact {build.image_path}")
126124
log.info("executing upload commands for ore")
127125
cmd, _ = get_cloud_ore_cmds(target)
128126
cmd(build, args)

src/cosalib/aliyun.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ def make_public(build, args):
137137

138138
@retry(reraise=True, stop=stop_after_attempt(3))
139139
def aliyun_run_ore(build, args):
140+
if not build.have_artifact:
141+
raise Exception(f"Missing build artifact {build.image_path}")
142+
140143
build.refresh_meta()
141144
ore_args = ['ore']
142145
if args.log_level:

src/cosalib/aws.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ def aws_run_ore_replicate(build, args):
110110

111111
@retry(reraise=True, stop=stop_after_attempt(3))
112112
def aws_run_ore(build, args):
113+
# Skip the artifact check for AWS Windows License Included (WinLI) builds.
114+
# The build artifact is not required for WinLI.
115+
if (not build.have_artifact) and (not args.winli):
116+
raise Exception(f"Missing build artifact {build.image_path}")
117+
113118
# First add the ore command to run before any options
114119
ore_args = ['ore', 'aws', 'upload']
115120

@@ -157,7 +162,10 @@ def aws_run_ore(build, args):
157162
'--billing-product-code', f"{args.winli_billing_product}"
158163
])
159164
else:
160-
ore_args.extend(['--disk-size-inspect'])
165+
ore_args.extend([
166+
'--disk-size-inspect',
167+
'--file', f"{build.image_path}",
168+
])
161169
winli_name = ""
162170
winli_description = ""
163171
buildmeta_key = "amis"
@@ -171,7 +179,6 @@ def aws_run_ore(build, args):
171179
'--name', f"{build.build_name}{winli_name}-{build.build_id}-{build.basearch}",
172180
'--ami-description', f"{build.summary} {build.build_id} {build.basearch}{winli_description}",
173181
'--arch', f"{build.basearch}",
174-
'--file', f"{build.image_path}",
175182
'--delete-object'
176183
])
177184
for user in args.grant_user:

src/cosalib/azure.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def azure_run_ore(build, args):
3434
:param build: Build instance to use
3535
:type build: Build
3636
"""
37+
if not build.have_artifact:
38+
raise Exception(f"Missing build artifact {build.image_path}")
39+
3740
azure_vhd_name = f"{build.image_name_base}.vhd"
3841
ore_args = [
3942
'ore',

src/cosalib/gcp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def gcp_run_ore(build, args):
3737
"""
3838
Execute ore to upload the tarball and register the image
3939
"""
40+
if not build.have_artifact:
41+
raise Exception(f"Missing build artifact {build.image_path}")
42+
4043
arg_exp_str = "parameter '--{}' or envVar '{}' must be defined"
4144
if args.bucket is None:
4245
raise Exception(arg_exp_str.format("bucket", "GCP_BUCKET"))

src/cosalib/ibmcloud.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ def write_ova(self, image_name):
102102

103103
@retry(reraise=True, stop=stop_after_attempt(3))
104104
def ibmcloud_run_ore(build, args):
105+
if not build.have_artifact:
106+
raise Exception(f"Missing build artifact {build.image_path}")
107+
105108
ore_args = ['ore']
106109
if args.log_level:
107110
ore_args.extend(['--log-level', args.log_level])

0 commit comments

Comments
 (0)