Fix AMI image registration

Depends-On: Ibe564b0edb64eaf2240f077f4adf042689ed6057
Change-Id: I5ab6b6720ae75d9f036b41c84b11e0fe0608b0d1
This commit is contained in:
Dmitry_Eremeev 2020-02-13 16:15:38 +03:00
parent 76e3d0af6c
commit eba6cf3805
2 changed files with 10 additions and 16 deletions

View File

@ -43,8 +43,8 @@ the local.conf or localrc the following line:
enable_plugin ec2-api https://opendev.org/openstack/ec2-api
Devstack installation with ec2-api and ec2api-tempest-plugin for tests running:
1. install packages: awscli, git, python3, python3-devel
Devstack installation with ec2-api and ec2api-tempest-plugin for development:
1. install packages: awscli, git, python3, python3-devel, ruby
2. clone devstack repository
::
@ -78,7 +78,6 @@ Devstack installation with ec2-api and ec2api-tempest-plugin for tests running:
cd ~/devstack/
./stack.sh
sudo systemctl enable httpd
8. check installed devstack

View File

@ -902,10 +902,10 @@ def _s3_create(context, metadata):
# NOTE(vish): this may be suboptimal, should we use cat?
enc_filename = os.path.join(image_path, 'image.encrypted')
with open(enc_filename, 'w') as combined:
with open(enc_filename, 'wb') as combined:
for filename in parts:
with open(filename) as part:
shutil.copyfileobj(part, combined)
with open(filename, "rb") as part:
combined.write(part.read())
except Exception:
LOG.exception('Failed to download %(image_location)s '
@ -935,7 +935,7 @@ def _s3_create(context, metadata):
_update_image_state('uploading')
try:
with open(unz_filename) as image_file:
with open(unz_filename, "rb") as image_file:
glance.images.upload(image.id, image_file)
except Exception:
LOG.exception('Failed to upload %(image_location)s '
@ -1013,13 +1013,8 @@ def _s3_download_file(s3_client, bucket_name, filename, local_dir):
s3_object = s3_client.get_object(Bucket=bucket_name, Key=filename)
local_filename = os.path.join(local_dir, os.path.basename(filename))
body = s3_object['Body']
with open(local_filename, 'w') as f:
if isinstance(body, six.string_types):
f.write(body)
else:
# TODO(andrey-mp): check big objects
f.write(body.read())
f.close()
with open(local_filename, 'wb') as f:
f.write(body.read())
return local_filename
@ -1028,12 +1023,12 @@ def _s3_decrypt_image(context, encrypted_filename, encrypted_key,
encrypted_key = binascii.a2b_hex(encrypted_key)
encrypted_iv = binascii.a2b_hex(encrypted_iv)
try:
key = _decrypt_text(encrypted_key)
key = _decrypt_text(encrypted_key).decode()
except Exception as exc:
msg = _('Failed to decrypt private key: %s') % exc
raise exception.EC2Exception(msg)
try:
iv = _decrypt_text(encrypted_iv)
iv = _decrypt_text(encrypted_iv).decode()
except Exception as exc:
msg = _('Failed to decrypt initialization vector: %s') % exc
raise exception.EC2Exception(msg)