hundreds-gpu-71155
03/13/2024, 4:54 PMnics = vm.network_profile.network_interfaces.apply(
lambda nics: [
network.get_network_interface_output(
resource_group_name=resource_group.name,
network_interface_name=get_name(nic),
)
for nic in nics
]
)
nics.apply(
lambda nics: pulumi.Output.all(
*[nic.ip_configurations for nic in nics]
).apply(
lambda ipcss: [
ipc["private_ip_address"] for ipcs in ipcss for ipc in ipcs
]
)
),
miniature-musician-31262
03/13/2024, 5:02 PMhundreds-gpu-71155
03/13/2024, 5:04 PMlist[Output] -> list[list[Output]] -> list[list[Output]]
(getting all the IP addresses from every Network Interface on a VM)hundreds-gpu-71155
03/13/2024, 5:04 PMhundreds-gpu-71155
03/13/2024, 5:05 PMhundreds-gpu-71155
03/13/2024, 5:07 PMhundreds-gpu-71155
03/13/2024, 5:09 PM[
ipc["private_ip_address"]
for nic in vm.network_profile.network_interfaces
for ipc in nic.ip_configurations
]
hundreds-gpu-71155
03/13/2024, 5:12 PMawait
through there and make it work, that would be great. excellent, even. but doing so requires extra work to get into the async context.hundreds-gpu-71155
03/13/2024, 5:23 PMhundreds-gpu-71155
03/13/2024, 5:26 PMOutput.apply()
accepts an async functionhundreds-gpu-71155
03/13/2024, 5:27 PMOutput._future
, although I bet that a bunch of metadata is losthundreds-gpu-71155
03/13/2024, 5:31 PM[
ipc["private_ip_address"]
for nic in await vm.network_profile.network_interfaces
for ipc in await (await get_network_interface_output(nic)).ip_configurations
]
hundreds-gpu-71155
03/13/2024, 5:31 PMminiature-musician-31262
03/13/2024, 8:16 PMminiature-musician-31262
03/13/2024, 8:21 PMhundreds-gpu-71155
03/13/2024, 8:22 PMOutput.apply()
accepts async functions (or you combine asyncio.ensure_future()
with Output()
), and that'll let you get into an async context. You can then use await some_output._future
inside to access data.
The big problem with this hack is that it'll lose a bunch of metadata (resource tracking, secret status). Pulumi could probably commit some sins to preserve some of that tracking (eg, add code to __await__
to mark when a value's been used in a coroutine, add encapsulation types), but there might be caveats (eg, it might only be able to track the metadata of the overall coroutine, not track the flow of data inside the coroutine).hundreds-gpu-71155
03/13/2024, 8:25 PMpulumi.runtime.run()
, which i didn't figure out until i had looked through the docs and source to find it.
the proper answer is "pulumi does not support python async. use async with caution."miniature-musician-31262
03/13/2024, 8:25 PMhundreds-gpu-71155
03/13/2024, 8:26 PMhundreds-gpu-71155
03/13/2024, 8:27 PMbusy-journalist-6936
03/13/2024, 8:30 PMhundreds-gpu-71155
03/13/2024, 8:33 PMpulumi_azure_native.compute.VirtualMachine
, how do I aggregate their IP addresses?hundreds-gpu-71155
03/13/2024, 8:35 PMbusy-journalist-6936
03/13/2024, 8:36 PMhundreds-gpu-71155
03/13/2024, 9:12 PM