Is there any way to customize the personality of a vm by injecting data into its file system at creation phase?
For example,if you want to insert ssh keys, set configuration files, or store data that you want to retrieve from inside the vm.
Is there any way to customize the personality of a vm by injecting data into its file system at creation phase?
For example,if you want to insert ssh keys, set configuration files, or store data that you want to retrieve from inside the vm.
Creating a custom attribute using the perl sdk looks like this:
$customFieldMgr->AddCustomFieldDef(name => $cfkey, moType => 'VirtualMachine');
Doing the same in python using pyvmomi creates a traceback:
>>> customFieldMgr.AddCustomFieldDef(name = cfkey, moType = 'VirtualMachine')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pyVmomi/VmomiSupport.py", line 553, in <lambda>
self.f(*(self.args + (obj,) + args), **kwargs)
File "pyVmomi/VmomiSupport.py", line 361, in _InvokeMethod
map(CheckField, info.params, args)
File "pyVmomi/VmomiSupport.py", line 936, in CheckField
% (info.name, info.type.__name__, valType.__name__))
TypeError: For "moType" expected type type, but got str
So whats wrong here?
BTW: does someone know a source of examples using pyvmomi?
Mathias
I understand that ova is an archive format of the ovf image. Basically it's a tarball of the files in the ovf image. Is there any API in VISDK to take an ova file directly from a remote server? An ova file can be really huge. Assuming the ova file is located on an FTP server. It'd become really inefficient if it requires download the huge ova file before import.
Thanks!
The docs (vSphere Documentation Center) say 'As a general rule, specify between 10 and 50 entities in a single call to the QueryPerf method."
How does one attach multiple eneties to queryspec?
Thanks in advance,
A
Hi Experts,
i am using the createpropertycollector to create the propertycollector object. This is per-thread basis.
if each thread calls up the retrieveproperties(...), then there would be crash. How to avoid this ?
Is it the problem with the vSphere 5.5 API ?
Thanks in advance.
--
Balaga
Is it possible to have the vSphere server to download files based on an asynchronos request?
For instance, if I want to create a VM from an external image.
So make a request to vSphere server and pass a url, then have vSphere server to download it.
Hi there,
Do we have Vijava.jar available as an OSGi-fied bundle that can deployed on the vSphere Web Client?
Thanks,
Bhrami
We are attempting to create a vmdk that points to an iSCSI target via a RDM. Our goal is to have this process be 100% automated via the SOAP API, but cannot find the necessary function calls within the API to create the vmdk. We can do so manually by connecting to the ESX host and using the vmkfstools command, but this requires that SSH be enabled on the host and we would definitely prefer not to have to do that. Our hope is that the API would allow us to do the same commands, but does not appear to have support for this use case.
Is this possible using the API, or is there a different path we could take that would result in the same goal?
I was wondering if there is a way to run vmkfstools through an api call. specifically I need the -r command.
Hi, how do you get all esx hosts from a vcenter? I can navigate via MOB (/mob/?moid=HostProfileManager) which lists my clusters and I can then click through on those to see the hosts but I cant work out how to use the api to do this?
I dont need code examples just a top level of what method needs to be called will suffice!
Thanks
If I add a static iSCSI target via the command line, and then do a rescan, i can see a new entry appear in /vmfs/devices/disks. This is great, however, very unreliable once more than one static target is added, you would have no idea which disk is associated with which target. Is there a way through either the CLI or API that allows you to see which disk maps to which static target?
I am using this to create vmdk's and need to know without a doubt which disk points to which target.
Thanks.
Hi,
I am trying to create a virtual machine in a cluster using a storage pod cluster.
I am getting an error when calling the RecommendDatastores.
The error looks like this:
Internal Server Error Occured: optional value not set
I have no idea what is the value that is missing.
I wonder if you can you give me some pointers or some troubleshooting tips?
Are there any logs that may help?
Should I try to configure the server to use HTTP and spy the SOAP messages?
Code transcript for creating the virtual machine using storage DRS
private void createVMDRS()
{
_service = cb.getServiceConnectionV25()._service;
_sic = cb.getServiceConnectionV25().ServiceContent;
ManagedObjectReference dcmor = null;
ManagedObjectReference storagePodmor = null;
ManagedObjectReference computeResourcemor = null;
ManagedObjectReference resourcePoolmor = null;
ManagedObjectReference vmFoldermor = null;
// get the datacenter and the vm folder
String dcName = cb.get_option("datacentername");
if (!string.IsNullOrEmpty(dcName))
{
dcmor
= cb.getServiceUtilV25().GetDecendentMoRef(null, "Datacenter", dcName);
if (dcmor == null)
{
Console.WriteLine("Datacenter " + dcName + " not found.");
return;
}
else
{
//get the vm folder
ObjectContent[] objArray = cb.getServiceUtilV25().GetObjectProperties(_sic.propertyCollector, dcmor, new string[] { "vmFolder" });
if (objArray.Length > 0)
{
vmFoldermor = (ManagedObjectReference)objArray[0].propSet[0].val;
}
else
{
Console.WriteLine("vmfolder not found.");
return;
}
}
}
else
{
Console.WriteLine("datacentername user option is null or empty!");
return;
}
// get the storage pod
String storagePodName = cb.get_option("storagepodname");
if (!string.IsNullOrEmpty(storagePodName))
{
storagePodmor = cb.getServiceUtilV25().GetDecendentMoRef(dcmor, "StoragePod", storagePodName);
if (storagePodmor == null)
{
Console.WriteLine("StoragePod " + storagePodName + " not found");
return;
}
}
else
{
Console.WriteLine("storagepodname user option is null or empty!");
return;
}
// get the computeresourcename (cluster)
String computeResourceName = cb.get_option("computeresourcename");
if (!string.IsNullOrEmpty(computeResourceName))
{
computeResourcemor = cb.getServiceUtilV25().GetDecendentMoRef(dcmor, "ClusterComputeResource", computeResourceName);
if (computeResourcemor == null)
{
Console.WriteLine("ComputeResourceName " + computeResourceName + " not found");
return;
}
//get the resource pool
ObjectContent[] objArray = cb.getServiceUtilV25().GetObjectProperties(_sic.propertyCollector, computeResourcemor, new string[] {
"resourcePool" });
if (objArray.Length > 0)
{
resourcePoolmor = (ManagedObjectReference)objArray[0].propSet[0].val;
}
else
{
Console.WriteLine("ResourcePool not found");
return;
}
}
else
{
Console.WriteLine("computeresourcename user option is null or empty!");
return;
}
// For create machine
// the Folder, ConfigSpec, ResourcePool and HostSystem parameters are expected
// in the StoragePlacementSpec
StoragePlacementSpec storageSpec = new StoragePlacementSpec();
storageSpec.type = "create";
storageSpec.resourcePool = resourcePoolmor;
storageSpec.folder = vmFoldermor;
// Storage DRS
storageSpec.podSelectionSpec = new StorageDrsPodSelectionSpec();
//user selected SDRS pod for the vm
storageSpec.podSelectionSpec.storagePod = storagePodmor;
// podSelectionSpec.initialVMConfig
storageSpec.podSelectionSpec.initialVmConfig = new VmPodConfigForPlacement[1];
storageSpec.podSelectionSpec.initialVmConfig[0] = new VmPodConfigForPlacement();
storageSpec.podSelectionSpec.initialVmConfig[0].storagePod = storagePodmor;
storageSpec.podSelectionSpec.initialVmConfig[0].storagePod.type = "StoragePod";
storageSpec.podSelectionSpec.initialVmConfig[0].disk = new PodDiskLocator[1];
storageSpec.podSelectionSpec.initialVmConfig[0].disk[0] = new PodDiskLocator();
storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskId = -48;
storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo = new VirtualDiskFlatVer2BackingInfo();
((VirtualDiskFlatVer2BackingInfo)storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo).fileName = "";
((VirtualDiskFlatVer2BackingInfo)storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo).diskMode = "persistent";
((VirtualDiskFlatVer2BackingInfo)storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo).thinProvisioned = true;
((VirtualDiskFlatVer2BackingInfo)storageSpec.podSelectionSpec.initialVmConfig[0].disk[0].diskBackingInfo).eagerlyScrub = false;
// configSpec
storageSpec.configSpec = new VirtualMachineConfigSpec();
storageSpec.configSpec.name = cb.get_option("vmname");
storageSpec.configSpec.version = "vmx-08";
storageSpec.configSpec.guestId = "windows7Server64Guest";
storageSpec.configSpec.files = new VirtualMachineFileInfo();
storageSpec.configSpec.files.vmPathName = "";
storageSpec.configSpec.numCPUs = 1;
storageSpec.configSpec.memoryMB = 1024;
storageSpec.configSpec.firmware = "bios";
// add devices to the machine
storageSpec.configSpec.deviceChange = new VirtualDeviceConfigSpec[5];
// add cd rom
storageSpec.configSpec.deviceChange[0] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[0].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[0].device = new VirtualCdrom();
storageSpec.configSpec.deviceChange[0].device.key = -44;
storageSpec.configSpec.deviceChange[0].device.backing = new VirtualCdromRemotePassthroughBackingInfo();
((VirtualCdromRemotePassthroughBackingInfo)storageSpec.configSpec.deviceChange[0].device.backing).deviceName = "";
((VirtualCdromRemotePassthroughBackingInfo)storageSpec.configSpec.deviceChange[0].device.backing).exclusive = false;
storageSpec.configSpec.deviceChange[0].device.connectable = new VirtualDeviceConnectInfo();
storageSpec.configSpec.deviceChange[0].device.connectable.startConnected = false;
storageSpec.configSpec.deviceChange[0].device.connectable.allowGuestControl = true;
storageSpec.configSpec.deviceChange[0].device.connectable.connected = false;
storageSpec.configSpec.deviceChange[0].device.controllerKey = 201;
storageSpec.configSpec.deviceChange[0].device.unitNumber = 0;
// add floppy
storageSpec.configSpec.deviceChange[1] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[1].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[1].device = new VirtualFloppy();
storageSpec.configSpec.deviceChange[1].device.key = -45;
storageSpec.configSpec.deviceChange[1].device.backing = new VirtualFloppyRemoteDeviceBackingInfo();
((VirtualFloppyRemoteDeviceBackingInfo)storageSpec.configSpec.deviceChange[1].device.backing).deviceName = "";
storageSpec.configSpec.deviceChange[1].device.connectable = new VirtualDeviceConnectInfo();
storageSpec.configSpec.deviceChange[1].device.connectable.startConnected = false;
storageSpec.configSpec.deviceChange[1].device.connectable.allowGuestControl = true;
storageSpec.configSpec.deviceChange[1].device.connectable.connected = false;
storageSpec.configSpec.deviceChange[2] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[2].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[2].device = new VirtualLsiLogicSASController();
storageSpec.configSpec.deviceChange[2].device.key = -46;
((VirtualLsiLogicSASController)storageSpec.configSpec.deviceChange[2].device).busNumber = 0;
((VirtualLsiLogicSASController)storageSpec.configSpec.deviceChange[2].device).sharedBus = VirtualSCSISharing.noSharing;
// add network
storageSpec.configSpec.deviceChange[3] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[3].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[3].device = new VirtualE1000();
storageSpec.configSpec.deviceChange[3].device.key = -47;
storageSpec.configSpec.deviceChange[3].device.backing = new VirtualEthernetCardNetworkBackingInfo();
((VirtualEthernetCardNetworkBackingInfo)storageSpec.configSpec.deviceChange[3].device.backing).deviceName = "VM Network SQA";
storageSpec.configSpec.deviceChange[3].device.connectable = new VirtualDeviceConnectInfo();
storageSpec.configSpec.deviceChange[3].device.connectable.startConnected = true;
storageSpec.configSpec.deviceChange[3].device.connectable.allowGuestControl = true;
storageSpec.configSpec.deviceChange[3].device.connectable.connected = true;
((VirtualE1000)storageSpec.configSpec.deviceChange[3].device).addressType = "generated";
((VirtualE1000)storageSpec.configSpec.deviceChange[3].device).wakeOnLanEnabled = true;
// add disk
storageSpec.configSpec.deviceChange[4] = new VirtualDeviceConfigSpec();
storageSpec.configSpec.deviceChange[4].operation = VirtualDeviceConfigSpecOperation.add;
storageSpec.configSpec.deviceChange[4].fileOperation = VirtualDeviceConfigSpecFileOperation.create;
storageSpec.configSpec.deviceChange[4].device = new VirtualDisk();
((VirtualDisk)storageSpec.configSpec.deviceChange[4].device).capacityInKB = 1048576;
storageSpec.configSpec.deviceChange[4].device.key = -48;
storageSpec.configSpec.deviceChange[4].device.controllerKey = -46;
storageSpec.configSpec.deviceChange[4].device.unitNumber = 0;
storageSpec.configSpec.deviceChange[4].device.backing = new VirtualDiskFlatVer2BackingInfo();
((VirtualDiskFlatVer2BackingInfo)storageSpec.configSpec.deviceChange[4].device.backing).fileName = "";
((VirtualDiskFlatVer2BackingInfo)storageSpec.configSpec.deviceChange[4].device.backing).diskMode = "persistent";
((VirtualDiskFlatVer2BackingInfo)storageSpec.configSpec.deviceChange[4].device.backing).thinProvisioned = true;
((VirtualDiskFlatVer2BackingInfo)storageSpec.configSpec.deviceChange[4].device.backing).eagerlyScrub = false;
// get recommened datastores call throws an error
// The error looks like this:
// Internal Server Error Occured: optional value not set
StoragePlacementResult storagePlacementRes = _service.RecommendDatastores(_sic.storageResourceManager, storageSpec);
if (storagePlacementRes.recommendations.Length > 0 )
{
string[] key = new String[1];
key[0] = storagePlacementRes.recommendations[0].key;
_service.ApplyStorageDrsRecommendation_Task(_sic.storageResourceManager, key);
}
return;
}
I am attaching a zip file with a small example.
I created the example by modifying the vm create example in SDK samples C#.
I tried a few variations of the example above.
I read in the documentation that I should specify the HostSystem.
1- I tried to add the HostSystem and I set it to reference the compute cluster.
When I do that I get an error that looks like this:
A specified parameter was not correct.
Storage DRS placement: target host vim.ClusterComputeResource:domain-c26 not connected to pod TestDatastoreCluster
2- I tried to add the HostSystem and I set it to reference an host in the cluster instead of the cluster.
When I do that I still get the error:
Internal Server Error Occured: optional value not set
Other ideas?
I tried using the same API RecommendDatastores and ApplyStorageDrsRecommendation_Task
to clone an existing machine using storage DRS. That worked fine. That example is also included in
the zipfile.
Thanks,
Teresa.
Hi, I'm trying to create virtual machine on datastore cluster using Java API, however I'm getting the following error on the invocation of "RecommendDatastores" method
"A general system error occurred: optional value not set"
I'm not sure what am I missing here, api is not returning the clear message/error, it seems very ambigous message, how do I know which value is not set?
Following is the code snippet I'm trying with.
//This is the storage pod where I want to create a VM
ManagedObjectReference storagePod = new ManagedObjectReference();
storagePod.set_value("group-p303");
storagePod.setType("StoragePod");
StorageDrsVmConfigInfo vmconfigInfo = new StorageDrsVmConfigInfo();
vmconfigInfo.setBehavior(StorageDrsPodConfigInfoBehavior._automated);
VmPodConfigForPlacement vmPodConfig = new VmPodConfigForPlacement();
vmPodConfig.setStoragePod(storagePod);
vmPodConfig.setVmConfig(vmconfigInfo);
//Storage Pod Sslection spec
StorageDrsPodSelectionSpec storageSelSpec = new StorageDrsPodSelectionSpec();
storageSelSpec.setStoragePod(storagePod);
storageSelSpec.setInitialVmConfig(new VmPodConfigForPlacement[]{vmPodConfig});
//Storage Placement spec
StoragePlacementSpec placementSpec = new StoragePlacementSpec();
placementSpec.setConfigSpec(spec);
placementSpec.setPodSelectionSpec(storageSelSpec);
placementSpec.setType(StoragePlacementSpecPlacementType._create);
placementSpec.setFolder(vmFolderMor);
placementSpec.setHost(hostMOR);
placementSpec.setResourcePool(poolMOR);
StoragePlacementResult placementRes = service.recommendDatastores(sic.getStorageResourceManager(), placementSpec);
task = service.applyStorageDrsRecommendationToPod_Task(sic.getStorageResourceManager(), storagePod/*Storage POD MOR*/, placementRes.getRecommendations(0).getKey());
I read through the API documentation, for me it looks like whatever is required is being set.My virtual machine spec has the VMName and its file info set. I'm not sure what is missing here, could some one help to find out.
In the above snippet "vmconfigInfo" and "vmPodConfig" are set later in the hopes to resolve the issue, however no luck. Appreciate any quick help.
Thanks,
Parash
Recently I had a motherboard issue on a Dell PowerEdge R420, Dell came in and replaced the motherboard. However after that here are the things that happened. The root password reverted back to default, which I expected. The bigger issue I saw was the ESXi library had lost all the VMs that were listed/built, but the datastore was there so it was easy to reload the VMs into the library. My question is why would the library lose the VMs listed by changing the motherboard?
The ManagedEntity object has a disabledMethods field (see http://pubs.vmware.com/vsphere-55/topic/com.vmware.wssdk.apiref.doc/vim.ManagedEntity.html) that lists disabled methods that are blocked on this specific managed entity.
I have found some links online (e.g. http://kb.vmware.com/kb/2008957) indicating that VC extensions / solutions can disable and enable methods on specific managed objects, but I've been unable to figure out how to do this.
Can anyone describe how one would go about disabling specific methods on managed entities (either through the API or by implementing an extension / solution)?
Hello,
I have had a decent amount of experience working with PowerCLI, but there has been a recent need to pick up the Java SDK. I am running Windows 7 and have downloaded JDK 7, and the SDK package from my local ESXi server, but am having some issues running the examples. Here is some output that has me scratching my head:
c:\SDK\JAXWS>run.bat Connect --username eshen --password mypassword --url https://myserver/sdk
WARNING: Java is now set to trust all SSL certificates.
-- VMware samples in Java --
The server at https://usyp-vctr55.kingstonlab.corp:7444/ims/STSService did not respond as expected. Is this a valid URL?Note: SSO connections only work on vCenter SSO enabled products.
Use the --basic-connection switch if you know this is an ESX host.
See the connection.properties file for more instructions.
No valid connection available. Exiting now.
Done.
It seems like changing the url around a bit always ends up redirectiong to the :7444/ims/STSService address.
When I go to that address, something does pop up, with the source code as follows:
<html> | |
<head><title> | |
Web Services | |
</title></head> | |
<body> | |
<h1>Web Services</h1> | |
<table width='100%' border='1'> | |
<tr> | |
<td> | |
Endpoint | |
</td> | |
<td> | |
Information | |
</td> | |
</tr> | |
<tr> | |
<td> | |
<table border="0"><tr><td>Service Name:</td><td>{http://docs.oasis-open.org/ws-sx/ws-trust/200512/wsdl}STSService</td></tr><tr><td>Port Name:</td><td>{http://docs.oasis-open.org/ws-sx/ws-trust/200512/wsdl}STSService_Port</td></tr></table> | |
</td> | |
<td> | |
<table border="0"><tr><td>Address:</td><td>https://usyp-vctr55.kingstonlab.corp:7444/sts/STSService</td></tr><tr><td>WSDL:</td><td><a href="https://usyp-vctr55.kingstonlab.corp:7444/sts/STSService?wsdl">https://usyp-vctr55.kingstonlab.corp:7444/sts/STSService?wsdl</a></td></tr><tr><td>Implementation class:</td><td>com.vmware.identity.sts.ws.StsServiceImpl</td></tr></table> | |
</td> | |
</tr> | |
</table> | |
</body> | |
</html>
Can anyone run into a similar issue when starting to learn the SDK? |
Forgive me if this is posted in the wrong forum but there doesn't appear to be one specifically for the SRM API.
So I've downloaded the WSDL files and compiled them to a C# dll and been able to successfully import them into a project. Using some of the example code in the SDK I was able to connect and retrieve Recovery Plans from my SRM instance but I was unable to initate a test or the actual plan itself. The error given in the vSphere client is "Unable to start the requested operation. Another operation might be in progress".
Checking the SRM logs I found this:
Hi,
What elements from esxtop do I have to aggregate to see the performance by datastore?
Thanks,
A
I can successfully clone a new Windows VM from a Win 2008 R2 template. However, when I use the following code to customize the VM. It shows the following error message: "A specified parameter was not correct. hostname"
The code I am using are:
private CustomizationSpec getCustomizationWindowsSpec() throws Exception { CustomizationSpec customizationSpec = new CustomizationSpec(); CustomizationIdentification id = new CustomizationIdentification(); CustomizationPassword domainAdminPass = new CustomizationPassword(); domainAdminPass.setValue("password"); id.setDomainAdmin("username"); id.setDomainAdminPassword(domainAdminPass); id.setJoinDomain("domain.com"); CustomizationUserData userData = new CustomizationUserData(); CustomizationName name = new CustomizationName(); name.setDynamicType("computername"); userData.setOrgName("compname"); userData.setFullName("admin"); userData.setComputerName(name); userData.setProductId("XXXXX-XXXXX-XXXXX-XXXXX-XXXXX"); CustomizationSysprep custWindowsPrep = new CustomizationSysprep(); custWindowsPrep.setIdentification(id); custWindowsPrep.setUserData(userData); CustomizationGuiUnattended guiUnattended = new CustomizationGuiUnattended(); guiUnattended.setAutoLogon(true); guiUnattended.setAutoLogonCount(1); guiUnattended.setTimeZone(190); custWindowsPrep.setGuiUnattended(guiUnattended); CustomizationDhcpIpGenerator fixIp = new CustomizationDhcpIpGenerator(); CustomizationIPSettings ipSettings = new CustomizationIPSettings(); ipSettings.setIp(fixIp); CustomizationAdapterMapping adapterMapping = new CustomizationAdapterMapping(); adapterMapping.setAdapter(ipSettings); customizationSpec.setIdentity(custWindowsPrep); customizationSpec .setGlobalIPSettings(new CustomizationGlobalIPSettings()); customizationSpec.getNicSettingMap().add(adapterMapping); return customizationSpec; }
I can't figure out what is wrong. Anyone please help T_T?
We have a ESX1 5.5 installed. Deployment of Windows 2012 R2 virtual template fails to deploy on this ESX with the error "Windows could not finish configuring the system. To attempt to resume configuration, restart the computer"
Does anyone have any idea. We need resolution for this asap.
thanks in advance.