-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Ubuntu 24 to deploy-agent. This includes adding support for Python 3.12. This requires updating some packages (e.g. requests, gevent, boto). For boto, an `s3_client` class was added to support new (boto3) and old (boto) packages. Testing done: - Unit tests passed - Installed the deploy-agent package on an Ubuntu 24 host - Deploy agent ran, but failed due to missing `facter` command - Installed the deploy-agent package on an Ubuntu 20 host - The deploy agent worked as expected. Was able to install new Teletraan builds and restart a Teletraan stage
- Loading branch information
Showing
9 changed files
with
135 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
USE_BOTO3 = False | ||
try: | ||
from boto.s3.connection import S3Connection | ||
except ImportError: | ||
import botocore | ||
import boto3 | ||
|
||
USE_BOTO3 = True | ||
|
||
|
||
class Boto2Client: | ||
""" | ||
Client to handle boto2 operations. This can be removed | ||
once boto2 is no longer used | ||
""" | ||
def __init__(self, aws_access_key_id, aws_secret_access_key): | ||
self.client = S3Connection(aws_access_key_id, aws_secret_access_key, True) | ||
|
||
def get_key(self, bucket_name, key_name): | ||
""" | ||
Return the object at the specified key | ||
""" | ||
return self.client.get_bucket(bucket_name).get_key(key_name) | ||
|
||
def download_object_to_file(self, obj, file_name): | ||
""" | ||
Download the object to the specified file name | ||
:param obj: the object returned from `self.get_key` | ||
:param file_name str: the file_name to download to | ||
""" | ||
obj.get_contents_to_filename(file_name) | ||
|
||
def get_etag(self, obj): | ||
""" | ||
Get the etag of the specified object | ||
:param obj: the object returned from `self.get_key` | ||
""" | ||
return obj.etag | ||
|
||
|
||
class Boto3Client: | ||
""" | ||
Client to handle boto3 operations. This can be renamed to | ||
`S3Client` once boto2 is no longer used. | ||
""" | ||
def __init__(self, aws_access_key_id, aws_secret_access_key): | ||
session = boto3.Session( | ||
aws_access_key_id=aws_access_key_id, | ||
aws_secret_access_key=aws_secret_access_key, | ||
) | ||
self.client = session.resource('s3') | ||
|
||
def get_key(self, bucket_name, key_name): | ||
""" | ||
Return the object at the specified key | ||
""" | ||
obj = self.client.Bucket(bucket_name).Object(key_name) | ||
try: | ||
# To be compatible with boto2, return None if key does not exist | ||
obj.load() | ||
return obj | ||
except botocore.exceptions.ClientError as e: | ||
if e.response['Error']['Code'] == "404": | ||
return None | ||
else: | ||
raise | ||
|
||
def download_object_to_file(self, obj, file_name): | ||
""" | ||
Download the object to the specified file name | ||
:param obj: the object returned from `self.get_key` | ||
:param file_name str: the file_name to download to | ||
""" | ||
obj.download_file(file_name) | ||
|
||
def get_etag(self, obj): | ||
""" | ||
Get the etag of the specified object | ||
:param obj: the object returned from `self.get_key` | ||
""" | ||
return obj.e_tag | ||
|
||
S3Client = Boto3Client if USE_BOTO3 else Boto2Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
-e . | ||
|
||
PyYAML==5.3.1 | ||
PyYAML==5.3.1; python_version < '3.12' | ||
PyYAML==6.0.1; python_version >= '3.12' | ||
zipp==1.2.0 | ||
configparser==4.0.2 | ||
python-daemon==2.0.6 | ||
setuptools==44.1.1; python_version < '3' | ||
setuptools==54.2.0; python_version >= '3' | ||
setuptools==54.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters