hyperv: How to get the controller number from WMI query? - wmi

When we create the SCSI hard disk for a VM, is there a way to get the scsi controller index/number.
I understand that we can create 4 virtual SCSI controller. How do i get SCSI 0, SCSI 1, SCSI 2, SCSI 3 ?
The select query output of Msvm_StorageAllocationSettingData gives the instanceID. How to read this field "Microsoft:E84A07DF-EDA6-4996-A190-3E5FD724194D\5177DAB1-6F95-4618-AC73-85B66F37B4A8\0\0\L" ?
Thanks in advance.

InstanceID is the instance of the Object in Msvm_StorageAllocationSettingData class. You probably require Parent attribute to get the HardDiskDrive and again you will need Parent attribute of that object to get the Controller.
In Powershell:
$VM = gwmi -namespace root\virtualization\v2 -query "SELECT * FROM msvm_computersystem WHERE ElementName = 'vm-name'"
$VSSD = $VM.getRelated("msvm_virtualsystemsettingdata")
$DISKS = $VSSD.getRelated("Msvm_StorageAllocationSettingData")
ForEach( $disk in DISKS ) {
$HDD = [wmi]$disk.Parent
$CTRL = [wmi]$hdd.Parent
echo $CTRL
}
However the more important question is how to find out number of the SCSI Controller when there are more than one ? Anyone know ?
It's easy for the IDE Controllers as it's implicitly specified on the IDE Controller object, but not on SCSI Controller.

Related

Offline Maps HERE-SDK - offline search and navigation

I am using HERE-Android-SDK to build a simple navigation solution with offline maps.
While using the offline mode for the search addresses and calculation of a route, I can see that there are results returned from the address-search, which are not included in the installed offline map datasets. Is there anything additional which I need to do, in order to get only search results which are located inside the offline-map data installed on my device?
I am using the following code snippets.
download offline maps for a specific country:
mapsLoader.selectDataGroup(MapPackage.SelectableDataGroup.TruckAttributes)
mapsLoader.installMapPackages(listOf(mapPackageId))
search request for addresses:
val term = "New York"
val center = GeoCoordinate(lastWayPoint.latitude, lastWayPoint.longitude)
val request = SearchRequest(term)
request.connectivity = Request.Connectivity.OFFLINE
request.locale = Locale.GERMAN
request.setSearchCenter(center)
request.collectionSize = 5
request.execute { data, error ->
if (error != ErrorCode.NONE) return
// handle search results here
}
Thanks for all of your help in advance!

Create NewRecord through Siebel Business Service eScript

I am trying to create a new record using BS server script.
Since the process is taking place inside the BS, the context of Parent is not present, hence I am unable to get Parent Row_Id which I need to explicitly stamp against the child record being created for visibility.
Initially I tried to pass the Parent Row_Id from applet as a profile, but this fails when there are no records in the child applet, ie this.BusComp().ParentBusComp().GetFieldValue returns "This operation is invalid when there are no records present" as the "this" context is unavailable.
Any suggestions?
I was able to achieve the desired with the below code
sId = TheApplication().ActiveBusObject().GetBusComp("Q").ParentBusComp().GetFieldValue("Id");
if(this.BusComp().CountRecords() > 0)
{
sA = TheApplication().ActiveBusObject().GetBusComp("Q").GetFieldValue("A");
sB = TheApplication().ActiveBusObject().GetBusComp("Q").GetFieldValue("B");
}
sEntity = TheApplication().ActiveBusObject().GetBusComp("Q").Name();
It is for these reasons that Siebel provides Pre-Default settings at the Business Component Field level. If you wish to do this entirely through scripting, you will have to find the Active context, you have to know which BC is the parent.
Lets say you know that the Parent BC has to be Account. So
ActiveBusObject().GetBusComp("Account").GetFieldValue("Id") will give you the row id of the currently selected Account BC record. But do make sure that this script fires only in this context. So check the ActiveViewName to check this.
if(TheApplication().GetProfileAttr("ActiveViewName")=="Custom View")
{
//put the scripting here.
}

