VMware {code} Community
Pierrot26
Contributor
Contributor
Jump to solution

Perl toolkit vmregister.pl How can I specify to register a VM in a folder ?

Hi all,

I use vmregister.pl to register a VM in a VI Infrastructure and It works ! But I would like to register one VM directly in a specific folder. Or after registation complete transfert this VM in the correct folder (to make a move entities thanks to a script) ...

Somebody have an idea ? I already tried to modify vmregister.pl but It didn't work certainly because I am newbie in perl

I will really appreciate yours solutions

Sincerly,

Pierrot

Reply
0 Kudos
1 Solution

Accepted Solutions
ssurana
VMware Employee
VMware Employee
Jump to solution

Hi Pierrot,

You can do that by editing the code of vmregister.pl

Change the following code in the pl file at line# 92:

my $folder_view = Vim::find_entity_view(view_type => 'Folder',

begin_entity => $begin,

filter => {'childType' => "VirtualMachine"});

with the following code:

my $folder_view = Vim::find_entity_view(view_type => 'Folder',

begin_entity => $begin,

filter => {'childType' => "VirtualMachine",

'name' => ' MyTargetFolder '});

Here you have to substitute the "MyTargetFolder" with the target folder where you want to place the VM. Please note that this folder should be of childType "VirtualMachine"

In your application code you can further modify it to request the same from the user as an argument and then use the value here.

Hope the above information helps

~ Sidharth

View solution in original post

Reply
0 Kudos
5 Replies
ssurana
VMware Employee
VMware Employee
Jump to solution

Hi Pierrot,

You can do that by editing the code of vmregister.pl

Change the following code in the pl file at line# 92:

my $folder_view = Vim::find_entity_view(view_type => 'Folder',

begin_entity => $begin,

filter => {'childType' => "VirtualMachine"});

with the following code:

my $folder_view = Vim::find_entity_view(view_type => 'Folder',

begin_entity => $begin,

filter => {'childType' => "VirtualMachine",

'name' => ' MyTargetFolder '});

Here you have to substitute the "MyTargetFolder" with the target folder where you want to place the VM. Please note that this folder should be of childType "VirtualMachine"

In your application code you can further modify it to request the same from the user as an argument and then use the value here.

Hope the above information helps

~ Sidharth

Reply
0 Kudos
Pierrot26
Contributor
Contributor
Jump to solution

Hi Sidharth,

I tried lot of things before and finally it's very easy.

Thank you very much Sidharth Smiley Wink and thanks Vmware's staff...

Pierrot

Reply
0 Kudos
virtualbob1
Contributor
Contributor
Jump to solution

Hi,

I am able to register a VM in a resource pool, but am running into an issue if I have multiple resource pools of the same name in differing clusters. Say for example I have 2 clusters:

ClusterA

Pool-1

Pool-2

ClusterB

Pool-1

Pool-2

If I try to add to Pool-1 I get this error: Resource pool <cob> not unique.

How do I specify the cluster?

Thanks

Robert

Reply
0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

I'm not an expert in using the VI API, but I was trying to use VI Perl Toolkit command "vmregister.pl" and realized that it requires you to provide "datacenter and resource pool" as part of the registration process. I think this should not be a hard requirement, not everyone uses resource pools.

I thought of looking at the RCLI command "vmware-cmd.pl" and unfortunately, that is also implemented similar to "vmregister.pl", requiring datacenter and resource pool. This makes it a little hard to automate and requires additional parameters. One thing I like about the VI Perl Toolkit command, "vmregister.pl" and other commands is the fact it utilizes the VI fast pass on VMware VIMA.

I was wondering if there is a snippet of code I could use to just register a VM given the following:

--vmname MY_VM, --vmxpath "[datastore1] MY_VM/MY_VM.vmx", --server ESX_HOST

and utilizing VI fast pass? Is there simple modification I can make to the existing commands or smaller script that would accomplish this task?

Reply
0 Kudos
radek1986
Contributor
Contributor
Jump to solution

Hi,

Could you tell me how i should modify the vmregister.pl script to register VM to another folder ?

I attached vmregister script which I'm using.

If it is wrong, and you have the script which is working, please send me.

Thank in advance,

Regards,

Radek

Reply
0 Kudos