VMware Cloud Community
CSIEnvironments
Enthusiast
Enthusiast

How to rename a civAppNetwork?

Hi,

I would like to rename a CIvAppNetwork from vAppNetwork to IntNat with PowerCLI.

I've tried the following:

$civapp | Get-CIVAppNetwork | Set-CIVAppNetwork -ReplaceNetworkWithNewNetworkWithChangedName "IntNat"

But as per the documentation it does more than just rename the vApp network, it gives it a new HREF etc...but it also won't change the name it if there are VM's attached to it.

Yet in the GUI it's easy as right click > properties > change name > ok.

Does anyone have the cloud views or sdk code to rename the vAppNetwork the way the gui does?

Thanks!

0 Kudos
4 Replies
andrey_anastaso
Enthusiast
Enthusiast

Hi CSIEnvironments,

This rename operation actually destroys the vApp network, then creates a new one with similar settings and the new name. As you point out, having VM network adapters attached to the network, prevents destroying the network and thus prevents the rename. To work around this, use the Set-CINetworkAdapter cmdlet to detach all VM network adapters from the network. Then do the rename operation. Then attach the VM network adapters to the new vApp network (the one with the new name).

Of the top of my head, the code to detach the adapters should be something like:

$myVAppNetwork | Get-CINetworkAdapter | Set-CINetworkAdapter -vAppNetwork $null

Cheers,

Andrey

0 Kudos
CSIEnvironments
Enthusiast
Enthusiast

Hi Andrey,

Sadly that's not the answer I was hoping for Smiley Sad I have a similar script except this poses 2 issues. I will then need to go an reattach every VM to the "new" network, then set the IP's for each VM's....This script will take a while considering we have 26 civms in 1 civapp. This is a mission especially since I need to do it for every CIvApp I add to cloud.

Any ideas how the GUI does it so simply without destroying the entire vApp network? Is it not possible to achieve the same result even with the restful api or c# sdk?

Thanks!

0 Kudos
andrey_anastaso
Enthusiast
Enthusiast

Hi, I have a question but first I'll answer yours:

- There is no way to avoid the "rename = delete + create" through the REST API. The REST API identifies the network by its name so when it sees a new name, it thinks "the network with the old name disappeared, and there's one new network with this new name". Personally I consider the lack of persistent network identifier a design flaw.

- Since the GUI uses a private API, I assume the private API does present a persistent ID for vApp networks and this allows a true rename operation.

Now, my question:

Can you confirm that you are just detaching the adapters and not deleting them? I imagine, that if you just detach the adapters from the network, without deleting them, all adapter settings (including IP address) should remain intact.

CSIEnvironments
Enthusiast
Enthusiast

That's sad to hear. I guess we will have to leave the pre-determined vAppNet- name.

Yes I can confirm that setting a civm to no network, then to a new one, it loses it's internal ip in a routed network.

get-civapp "Test vApp" | get-civm | Get-CINetworkAdapter | Set-CINetworkAdapter -vAppNetwork $null

or using the extensiondata property of the civm and setting the network to none/$null clears the IP it had.

Even if it didn't remove the IP, the amount of required to that for each VM is not worth the gain.

0 Kudos