Google Directory API - batch add members to a group

I am using the Google Admin SDK to create, update and delete mailing lists (aka groups).
Everything works fine so far and I can create a new group and add members to it. But: Every adding of a member takes about 1s so I was thinking of a batch request to add several users to a group at once.
In the Google Admin interface it is easy to add several users at once but I didn't find any way to implement this via the API.
Is there a way to do so or do I have to loop through every user?
This works but takes a lot of time if I have to do it for every single user:
$service = new Google_Service_Directory($this->getGoogleClient());
$user = new Google_Service_Directory_Member();
$user->setEmail('test#test.com');
$user->setRole('MEMBER');
$user->setType('USER');
$service->members->insert($group_id, $user);
finally I found a solution on my own: The Admin SDK comes with a Batch class :)
To get batch requests working these steps are necessary:
When initiating the Google Client add the following line to the code
$client->setUseBatch(true);
then you can initiate the batch object
$batch = new Google_Http_Batch($client);
a little modification on the code posted above brings me to this code
foreach($arr_users as $user)
{
$userdata = new Google_Service_Directory_Member();
$userdata->setEmail($user);
$userdata->setRole('MEMBER');
$userdata->setType('USER');
$batch->add($service->members->insert($temp_list_name, $userdata));
}
finally you have to execute the request which is done by this line:
$client->execute($batch);
that's all and it works perfectly
While using the method of Christian Lange I was getting this error -
Argument 1 passed to Google\Client::execute() must implement interface Psr\Http\Message\RequestInterface, instance of Google\Http\Batch given,
So I used this instead
$client->setUseBatch(true);
$service = new Google_Service_Directory($client);
$batch = $service->createBatch();
foreach ($emails as $email)
{
$user = new Google_Service_Directory_Member(array('email' => $email,
'kind' => 'member',
'role' => 'MEMBER',
'type' => 'USER'));
$list = $service->members->insert($key, $user);
$batch->add($list);
}
$resultsBatch = $batch->execute();

XCART-5 Get Attributes Values in programming and Assigning some other values progmatically

I am working on Xcart-5 website customization. And I created my own module and doing work on that. I just created some Global Attributes (" As a Plain text ") field and assign these attributes to some product. Now I want to access these fields value in programming in the product details page for assigning some other value programatically at run time.
How can I achieve this task. Kindly provide me the solution .
In your module you should decorate the \XLite\Model\Attribute class and extend the getAttributeValue() method there.
For instance, if I use a module with developer ID Tony and module ID AttributesDemo, then I would need to create the XCartDirectory/classes/XLite/Module/Tony/AttributesDemo/Model/Attribute.php file with the following content:
<?php
// vim: set ts=4 sw=4 sts=4 et:
namespace XLite\Module\Tony\AttributesDemo\Model;
/**
* Attribute
* #MappedSuperClass
*/
abstract class Attribute extends \XLite\Model\AttributeAbstract implements \XLite\Base\IDecorator
{
public function getAttributeValue(\XLite\Model\Product $product, $asString = false)
{
$result = parent::getAttributeValue($product, $asString);
if (!$asString) {
foreach ($result as $obj) {
if ($obj->asString() == 'Mac') {
$obj->getAttributeOption()->setName('Windows');
}
}
}
return $result;
}
}
Such implementation will change Mac values to Windows ones in all attributes.

Zend Framework 2 Saving layout and template content in database

