18f2a6b09e
Remove exists images after restore call because they are contains old ssh keys and can't be used anymore. Change-Id: Ib8887621d2fef69c2ee00ebad486415a9be476d3 Closes-Bug: #1558057
34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import json
|
|
|
|
from octane import magic_consts
|
|
from octane.util import subprocess
|
|
|
|
|
|
def get_not_active_images_uuids():
|
|
fuel_bootstrap_list = ["fuel-bootstrap", "list", "--format", "json"]
|
|
images = json.loads(subprocess.call_output(fuel_bootstrap_list))
|
|
return [img["uuid"] for img in images if img["status"] != "active"]
|
|
|
|
|
|
def delete_image(uuid):
|
|
subprocess.call(["fuel-bootstrap", "delete", uuid])
|
|
|
|
|
|
def delete_not_active_images():
|
|
# Remove old images cause they were created with old ssh keys pair
|
|
for image_uuid in get_not_active_images_uuids():
|
|
if image_uuid not in magic_consts.BOOTSTRAP_UNSUPPORTED_IMAGES:
|
|
delete_image(image_uuid)
|