Quantcast
Channel: VMware Communities : Popular Discussions - VIX API
Viewing all 34639 articles
Browse latest View live

API or script to create ESX cluster and reconfigure HA

$
0
0

I know am very new to this vmware and this virtualisation developers world I have managed theVM infra however havent laid my hands on Development now there is a requirement at my place that we should automate the whole process of going virtualisation thru automation tools like Operations orchestration.

 

I would seek you guys help in any kind of document stuff or so..we have done couple off automations for simpler things like power ops and health checks and monitoring stuff .

 

 

Please help me if we can create a ESX cluster, and manage HA configurations.... wen checked in reference guide found functions like createclusteex and Das* objects..

 

 

If there is already a script handy or any API please help me...appreaciate your help and patience to go through this

 

 


Bug? RevertToSnapshot() hangs after a few hundred calls

$
0
0

I have a malware analysis program that I wrote in C# with VIX 1.6.2 that controls a set of 40 VMs on an ESX 3.5 server. The basic operation of this program is the VMs are grouped in sets of 2 and a thread is created for each group(ie, 20 threads controlling 2 VMs each).For each thread the program has a loop that opens up a VM, reverts to an initial snapshot, runs some malware, takes a snapshot, then reverts back to the initial snapshot and then shuts down the VM. The problem is, after about ~300 calls to RevertToSnapshot() my program hangs. No error messages are given, no exceptions are thrown, it just sits there doing nothing. Has anyone else run into this problem? Is there a fix available for this or is there some way to work around this? I really need this program to keep going without having to restart it every couple of hours. Below is the code I use in my RevertToSnapshot() wrapper:

 

public bool RevertToSnapshot(VixCOM.ISnapshot snapshot)

        {

            IJob jobHandle = vmHandle.RevertToSnapshot(snapshot, 0, null, null);

 

            vixError = jobHandle.WaitWithoutResults();

 

            return (vixError == VixCOM.Constants.VIX_OK);

        }

Let program know it is running in a VM?

$
0
0

 

Is there a "standard" or clean way for a program to determine that it is running in a VM (Linux guest OS)?

 

 

 

 

 

Situation: We're testing KickStarting RHEL Linux VMs.  So we'd like to programmatically see "You are running in a VM" and then based on that, you would do some things differently. E.g. not configuring NTP, need to install VMware Tools, etc...

 

 

 

 

 

Current solution is doing /sbin/lspci and looking for "VMware Inc" for the VGA controller. 

 

 

 

 

 

Just wondering if there is a "cleaner" or more standard way?   Since this program is running after the guest OS has been installed, but it is in the process of configuring services, packages, etc... VMware Tools has not been installed in the guest OS when the program runs.

 

 

 

 

 

 

 

 

Find guest operating system type

$
0
0

 

Hello everyone!!!

 

 

I'm looking for a way to find the guest operating system type using vix api. I saw that was possible using VI but didn't experiment it yet... If I don't find a "clean" way to get it done, I think I'm going to pass it through a vm property:

 

 

vmware-guestd --cmd "info-set guestinfo.guestos linux"

 

 

for instance, running such a little script within my virtual machine as a daemon, but I don't really like that...

 

 

Could somebody help me?

 

 

VIX_E_NOT_SUPPORTED returned from VMWareVirtualMachine.Clone

$
0
0

 

 

 

 

Hi, I'm using the Vestris .NET wrapper for VIX, and I've been able to successfully connect to my ESX server, get handles on VMs and stop and start them (great!). But now I want to clone a VM, and I'm getting VIX_E_NOT_SUPPORTED back. Here's my (C#) code:

 

VMWareVirtualMachine vm = null;
VMWareVirtualHost vmServer = new VMWareVirtualHost();
vmServer.ConnectToVMWareVIServer(_hostname, _username, password);
vm = vmServer.Open(
vmname);
vm.Clone(VMWareVirtualMachineCloneType.Full, _clonepath);

 

I've stripped out some logging and exception catching stuff, so I know that everything before the Clone call succeeds, and I know that my VM is powered off. I've also tried getting a handle on a snapshot on that VM and cloning that, with the same result.

 

 

Anyone any ideas?!

 

 

Error in VMRunProgramInGuest for Linux Guest

$
0
0

 

Hi all,

 

 

I am using script (guestcommand.pl) which does a guest login and run a guest command execution using VMRunProgramInGuest and display the command output at the host. If I run the program for a Windows guest, the script could execute a command at the remote system and gives the output, but If I run a command to a linux guest, Login to the guest command is working (VMGuestLogin), but during the function call VMRunPrograminGuest results in a error "VMRunPrograminGuest failed: 3015 Authentication failure or insufficient privileges". I have installed VMWare Tools in the guest(Rehat Enterprise 5).

 

 

Do I have to enable anything at the guest to make this script work?

 

 

Following is the link where I took the guestcommand.pl file from :http://blogs.vmware.com/vix/files/guestcommand.pl

 

 

Thanks,

 

 

Siva.

 

 

PowerOff after shutdown timeout

$
0
0

 

I am using VMware server 2.0 for testing end-user Windows applications.  Sometimes, when I try to do a soft shutdown of a guest OS, the shutdown halts.  When this happens via the VI web page, the interface will not allow me to perform a hard power off while it waits indefinitely for the soft shutdown.

 

 

I have a pretty extensive backup script that I have written to shuts down VM's before archiving and compressing them.  Currently, I simply use a blocking synchronous wait (WaitWithoutResults).  I know I can create a timeout wait by just  looping on the VM power status instead.  Before I bother actually modifying the code to do this, I want to ask the simple question.  Can I actually force a hard power off using the VixCOM package if I have already initiated a soft shutdown?  I know I can't using the VI interface; I just want to know if I can programatically.

 

 

Finding VM Power State is Inaccurate

$
0
0

 

I am using the following script to determine the power state of VMs.  Regardless of the real state, the result from this script is powerOn.  Thanks.

 

 

Script:

 

 

$VIServer = $Args[0]

$Image = $Args[1]

$User = $Args[2]

$Password = $Args[3]

$FilePath = "C:\Vmware_Healthcheck\Status_$Image.txt"

 

 

Add-PSsnapin VMware.VimAutomation.Core

Initialize-VIToolkitEnvironment.ps1

 

 

connect-viserver -server $VIServer -user $User -password $Password

 

 

$vm = Get-View -ViewType VirtualMachine -Filter @{"Name" = "$Image"}

$hostView = Get-View -ID $vm.Runtime.Host

$hostView.Summary.Runtime | Out-File -FilePath $FilePath

 

 

Disconnect-VIServer -Confirm:$False

 

 

 

 

 

 

 

 

Result:

 

 

ConnectionState     : connected

PowerState          : poweredOn

InMaintenanceMode   : False

BootTime            : 4/30/2009 15:05:19

HealthSystemRuntime : VMware.Vim.HealthSystemRuntime

DynamicType         :

DynamicProperty     :

 

 

 

 

 


VixJob_Wait API results segmentation fault after VixVM_PowerOn

$
0
0

 

All,

 

 

Trying some VM automation Code using VIX API SDK. After Loading  libvixAllProducts.so, VM registers successfully.

 

 

But when I tried to PowerOn,  VM VixJob_Wait give me segmentation fault after executing VixVM_PowerOn.

 

 

Observation:

 

 

1. Even it gives me segmentation fault, VM got powered on ESX server.

 

 

2. If i remove wait API with some sleep function, still i will get some segmentation fault.

 

 

 

 

 

Any suggestion, comments will be appriciated.

 

 

thanks

 

 

-tej

 

 

Cannot Start a VM Using Vmrun

$
0
0

 

I have VMWare WorkStation 6.5.2 on a Windows XP machine and I am trying to use vmrun to start a virtual machine. Seems like a straightforward task to me but I keep getting the message "Error: The specified service provider was not found." When I experimented with the COM API I got the same message (that was on another machine though).

 

 

wmrun -T ws -gu myUserNameOnGuestOS -gp myPasswordOnGuestOS start pathToMyVMXFile

 

 

What seems to be the problem here?

 

 

Error when running vmrun on Linux (vmrun 2.0.1)

$
0
0

 

Hi,

 

 

I tried to use vmrun on Linux (Ubuntu 8) with VMWare Server 2.0 installed (and vmrun 2.0.1 included).

 

 

I can browse my server with Web GUI (locally or remotely) with no problem, but when I tried to control it via command line locally (from that Linux itself), I keep getting this error message:

 

 

    Error: The specified service provider was not found

 

 

As I also have installed VMWare Server 2.0 on Windows (and vmrun 2.0.0, under VIX directory), I tried to control remotely to that first Linux machine and it works perfectly (needless to say that I can also control my local VMWare Server on my Windows box itself). The documentation and forum I read so far suggest that the vmrun is probably too old, to support -T server (but while my Windows can successfully do it with vmrun 2.0.0, and my Linux has 2.0.1, I'm a bit puzzled in that remark - but if it's the case, where can we download newer vmrun that support "-T server" for Linux?).

 

 

I'm pretty sure, it's not the security problem or wrong syntax (I even tried it as root), as I executed identical command on both machine. But if you're interested to know, the command I tried is:

 

 

   vmrun -T server -h https://10.128.41.27:8333/sdk -u (username) -p (password) list

 

 

(also have tried to use localhost, its machine name, or 127.0.0.1 on my local Linux with no difference)

 

 

Note:

 

 

I actually found a workaround to make it works using vmware-vim-cmd, but I found it much more tedious in syntax than vmrun. So, would prefer if I can make vmrun works.

 

 

Thanks for helping.

 

 

WaitForToolsInGuest does not return and hangs

$
0
0

 

I'm using VIX API 1.6.2 on 32 bit Windows 2003 (SP2) to control vitrual machines running on another 64-bit machine running ESXi 4.0.0 (171294).

 

 

The Virtual machine is running 32-bit Windows 2003 (SP2)  and has VMWare tools installed.

 

 

Using the VIX API I first revert to a named snapshot (that has the machine in shutdown state), then I power it on and wait for tools in guest before I run programs inside the VM.

 

 

The problem is that WaitForToolsInGuest ( ) does not return and hangs indefinately even after the OS has booted up successfully.

 

 

The code below works fine for ESX 3.5 (update 3) and also VMWare Server 2.0.1 but does not work forESXi 4.0.0 (171294)

 

 

 

 

 

My VBScript code that uses VIX API looks like this:

 

 

 

 

 

' Create the VIX library

 

 

Dim lib

 

 

Set lib = CreateObject("VixCOM.VixLib")

 

 

 

 

 

' Connect to ESXi server

 

 

Dim jobConnect

Set jobConnect = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_VI_SERVER, "https://myesxiserver:443/sdk/", 0, "root", "mypwd", 0, Nothing, Nothing)

 

 

