File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ our @EXPORT = qw(
4545 az_vm_as_create
4646 az_vm_as_list
4747 az_vm_as_show
48+ az_vm_as_id
4849 az_img_from_vhd_create
4950 az_vm_create
5051 az_vm_list
@@ -751,6 +752,37 @@ sub az_vm_as_show(%args) {
751752 assert_script_run($az_cmd );
752753}
753754
755+ =head2 az_vm_as_id
756+
757+ az_vm_as_id(resource_group => 'openqa-rg', name => 'openqa-as');
758+
759+ Get the id of an availability set.
760+
761+ =over
762+
763+ =item B<resource_group > - existing resource group where to create the availability set
764+
765+ =item B<name > - name of the availability set
766+
767+ =back
768+ =cut
769+
770+ sub az_vm_as_id (%args ) {
771+ foreach (qw( resource_group name) ) {
772+ croak(" Argument < $_ > missing" ) unless $args {$_ };
773+ }
774+
775+ my $az_cmd = join (' ' , ' az vm availability-set show' ,
776+ ' --resource-group' , $args {resource_group },
777+ ' --name' , $args {name },
778+ ' --query id -o tsv' );
779+
780+ my $id = script_output($az_cmd );
781+ $id =~ s / ^\s +|\s +$// g ;
782+
783+ return $id ;
784+ }
785+
754786=head2 az_img_from_vhd_create
755787
756788 az_img_from_vhd_create(resource_group => $rg, name => $name, source => $uploaded_vhd_url);
Original file line number Diff line number Diff line change @@ -324,6 +324,9 @@ sub ipaddr2_infra_deploy(%args) {
324324 az_vm_as_show(
325325 resource_group => $rg ,
326326 name => $as );
327+ my $as_id = az_vm_as_id(
328+ resource_group => $rg ,
329+ name => $as );
327330
328331 my $storage_name ;
329332 if ($args {diagnostic }) {
@@ -349,7 +352,7 @@ sub ipaddr2_infra_deploy(%args) {
349352 public_ip => " " );
350353
351354 my %vm_create_internal_args = %vm_create_generic_args ;
352- $vm_create_internal_args {availability_set } = $as ;
355+ $vm_create_internal_args {availability_set } = $as_id ;
353356 $vm_create_internal_args {nsg } = $nsg ;
354357 $vm_create_internal_args {public_ip } = " " ;
355358 $vm_create_internal_args {custom_data } = $args {cloudinit_profile } if ($args {cloudinit_profile });
You can’t perform that action at this time.
0 commit comments