Skip to content

Commit

Permalink
CASMCMS-8651: Remove ARS from CLI; Use updated BSS API spec with upda…
Browse files Browse the repository at this point in the history
…ted non-ARS link examples
  • Loading branch information
mharding-hpe committed May 30, 2023
1 parent 4d8bece commit b8888f4
Show file tree
Hide file tree
Showing 9 changed files with 3,172 additions and 5,525 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/cray/modules/ars @Cray-HPE/cray-management-systems
/cray/modules/artifacts @Cray-HPE/cray-management-systems
/cray/modules/badger @Cray-HPE/hardware-management
/cray/modules/bos @Cray-HPE/cms-core-bos
Expand Down
Empty file removed cray/modules/ars/__init__.py
Empty file.
31 changes: 0 additions & 31 deletions cray/modules/ars/cli.py

This file was deleted.

1,968 changes: 0 additions & 1,968 deletions cray/modules/ars/swagger3.json

This file was deleted.

60 changes: 9 additions & 51 deletions cray/modules/artifacts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
""" Artifact - thin wrapper over S3 with ARS backwards compatibility """
""" Artifact - thin wrapper over S3 """
# pylint: disable=invalid-name,redefined-outer-name,missing-docstring,unused-argument,broad-except
import datetime
import hashlib
Expand Down Expand Up @@ -144,37 +144,16 @@ def describe_object(ctx, bucket, obj):
@argument('bucket', metavar='BUCKET')
@argument('obj', metavar='OBJECT')
@argument('filename', metavar='FILEPATH')
@option(
'--expires',
metavar='EXPIRES',
help='Seconds until download url expiration.',
default=60 * 60
)
@pass_context
def upload_object(ctx, bucket, obj, filename, expires):
""" Create a new object in a bucket """

#
# Remove this check along with the --expires parameter when ARS is fully deprecated
#
if expires > 3600:
raise click.ClickException(
f"Maximum download url timeout is 3600 seconds: {expires:d}"
)

s3client = get_s3_client()
md5sum = md5(filename)

if bucket == 'ars-app':
# Generate an ID, for compatibility of some services that validate that ARS
# artifacts are UUID, this must be a UUID and the S3 object must use it as
# the object name. Can be removed when ARS is fully deprecated.
obj_id = str(uuid.uuid4())
else:
obj_id = obj
obj_id = obj

# Create the object and a download url, then upload the file with the ARS-
# compatible metadata
# Create the object and a download url, then upload the file
try:
s3client.put_object(Bucket=bucket, Key=obj_id, ACL='public-read')
url = s3client.generate_presigned_url(
Expand All @@ -198,35 +177,14 @@ def upload_object(ctx, bucket, obj, filename, expires):
upload_args = (filename, bucket, obj_id)

config = TransferConfig(use_threads=False)
if bucket == 'ars-app':
# ARS-compatible metadata, remove when ARS is fully deprecated
upload_kwargs = {
'Config': config,
'ExtraArgs': {
'Metadata': {
'artifact_id': obj_id,
'atype': 'generic',
'created': datetime.datetime.now().isoformat(),
'download_url': url,
'md5sum': md5sum,
'name': obj,
'state': 'upload-complete',
'upload_id': obj_id,
'uri': '/apis/ars/downloads/' + obj_id,
'url': url,
'version': '1',
}
}
}
else:
upload_kwargs = {
'Config': config,
'ExtraArgs': {
'Metadata': {
'md5sum': md5sum,
}
upload_kwargs = {
'Config': config,
'ExtraArgs': {
'Metadata': {
'md5sum': md5sum,
}
}
}

s3client.upload_file(*upload_args, **upload_kwargs)

Expand Down
4 changes: 2 additions & 2 deletions cray/modules/bss/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -828,11 +828,11 @@ definitions:
kernel:
type: string
description: URL or file system path specifying kernel image.
example: "http://10.252.100.50/apis/ars/downloads/30b96241-12ff-4185-93ea-a1f7991372d3"
example: "s3://boot-images/1dbb777c-2527-449b-bd6d-fb4d1cb79e88/kernel"
initrd:
type: string
description: URL or file system path specifying initrd image.
example: "http://10.252.100.50/apis/ars/downloads/7e0bcf9f-10fc-46a9-b2f8-ba8814c1999c"
example: "s3://boot-images/1dbb777c-2527-449b-bd6d-fb4d1cb79e88/initrd"
cloud-init:
$ref: '#/definitions/CloudInit'

Expand Down
Loading

0 comments on commit b8888f4

Please sign in to comment.