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

CASMCMS-8651: Remove ARS from CLI; Use updated BSS API spec with updated non-ARS link examples #108

Merged
merged 1 commit into from
Jun 5, 2023
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
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/platform-engineering
/cray/modules/badger @Cray-HPE/hardware-management
/cray/modules/bos @Cray-HPE/cray-management-systems
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.

69 changes: 9 additions & 60 deletions cray/modules/artifacts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,18 @@
# 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
import json
import sys
import uuid
import click
import boto3
from boto3.s3.transfer import TransferConfig
from botocore.exceptions import ClientError

from cray.core import argument
from cray.core import group
from cray.core import option
from cray.core import pass_context
from cray.echo import echo
from cray.errors import BadResponseError
Expand Down Expand Up @@ -144,44 +141,17 @@ 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)
obj_id = obj

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

# Create the object and a download url, then upload the file with the ARS-
# compatible metadata
# Create the object and then upload the file
try:
s3client.put_object(Bucket=bucket, Key=obj_id, ACL='public-read')
url = s3client.generate_presigned_url(
'get_object',
Params={'Bucket': bucket, 'Key': obj_id},
ExpiresIn=expires,
)
except s3client.exceptions.NoSuchBucket as err:
sys.exit(str(err))
except ClientError as err:
Expand All @@ -198,35 +168,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