Open pegasus association provider - c++

I am developing a SMI-S provider using openpegasus,
when I try
cimserver "cimcli -n root/ift a CIM_StoragePool -i"
console shows instance list of CIM_StoragePool,
which means that enumerateInstanceNames method in Instance provider works,
but, when I select a instance,there is nothing happening.
My associator method in association provider did not be called.
I register association provider in my mof below:
instance of PG_ProviderModule
{
Name = "IFTComputerSystemModule";
Location = "IFT_ComputerSystemProvider";
Vendor = "Infortrend";
Version = "2.4.0";
InterfaceType = "C++Default";
InterfaceVersion = "2.1.0";
};
instance of PG_Provider
{
ProviderModuleName = "IFTComputerSystemModule";
Name = "IFT_ComputerSystemProvider";
};
instance of PG_ProviderCapabilities
{
ProviderModuleName = "IFTComputerSystemModule";
ProviderName = "IFT_ComputerSystemProvider";
CapabilityID = "1";
ClassName = "CIM_ComputerSystem";
Namespaces = {"root/ift"};
ProviderType = { 2, 3 }; // Instance
SupportedProperties = NULL; // All properties
SupportedMethods = NULL; // All methods
};
Is there anyone could help ? thanks a lot!

Related

cloneVM_Task configure cloned VM to another distributed virtual port

How do I use VirtualMachineConfigSpec to set device change and configure my new clone to another distributed virtual port? My cloned VM network adapter type is VirtualVmxnet3, I would like to configure the 10.xx.xxx.xx-x_vm_ddc (dv port name) dv switch upon successful clone.
Following clone method takes a source vm (powered off) as template for new clone:
public ResponseEntity<?> cloneRhcosVm(#PathVariable String vcenter, #RequestBody VmClone vmClone) {
VirtualMachine vm = null;
VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
VirtualMachineConfigSpec configSpec = new VirtualMachineConfigSpec();
VirtualMachineRelocateSpec relocSpec = new VirtualMachineRelocateSpec();
VirtualMachineBootOptions boot = new VirtualMachineBootOptions();
VirtualMachineBootOptionsBootableCdromDevice isoBoot = new
VirtualMachineBootOptionsBootableCdromDevice();
VirtualMachineBootOptionsBootableDevice[] bootOrder = new
VirtualMachineBootOptionsBootableDevice[]{isoBoot};
List<VirtualDeviceConfigSpec> vdSpecAll = new ArrayList<VirtualDeviceConfigSpec>();
VirtualDeviceConfigSpec[] vdSpecArray = new VirtualDeviceConfigSpec[]{};
try {
String sourceVmName = vmClone.getSourceVmName();
String cloneVmName = vmClone.getTargetVmName();
vm = vmService.getVirtualMachine(vcenter, sourceVmName);
int cloneVmCPUs = vmClone.getTargetVmCPUs();
long cloneVmMemoryMB = (long) vmClone.getTargetVmMemoryGB() * Constants.MB_TO_GB;
String cloneVmNicName = vmClone.getTargetVmNicName();
boot.setBootOrder(bootOrder);
// Get target nic (dv switch) virutal device
VirtualDeviceConfigSpec nicSpec = getTargetNicVDConfigSpec(vm, cloneVmNicName);
if (nicSpec != null) {
vdSpecAll.add(nicSpec);
}
vdSpecArray = vdSpecAll.toArray(new VirtualDeviceConfigSpec[vdSpecAll.size()]);
configSpec.setDeviceChange(vdSpecArray);
configSpec.setName(cloneVmName);
configSpec.setNumCPUs(cloneVmCPUs);
configSpec.setNumCoresPerSocket(cloneVmCPUs);
configSpec.setMemoryMB(cloneVmMemoryMB);
configSpec.setBootOptions(boot);
cloneSpec.setConfig(configSpec);
cloneSpec.setLocation(relocSpec);
cloneSpec.setPowerOn(true);
cloneSpec.setTemplate(false);
Task task = vm.cloneVM_Task((Folder) vm.getParent(), cloneVmName, cloneSpec);
TaskInfo taskInfo = task.getTaskInfo();
...
}
Following method used to configure new nic virtual device: targetNicName is the new 10.xx.xxx.xx-x_vm_ddc I want to set to after cloning
private VirtualDeviceConfigSpec getTargetNicVDConfigSpec(VirtualMachine vm, String targetNicName) {
VirtualDevice[] vds = vm.getConfig().getHardware().getDevice();
VirtualDeviceConfigSpec nicSpec = new VirtualDeviceConfigSpec();
VirtualDeviceConnectInfo deviceConnInfo = new VirtualDeviceConnectInfo();
String adapter1 = "Network adapter 1";
for (int i = 0; i < vds.length; i++) {
if ((vds[i] instanceof VirtualEthernetCard) && (vds[i].getDeviceInfo().getLabel().equalsIgnoreCase(adapter1))) {
VirtualEthernetCard nic = (VirtualEthernetCard) vds[i];
VirtualEthernetCardNetworkBackingInfo nicBacking = (VirtualEthernetCardNetworkBackingInfo) nic.getBacking();
deviceConnInfo.setConnected(true);
nicBacking.setDeviceName(targetNicName);
nic.setBacking(nicBacking);
nic.setConnectable(deviceConnInfo);
nicSpec.setOperation(VirtualDeviceConfigSpecOperation.edit);
nicSpec.setDevice(nic);
return nicSpec;
}
}
return null;
}
Above code works but the new network adapter is not being configured as a dvSwitch as I was expecting by setting the new device name.
I found that my network adapter virtual device (vd) is of class VirtualVmxnet3 and the vd's backing info is of class VirtualEthernetCardDistributedVirtualPortBackingInfo, however these classes do not have any method that works like .setDevice(nicName) to configure the network adapter to new dvSwitch by passing name 10.xx.xxx.xx-x_vm_ddc.
Any clues if it's possible to clone and configure to another dv port?

Codeigniter routing how to permit null parameter

I want paginate my index http:localhost/mysite/home but if I write only this http:localhost/mysite/home the page said: "page not found", but if I write http:localhost/mysite/home/3 its work! how to I can configure my routing to get null parameters? I tried with (:any) and (num) but not work
My route file is:
$route['404_override'] = 'welcome/no_found';
$route['home/'] = "welcome/home/$1";
My controller:
$config['base_url'] = base_url().'/mysite/home';
$config['total_rows'] = $this->mtestmodel->countNews();
$config['per_page'] = 2;
$config['num_links'] = 20;
$this->pagination->initialize($config);
$data['paginator']=$this->pagination->create_links();
$data['news']=$this->mtestmodel->show_news( $config['per_page'],intval($to) );
//$to is a parameter in url base_url()/mysite/home/3
Change your route.php file to the following:
$route['404_override'] = 'welcome/no_found';
$route['home/(:num)'] = "welcome/home/$1";
$route['home'] = "welcome/home";
This way, your application will catch both requests (http://localhost/mysite/home and http://localhost/mysite/home/3), and will send them both to your controller.
You should then be able to access your $to variable (which has been passed as the first argument into your controller's function) or use $this->uri->segment(2) instead.
e.g.
public function home($to = 0) {
$config['base_url'] = base_url().'/mysite/home';
$config['total_rows'] = $this->mtestmodel->countNews();
$config['per_page'] = 2;
$config['num_links'] = 20;
$this->pagination->initialize($config);
$data['paginator'] = $this->pagination->create_links();
$data['news'] = $this->mtestmodel->show_news( $config['per_page'],intval($to) );
}
Hope that helps!

Dynamics CRM Web Service Execute returns "Server was unable to process request."

I'm going crazy here with DCRM web services,
I'm trying to create a Connection between two leads dynamically.
I'm getting the following error:
"0x80040216
An unexpected error occurred.
Platform
An unexpected error occurred.
Type:Microsoft.Crm.CrmException ErrorCode:0x80040216
Object reference not set to an instance of an object."
Here is my code:
Guid connectionRoleID = new Guid("64f33a74-0342-e211-b55e-00155d00041e");
connectionroleobjecttypecode connroleobjecttypecode = new connectionroleobjecttypecode() { connectionroleid = new Lookup(){Value = connectionRoleID}, associatedobjecttypecode = EntityName.lead.ToString()};
connection conn = new connection();
List<Property> list = new List<Property>();
Lookup lookup = new Lookup();
lookup.Value = customers[i].ID.Value.Value;
lookup.name = EntityName.lead.ToString();
Lookup lookup2 = new Lookup();
lookup2.Value = customers[j].ID.Value.Value;
lookup2.name = EntityName.lead.ToString();
conn.record1roleid = new Lookup() { name = "duplicate", Value = new Guid("64f33a74-0342-e211-b55e-00155d00041e") };
conn.record2roleid = new Lookup() { name = "duplicate", Value = new Guid("64f33a74-0342-e211-b55e-00155d00041e") };
list.Add(new LookupProperty(){Name = "record1id", Value = lookup});
list.Add(new LookupProperty(){Name = "record2id", Value = lookup2});
list.Add(new LookupProperty(){Name = "record1roleid", Value = conn.record1roleid});
list.Add(new LookupProperty() { Name = "record2roleid", Value = conn.record2roleid });
I've tried tracing (which did not help), and in the eventviewer I get an error, but there is no helpful information.
I'm dying here! Please help... :-)
I think its because you are doing:
conn.record1roleid = new Lookup() { name = "duplicate", Value = new Guid("64f33a74-0342-e211-b55e-00155d00041e") };
name should be the name of an entity, e.g. contact, lead, incident. In this case I believe you should be using: connectionrole.
conn.record1roleid = new Lookup() { name = "connectionrole", Value = new Guid("64f33a74-0342-e211-b55e-00155d00041e") };
I would suggest having at Sample: Create a Connection (Early Bound).
Add type for the entity to lookup
Lookup lookup2 = new Lookup();
lookup2.Value = customers[j].ID.Value.Value;
lookup2.name = EntityName.lead.ToString();
**lookup2.type = "lead";**

VMWare VIM SDK. List all VM's working, but list all datasources does not. Am I missing something?

My goal is to get a listing of all the DataStores in a specific datacenter. I'm able to list all of the Hosts, and VM's, but not the Datastores, and I don't understand why (I'm still learning the API's). Any insight would be appreciated.
Here's the code for grabbing all of the VM's (this works as expected):
public List<VM> getVMsInDatacenter(String datacenter, IEnumerable<String> properties)
{
List<VM> VMs = null;
this.joinConnection((appUtil) =>
{
var svcUtil = appUtil.getServiceUtil();
var dcMoRef = svcUtil.GetDecendentMoRef(null, "Datacenter", datacenter);
var typeinfo = buildTypeInfo("VirtualMachine", properties.ToList());
VMs = buildVMsFromObjectContent(svcUtil.GetContentsRecursively(null, dcMoRef, typeinfo, true));
});
return VMs;
}
Here is the analogous code for the Datastore (which does not work as expected):
public List<DataStore> getDataStoresInDatacenter(String datacenter, IEnumerable<String> properties)
{
List<DataStore> DataStores = null;
this.joinConnection((appUtil) =>
{
var svcUtil = appUtil.getServiceUtil();
var dcMoRef = svcUtil.GetDecendentMoRef(null, "Datacenter", datacenter);
var typeinfo = buildTypeInfo("Datastore", properties.ToList());
DataStores = buildDataStoresFromObjectContent(svcUtil.GetContentsRecursively(null, dcMoRef, typeinfo, true));
});
return DataStores;
}
appUtil is an instantiation of the AppUtil class that came with the VIM SDK samples. It houses functionality for connecting, querying, etc.
joinConnection is a method for connecting, or re-using a connection if we've already connected.
If there are any other questions about the code, please let me know.
Also, if there's a better way, I'd like to know that too :)
Found the problem. The method getContentsRecursively is calling a method called 'buildFullTraversal' that builds a traversal/selection spec. This method was not adding a traversal for the datastore. I added one that like so:
TraversalSpec vmToDs = new TraversalSpec();
vmToDs.name = "vmToDs";
vmToDs.type = "VirtualMachine";
vmToDs.path = "datastore";
HToVm.skip = false;
HToVm.skipSpecified = true;
And then I modified the visitFolders traversal like so:
// Recurse through the folders
TraversalSpec visitFolders = new TraversalSpec();
visitFolders.name = "visitFolders";
visitFolders.type = "Folder";
visitFolders.path = "childEntity";
visitFolders.skip = false;
visitFolders.skipSpecified = true;
visitFolders.selectSet = new SelectionSpec[] { new SelectionSpec(), new SelectionSpec(), new SelectionSpec(), new SelectionSpec(), new SelectionSpec(), new SelectionSpec(), new SelectionSpec(), new SelectionSpec() };
visitFolders.selectSet[0].name = "visitFolders";
visitFolders.selectSet[1].name = "dcToHf";
visitFolders.selectSet[2].name = "dcToVmf";
visitFolders.selectSet[3].name = "crToH";
visitFolders.selectSet[4].name = "crToRp";
visitFolders.selectSet[5].name = "HToVm";
visitFolders.selectSet[6].name = "rpToVm";
visitFolders.selectSet[7].name = "vmToDs";
return new SelectionSpec[] { visitFolders, dcToVmf, dcToHf, crToH, crToRp, rpToRp, HToVm, rpToVm, vmToDs };
Now, calls to getContentsRecursively will also include the datastores that belong to a VM, so the method in the question will works as expected.

Dynamics GP Web Services: SalesInvoice Creation with Lot Allocation

I'm trying to use the following code to create a new SalesInvoice based on an existing SalesOrder:
SalesInvoice invoice = new SalesInvoice();
invoice.DocumentTypeKey = new SalesDocumentTypeKey { Type = SalesDocumentType.Invoice };
invoice.CustomerKey = originalOrder.CustomerKey;
invoice.BatchKey = originalOrder.BatchKey;
invoice.Terms = new SalesTerms { DiscountTakenAmount = new MoneyAmount { Value = 0, Currency = "USD", DecimalDigits = 2 }, DiscountAvailableAmount = new MoneyAmount { Value = 0, Currency = "USD", DecimalDigits = 0 } };
invoice.OriginalSalesDocumentKey = originalOrder.Key;
List<SalesInvoiceLine> lineList = new List<SalesInvoiceLine>();
for (int i = 0; i < originalOrder.Lines.Length; i++)
{
SalesInvoiceLine line = new SalesInvoiceLine();
line.ItemKey = originalOrder.Lines[i].ItemKey;
line.Key = new SalesLineKey { LineSequenceNumber = originalOrder.Lines[i].Key.LineSequenceNumber; }
SalesLineLot lot = new SalesLineLot();
lot.LotNumber = originalOrder.Lines[i].Lots[0].LotNumber;
lot.Quantity = new Quantity { Value = 2200 };
lot.Key = new SalesLineLotKey { SequenceNumber = originalOrder.Lines[i].Lots[0].Key.SequenceNumber };
line.Lots = new SalesLineLot[] { lot };
line.Quantity = new Quantity { Value = 2200 };
lineList.Add(line);
}
invoice.Lines = lineList.ToArray();
DynamicsWS.CreateSalesInvoice(invoice, DynamicsContext, DynamicsWS.GetPolicyByOperation("CreateSalesInvoice", DynamicsContext));
When executed, I receive the following error:
SQL Server Exception: Operation expects a parameter which was not supplied.
And the more detailed exception from the Exception Console in Dynamics:
Procedure or function 'taSopLotAuto' expects parameter '#I_vLNITMSEQ',
which was not supplied.
After a considerable amount of digging through Google, I discovered a few things.
'taSopLotAuto' is an eConnect procedure within the Sales Order Processing component that attempts to automatically fill lots. I do not want the lots automatically filled, which is why I try to fill them manually in the code. I've also modified the CreateSalesInvoice policy from Automatic lot fulfillment to Manual lot fulfillment for the GP web services user, but that didn't change which eConnect procedure was called.
'#I_vLNITMSEQ' refers to the LineSequenceNumber. The LineSequenceNumber and SequenceNumber (of the Lot itself) must match. In my case they are both the default: 16384. Not only is this parameter set in the code above, but it also appears in the SOAP message that the server attempted to process - hardly "not supplied."
I can create an invoice sans line items without a hitch, but if I add line items it fails. I do not understand why I am receiving an error for a missing parameter that is clearly present.
Any ideas on how to successfully create a SalesInvoice through Dynamics GP 10.0 Web Services?
Maybe you mess to add the line key to the lot:
lot.Key = new SalesLineKey();
lot.Key.SalesDocumentKey = new SalesDocumentKey();
lot.Key.SalesDocumentKey.Id = seq.ToString();