Commit a40eeeeb by Szabolcs Gelencser

Fix azure vm size, template imports

parent a4cab8dc
......@@ -111,7 +111,11 @@ def update_azure_vm_sizes():
REGION,
)
current_vm_sizes = []
for vm_size in vm_sizes:
current_vm_sizes.append(vm_size.name)
try:
old_vm_size = AzureVirtualMachineSize.objects.get(name=vm_size.name)
old_vm_size.name = vm_size.name
......@@ -136,6 +140,12 @@ def update_azure_vm_sizes():
logger.info("finished importing azure vm sizes")
# delete old vm sizes
AzureVirtualMachineSize.objects.exclude(
name__in=current_vm_sizes).delete()
logger.info("finished deleting old azure vm sizes")
@celery.task(ignore_result=True)
def update_azure_builtin_templates():
logger.info("beginning azure built-in template imports")
......@@ -150,9 +160,14 @@ def update_azure_builtin_templates():
REGION,
)
for publisher in result_list_pub:
current_publisher = AzureBuiltinPublisher(
azure_id=publisher.id, name=publisher.name,
)
try:
current_publisher = AzureBuiltinPublisher.objects.get(
azure_id=publisher.id)
except ObjectDoesNotExist:
current_publisher = AzureBuiltinPublisher(
azure_id=publisher.id, name=publisher.name,
)
current_publisher.save()
current_publisher_ids.append(current_publisher.azure_id)
......@@ -161,9 +176,15 @@ def update_azure_builtin_templates():
publisher.name,
)
for offer in result_list_offers:
current_offer = AzureBuiltinOffer(
azure_id=offer.id, name=offer.name, publisher=current_publisher
)
try:
current_offer = AzureBuiltinOffer.objects.get(
azure_id=offer.id)
except ObjectDoesNotExist:
current_offer = AzureBuiltinOffer(
azure_id=offer.id, name=offer.name,
publisher=current_publisher
)
current_offer.save()
current_offer_ids.append(current_offer.azure_id)
......@@ -173,9 +194,14 @@ def update_azure_builtin_templates():
offer.name,
)
for sku in result_list_skus:
current_sku = AzureBuiltinSKU(
azure_id=sku.id, name=sku.name, offer=current_offer
)
try:
current_sku = AzureBuiltinSKU.objects.get(
azure_id=sku.id)
except ObjectDoesNotExist:
current_sku = AzureBuiltinSKU(
azure_id=sku.id, name=sku.name, offer=current_offer
)
current_sku.save()
current_sku_ids.append(current_sku.azure_id)
......@@ -186,9 +212,15 @@ def update_azure_builtin_templates():
sku.name,
)
for version in result_list:
current_version = AzureBuiltinVersion(
azure_id=version.id, name=version.name, sku=current_sku
)
try:
current_version = AzureBuiltinVersion.objects.get(
azure_id=version.id)
except ObjectDoesNotExist:
current_version = AzureBuiltinVersion(
azure_id=version.id, name=version.name,
sku=current_sku
)
current_version.save()
current_version_ids.append(current_version.azure_id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment