cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3868
Views
0
Helpful
1
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee
Task Name

Configure number of virtual sockets and number of cores per socket of a VM

Description

Prerequisites
  1. Tested on 5.4.0.2
CategoryWorkflow
ComponentsvSphere 5.x
User Inputse-mail address
Outpute-mail with counter

Instructions for Regular Workflow Use:

  1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
  2. Unzip the file on your computer. Should end up with a .WFD file.
  3. Log in to UCS Director as a user that has "system-admin" privileges.
  4. Navigate to "Policies-->Orchestration" and click on "Import".
  5. Click "Browse" and navigate to the location on your computer where the .WFDX file resides. Choose the .WFDX file and click "Open".
  6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
  7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
  8. Click "Submit".
  9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment

A big thank you goes to:

Credit goes to Logesh Kandasamy and Tejeswar Sahu for developing the custom task

The import:

Screen Shot 2016-04-19 at 2.27.00 PM.png

Screen Shot 2016-04-19 at 2.27.32 PM.png

The workflow:

Screen Shot 2016-04-19 at 2.29.03 PM.png

User input to the task:

     (VM Context could be set in global variable section and linked to the task input!)

Screen Shot 2016-04-19 at 2.29.15 PM.png

The code:

importPackage(com.cloupia.model.cIM);//VMWareVMSummary,Account

importPackage(com.cloupia.service.cIM.inframgr);//InfraPersistenceUtil

importPackage(com.cloupia.lib.cIaaS.vmware);//VCenterConnectionManager

importPackage(com.vmware.vim25.mo);

importPackage(com.vmware.vim25);

importPackage(java.lang);

importPackage(java.util);

var vmId = input.vmid;

var noOfVirtualSockets = input.noOfVSockets;

var noOfCoresPerSocket = input.noOfCoresPerSocket;

var totalNoOfCores = noOfVirtualSockets*noOfCoresPerSocket;

logger.addInfo("vmId:"+vmId+",noOfVirtualSockets:"+noOfVirtualSockets+",noOfCoresPerSocket:"+noOfCoresPerSocket+",totalNoOfCores:"+totalNoOfCores);

//VMWareVMSummary getVMwareVMSummary(int vmId)

var vmwareVMSummary = InfraPersistenceUtil.getVMwareVMSummary(parseInt(vmId));

var accountName = vmwareVMSummary.getAccountName();

var vmName = vmwareVMSummary.getName();

logger.addInfo("Account name:"+accountName);

logger.addInfo("Vm name is:"+vmName);

//Account getAccount(String accountName)

var acc = InfraPersistenceUtil.getAccount(accountName);

try{

var si = new VCenterConnectionManager(acc).getServiceInstance();

}catch(e1){

logger.addError("Connection to the account "+accountName+" got failed."+e1);

ctxt.exit();

}

logger.addInfo("Service Instance is:"+si)

try {

var rootFolder = si.getRootFolder();

  var vm = new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine",vmName);

  if (vm != null) {

  if(vm.getSummary().runtime.powerState.toString().equals("poweredOn")){

    logger.addError(" The vm "+vmName+" is powered on.The vm needs to be powered off first in order to change CPUs.....");

  ctxt.setFailed("The vm needs to be powered off first in order to change CPUs.....");

  ctxt.exit();

   }

  

  //Thread.sleep(10000);

  while(true){

  var vmConfigSpec = new VirtualMachineConfigSpec();

     vmConfigSpec.setNumCoresPerSocket(parseInt(noOfCoresPerSocket));

     vmConfigSpec.setNumCPUs(parseInt(totalNoOfCores));

     var task = vm.reconfigVM_Task(vmConfigSpec);

  waitForTask = task.waitForTask();

  if("success"!=waitForTask){

  logger.addInfo("waiting for completion of the reconfiguration of the vm......");

  Thread.sleep(10000);

    }

    else{

    logger.addInfo("Reconfiguration of the vm got completed....");

    break;

    }

    }

  logger.addInfo("Task got completed successfully...");

  }

     } catch (e) {

  logger.addError("Exception occured " + e);

  } finally {

  si.getServerConnection().logout();

  }

Comments
gputtasw
Cisco Employee
Cisco Employee

Thanks, Orf for putting this on communities. Credit goes to Logesh Kandasamy and Tejeswar Sahu for developing the custom task.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links