Hello all,
I need to attach some information to the datacenter object. In every time I log in to the system I will read this information from the selected datacenter and perform some actions. So what is the best way to achieve that goal and what is the most sophisticated one ?
Regards,
Stefan
Where to map a custom object to mark the datacenter.
Possible to create my own "Open Console" feature?
Hi,
I'm working on a tool in c# to request new VMs, edit them, etc. and the users won't have access to the VPXClient so I'm wondering if there's a possibility to create my own "Open Console" feature there so they could RDP to the machines in case the network is down or whatever.
I would be glad for any directions you could give me as I don't even know where to start. I assume there must be some usercontrol where I tell it to tunnel through server X to get to the target VM.
Any help would be much appreciated.
Thanks
VCSIM 2.0 does not simulate "raw data feed"?
Our application uses QueryPerf to fetch real time (20 second) performance stats as described in the vSphere 5.5 SDK docs. This specially constructed request reduces vCenter load by getting stats directly from the ESXi hosts rather than the vCenter database. (Our application handles rollup and normalization.)
This method works great for a real vCenter but it does not work very well with the vCenter Simulator (VCSIM), which we would like to use for scale testing. Many of the host and VM CPU stats are missing. I think this might be caused by the fact that the ESXi hosts are simulated and therefore cannot respond to API requests for performance stats.
I spent a lot of time messing around with the variousVCSIM configuration files before realizing that our application uses the "raw data feed". I can generate stats if I request "non real time" metrics.
Can anyone confirm this? Or am I doing something wrong?
Thanks for any info or advice!
--Scott
Creating "Read-Only" Custom Roles
Hi,
in our vSphere WebClient Plug-in, we want to create custom roles which contain the privileges needed to operate the plug-in correctly.
We would like to have these roles "read-only", the user should either use the role as is, or clone it to add/remove priviliges. I found that
there is a Boolean value in the AuthorizationRole class called "system" . If set to true, the role can not be changed or removed. This sounds perfect, but is it ok for a plugin to create a "system" role? Or are the system roles reserved for vmware?
thanks for the info
Cathy
Need some help configuring LACP using PowerShell...
I am trying to script LACP and LAG creation. As of right now this can only be achieve via the web client.
I manually enabled LACP on test-switch01, created a lag1 and trying to configure use that lag1 as an uplink on dportgroup1:
- when i issue the-- (get-vdswitch "test-switch01" | get-view ).Config.Lacpgroupconfig I can see that lag1 was created.
- however when i run get-vdswitch "test-switch01" | get-vdportgroup "Dportgroup1" | get-uplinkteamingpolicy | fl lag1 does not show up as an UnusedUplinkPort, If I manually configure the portgroup to use lag1 as the uplink and issue the command above, it will see lag1 as the activeuplinkport.
Creating the lag using vmware.vim.vmwaredvslacpgroupconfig. I wrote the script below and everything seems to work except when I try to apply the changes to the test-switch01.
- when I run $target.config.lacpgroupconfig = $lacpgroup --it looks like the changes were applied to the test-switch01 but from the web client there is no changes.
- when i use the $target.UpdateDVSLacpGroupConfig_task($dvsconfig) method there is a different error shown below the script...
$target = get-vdswitch "test-switc01" | get-view
$lacpgroup = New-Object VMware.Vim.VMwareDvsLacpGroupConfig
$lacpgroup.Key = "1234"
$lacpgroup.Name = "testlag1"
$lacpgroup.Mode = "active"
$lacpgroup.UplinkNum = "2"
$lacpgroup.LoadbalanceAlgorithm = "srcDestIpTcpUdpPortVlan"
$lacpgroup.Vlan = New-Object VMware.Vim.VMwareDvsLagVlanConfig
$lacpgroup.Ipfix = New-Object VMware.Vim.VMwareDvsLagIpfixConfig
$lacpgroup.UplinkName = "{testlag-1, testlag-2}"
$dvsconfig = New-Object VMware.Vim.VMwareDvsLacpGroupSpec
$dvsconfig.LacpGroupConfig = $lacpgroup
#seems like it did apply but in the actual switch there wasnt any change
$target.Config.LacpGroupConfig = $lacpgroup
#command doesnt work missing something
$target.UpdateDVSLacpGroupConfig_task($dvsconfig)
ERROR MESSAGE:
$target.UpdateDVSLacpGroupConfig_task($dvsconfig)
Exception calling "UpdateDVSLacpGroupConfig_Task" with "1" argument(s): "
Required property operation is missing from data object of type VMwareDvsLacpGroupSpec
while parsing serialized DataObject of type vim.dvs.VmwareDistributedVirtualSwitch.LacpGroupSpec
at line 1, column 326
while parsing call information for method UpdateDVSLacpGroupConfig_Task
at line 1, column 218
while parsing SOAP body
at line 1, column 207
while parsing SOAP envelope
at line 1, column 38
while parsing HTTP request for method updateLacpGroupConfig
on object of type vim.dvs.VmwareDistributedVirtualSwitch
at line 1, column 0"
At line:2 char:38
+ $target.UpdateDVSLacpGroupConfig_task <<<< ($dvsconfig)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Can anyone give me some pointers???
Also the Vmware.Vim.VmwareDVSLACPGroupConfig has some properties with get;set; how do i get or set these values???
TypeName: VMware.Vim.VMwareDvsLacpGroupConfig
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
DynamicProperty Property VMware.Vim.DynamicProperty[] DynamicProperty {get;set;}
DynamicType Property System.String DynamicType {get;set;}
Ipfix Property VMware.Vim.VMwareDvsLagIpfixConfig Ipfix {get;set;}
Key Property System.String Key {get;set;}
LoadbalanceAlgorithm Property System.String LoadbalanceAlgorithm {get;set;}
Mode Property System.String Mode {get;set;}
Name Property System.String Name {get;set;}
UplinkName Property System.String[] UplinkName {get;set;}
UplinkNum Property System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e08...
UplinkPortKey Property System.String[] UplinkPortKey {get;set;}
Vlan Property VMware.Vim.VMwareDvsLagVlanConfig Vlan {get;set;}
Writing SOAP calls manually
I need to find a good reference or tool to help write SOAP calls. I am using SOAPUI to talk to vimService.wsdl. An example of a simple task that I'm trying to do:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:vim25"> <soapenv:Header/> <soapenv:Body> <urn:CreateVirtualDisk_Task> <urn:_this type="?">?</urn:_this> <urn:name>?</urn:name> <!--Optional:--> <urn:datacenter type="?">?</urn:datacenter> <urn:spec> <!--Optional:--> <urn:dynamicType>?</urn:dynamicType> <!--Zero or more repetitions:--> <urn:dynamicProperty> <urn:name>?</urn:name> <urn:val>?</urn:val> </urn:dynamicProperty> <urn:diskType>?</urn:diskType> <urn:adapterType>?</urn:adapterType> </urn:spec> </urn:CreateVirtualDisk_Task> </soapenv:Body></soapenv:Envelope>
I was using the following as a reference, but it seems more geared towards folks using an IDE/SDK. http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.apiref.doc/vim.VirtualDiskManager.html#createVirtualDisk
(there is a reason I'm not using the SDK, we have an extant platform that can make HTTP requests and it is not possible to modify that platform to include vSphere SDK)
My problems:
What do I put in _this type? The above reference documentation is not helpful for writing SOAP calls.
Is there a tool or utility or reference I can use to figure out what needs to go into these SOAP calls?
Getting the list of custom field keys from the CustomFieldsManager using pyVmomi?
Hi, I'm trying to use the pyvmomi python SDK to access the CustomFieldsManager's field value and iterate through the list to find the name vs key combinations. I can do this with the Perl SDK by just treating the field as a list however when I try with pyvmomi I'm met with an error stating that 'property' object is not iterable.
Eg:
cfm = vim.CustomFieldsManager
for pairs in cfm.field:
print(pairs)
TypeError: 'property' object is not iterable
My end goal though is just to be able to ask for and set a VM's values in custom fields by the custom field's name and with Perl I'd have to first find out the custom field's key based on its name string, perhaps I'm just doing this wrong now? Just following the same methods I'd used in the Perl SDK that's all.
Any help would be appreciated.
Edit: Oops sorry I posted this to the wrong subforum, could a mod move this to VMware vSphere™ Web Services SDK please? Thanks!
Delay in creating service instance from vijava.
hi all,
i am getting 65-70 Seconds of delay in any call of vSphere through my vijava code.
i have checked and found it is taking this time in creating the service instance.
i have checked all the networks and network is not introducing any delay.
Can someone tell what is going wrong? or if any body else have faced same issue?
Delay in creating service instance from vijava.
hi all,
i am getting 65-70 Seconds of delay in any call of vSphere through my vijava code.
i have checked and found it is taking this time in creating the service instance.
i have checked all the networks and network is not introducing any delay.
Can someone tell what is going wrong? or if any body else have faced same issue?
Creating custom attributes using pyvmomi
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
pyVmomi - Example of CustomFieldsManager.SetField please?
I can't for the life of me get this method to work, as per the SDK and Github documentation I should be able to call it like such "vim.CustomFieldsManager(myVMRef, intKeyOfCustomField, strValueToPutThere)" but it refuses to accept those arguments, the closest I can get is when I put the VM's reference in twice (making four arguments, ie ref,ref,key,value) and this time it bombed differently with an "The request refers to an unexpected or unknown type."
vSwitch/PortGroup Events?
There are events for Distributed vSwitches and Distributed PortGroups:
http://pubs.vmware.com/vsphere-55/topic/com.vmware.wssdk.apiref.doc/vim.event.DvsEvent.html
http://pubs.vmware.com/vsphere-55/topic/com.vmware.wssdk.apiref.doc/vim.event.DVPortgroupEvent.html
Are there events for the non-distributed vSwitch/PortGroup? I can't find any in the API. I hoped that events for vSwitch/PortGroup would be sent against the host when these objects are modified, but I don't see those either? It looks like only a TaskEvent is generated?
Thanks
Error processing attribute "type" with value "DistributedVirtualPortgroup"
Hello everyone. I'm back with an API error message I cannot decipher. At first I thought I was maybe getting the wrong API version but I checked vimServiceVersions.xml and it is correct (namespace urn:vim25 has version 5.5)
I feel like I've tried everything under the sun and I have no idea what the heck is going wrong. RetrieveProperties method works against type VirtualMachine but not DistributedVirtualPortgroup.
Another hypothesis is that I'm just using the Login method instead of LoginByToken, but I'm not sure that has anything to do with it.
Outgoing request:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><RetrieveProperties xmlns="urn:vim25"><_this type="PropertyCollector">propertyCollector</_this><specSet><propSet><type>DistributedVirtualPortgroup</type><all>true</all></propSet><objectSet><obj type="DistributedVirtualPortgroup">dvportgroup-72</obj></objectSet></specSet></RetrieveProperties></soap:Body></soap:Envelope>
Error response:
The remote server returned an error: (500) Internal Server Error.<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><soapenv:Fault><faultcode>ServerFaultCode</faultcode><faultstring> Error processing attribute "type" with value "DistributedVirtualPortgroup" while parsing MoRef for ManagedObject of type vmodl.ManagedObject at line 1, column 369 while parsing property "obj" of static type ManagedObject while parsing serialized DataObject of type vmodl.query.PropertyCollector.ObjectSpec at line 1, column 358 while parsing property "objectSet" of static type ArrayOfObjectSpec while parsing serialized DataObject of type vmodl.query.PropertyCollector.FilterSpec at line 1, column 275 while parsing call information for method RetrieveProperties at line 1, column 180 while parsing SOAP body at line 1, column 169 while parsing SOAP envelope at line 1, column 0 while parsing HTTP request for method retrieveContents on object of type vmodl.query.PropertyCollector at line 1, column 0</faultstring><detail><InvalidRequestFault xmlns="urn:vim25" xsi:type="InvalidRequest"></InvalidRequestFault></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>
Automating VM deployment using C# SDK
Hello All,
I am planning to deploy a web application which will automatically deploy the VM in VMWare. The application will take inputs about cpu,memory etc and contact vCenter/ESXi to have the VM deploy
Anyone has an idea how to proceed with this? Website will be built in asp.net and I am planning to use C# as a backend programing language.
Please guide.
Thanks,
-Prashant Girennavar.
RemoveDatastore task status is not updated in Task console
Hello,
I'm using the HostdatstoreSystem.removeDatstore() for removing the datastore from the vCenter. First time the task console shows the status with Remove datastore task with Target object as "datastore" as success in completed state. But if you navigate to any other page and traverse back to the task console, the Task shows as in-progress with target object as "HostSystem" in running state.
Any thoughts on this?
Thanks.
VCSIM Host and VM names
I have VCSIM running pretty well but as most I need to push it a tad more.
Is there a way to extract the Host and VM names from a live vcenter and convert it to a VCSIM environment?
Names (prefix) are the only issue I am really having right now as the DC_CO stuff is still hounding me. My prefix tag works but MYNAME_DC0_CO_HO is just not cutting it. Been over Lam's excellent steps but I must be missing something so a nudge would be great. The Vagrant script is also the absolute best!!
Automating VM Depolyment using C# SDK
Hello Experts,
I want to automate VM deployed in vCenter. I want to create a webpage(asp.net) and write the code behind with C# using VMWare SDK for .net which will contact the vCenter and deploy the VM on the ESXI. The webfornt will give option to put inputs like , vCPU,Memroy Etc
How to make this happen? Do any one have information about using VMWare sdk for about request?
Please let me know.
Thanks,
-Prashant GIrennavar.
Data Object - VirtualSCSIController doesnt return initialized array for property 'devices' if Controller type != LsiLogic
When iterating through a list of devices attached to a VM with the following perl loop, VirtualSCSIController objects instantiated by VirtualLsiLogicSASController, VirtualBusLogicController, or ParaVirtualController return an *UN*initialized array for the device[] property which is supposed to return a list of devices attached to that controller.
If VirtualSCSIController is instantiated by VirtualLsiLogicController, the device[] property is properly initialized as an array and contains a list of devices attached to the controller.
//@vm_devices is returned earlier from a call to the subroutine find_scsi_controller_device() in VMUtil.pm which I have modified to return all VirtualSCSIController objects that match a specific busNumber
sub find_scsi_controller_device {
my %args = @_;
my $vm = $args{vm};
my $vctrl_num = $args{vctrl_num};
my $devices = $vm->config->hardware->device;
print "Controller number passed to find_scsi_controller_device is $vctrl_num\n";
foreach my $device (@$devices) {
if ( $device->isa('VirtualSCSIController') && ($device->busNumber == $vctrl_num) )
{
print "Returning Virtual SCSI Cntroller\n";
print "Device is ".$device." BEFORE RETURN\n";
return $device;
}
}
print "Returning UNDEF from find_scsi_controller_device\n";
return undef;
}
<my code snippet>
my $controller;
foreach my $vm_device (@$vm_devices)
{
print "$vm_device\n";
if ( (ref($vm_device) =~ /VirtualBusLogicController|VirtualLsiLogicController|VirtualLsiLogicSASController|ParaVirtualSCSIController/) && ($vm_device->busNumber == $vctrl_num) )
{
Util::trace(1, "SCSI controller found : $&\n");
$controller = $vm_device;
print "Controller FOUND!!!!!!!!\n";
last;
}
}
my $controllerKey = $controller->key;
# Set new unit number (7 cannot be used, and limit is 15)
my $unitNumber;
my $vm_vdisk_number = $#{$controller->device} + 1;
if ($vm_vdisk_number < 7) {
$unitNumber = $vm_vdisk_number;
}
elsif ($vm_vdisk_number == 15) {
die "ERR: one SCSI controller cannot have more than 15 virtual disks\n";
}
else {
$unitNumber = $vm_vdisk_number + 1;
}
<end code snippet>
Again, if the VM I am running this query against has a VirtualLsiLogicController configured at my specified busNumber, the device[] array is initialized, and the logic to pick the next free device id number works. If the scsi controller is one of the other 3 available types, the device[] array is not initialized and the code fails at the "my $vm_vdisk_number = $#{$controller->device} + 1;" line.
Any ideas?
Is there any limit on no. of ExtensionEventTypeInfo per Extension
Hi,
For one of our alrams related requirement,
we are creating multiple Extensions with different keys and for each Extension object we are adding multiple ExtensionEventTypeInfo with unique eventID.
I would like to know -
1. Is there any limit on no. of Extensions that we can register with vCenter server?
2. Is there any limit on no. of ExtensionEventTypeInfo that I can add to an Extension using extension.getEventList().add(extensionEventTypeInfo)?
Thanks in advance!
Alarm statuses are not correct
Hi VMware,
I'm trying to create an application that monitors vCenter alarms however I can't seem to get the correct status for triggered alarms. Here is my code:
public IEnumerable<Alarm> GetAlarms()
{
return InternalGetAlarms(InternalGetAlarmReferences(parent));
}
private IEnumerable<Alarm> InternalGetAlarmsAsync(IEnumerable<ManagedObjectReference> alarmReferences)
{
List<Alarm> list = new List<Alarm>();
ManagedObjectReference mgr = serviceContent.alarmManager;
AlarmState[] alarmStates = null;
foreach (ManagedObjectReference reference in alarmReferences)
{
AlarmInfo info = (AlarmInfo) GetPropertiesAsync(reference, new[] {"info"})[0];
if (info == null) continue;
if (alarmStates == null)
{
var asyncResult = service.BeginGetAlarmState(mgr, info.entity, null, null);
asyncResult.AsyncWaitHandle.WaitOne();
alarmStates = service.EndGetAlarmState(asyncResult);
}
AlarmState state = LookupAlarmState(info.alarm, alarmStates);
if (state == null)
{
var asyncResult = service.BeginGetAlarmState(mgr, info.entity, null, null);
asyncResult.AsyncWaitHandle.WaitOne();
AlarmState[] newStates = service.EndGetAlarmState(asyncResult);
if (newStates != null && newStates.Length > 0)
{
alarmStates = alarmStates.Concat(newStates).Distinct().ToArray();
state = LookupAlarmState(info.alarm, alarmStates, true);
}
if (state == null)
continue; // we don't add alarms that don't have states
}
Alarm alarm = new Alarm(info.alarm.Value, info.name, info.alarm, info, state, info.description, info.enabled);
list.Add(alarm);
}
return list;
}
private IEnumerable<ManagedObjectReference> InternalGetAlarmReferences()
{
return service.GetAlarm(serviceContent.alarmManager, null);
}
private Object[] GetPropertiesAsync(ManagedObjectReference moRef, String[] properties)
{
PropertySpec pSpec = new PropertySpec();
pSpec.type = moRef.type;
pSpec.pathSet = properties;
ObjectSpec oSpec = new ObjectSpec();
// Set the starting object
oSpec.obj = moRef;
PropertyFilterSpec pfSpec = new PropertyFilterSpec();
pfSpec.propSet = new[] {pSpec};
pfSpec.objectSet = new[] {oSpec};
ObjectContent[] ocs = RetrievePropertiesAsync(serviceContent.propertyCollector, new[] {pfSpec});
Object[] ret = new Object[properties.Length];
if (ocs != null)
{
foreach (ObjectContent oc in ocs)
{
DynamicProperty[] dps = oc.propSet;
if (dps != null)
{
foreach (DynamicProperty dp in dps)
{
for (int p = 0; p < ret.Length; ++p)
{
if (properties[p].Equals(dp.name))
{
ret[p] = dp.val;
}
}
}
}
}
}
return ret;
}
private static AlarmState LookupAlarmState(ManagedObjectReference alarmMor, IEnumerable<AlarmState> alarmStates, bool reverse = false)
{
if (alarmStates == null || alarmMor == null) return null;
if (reverse)
alarmStates = alarmStates.Reverse();
return alarmStates.Where(state => state != null).FirstOrDefault(state => state.alarm.Value == alarmMor.Value);
}
First of all I hate the fact that I need to do a WS call for each alarm to get some properties then it happens a lot of times that the alarmState comes with a gray triggered state and on the console I can clearly see it's triggered. The MOR of the alarmState is clearly the same as the alarm object however it's not reporting a red state. I've tried the following PowerCLI script to get the triggered alarms and again nothing showed up and in the console app I can see two triggered alarms.
$esx_all = Get-VMHost | Get-View
$Report=@()
foreach ($esx in $esx_all){
foreach($triggered in $esx.TriggeredAlarmState){
If ($triggered.OverallStatus -like "red" ){
$lineitem={} | Select Name, AlarmInfo
$alarmDef = Get-View -Id $triggered.Alarm
$lineitem.Name = $esx.Name
$lineitem.AlarmInfo = $alarmDef.Info.Name
$Report+=$lineitem
}
}
}
$Report |Sort Name
Kind Regards,
Paul