Fix AMI image registration
Depends-On: Ibe564b0edb64eaf2240f077f4adf042689ed6057 Change-Id: I5ab6b6720ae75d9f036b41c84b11e0fe0608b0d1
This commit is contained in:
parent
76e3d0af6c
commit
eba6cf3805
|
@ -43,8 +43,8 @@ the local.conf or localrc the following line:
|
||||||
|
|
||||||
enable_plugin ec2-api https://opendev.org/openstack/ec2-api
|
enable_plugin ec2-api https://opendev.org/openstack/ec2-api
|
||||||
|
|
||||||
Devstack installation with ec2-api and ec2api-tempest-plugin for tests running:
|
Devstack installation with ec2-api and ec2api-tempest-plugin for development:
|
||||||
1. install packages: awscli, git, python3, python3-devel
|
1. install packages: awscli, git, python3, python3-devel, ruby
|
||||||
2. clone devstack repository
|
2. clone devstack repository
|
||||||
|
|
||||||
::
|
::
|
||||||
|
@ -78,7 +78,6 @@ Devstack installation with ec2-api and ec2api-tempest-plugin for tests running:
|
||||||
|
|
||||||
cd ~/devstack/
|
cd ~/devstack/
|
||||||
./stack.sh
|
./stack.sh
|
||||||
sudo systemctl enable httpd
|
|
||||||
|
|
||||||
8. check installed devstack
|
8. check installed devstack
|
||||||
|
|
||||||
|
|
|
@ -902,10 +902,10 @@ def _s3_create(context, metadata):
|
||||||
|
|
||||||
# NOTE(vish): this may be suboptimal, should we use cat?
|
# NOTE(vish): this may be suboptimal, should we use cat?
|
||||||
enc_filename = os.path.join(image_path, 'image.encrypted')
|
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:
|
for filename in parts:
|
||||||
with open(filename) as part:
|
with open(filename, "rb") as part:
|
||||||
shutil.copyfileobj(part, combined)
|
combined.write(part.read())
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Failed to download %(image_location)s '
|
LOG.exception('Failed to download %(image_location)s '
|
||||||
|
@ -935,7 +935,7 @@ def _s3_create(context, metadata):
|
||||||
|
|
||||||
_update_image_state('uploading')
|
_update_image_state('uploading')
|
||||||
try:
|
try:
|
||||||
with open(unz_filename) as image_file:
|
with open(unz_filename, "rb") as image_file:
|
||||||
glance.images.upload(image.id, image_file)
|
glance.images.upload(image.id, image_file)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('Failed to upload %(image_location)s '
|
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)
|
s3_object = s3_client.get_object(Bucket=bucket_name, Key=filename)
|
||||||
local_filename = os.path.join(local_dir, os.path.basename(filename))
|
local_filename = os.path.join(local_dir, os.path.basename(filename))
|
||||||
body = s3_object['Body']
|
body = s3_object['Body']
|
||||||
with open(local_filename, 'w') as f:
|
with open(local_filename, 'wb') as f:
|
||||||
if isinstance(body, six.string_types):
|
f.write(body.read())
|
||||||
f.write(body)
|
|
||||||
else:
|
|
||||||
# TODO(andrey-mp): check big objects
|
|
||||||
f.write(body.read())
|
|
||||||
f.close()
|
|
||||||
return local_filename
|
return local_filename
|
||||||
|
|
||||||
|
|
||||||
|
@ -1028,12 +1023,12 @@ def _s3_decrypt_image(context, encrypted_filename, encrypted_key,
|
||||||
encrypted_key = binascii.a2b_hex(encrypted_key)
|
encrypted_key = binascii.a2b_hex(encrypted_key)
|
||||||
encrypted_iv = binascii.a2b_hex(encrypted_iv)
|
encrypted_iv = binascii.a2b_hex(encrypted_iv)
|
||||||
try:
|
try:
|
||||||
key = _decrypt_text(encrypted_key)
|
key = _decrypt_text(encrypted_key).decode()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
msg = _('Failed to decrypt private key: %s') % exc
|
msg = _('Failed to decrypt private key: %s') % exc
|
||||||
raise exception.EC2Exception(msg)
|
raise exception.EC2Exception(msg)
|
||||||
try:
|
try:
|
||||||
iv = _decrypt_text(encrypted_iv)
|
iv = _decrypt_text(encrypted_iv).decode()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
msg = _('Failed to decrypt initialization vector: %s') % exc
|
msg = _('Failed to decrypt initialization vector: %s') % exc
|
||||||
raise exception.EC2Exception(msg)
|
raise exception.EC2Exception(msg)
|
||||||
|
|
Loading…
Reference in New Issue