vmware/pyvmomi-community-samples

Create a directory and move connections into it

Offen

#484 geöffnet am 14.05.2018

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (914 Forks)batch import
help wanted

Repository-Metriken

Stars
 (972 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Hello,

I'm currently trying to automate a movement of ports groups into a directory in the inventory/networks interface.

If I've understood clearly, a directory appears depending of what you put in it.

That's what I am trying to do (it's a sample of code, of course the complete code is bigger ) :

def create_folder(content, host_folder, folder_name):
       host_folder.CreateFolder(folder_name)

si = SmartConnect(host=inputs['vcenter_ip'],user=inputs['vcenter_user'],pwd=inputs['vcenter_password'],port=int("443"))
content = si.RetrieveContent()
dc = get_obj(content, [vim.Datacenter], "Datacenter")
create_folder(content, dc.hostFolder, "MyDirectory")
nt = get_obj(content, [vim.Network], "MyPortgroup")
dr = get_obj(content, [vim.Folder], "MyDirectory")
dr.MoveInto([nt])

The error is : this operation is not supported on this object.

I suppose it's due to the way the directory is created, so how could I correct it to make it work ?

Thank you

Contributor Guide