VMware {code} Community
MR-Z
VMware Employee
VMware Employee
Jump to solution

--server option?

I have a number of virtual servers and need to take an educated guess in my script which server to connect to (based on the vm name for example). This way the user who runs the script does not need to provide --server argument.

What variable should I use to set the server name? $VI_SERVER does not seem to be it...

Reply
0 Kudos
1 Solution

Accepted Solutions
MR-Z
VMware Employee
VMware Employee
Jump to solution

Thanks. I have some default server already configured in .visdkrc, but relying on that is cumbersome, especially since I am trying to use different servers based on a specific user input.

After reading through some subs in VILib.pm, look like Opts::set_option('server' => $server) is all I need:

# validate options, and connect to the server

Opts::add_options(%opts);

Opts::parse();

Opts::validate();

Opts::set_option('server' => 'XXXX');

Util::connect();

View solution in original post

Reply
0 Kudos
2 Replies
lamw
Community Manager
Community Manager
Jump to solution

It is VI_SERVER, however that needs to be defined inside a file and then you can pass that using --config param. To get a list of variables, you can just run --help and each param will have it's equivalent variable listed in the output

MR-Z
VMware Employee
VMware Employee
Jump to solution

Thanks. I have some default server already configured in .visdkrc, but relying on that is cumbersome, especially since I am trying to use different servers based on a specific user input.

After reading through some subs in VILib.pm, look like Opts::set_option('server' => $server) is all I need:

# validate options, and connect to the server

Opts::add_options(%opts);

Opts::parse();

Opts::validate();

Opts::set_option('server' => 'XXXX');

Util::connect();

Reply
0 Kudos