Set connectResults = Nothing

err = jobConnect.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), connectResults)

If lib.ErrorIndicatesFailure(err) Then

       Wscript.Echo "Connecting to host failed with error code "

       WScript.Quit(err)

End If

 

 

Dim host

 

 

Set host = connectResults(0)

 

 

 

 

 

' Open the virtual machine

 

 

Set jobOpenVM = host.OpenVM("[datastore] myvm/myvm.vmx", Nothing)

 

Set openVMResults = Nothing

err = jobOpenVM.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), openVMResults)

If lib.ErrorIndicatesFailure(err) Then

       WScript.Echo "Opening virtual machine failed with error code "

       WScript.Quit(err)

End If

 

' The vm object will be first element in the results array.   

 

 

Dim vm

Set vm = openVMResults(0)

 

 

 

 

 

' Power on the virtual machine

 

 

Dim jobPowerOn

Set jobPowerOn = vm.PowerOn(VixCOM.Constants.VIX_VMPOWEROP_NORMAL, Nothing, Nothing)

err = jobPowerOn.WaitWithoutResults()

If lib.ErrorIndicatesFailure(err) Then

        WScript.Echo "Powering on guest failed with error code "

        WScript.Quit(err)

End If

 

 

 

' Wait until VMWare tools starts inside the guest

 

 

Dim jobWaitForTools

 

 

Set jobWaitForTools = vm.WaitForToolsInGuest(0, Nothing)

err = jobWaitForTools.WaitWithoutResults()

If lib.ErrorIndicatesFailure(err) Then

       WScript.Echo "Waiting for tools in guest failed with error code "

       WScript.Quit(err)

 

 

End If

 

 

 

 

 

Thanks in advance.

 

 

 

 

 

Host Connect Problems [Vix-Perl]

$
0
0

 

Hi,

 

My code (shown below) is producing the following error:

 

 

 

Failed to get property type for 3010 on handle 16799219.

HostConnect() failed, 22003, GetErrorText(22003)

Retrieving Host Handle...% 

 

 

Code: http://www.pastie.org/544455

 

 

The above is the module, and to test it I just made a normal .plx file that included the module,  and

 

 

vm( '/home/josh/vmware/SLES 10.2/SLES10.2.vmx' , 'start' );

 

 

...which should run the subroutine start, and use the path specified, but as shown above, I get that instead.

 

 

All help is greatly appreicated :).

 

 

 

 

 

-Josh

 

 

"Unknown Error" problem

$
0
0

 

Hi,

 

 

I see an error like one below in my program and have no idea what's causing it:

 

 

7/14/2009 11:34:52 AM: Vestris.VMWareLib.VMWareException: Unknown error

   at Vestris.VMWareLib.VMWareInterop.Check(UInt64 errCode)

   at Vestris.VMWareLib.VMWareJob.Wait[T](Object[] properties)

   at Vestris.VMWareLib.VMWareJob.Wait[T](Object[] properties, Int32 timeoutInSeconds)

   at Vestris.VMWareLib.VMWareVirtualMachine.RunProgramInGuest(String guestProgramName, String commandLineArgs, Int32 options, Int32 timeoutInSeconds)

 

 

I'm using dblocks VMWareTasks VIX Wrapper for C# (http://vmwaretasks.codeplex.com). My program is responsible for managing automation jobs running on an ESXi 3.5 server. The format of such an automation jobs is as follows:

 

 

