Fix alias creation
Fingerprint was not being set back from LXD so generate fingerprint from the files downloaded from glance. Signed-off-by: Chuck Short <chuck.short@canonical.com>
This commit is contained in:
parent
2227067a6f
commit
13b5d3773e
|
@ -13,6 +13,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import hashlib
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
from nova import exception
|
from nova import exception
|
||||||
|
@ -74,12 +75,13 @@ class LXDContainerImage(object):
|
||||||
image_meta)
|
image_meta)
|
||||||
utils.execute('xz', '-9', container_manifest_img)
|
utils.execute('xz', '-9', container_manifest_img)
|
||||||
|
|
||||||
img_info = self._image_upload(
|
self._image_upload(
|
||||||
(container_manifest_img + '.xz', container_rootfs_img),
|
(container_manifest_img + '.xz', container_rootfs_img),
|
||||||
container_manifest_img.split('/')[-1], False,
|
container_manifest_img.split('/')[-1], False,
|
||||||
instance)
|
instance)
|
||||||
|
|
||||||
self._setup_alias(instance, img_info)
|
self._setup_alias((container_manifest_img + '.xz',
|
||||||
|
container_rootfs_img), instance)
|
||||||
|
|
||||||
os.unlink(container_manifest_img + '.xz')
|
os.unlink(container_manifest_img + '.xz')
|
||||||
|
|
||||||
|
@ -182,6 +184,7 @@ class LXDContainerImage(object):
|
||||||
try:
|
try:
|
||||||
status, data = self.connection.image_upload(data=body,
|
status, data = self.connection.image_upload(data=body,
|
||||||
headers=headers)
|
headers=headers)
|
||||||
|
|
||||||
except lxd_exceptions as ex:
|
except lxd_exceptions as ex:
|
||||||
raise exception.ImageUnacceptable(
|
raise exception.ImageUnacceptable(
|
||||||
image_id=instance.image_ref,
|
image_id=instance.image_ref,
|
||||||
|
@ -189,13 +192,18 @@ class LXDContainerImage(object):
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _setup_alias(self, instance, img_info):
|
def _setup_alias(self, path, instance):
|
||||||
LOG.debug('Updating image and metadata')
|
LOG.debug('Updating image and metadata')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
meta_path, rootfs_path = path
|
||||||
|
with open(meta_path, 'rb') as meta_fd:
|
||||||
|
with open(rootfs_path, "rb") as rootfs_fd:
|
||||||
|
fingerprint = hashlib.sha256(meta_fd.read() +
|
||||||
|
rootfs_fd.read()).hexdigest()
|
||||||
alias_config = {
|
alias_config = {
|
||||||
'name': instance.image_ref,
|
'name': instance.image_ref,
|
||||||
'target': img_info['metadata']['fingerprint']
|
'target': fingerprint
|
||||||
}
|
}
|
||||||
LOG.debug('Creating alias: %s' % alias_config)
|
LOG.debug('Creating alias: %s' % alias_config)
|
||||||
self.connection.alias_create(alias_config)
|
self.connection.alias_create(alias_config)
|
||||||
|
|
Loading…
Reference in New Issue