@@ -13,7 +13,10 @@ class AzureConfigBuilderV2(BaseConfigBuilder):
1313 "azurerm" : {"source" : "hashicorp/azurerm" , "version" : f"~> { provider_version } " }
1414 }
1515
16- default_x86_vm_size = 'Standard_DS1_v2'
16+ default_x86_vm_size = {
17+ "gen1" : "Standard_DS1_v2" ,
18+ "gen2" : "Standard_B2ms"
19+ }
1720 default_arm64_vm_size = 'Standard_D2pls_v5'
1821 default_hyper_v_generation = 'V2'
1922 default_admin_username = 'azure'
@@ -86,8 +89,6 @@ def build_resources(self):
8689 self .__new_azure_shared_image (instance )
8790 self .__new_azure_shared_image_version (instance )
8891
89- self .__new_azure_public_ip (instance )
90- self .__new_azure_nic (instance )
9192 self .__new_azure_vm (instance )
9293
9394 if not self .resources_tf ['resource' ]['azurerm_shared_image_gallery' ]:
@@ -218,8 +219,9 @@ def __new_azure_subnet(self, instance):
218219
219220 self .resources_tf ['resource' ]['azurerm_subnet' ][name ] = new_subnet
220221
221- def __new_azure_public_ip (self , instance ):
222- name = self .create_resource_name ([instance ['hostname' ], 'public-ip' ])
222+ def __new_azure_public_ip (self , instance , gen_suffix = None ):
223+ suffix = f"-{ gen_suffix } " if gen_suffix else ""
224+ name = self .create_resource_name ([instance ['hostname' ], 'public-ip' ]) + suffix
223225 instance ['azurerm_public_ip' ] = name
224226
225227 new_public_ip = {
@@ -233,8 +235,9 @@ def __new_azure_public_ip(self, instance):
233235
234236 self .resources_tf ['resource' ]['azurerm_public_ip' ][name ] = new_public_ip
235237
236- def __new_azure_nic (self , instance ):
237- name = self .create_resource_name ([instance ['hostname' ], 'nic' ])
238+ def __new_azure_nic (self , instance , gen_suffix = None ):
239+ suffix = f"-{ gen_suffix } " if gen_suffix else ""
240+ name = self .create_resource_name ([instance ['hostname' ], 'nic' ]) + suffix
238241 instance ['azurerm_network_interface' ] = name
239242
240243 ip_configuration = {
@@ -273,7 +276,20 @@ def __new_azure_vm(self, instance):
273276 if instance ['arch' ] == 'Arm64' :
274277 instance ['instance_type' ] = self .default_arm64_vm_size
275278 else :
276- instance ['instance_type' ] = self .default_x86_vm_size
279+
280+ for gen , vm_size in self .default_x86_vm_size .items ():
281+ temp_instance = instance .copy ()
282+ temp_instance ['instance_type' ] = vm_size
283+ temp_instance ['hostname' ] = self .create_resource_name ([instance ['hostname' ], gen ])
284+ self .__new_azure_public_ip (temp_instance , gen )
285+ self .__new_azure_nic (temp_instance , gen )
286+ self .__create_single_vm (temp_instance )
287+ else :
288+ self .__new_azure_public_ip (instance )
289+ self .__new_azure_nic (instance )
290+ self .__create_single_vm (instance )
291+
292+ def __create_single_vm (self , instance ):
277293
278294 instance_hostname = instance ['hostname' ]
279295
0 commit comments