@@ -728,7 +728,7 @@ def create_virtual_machine(
728728 # create vm
729729 logger .debug (
730730 'creating virtual machine: {} availset={} zone={}' .format (
731- vm_name , availset .id , zone ))
731+ vm_name , availset .id if availset is not None else None , zone ))
732732 return compute_client .virtual_machines .create_or_update (
733733 resource_group_name = vm_resource .resource_group ,
734734 vm_name = vm_name ,
@@ -953,10 +953,12 @@ def deallocate_virtual_machine(compute_client, rg_name, vm_name):
953953 )
954954
955955
956- def get_ssh_info (compute_client , network_client , vm_res , nic = None , pip = None ):
956+ def get_ssh_info (
957+ compute_client , network_client , vm_res , ssh_key_prefix = None , nic = None ,
958+ pip = None ):
957959 # type: (azure.mgmt.compute.ComputeManagementClient,
958960 # azure.mgmt.network.NetworkManagementClient,
959- # settings.VmResource, networkmodes.NetworkInterface,
961+ # settings.VmResource, str, networkmodes.NetworkInterface,
960962 # networkmodels.PublicIPAddress) ->
961963 # Tuple[pathlib.Path, int, str, str]
962964 """Get SSH info to a federation proxy
@@ -965,6 +967,7 @@ def get_ssh_info(compute_client, network_client, vm_res, nic=None, pip=None):
965967 :param azure.mgmt.network.NetworkManagementClient network_client:
966968 network client
967969 :param settings.VmResource vm_res: resource
970+ :param str ssh_key_prefix: ssh key prefix
968971 :param networkmodels.NetworkInterface nic: network interface
969972 :param networkmodels.PublicIPAddress pip: public ip
970973 :rtype: tuple
@@ -998,30 +1001,30 @@ def get_ssh_info(compute_client, network_client, vm_res, nic=None, pip=None):
9981001 ssh_priv_key = vm_res .ssh .ssh_private_key
9991002 else :
10001003 ssh_priv_key = pathlib .Path (
1001- vm_res .ssh .generated_file_export_path ,
1002- crypto .get_federation_ssh_key_prefix ())
1004+ vm_res .ssh .generated_file_export_path , ssh_key_prefix )
10031005 if not ssh_priv_key .exists ():
10041006 raise RuntimeError ('SSH private key file not found at: {}' .format (
10051007 ssh_priv_key ))
10061008 return ssh_priv_key , 22 , vm .os_profile .admin_username , ip_address
10071009
10081010
10091011def ssh_to_virtual_machine_resource (
1010- compute_client , network_client , vm_res , tty , command ):
1012+ compute_client , network_client , vm_res , ssh_key_prefix , tty , command ):
10111013 # type: (azure.mgmt.compute.ComputeManagementClient,
10121014 # azure.mgmt.network.NetworkManagementClient,
1013- # settings.VmResource, bool, tuple) -> None
1014- """SSH to a node in federation proxy
1015+ # settings.VmResource, str, bool, tuple) -> None
1016+ """SSH to a node
10151017 :param azure.mgmt.compute.ComputeManagementClient compute_client:
10161018 compute client
10171019 :param azure.mgmt.network.NetworkManagementClient network_client:
10181020 network client
10191021 :param settings.VmResource vm_res: resource
1022+ :param str ssh_key_prefix: ssh key prefix
10201023 :param bool tty: allocate pseudo-tty
10211024 :param tuple command: command to execute
10221025 """
10231026 ssh_priv_key , port , username , ip = get_ssh_info (
1024- compute_client , network_client , vm_res )
1027+ compute_client , network_client , vm_res , ssh_key_prefix = ssh_key_prefix )
10251028 crypto .connect_or_exec_ssh_command (
10261029 ip , port , ssh_priv_key , username , tty = tty , command = command )
10271030
0 commit comments