I want to save both layout and view template CONTENT in the database. Each view template will be associated to a layout_id. When a controller action loads, it will fetch the appropriate layout and view from database.
I've done fair amount of researching, looks like this hasn't been discussed before, at least not with ZF2. Not only I want different themes for the site, I also want version control on the design, user can work on a version of template, save it and when done publish the site. I've been looking into custom view strategy and renderer and could not find out how to piece everything together.
Please advice how to proceed with this problem. If there are any tutorials out there please let me know.
First, you have to decide your database structure. I would prefer a table where for each controller/action, depending on the version of the design, you have a file for the layout view, and another for the action view. I think it is a flexible way, since you can have for instance the same layout for all the controllers, but a a different view for the content of every action, or you can have a different layout for an specific controller.
It could be something like this.
CREATE TABLE `templates` (
`version` INT(5) NOT NULL,
`controller` VARCHAR(30) NOT NULL,
`action` VARCHAR(30) NOT NULL,
`layout_view` VARCHAR(30) DEFAULT NULL,
`action_view` VARCHAR(30) DEFAULT NULL,
PRIMARY KEY (`version`,`module`,`controller`,`action`)
)
remember that the template names has to be 'MODULE/CONTROLLER/ACTION' that is the format that the function ViewModel::setTemplate is expecting. So if in your Module Foo, you have the folder view, with a hierachy like this Foo/view/foo/controllerName/actionName.phtml in your database you should store: foo/controllerName/actionName
Then you have to set, somewhere in the config files, the current design version that has to be used. This version could be a different one in your local machine, and in the production server. For that, you leverage the /config/autoload/local.php that allows you to have different configuration in the different enviroments, just telling your git, subversion, or ftp, to ignore this file, so you can have a different one in every enviroment. Check this docs. It will be enough if you put something like this:
/config/autoload/local.php
return array(
'designVersion' => 1,
);
Then when the application loads, you have to check the current version of the design, and set the correct templates to be used. I would do it after the dispatch event, so the way would be to add a listener in the app bootstrarp. For that, in your main module (i.e. "App" or "Application" module), in the Module.php you overwrite the onBootstrap function, load the event manager, and add a callback to the MvcEvent::EVENT_DISPATCH event.
There, you can have access to the serviceManager, so you can retrieve your database adapter, also, you can know the current requested controller and action, the current viewmodel object, and from it, the action viewmodel. So you already have everything you need. So you can go like this:
public function onBootstrap(MvcEvent $e) {
//get the service manager
$sm = $e->getApplication ()->getServiceManager ();
//get your db adapter
$db=$sm->get("whatever is the service name of your database adapter, entity manager, or whatever you are using");
//get the config
$config = $sm->get ( 'config' );
$version = $config ['designVersion'];
//get the event manager, and attach a callback to the MvcEvent::EVENT_DISPATCH
$em = $e->getApplication ()->getEventManager ();
$em->attach ( MvcEvent::EVENT_DISPATCH, function ($e) use($sm) {
//you get the routeMath, so you can know the controller and action
$routeMatch = $e->getRouteMatch ();
$action=$routeMatch->getParam ( 'action' );
$controller=$routeMatch->getParam ( 'controller' );
//now, with $action, $controller, and $version
//you query your db to get the layout and view templates:
$views=$db->whetever..
$layout_template= $views->layout_view;
$action_template= $views->action_view;
//you get the current viewModel, it hasnt been rendered yet, so we can set the templates
$viewModel = $e->getViewModel ();
if (is_null ( $viewModel ))
return;
$viewModel->setTemplate ($layout_template);
//and now, we get the action view model, that we know that is set as a children of the layout viewmodel. So we can retrieve it like this:
$children = $viewModel->getCurrent()->getChildren();
$child = $children[0];
//if we are afraid the view could have more children, and you want to make sure that you rerieve the correct one, then you could iterate over $children and look for the child that has the correct captureTo name set. For the action’s view model, this defaults to content:
/*
$children = $viewModel->getCurrent()->getChildren();
$child=null;
foreach($children as $c) {
if ($c->captureTo() == 'content') {
$child=$c;
break;
}
}
*/
//and now, you set the template to the view:
$child->setTemplate ($action_template);
}, - 100 );
}