- Open the required VM, and login.

 

 

- Copy in some script files necessary to run the job.

 

 

- Run the scripts, wait until they're complete, (could be 30 - 40 minutes).

 

 

- Copy out some results files.

 

 

- Logout and close the VM.

 

 

I get the this 'Unknown Error' in the following scenario, (for example):

 

 

- Three automation jobs are running, with each running on a different VM on the same ESX server. I have three distinct connections to the server.

 

 

- One job completes and logs out and closes down the VM.

 

 

- This error is seen on the other two jobs, so they don't complete.

 

 

I know there is a VIX bug with multiple connections and host handle sharing, but these are three distinct connections to the server and I even keep any handles to the server until the end of the programs execution.

 

 

Does anyone have any idea what may be happening? If you need anymore information, please ask and I will provide. Or can anybody give me some steps to help debug this further?

 

 

Thanks.

 

 

 

 

 

Any infos on the new 1.6.2 Version?

$
0
0

Hello all,

 

I just stumpled on VMware-vix-1.6.2-156745.exe available on the VMware Server 2 download page. The package's date: 30/3/2009, product version: 2.0.1 build-156745

Unfortunately, I could not find a changelog or something like that anywhere.

The VIX API landing page still claims that VMware-vix-1.6.2-127388.exe (03/12/2008, product version: 2.0.0 build-127388) is the most recent version of the VIX API.

http://www.vmware.com/support/developer/vix-api/

 

Can anyone point me to a changelog?

 

Thanks in advance.

 

Regards,

Patrick


Possible to list snapshots using VIX?

$
0
0

 

Is it possible to use just VIX 1.7 within a C# app to list a VM's snapshots by name? I've been looking over the VIX API Reference Documentation and haven't been able to find a function that will list the snapshots by name, but apparently vmrun.exe can do this using the listSnapshots command. I would like to know if there is something similar to this command in the VIX API.

 

 

 

 

 

Thanks!

 

 

Is there a way to retrieve performance statistics in VIX API?

$
0
0

I am going to use VIX API to control VMs host in ESX servers in my automation system. Is there a way to get the statistics for ESX and storage? I'd like to use them to determine if the action is allowed, for example, it won't power on any VMs if CPU usage is more than 70%.

Since upgrading from VIX 1.6 to 1.7, VIX_E_LICENSE on Open

$
0
0

Hi,

 

Since upgrading to VIX 1.7 today, my C# program fails on the line:

  VixCOM.IJob jobHandle = hostHandle.OpenVM(vmxFileName, null);

With the vix error VIX_E_LICENSE.

 

I'm connecting to an ESXi box which reports that it's licensed when I look at it with the client infrastructure tool.

 

I'm wondering if anybody else has seen this problem or could give me a suggestion as to what's going on?

 

I've rebooted after installing VIX 1.7 and have recompiled all my code that uses it.

 

Any help would be appreciated,

   -Scott

Possible is it that VixHost_Connect() complete a connection through a session ID, not the username and password?

$
0
0

What I want to realize is that accomplish a interaction with the vm on some ESX host under my VC. Because of  the unreachable of ESX host username and password, I can only get the session from the VC, then how can I reach the vm with VIX?

 

 

I have some try, just initialize the username with session ID and  password NULL, then I get such error: CRITICAL **: gvmomi_session_connect: assertion `cnxParams' failed, anyone have ideas?

 

 

 

 

 

 

 

 

Thanks in advance.

'Authentication failure' error thrown from RunProgramInGuest mehod

$
0
0

 

Hey,

 

 

I was trying to run a program with a graphical user interface, but got 'Authentication failure or insufficient permission in guest operation system" error from RunProgramInGuest after log in with Interactive option.

 

 

Here is my code:

 

 

Set job = VM.LoginInGuest(userId, userPassword, VixCOM.Constants.VIX_LOGIN_IN_GUEST_REQUIRE_INTERACTIVE_ENVIRONMENT, Nothing)

 

 

  Set job = VM.ListProcessesInGuest(0,Nothing)

 

 

  Set job = VM.RunProgramInGuest("C:\Tests\Test.exe", "A", VixCOM.Constants.VIX_RUNPROGRAM_ACTIVATE_WINDOW, Nothing, Nothing)   -- i want the application visible to user

 

 

I set up my VM with auto logon, so when VM powered on, an interactive user with the user name and password i provided in the LoginIn method would automatically log on in the guest OS.

 

 

There is no error during the logon, but 'Authentication error" thrown nomatter what program i run from VM.

 

 

Any suggestion?

 

 

Thanks very much.

 

 

J

 

 

   

 

 

 

 

 

 

 

 

Viewing all 34639 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>