scripts/update_test_amis.py uses code from moto instead of copy
This commit is contained in:
parent
e3b7e6a44b
commit
68ae92db1e
|
@ -1,7 +0,0 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(strict=True, reason="cleanup update_test_amis.py to use moto.ec2.utils.gen_moto_amis")
|
|
||||||
def test_for_update_test_amis_cleanup():
|
|
||||||
from moto.ec2.utils import gen_moto_amis
|
|
||||||
return type(gen_moto_amis)
|
|
|
@ -11,6 +11,7 @@ deploy_path = os.path.join(os.path.dirname(__file__), "../deploy")
|
||||||
sys.path.append(deploy_path)
|
sys.path.append(deploy_path)
|
||||||
|
|
||||||
from awstools.awstools import get_f1_ami_id
|
from awstools.awstools import get_f1_ami_id
|
||||||
|
from moto.ec2.utils import gen_moto_amis
|
||||||
|
|
||||||
our_ami = get_f1_ami_id()
|
our_ami = get_f1_ami_id()
|
||||||
print(f"Current FPGA Dev AMI used by firesim is {our_ami}")
|
print(f"Current FPGA Dev AMI used by firesim is {our_ami}")
|
||||||
|
@ -24,32 +25,10 @@ client = boto3.client("ec2")
|
||||||
test = client.describe_images(ImageIds=instances)
|
test = client.describe_images(ImageIds=instances)
|
||||||
test["Images"].shouldnt.be.empty
|
test["Images"].shouldnt.be.empty
|
||||||
|
|
||||||
result = []
|
|
||||||
for image in test["Images"]:
|
|
||||||
try:
|
|
||||||
tmp = {
|
|
||||||
"ami_id": image["ImageId"],
|
|
||||||
"name": image["Name"],
|
|
||||||
"description": image["Description"],
|
|
||||||
"owner_id": image["OwnerId"],
|
|
||||||
"public": image["Public"],
|
|
||||||
"virtualization_type": image["VirtualizationType"],
|
|
||||||
"architecture": image["Architecture"],
|
|
||||||
"state": image["State"],
|
|
||||||
"platform": image.get("Platform"),
|
|
||||||
"image_type": image["ImageType"],
|
|
||||||
"hypervisor": image["Hypervisor"],
|
|
||||||
"root_device_name": image["RootDeviceName"],
|
|
||||||
"root_device_type": image["RootDeviceType"],
|
|
||||||
"sriov": image.get("SriovNetSupport", "simple"),
|
|
||||||
}
|
|
||||||
result.append(tmp)
|
|
||||||
except Exception as err:
|
|
||||||
raise # we can't afford to ignore any AMIs in our list, we need them all to be available
|
|
||||||
|
|
||||||
test_ami_path = os.path.join(deploy_path, "tests/test_amis.json")
|
test_ami_path = os.path.join(deploy_path, "tests/test_amis.json")
|
||||||
with open(test_ami_path, 'w') as test_amis:
|
with open(test_ami_path, 'w') as test_amis:
|
||||||
json.dump(result, test_amis, indent=2)
|
json.dump(gen_moto_amis(test["Images"]), test_amis, indent=2)
|
||||||
|
|
||||||
print(f"Updated {test_ami_path}")
|
print(f"Updated {test_ami_path}")
|
||||||
os.system(f"git diff {test_ami_path}")
|
os.system(f"git diff {test_ami_path}")
|
||||||
|
|
Loading…
Reference in New Issue