pages

Showing posts with label rights. Show all posts
Showing posts with label rights. Show all posts

Thursday, September 20, 2012

vCloud Director - get chain length and consolidate a vCloud:VM

As you may know it isn´t possible to consolidate a VM as an organization administrator. In most environments the customer gets an Org (Cola for example) and can deploy vApps etc. but isn´t able to consolidate a vCloud:VM (i use the vCO syntax for explicit wording).

If you want to provide this function in a customer portal, with WaveMaker for example, you need to check the chain length and when the user decides the consolidate method has to be called.

I build a workflow:





















The workflow has three steps: determination of the chain length, user decision to consolidate or not and the consolidate call itself. The first part (getChain script) looks like this:



myVm.updateInternalState();

System.log("VM name: "+myVm.name);

var doc = new XML(myVm.toXml());
default xml namespace = doc.namespace();
var n8 = new Namespace("http://www.vmware.com/vcloud/extension/v1.5");

System.log("ChainLength: "+doc.VCloudExtension.*::VmVimInfo.*::VirtualDisksMaxChainLength);

var chainLength = doc.VCloudExtension.*::VmVimInfo.*::VirtualDisksMaxChainLength;

if(myVm.vmStatus.value != 8){
throw("VM is not powered off!");




As you can see I update the state of "myVM" (vCloud:VM) and setting the variable "chainLength" (number). The chain length is used as external input for the user interaction, so it´s possible to decide based on the count.

After the submission the myVm.consolidate() method is called and the workflows waits for it.

With my host.login() workflow you can combine the Org based login with the consolidation of vCloud:VM´s :)

Monday, July 9, 2012

chain length consolidation in vCloud Director - multi-tenancy part 2

Based on the last article I think about a solution to enable vCloud Director organization administrators to consolidate their virtual machines (keep in mind this is only available in the SYSTEM organization) without being the SYSTEM administrator.

So if your customers are administrators in their org they aren´t able to consolidate their VMs and this could cause performance issues.

With the "host.login()" method in the vCloud Director plug-in of vCenter Orchestrator you will be able to authorize organization administrators and identify their organizational vApps and VMs. Because the vCenter Orchestrator is connected as a SYSTEM administrator to the vCloud Director you can call methods like "consolidate" directly.

The most valuable step is to identify the chain length of the VM which isn´t viewable as organization admin. So if you know have identified your VMs you can create an scriptable task like this:



myVm.updateInternalState();


System.log("VM name: "+myVm.name);


var doc = new XML(myVm.toXml());
default xml namespace = doc.namespace();
var n8 = new Namespace("http://www.vmware.com/vcloud/extension/v1.5");


System.log("ChainLength: "+doc.VCloudExtension.*::VmVimInfo.*::VirtualDisksMaxChainLength);


var chainLength = doc.VCloudExtension.*::VmVimInfo.*::VirtualDisksMaxChainLength;


if(myVm.vmStatus.value != 8){
throw("VM is not powered off!");





Please keep in mind that the vm.updateInternalState() method is useful cause the state is sometimes not the same as displayed in vCO. This is also useful for the host.login() method in my last article.


The first step identifies the chain length and the second one checks the state of the VM. In my workflow used a "user interaction" with the chain length as external input to ask if the VM should be consolidate. From a external portal you have to use the "answerWorkflow" method.


When the user decides to consolidate (with seeing the chain length in the decision field) the next scriptable task only has a consolidate call:



var task = myVm.consolidate();



The whole workflow looks like this:

















You can control the operation in you vCloud Director, there you will see a "consolidating VM" even if you aren´t a SYSTEM administrator :)

Tuesday, July 3, 2012

vCD is multi-tenant, vCO is single-tenant, what now?

This week I had a discussion with one of our VSSP customers about the integration of vCloud Director in vCenter Orchestrator. As you might know there ist a plug-in for the vCD available which allows you to configure the vCD connection and make it available in vCO.

Now there is one thing to know about: If you configure the plug-in you will use the SYSTEM organization to have all other organizations available. If you connect to the vCO with the SOAP interface (with WaveMaker for example) the users will have full access to the vCD and not only to their organization.

Because of the user and role management in vCloud Director you will be limited in some functions. As example: There is no way to "consolidate" a VM even if you can see the chain length in their properties. This is limited to the provider administrator role.

So what´s the solution?

You can insert all organizations as new vCD connections in the vCD plug-in and as a vCO admin you are able to consolidate... but this isn´t really slick. The other was is to "authenticate" users with their organization and limit their access to their vApps/VMs.

After some attempts i designed a workflow like this:

IN-Parameter:

  • org (string)
  • user (string)
  • pass (string)

IN-Attributes:
  • url (string)
which were easy to fill from a web portal. With these parameters you are able to use the VclHost.login() method like this:

VclHostManager.setRuntimeCredentials(user, pass); 
var host = VclHostManager.createHost(); 
host.url = url; 
host.organization = org; 
host.sessionMode = VclHostSessionMode.PER_USER_SESSION; 
host.enabled = true; 
host.login(); 

Now you are "logged" in with the user and the matching org. A way to verify this is to check for the organizations:

var Organizations = host.getOrganizations(); 
for (i in Organizations){
    System.log("Organization: "+Organizations[i].name);
}


As you can see you will only receive the organizations of the logged in user :)

In my test environment it looks like this:














Now you will be able to get the vApps and Vms of the organization and do some magic with them. I will post some further steps (chain length, WaveMaker portal) later... cause I´m a consultant... in a hotel... with some beer... and only a notebook :)