net.siveo.virtualization.vmware.Main.java Source code

Java tutorial

Introduction

Here is the source code for net.siveo.virtualization.vmware.Main.java

Source

package net.siveo.virtualization.vmware;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Constructor;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

import org.apache.commons.beanutils.PropertyUtils;
import org.beanio.BeanReader;
import org.beanio.StreamFactory;

import com.vmware.vim25.*;

import net.siveo.utils.ErrorHelper;
import net.siveo.utils.NumericRange;
import net.siveo.utils.VMwareException;
import net.siveo.virtualization.vmware.authorization.AuthorizationManager;
import net.siveo.virtualization.vmware.authorization.Permission;
import net.siveo.virtualization.vmware.authorization.Privilege;
import net.siveo.virtualization.vmware.authorization.Privileges;
import net.siveo.virtualization.vmware.authorization.Role;
import net.siveo.virtualization.vmware.computeresource.ClusterComputeResource;
import net.siveo.virtualization.vmware.computeresource.ComputeResource;
import net.siveo.virtualization.vmware.computeresource.ResourceManager;
import net.siveo.virtualization.vmware.datacenter.Datacenter;
import net.siveo.virtualization.vmware.datacenter.DatacenterManager;
import net.siveo.virtualization.vmware.datastore.DataStoreManager;
import net.siveo.virtualization.vmware.datastore.Datastore;
import net.siveo.virtualization.vmware.distributedvirtualswitch.DVPort;
import net.siveo.virtualization.vmware.distributedvirtualswitch.DVPortGroup;
import net.siveo.virtualization.vmware.distributedvirtualswitch.DVSwitch;
import net.siveo.virtualization.vmware.distributedvirtualswitch.DVSwitchManager;
import net.siveo.virtualization.vmware.folder.Folder;
import net.siveo.virtualization.vmware.folder.FolderManager;
import net.siveo.virtualization.vmware.guest.Guest;
import net.siveo.virtualization.vmware.guest.GuestCustUtil;
import net.siveo.virtualization.vmware.guest.GuestDisk;
import net.siveo.virtualization.vmware.guest.GuestIPConfig;
import net.siveo.virtualization.vmware.guest.GuestNic;
import net.siveo.virtualization.vmware.guest.IpConfigInfoIpAddress;
import net.siveo.virtualization.vmware.host.CPU;
import net.siveo.virtualization.vmware.host.Host;
import net.siveo.virtualization.vmware.host.HostDisk;
import net.siveo.virtualization.vmware.host.HostManager;
import net.siveo.virtualization.vmware.host.HostNetworkConfiguration;
import net.siveo.virtualization.vmware.host.HostNetworkSystem;
import net.siveo.virtualization.vmware.inventory.Inventory;
import net.siveo.virtualization.vmware.inventory.InventoryManager;
import net.siveo.virtualization.vmware.inventory.InventoryMonitor;
import net.siveo.virtualization.vmware.inventory.ManagedObject;
import net.siveo.virtualization.vmware.inventory.TreeNode;
import net.siveo.virtualization.vmware.iso.ISO;
import net.siveo.virtualization.vmware.iso.ISOManager;
import net.siveo.virtualization.vmware.licence.Feature;
import net.siveo.virtualization.vmware.licence.LicenceManager;
import net.siveo.virtualization.vmware.licence.License;
import net.siveo.virtualization.vmware.mor.Mor;
import net.siveo.virtualization.vmware.mor.MorManager;
import net.siveo.virtualization.vmware.mor.Results;
import net.siveo.virtualization.vmware.network.NetCapabilities;
import net.siveo.virtualization.vmware.network.Network;
import net.siveo.virtualization.vmware.network.NetworkManager;
import net.siveo.virtualization.vmware.network.PNic;
import net.siveo.virtualization.vmware.network.PortGroup;
import net.siveo.virtualization.vmware.network.VirtualSwitch;
import net.siveo.virtualization.vmware.performance.Counter;
import net.siveo.virtualization.vmware.performance.PerfMetric;
import net.siveo.virtualization.vmware.performance.PerfResult;
import net.siveo.virtualization.vmware.performance.Performance;
import net.siveo.virtualization.vmware.performance.PerformanceManager;
import net.siveo.virtualization.vmware.resourcepool.ResourcePool;
import net.siveo.virtualization.vmware.resourcepool.ResourcePoolManager;
import net.siveo.virtualization.vmware.snapshot.Snapshot;
import net.siveo.virtualization.vmware.snapshot.SnapshotManager;
import net.siveo.virtualization.vmware.sysprep.GuiRunOnce;
import net.siveo.virtualization.vmware.sysprep.GuiUnattended;
import net.siveo.virtualization.vmware.sysprep.Identification;
import net.siveo.virtualization.vmware.sysprep.LicenseFilePrintData;
import net.siveo.virtualization.vmware.sysprep.SysprepLinux;
import net.siveo.virtualization.vmware.sysprep.SysprepWindows;
import net.siveo.virtualization.vmware.sysprep.UserData;
import net.siveo.virtualization.vmware.task.Task;
import net.siveo.virtualization.vmware.task.TaskCollector;
import net.siveo.virtualization.vmware.utils.Jsch;
import net.siveo.virtualization.vmware.view.ViewManager;
import net.siveo.virtualization.vmware.virtualapp.VirtualApp;
import net.siveo.virtualization.vmware.virtualapp.VirtualAppManager;
import net.siveo.virtualization.vmware.virtualcenter.VirtualCenter;
import net.siveo.virtualization.vmware.virtualdevice.VirtualCPU;
import net.siveo.virtualization.vmware.virtualdevice.VirtualDVSwitch;
import net.siveo.virtualization.vmware.virtualdevice.VirtualDeviceOperation;
import net.siveo.virtualization.vmware.virtualdevice.VirtualDisk;
import net.siveo.virtualization.vmware.virtualdevice.VirtualMemory;
import net.siveo.virtualization.vmware.virtualdevice.VirtualNetwork;
import net.siveo.virtualization.vmware.virtualmachine.NetworkAdapter;
import net.siveo.virtualization.vmware.virtualmachine.Question;
import net.siveo.virtualization.vmware.virtualmachine.VMConfiguration;
import net.siveo.virtualization.vmware.virtualmachine.VMManager;
import net.siveo.virtualization.vmware.virtualmachine.VMNetwork;
import net.siveo.virtualization.vmware.virtualmachine.VirtualMachine;
import net.siveo.virtualization.vmware.virtualmachine.Vnc;
import net.siveo.virtualization.vmware.vmx.Vmx;
import net.siveo.virtualization.vmware.vmx.Vmx2;
import net.siveo.virtualization.vmware.vmx.VmxBuilder;
import net.siveo.virtualization.vmware.ws.WS;
import net.siveo.virtualization.vmware.ws.WSManager;

public class Main {

    public static void main(String[] args) {

        try {

            Main myMain = new Main();

            //String decode=Crypto.decryptString("TWNUYRbFIfa7FFXGeQqTOF9UCFE=");
            //         String decode=Crypto.decryptString("y1lwzhJOzZpvWFNPiW2MVQ==");
            //         String encocde=Crypto.encryptString("mandriva");
            //System.out.println("Decode: "+decode);
            //         System.out.println("Encode: "+encocde);
            //         
            //         String v1="4.1";
            //         String v2="5.0";
            //         String v3="5.5";
            //         String current="4.1";
            //         
            //         System.out.println("compare v1: "+current.compareTo(v1));
            //         System.out.println("compare v2: "+current.compareTo(v2));
            //         System.out.println("compare v3: "+current.compareTo(v3));

            //myMain.checkInventory();
            //myMain.getVMConfigInfo();
            //myMain.getVirtualCenterInfos();
            //myMain.getDatastores();

            //myMain.queryAvailablePerfMetric();

            //myMain.getAPIVersion();

            //myMain.getVMNetworkAvailable();
            //myMain.configureVM("VJTH-TSTWIN-22");

            //myMain.disconnectAndReconnect();
            //myMain.getCurrentTime();

            //myMain.getOSonESX();
            //myMain.loadInventoryEx();
            //myMain.retrieveAllInventoryElementsPropertiesEx();
            //###############################################

            //myMain.deployInstantVM();

            //myMain.getVMFiles("SmallVM");
            //myMain.getTemplateInfo("SmallVM");
            //myMain.configureTemplate("my_template");

            //myMain.getVirtualCenterInfos();
            //VirtualCenter vc = VMware.getVirtualCenterInfos(hostname);
            //myMain.getVirtualMachinesInfo();

            myMain.loadInventory();
            //myMain.getVirtualMachineInfo();
            //myMain.listISO();

            //myMain.configureVM("CreateVMCDO00");
            //myMain.listSnapshot("VM-JTH-TEST");
            //myMain.takeSnapshot("LaVMCDO","Snap-01", "Description du snapshot Snap-01");
            //myMain.revertToSnapshotBySnapshotID("VM-MANU","31-snapshot-5");
            //myMain.revertToSnapshotBySnapshotName("VM-JTH-TEST","SN01");
            //myMain.removeSnapshotBySnapshotID("VM-MANU","31-snapshot-7");
            //myMain.removeAllSnapshot("LaVMCDO");
            //myMain.createVM();
            //myMain.enbaleVNC("vmtestdebi");
            //myMain.getVNCInfo("VM-JTH-TEST");
            //myMain.createContainerView();
            //myMain.runCmd();
            //myMain.gereVMX();
            //myMain.reconfigureVMX();
            //myMain.loadVMX();

            //myMain.unMarshallVmx1();
            //myMain.marshallVmx(null);
            //myMain.unMarshallVmxTest();

            //myMain.getBackinfInfo();

            //myMain.renameOnESXi();
            //myMain.getOSonESX();
            //myMain.getVMByName();
            //myMain.getVMPath();
            //myMain.enbaleVNCOnESXi();
            //myMain.configureOnESXi();
            //myMain.convertVMToTemplateOnESXi();
            //myMain.getSyntheseOnESXi();
            //myMain.deleteVM();
            //myMain.getCurrentTasks();

            //myMain.vmwareCmd();
            //myMain.getLicenceInfo();

            //###############################################

            //myMain.getVirtualMachinesInfo();
            //myMain.getVMIPInfos();
            //myMain.getVMGuest();
            //myMain.getHostResourceAllocation();

            //myMain.getHostResourcesAllocation();

            //myMain.loadInventoryEX();

            //omyMain.loadInventory();

            //myMain.loadInventory();
            //myMain.changeMACAddress();
            //myMain.reconfMACAddress();

            //myMain.setGuestHostname();

            //myMain.customizeVM("VJTH-TSTWIN-02");
            //myMain.getURLConsole("TPL_debian", true, true);

            //myMain.getVMInfo("VJTH-TSTWIN-12");

            //myMain.getSnapshot("VTES-TEST-03");
            //myMain.revertToSnapshot();
            //myMain.testJSCH();

            //myMain.cloneVMTOVMOnESX();

            //myMain.createVM();

            //myMain.listISO();

            //myMain.displayRoles();
            //myMain.displayPrivileges();
            //myMain.displayPermissions();
            //myMain.createRoleSimple();
            //myMain.createRole();
            //myMain.updateRoleSimple();
            //myMain.updateRole();
            //myMain.deleteRole();
            //myMain.removeTreeNodePermissions();
            //myMain.listTreeNodePermissions();
            //myMain.addTreeNodePermissions();
            //myMain.retrieveProperties();
            //myMain.retrieveVNCInfos();
            //myMain.updateTreeNodePermissions();
            //myMain.getPermissions();

            //myMain.testGetSnapshotSize();
            //myMain.testInventory();

            //myMain.getVMFilesSizeInfo();
            //myMain.getVM_VMXFile(null);
            //myMain.getVMFiles("e-planet.siveo.net");

            //myMain.getVMFiles("TPL_VTES-TEST-03");

            //myMain.answerVM();
            //myMain.answerQuestion();

            //myMain.getTreeNodeRoles();
            //myMain.loadInventory();
            //myMain.checkifESX();
            //myMain.displayDatastorePermissions();

            //myMain.displayRoles();

            //myMain.GetDatastoreByID();

            //myMain.cloneVMTOVMOnESX();
            //myMain.customizeVM("CDOmyVM");
            //myMain.testVMwareTools();

            //myMain.testVMDeleteState();
            //myMain.getResourcePool();
            //myMain.getVMHost();

            // Dj - InstantVM
            //myMain.deployInstantVM();
            //myMain.deployInstantWindowsVM();
            //myMain.deployInstantWindowsVM();
            //myMain.deployInstantVMOnProd();
            //myMain.templateListNetworks();
            //myMain.updateNetwork();
            //myMain.connectDeviceOnStart();
            //myMain.startInstantVM();

            //myMain.cloneTemplateToVM();

            //myMain.cloneTemplateToVirtualMachine();

            //myMain.simpleCloneVMTOVMOnESX();
            //myMain.registerVM();

            //myMain.getTemplateInfo("");
            //myMain.getVMInfo("Template-Centos-secure-5.8-x32-20GB-8GB_SWAP-1vCPU-8GB_RAM-V1.0");

            //myMain.getVMInfo("MBS_eVA");

            //myMain.configureVM(vmName)

            //myMain.convertVMToTemplate();

            // Liste l'inventaire des objets VMware
            // ##########################"
            //myMain.createContainerView();

            //myMain.createFolder();
            //myMain.getResourcesAllocation();
            //myMain.loadInventoryEx();
            //myMain.getHostResourcesAllocation();

            //myMain.checkDatastore();
            //myMain.testDateiso();
            //myMain.getVMInfo("evanavaho");
            //myMain.createNodePermission();

            //myMain.testVM();
            //System.out.println("Time: "+System.currentTimeMillis());

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void displayWebService() throws VMwareException {
        VMware vmware = new VMware();
        WSManager wsmanager = WSManager.getInstance();
        WS ws = null;

        for (int i = 0; i < wsmanager.getAllWS().size(); i++) {
            ws = wsmanager.getAllWS().get(i);
            System.out.println("WebService n" + i);
            System.out.println("- URL         : " + ws.getUrl());
            System.out.println("- Name        : " + ws.getName());
            System.out.println("- FullName    : " + ws.geFullName());
            System.out.println("- API Type    : " + ws.getAPIType());
            System.out.println("- API Version : " + ws.getAPIFullVersion());
            System.out.println("- Build       : " + ws.getBuild());
            System.out.println("- InstanceUuid: " + ws.getInstanceUuid());
            System.out.println("- License Product Name   : " + ws.getLicenseProductName());
            System.out.println("- License Product Version: " + ws.getLicenseProductVersion());
            System.out.println("- Locale Build: " + ws.getLocaleBuild());
            System.out.println("- Locale Version: " + ws.getLocaleVersion());
            System.out.println("- OsType      : " + ws.getOsType());
            System.out.println("- Product LineId: " + ws.getProductLineId());
            System.out.println("- Vendor      : " + ws.getVendor());
            System.out.println("- Version     : " + ws.getVersion());
            System.out.println("");

        }

    }

    // Parcours d'un arbre en profondeur
    public void depth_traversal() {
        // Parcour de l'arbre

    }

    // Parcours d'un arbre en largeur
    public void breath_traversal() {

    }

    public void answerQuestion() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "CDOnavaho");

        // =========================================================================================
        // Answer the Question
        // =========================================================================================
        vm.answerQuestion();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void answerVM() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "CDOnavaho");

        System.out.println("VirtualMachine: " + vm);

        Question question = vm.retrieveQuestion();

        System.out.println("Question: " + question);

        //      System.out.println("VM Power State: "+vm.getPowerState());
        //      
        //      VirtualMachineQuestionInfo virtualMachineQuestionInfo=(VirtualMachineQuestionInfo)MorManager.getMorProperty(ws, vm.getMor(),new String[]{"runtime.question"});
        //         
        //      if(virtualMachineQuestionInfo!=null)
        //      {
        //         System.out.println("- Question:");
        //         System.out.println("  - ID: "+virtualMachineQuestionInfo.getId());
        //         System.out.println("  - Text: "+virtualMachineQuestionInfo.getText());
        //
        //         ChoiceOption choiceOption=virtualMachineQuestionInfo.getChoice();
        //         ElementDescription[] tabOfElementDescriptions=null;
        //         
        //         if(choiceOption!=null)
        //         {
        //            System.out.println("  - Choice Option:");
        //            System.out.println("    - DefaultIndex: "+choiceOption.getDefaultIndex());
        //
        //            tabOfElementDescriptions=choiceOption.getChoiceInfo();
        //            if(tabOfElementDescriptions!=null && tabOfElementDescriptions.length>0)
        //            {
        //               for(ElementDescription elementDescription:tabOfElementDescriptions)
        //               {
        //                  System.out.println("    - Info Key: "+elementDescription.getKey());
        //                  System.out.println("    - Info Label: "+elementDescription.getLabel());
        //                  System.out.println("    - Info Summary: "+elementDescription.getSummary());
        //               }
        //            }
        //         }
        //      }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVMFiles(String vmName) throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //      String hostName="192.168.101.110";
        //      VMware.create(hostName,443,"root","mandriva",false,-1L);

        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Retrieve the Virtual Machine Files
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        VirtualMachineFileLayoutEx virtualMachineFileLayoutEx = null;
        virtualMachineFileLayoutEx = (VirtualMachineFileLayoutEx) MorManager.getMorProperty(ws, vm.getMor(),
                new String[] { "layoutEx" });

        VirtualMachineFileLayoutExDiskLayout[] listOfVirtualMachineFileLayoutExDiskLayouts = null;
        VirtualMachineFileLayoutExSnapshotLayout[] listOfVirtualMachineFileLayoutExSnapshotLayouts = null;
        VirtualMachineFileLayoutExFileInfo[] listOfVirtualMachineFileLayoutExFileInfos = null;

        listOfVirtualMachineFileLayoutExDiskLayouts = virtualMachineFileLayoutEx.getDisk();
        listOfVirtualMachineFileLayoutExSnapshotLayouts = virtualMachineFileLayoutEx.getSnapshot();
        listOfVirtualMachineFileLayoutExFileInfos = virtualMachineFileLayoutEx.getFile();

        VirtualMachineFileInfo virtualMachineFileInfo = (VirtualMachineFileInfo) MorManager.getMorProperty(ws,
                vm.getMor(), new String[] { "config.files" });

        String dsURL = (String) MorManager.getMorProperty(ws, vm.getDatastores().get(0).getMor(),
                new String[] { "info.url" });

        if (listOfVirtualMachineFileLayoutExFileInfos != null
                && listOfVirtualMachineFileLayoutExFileInfos.length > 0) {
            System.out.println("########################### Virtual Machine Files ###########################");
            System.out.println("- VM: " + vm.getName() + " / " + vm.getMor().get_value());
            System.out.println("- Path: " + virtualMachineFileInfo.getVmPathName());
            System.out.println("- URL: " + dsURL);
            System.out.println("");

            for (VirtualMachineFileLayoutExFileInfo files : listOfVirtualMachineFileLayoutExFileInfos) {
                System.out.println("- Name: " + files.getName());
                System.out.println("- Key: " + files.getKey());
                System.out.println("- Size: " + files.getSize());
                System.out.println("- Type: " + files.getType());
                System.out.println("");
            }

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVMFilesSizeInfo() throws VMwareException {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "ovmmnager");

        System.out.println("VM total Files size: " + vm.computeSizeForVMAllFiles());
        System.out.println("VM total snaphsot Files size: " + vm.computeSizeForAllSnapshots());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testInventory() throws VMwareException {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);
        //VMware.create(hostName,443,"SIVEO\\actidev1","P@ssw0rd",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        VMManager vmManager = VMManager.getInstance();
        ArrayList<VirtualMachine> listOfVirtualMachines = vmManager.getAllVM(hostName);
        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();

        System.out.println("Nb VM: " + listOfVirtualMachines.size());

        if (listOfVirtualMachines != null && !listOfVirtualMachines.isEmpty()) {
            for (VirtualMachine vm : listOfVirtualMachines) {
                listOfMors.add(vm.getMor());
            }

            Date dt1 = new Date();
            inventory.getVirtualMachinePropertiesEx(listOfMors);
            Date dt2 = new Date();

            System.out.println("Temps recup VM Properties:  " + (dt2.getTime() - dt1.getTime()));

        }

        // Get All Hosts
        HostManager hostManager = HostManager.getInstance();
        ArrayList<Host> listOfHosts = hostManager.getAllHosts(hostName);
        listOfMors.clear();

        if (listOfHosts != null && !listOfHosts.isEmpty()) {
            for (Host host : listOfHosts) {
                listOfMors.add(host.getMor());
            }

            Date dt1 = new Date();
            inventory.getHostPropertiesEx(listOfMors);
            Date dt2 = new Date();

            System.out.println("Temps recup Host Properties:  " + (dt2.getTime() - dt1.getTime()));

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testGetSnapshotSize() throws VMwareException {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);
        //VMware.create(hostName,443,"SIVEO\\actidev1","P@ssw0rd",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "ovmmnager");

        System.out.println("vm: " + vm);

        VirtualMachineFileLayoutEx virtualMachineFileLayoutEx = null;
        virtualMachineFileLayoutEx = (VirtualMachineFileLayoutEx) MorManager.getMorProperty(vm.getWS(), vm.getMor(),
                new String[] { "layoutEx" });

        if (virtualMachineFileLayoutEx != null) {
            // Prepare an internal hashtable
            VirtualMachineFileLayoutExFileInfo[] machineFileLayoutExFileInfos = null;
            machineFileLayoutExFileInfos = virtualMachineFileLayoutEx.getFile();

            if (machineFileLayoutExFileInfos != null && machineFileLayoutExFileInfos.length > 0) {
                HashMap<Integer, VirtualMachineFileLayoutExFileInfo> mapOfVMLayoutByKey = new HashMap<Integer, VirtualMachineFileLayoutExFileInfo>();
                for (VirtualMachineFileLayoutExFileInfo machineFileLayoutExFileInfo : machineFileLayoutExFileInfos) {
                    System.out.println("- Key: " + machineFileLayoutExFileInfo.getKey());
                    System.out.println("- Name: " + machineFileLayoutExFileInfo.getName());
                    System.out.println("- Type: " + machineFileLayoutExFileInfo.getType());
                    System.out.println("- Size: " + machineFileLayoutExFileInfo.getSize());
                    System.out.println("");
                }

            }

            VirtualMachineFileLayoutExSnapshotLayout[] snapshotLayouts = null;
            VirtualMachineFileLayoutExDiskLayout[] vmFilesLayouts = null;

            //ArrayOfVirtualMachineFileLayoutExSnapshotLayout

            snapshotLayouts = virtualMachineFileLayoutEx.getSnapshot();
            if (snapshotLayouts != null && snapshotLayouts.length > 0) {
                for (VirtualMachineFileLayoutExSnapshotLayout snapshotLayout : snapshotLayouts) {
                    System.out.println("Snapshot File Layout Key: " + snapshotLayout.getDataKey());

                    /*
                    vmFilesLayouts=snapshotLayout.getDisk();
                        
                    if (vmFilesLayouts!=null && vmFilesLayouts.length>0)
                    {
                       for (VirtualMachineFileLayoutExDiskLayout vmfilelayout:vmFilesLayouts)
                       {
                          System.out.println("Snapshot File Layout Key: "+vmfilelayout.getKey());
                       }
                    }
                    */

                }
            }

            //
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void retrieveVNCInfos() throws VMwareException {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);
        //VMware.create(hostName,443,"SIVEO\\actidev1","P@ssw0rd",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        List<Integer> listOfPorts = null;

        VMManager vmManager = VMManager.getInstance();
        ArrayList<VirtualMachine> listOfVMs = vmManager.getAllVM(hostName);
        Vnc vnc = null;

        //VirtualMachine vm=vmManager.getVmByID(hostName, vmID)

        listOfPorts = vmManager.retrieveVNCInfos(listOfVMs);

        for (int port : listOfPorts) {
            System.out.println("Port:" + port);

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void retrieveProperties() throws VMwareException {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);
        //VMware.create(hostName,443,"SIVEO\\actidev1","P@ssw0rd",false,-1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        VMManager vmManager = VMManager.getInstance();
        ArrayList<VirtualMachine> listOfVMs = vmManager.getAllVM(hostName);

        ArrayList<ManagedObjectReference> listMors = new ArrayList<ManagedObjectReference>();

        for (VirtualMachine vm : listOfVMs) {
            listMors.add(vm.getMor());
        }

        //ObjectContent objectContent=null;
        DynamicProperty[] dynamicProperties = null;
        DynamicProperty dynamicProperty = null;

        ObjectContent[] tabOfObjectContents = MorManager.getPropertiesEx(ws, listMors, new String[] { "config" });

        for (ObjectContent objectContent : tabOfObjectContents) {
            System.out.println("VM:");
            System.out.println("- ID: " + objectContent.getObj().get_value());
            dynamicProperties = objectContent.getPropSet();
            dynamicProperty = dynamicProperties[0];

            System.out.println("" + dynamicProperty.getName() + " / " + dynamicProperty.getVal());

            //vm.setVirtualMachineConfigInfo(virtualMachineConfigInfo);

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void displayDatastorePermissions() throws VMwareException {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        ////VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);
        //VMware.create(hostName,443,"SIVEO\\actidev1","P@ssw0rd",false,-1L);

        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        Datastore ds = dataStoreManager.getDatastoreByName("SIVEO_ADM", hostName);

        ArrayList<Permission> listOfPermissions = null;

        if (ds != null) {
            listOfPermissions = ds.getPermission();
            if (listOfPermissions != null && !listOfPermissions.isEmpty()) {
                System.out.println("Permission recuperee depuis le Datastore");
                for (Permission permission : listOfPermissions) {
                    System.out.println("-Principal: " + permission.getPrincipal());
                    System.out.println("-Role: " + permission.getRole().getName());
                }
            }
        }

        System.out.println("");

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        listOfPermissions = authorizationManager.retrieveTreeNodePermissions(ds.getMor().get_value(), hostName,
                true);

        if (listOfPermissions != null) {
            System.out.println("Permission recuperee via API");

            for (Permission permission : listOfPermissions) {
                System.out.println("-Permission: ");
                System.out.println("-Entity: " + permission.getEntity().getType() + " / "
                        + permission.getEntity().get_value());
                System.out.println("-Principal: " + permission.getPrincipal());
                System.out.println("-Role: " + permission.getRole().getName());
                System.out.println("-Propagate: " + permission.isPropagate());
                System.out.println("");
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void displayPermissions() throws VMwareException {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        ////VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);
        //VMware.create(hostName,443,"SIVEO\\actidev1","P@ssw0rd",false,-1L);

        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VJTH-CHIN-01");

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        ArrayList<Permission> listOfPermissions = authorizationManager
                .retrieveTreeNodePermissions(vm.getMor().get_value(), hostName, true);

        if (listOfPermissions != null) {
            for (Permission permission : listOfPermissions) {
                System.out.println("-Permission: ");
                System.out.println("-Entity: " + permission.getEntity().getType() + " / "
                        + permission.getEntity().get_value());
                System.out.println("-Principal: " + permission.getPrincipal());
                System.out.println("-Role: " + permission.getRole().getName());
                System.out.println("-Propagate: " + permission.isPropagate());
                System.out.println("");
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void displayPrivileges() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        //String hostName="10.1.109.236";
        //VMware.create(hostName,443,"administrator","8x63-K/!/",false,-1L);

        // =========================================================================================
        // Get Inventory
        // =========================================================================================
        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        ArrayList<Privilege> listOfPrivileges = authorizationManager.getAllPrivileges(hostName);
        //ArrayList<Role> listOfRoles=authorizationManager.retrieveRoles(hostName);

        if (listOfPrivileges != null) {
            for (Privilege privilege : listOfPrivileges) {
                System.out.println("-ID: " + privilege.getID());
                System.out.println("-Label: " + privilege.getLabel());
                System.out.println("-Description: " + privilege.getDescription());
                System.out.println("");
            }
        }

        //authorizationManager.getAllPrivileges(hostName);
        //authorizationManager.loadAllPrivileges(hostName);
        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testRoles() throws Exception {

    }

    public void GetDatastoreByID() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        Performance performance = performanceManager.create(hostName);

        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS");
        Calendar curTime = performance.getCurrentDateTime();

        System.out.println("Current Time: " + dateFormat.format(curTime.getTime()));

        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        ArrayList<Datastore> listOfDatastores = dataStoreManager.getAllDatastore(hostName);

        if (listOfDatastores != null && !listOfDatastores.isEmpty()) {
            for (Datastore datastore : listOfDatastores) {
                System.out.println("- Name: " + datastore.getName());
                System.out.println("  - UUID: " + datastore.getUuid());
                System.out.println("");
            }
        }

        Datastore ds = dataStoreManager.getDatastoreByUUID("4d8b5ee6-baeef85b-f5e8-e41f1342fa86", hostName);
        if (ds != null) {
            System.out.println("Datastore by UUID");
            System.out.println(" - Name: " + ds.getName());
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void displayRoles() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //String hostName="10.1.109.236";
        //VMware.create(hostName,443,"administrator","8x63-K/!/",false,-1L);

        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Get Inventory
        // =========================================================================================
        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        ArrayList<Role> listOfRoles = authorizationManager.getAllRoles(hostName);
        //ArrayList<Role> listOfRoles=authorizationManager.retrieveRoles(hostName);

        System.out.println("Premier affichage des roles");

        if (listOfRoles != null) {
            for (Role role : listOfRoles) {
                System.out.println("-Name: " + role.getName());
                System.out.println("-ID: " + role.getID());
                System.out.println("-Label: " + role.getInfo_label());
                System.out.println("-Summary: " + role.getInfo_summary());

                if (role.getListOfPrivileges() != null) {
                    System.out.println("-Privilege: ");
                    for (Privilege privilege : role.getListOfPrivileges()) {
                        System.out.println(" -" + privilege.getID() + " / " + privilege.getDescription());
                    }
                }

                System.out.println("");
            }
        }

        System.out.println("###################################");
        System.out.println("Press a key to exit");
        System.out.println("###################################");
        System.in.read();

        System.out.println("Second affichage des roles");
        listOfRoles = authorizationManager.retrieveRoles(hostName);

        if (listOfRoles != null) {
            for (Role role : listOfRoles) {
                System.out.println("-Name: " + role.getName());
                System.out.println("-ID: " + role.getID());
                System.out.println("-Label: " + role.getInfo_label());
                System.out.println("-Summary: " + role.getInfo_summary());

                if (role.getListOfPrivileges() != null) {
                    System.out.println("-Privilege: ");
                    for (Privilege privilege : role.getListOfPrivileges()) {
                        System.out.println(" -" + privilege.getID() + " / " + privilege.getDescription());
                    }
                }

                System.out.println("");
            }
        }

        //authorizationManager.getAllPrivileges(hostName);
        //authorizationManager.loadAllPrivileges(hostName);
        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void createRoleSimple() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        String[] myPriv = new String[] { Privileges.VIRTUALMACHINE_INTERACT_POWERON,
                Privileges.VIRTUALMACHINE_INTERACT_POWEROFF, Privileges.SYSTEM_ANONYMOUS, Privileges.SYSTEM_READ,
                Privileges.SYSTEM_VIEW };

        String roleName = "TestRole1";

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        authorizationManager.createRole(roleName, myPriv, hostName);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void createRole() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        ArrayList<Privilege> listOfPrivileges = new ArrayList<Privilege>();
        Privilege privilege = null;

        privilege = new Privilege();
        privilege.setID(Privileges.SYSTEM_ANONYMOUS);
        listOfPrivileges.add(privilege);

        privilege = new Privilege();
        privilege.setID(Privileges.SYSTEM_READ);
        listOfPrivileges.add(privilege);

        privilege = new Privilege();
        privilege.setID(Privileges.SYSTEM_VIEW);
        listOfPrivileges.add(privilege);

        privilege = new Privilege();
        privilege.setID(Privileges.SYSTEM_VIEW);
        listOfPrivileges.add(privilege);

        privilege = new Privilege();
        privilege.setID(Privileges.VIRTUALMACHINE_INTERACT_RESET);
        listOfPrivileges.add(privilege);

        String roleName = "TestRole2";

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        authorizationManager.createRole(roleName, listOfPrivileges, hostName);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void updateRoleSimple() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        String[] myPriv = new String[] { Privileges.VIRTUALMACHINE_INTERACT_SUSPEND, Privileges.SYSTEM_ANONYMOUS,
                Privileges.SYSTEM_READ, Privileges.SYSTEM_VIEW };

        String roleName = "TestRole1_1";

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        authorizationManager.updateRole(637534613, hostName, roleName, myPriv);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void updateRole() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        ArrayList<Privilege> listOfPrivileges = new ArrayList<Privilege>();
        Privilege privilege = null;

        privilege = new Privilege();
        privilege.setID(Privileges.SYSTEM_ANONYMOUS);
        listOfPrivileges.add(privilege);

        privilege = new Privilege();
        privilege.setID(Privileges.SYSTEM_READ);
        listOfPrivileges.add(privilege);

        privilege = new Privilege();
        privilege.setID(Privileges.SYSTEM_VIEW);
        listOfPrivileges.add(privilege);

        privilege = new Privilege();
        privilege.setID(Privileges.SYSTEM_VIEW);
        listOfPrivileges.add(privilege);

        privilege = new Privilege();
        privilege.setID(Privileges.VIRTUALMACHINE_INTERACT_POWERON);
        listOfPrivileges.add(privilege);

        privilege = new Privilege();
        privilege.setID(Privileges.VIRTUALMACHINE_INTERACT_POWEROFF);
        listOfPrivileges.add(privilege);

        String roleName = "TestRole2_2";

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        authorizationManager.updateRole(637534614, hostName, roleName, listOfPrivileges);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void deleteRole() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        authorizationManager.deleteRole(637534613, hostName);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void listTreeNodePermissions() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx4.siveo.net", hostName);

        ArrayList<Permission> listOFPerm = host.getPermission();

        if (listOFPerm != null && !listOFPerm.isEmpty()) {
            System.out.println("Permission Recuperee depuis l'inventaire:");

            for (Permission permission : listOFPerm) {
                System.out.println("- Principal: " + permission.getPrincipal());
                System.out.println("- Role: " + permission.getRole().getName());
                System.out.println("");
            }
        }

        System.out.println("");

        //retrieveTreeNodePermissions
        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        listOFPerm = authorizationManager.retrieveTreeNodePermissions(host.getMor().get_value(), hostName, true);
        if (listOFPerm != null && !listOFPerm.isEmpty()) {
            System.out.println("Permission Recuperee depuis l'API:");

            for (Permission permission : listOFPerm) {
                System.out.println("- Principal: " + permission.getPrincipal());
                System.out.println("- Role: " + permission.getRole().getName());
                System.out.println("");
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void removeTreeNodePermissions() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "CDO01");

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx4.siveo.net", hostName);
        System.out.println("host: " + host.getMor().get_value());

        ComputeResource computeResource = host.getComputeResource();

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        //authorizationManager.removeTreeNodePermisssions(vm.getMor().get_value(), hostName, "SIVEO\\demo05", false);
        authorizationManager.removeTreeNodePermisssions(computeResource.getMor().get_value(), hostName,
                "SIVEO\\Demonstration", true);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void addTreeNodePermissions() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "CDO01");

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx4.siveo.net", hostName);

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        authorizationManager.addTreeNodePermission(vm.getMor().get_value(), hostName, 637534611, "SIVEO\\demo05",
                false, false);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getPermissions() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx3.siveo.net", hostName);

        ArrayList<Permission> listOfPermissions = host.getPermission();

        if (listOfPermissions != null && !listOfPermissions.isEmpty()) {
            for (Permission permission : listOfPermissions) {
                System.out.println("Role Id: " + permission.getRoleId());
                System.out.println("Principal: " + permission.getPrincipal());
            }
        }

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        //authorizationManager.updateTreeNodePermission(vm.getMor().get_value(), hostName, "SIVEO\\demo05", false);
        authorizationManager.updateTreeNodePermission(host.getMor().get_value(), hostName, "siveo\\actidev2",
                637534611, false);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void updateTreeNodePermissions() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "CDO01");

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx3.siveo.net", hostName);

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        //authorizationManager.updateTreeNodePermission(vm.getMor().get_value(), hostName, "SIVEO\\demo05", false);
        authorizationManager.updateTreeNodePermission(host.getMor().get_value(), hostName, "siveo\\actidev2",
                637534611, false);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getTreeNodeRoles() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Create a Role
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "CDO01");

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        ArrayList<Role> listOfRoles = authorizationManager.retrieveTreeNodeRoles(vm.getMor().get_value(), hostName,
                true);

        if (listOfRoles != null) {
            for (Role role : listOfRoles) {
                System.out.println("-Name: " + role.getName());
                System.out.println("-ID: " + role.getID());
                System.out.println("");
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getRole(String roleName) throws VMwareException {
        VMware vmware = new VMware();
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getAllWS().get(0);

        // Get the AuthorizationManager
        ManagedObjectReference authorizationManager = ws.getVIMService().getServiceContent()
                .getAuthorizationManager();

        //Get the roles
        AuthorizationRole authorizationRole = null;
        AuthorizationRole[] authorizationRoleArr = null;
        ArrayOfAuthorizationRole authorizationRoleArrOf = null;
        authorizationRoleArrOf = (ArrayOfAuthorizationRole) MorManager.getMorProperty(ws, authorizationManager,
                new String[] { "roleList" });

        if (authorizationRoleArrOf != null && authorizationRoleArrOf.getAuthorizationRole() != null
                && authorizationRoleArrOf.getAuthorizationRole().length > 0) {
            authorizationRoleArr = authorizationRoleArrOf.getAuthorizationRole();
            System.out.println("Role");

            for (int nbRole = 0; nbRole < authorizationRoleArr.length; nbRole++) {
                authorizationRole = authorizationRoleArr[nbRole];

                //if (authorizationRole.getName().equals(roleName))
                //{
                if (authorizationRole.isSystem()) {
                    System.out.println("- Name   : " + authorizationRole.getName());
                    System.out.println("- ID     : " + authorizationRole.getRoleId());
                    System.out.println("- Label  : " + authorizationRole.getInfo().getLabel());
                    System.out.println("- Summary: " + authorizationRole.getInfo().getSummary());
                    if (authorizationRole.getPrivilege() != null && authorizationRole.getPrivilege().length > 0) {
                        for (int nbPriv = 0; nbPriv < authorizationRole.getPrivilege().length; nbPriv++) {
                            System.out.println("- Privlege " + nbPriv);
                            System.out.println("- Name: " + authorizationRole.getPrivilege()[nbPriv]);

                        }

                    }
                    System.out.println("");
                }
                //}

            }
        }

        wsManager.deleteVIM();

    }

    // Creation d'un role

    public void browseInventory() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        InventoryManager inventoryManager = InventoryManager.getInstance();
        //Inventory inventory=inventoryManager.loadInventory(hostName);

        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        inventory.getRootNode();
        System.out.println("Root node: " + inventory.getRootNode());

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx3.siveo.net", hostName);
        ResourcePool rsPool = host.getResourcePool();
        System.out.println("resource pool: " + rsPool.getName() + "/ " + rsPool.getMor().get_value());

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "CentOSVM");
        ResourcePool resourcePool = vm.getResourcePool();
        System.out.println(
                "CentOSVM resource pool: " + resourcePool.getName() + " / " + resourcePool.getMor().get_value());

        vm = vmManager.getVmByName(hostName, "chinatelco");
        resourcePool = vm.getResourcePool();
        System.out.println(
                "chinatelco resource pool: " + resourcePool.getName() + " / " + resourcePool.getMor().get_value());

        vm = vmManager.getVmByName(hostName, "demotestchen");
        resourcePool = vm.getResourcePool();
        host = vm.getHost();
        System.out.println("demotestchen resource pool: " + resourcePool.getName() + " / "
                + resourcePool.getMor().get_value());
        System.out.println("host: " + host.getName() + " / " + host.getMor().get_value());

        //FolderManager folderManager=FolderManager.getInstance();
        //folderManager.getRootFolder("vsphere-4-0-1");

        //InventoryManager inventoryManager=InventoryManager.getInstance();
        //inventoryManager.browseInventory("vsphere-4-0-1");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void loadInventory(String hostName, String userName, String password, boolean ssl, long wsTimeOut,
            long taskTimeOut) throws VMwareException {
        VMware vmware = new VMware(hostName, 443, userName, password, ssl, wsTimeOut, taskTimeOut);
        WSManager wsManager = WSManager.getInstance();

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        System.out.println("");
        System.out.println("");

        // Network info
        HostManager hostManager = HostManager.getInstance();
        //Host hostESXi=hostManager.getHostByName("dskesxi.siveo.net", hostName);
        //Host hostESX=hostManager.getHostByName("jerakine.siveo.net", hostName);

        ArrayList<Host> listOfHosts = hostManager.getAllHosts(hostName);
        ComputeResource computeResource = null;
        ComputeResourceSummary computeResourceSummary = null;

        if (listOfHosts != null && listOfHosts.size() > 0) {
            for (Host host : listOfHosts) {
                /*
                computeResourceSummary=host.getComputeResource().getComputeResourceSummary();
                System.out.println("");
                System.out.println("Host: "+host.getName());
                System.out.println("-Effective Cpu: "+computeResourceSummary.getEffectiveCpu());
                System.out.println("-EffectiveMemory: "+computeResourceSummary.getEffectiveMemory());
                System.out.println("-Num Cpu Cores: "+computeResourceSummary.getNumCpuCores());
                System.out.println("-Num Cpu Threads: "+computeResourceSummary.getNumCpuThreads());
                System.out.println("-Num Effective Hosts: "+computeResourceSummary.getNumEffectiveHosts());
                System.out.println("-Total Cpu: "+computeResourceSummary.getTotalCpu());
                System.out.println("-Total Memory: "+computeResourceSummary.getTotalMemory());
                */
            }
        }

        //ArrayList<Network> listOfNetworks=host_.loadNetworks();

        //this.getNetworkInfo(host_);

        /*
            
        ArrayList<Datastore> listOfDS=null;
        ArrayList<Network> listOfNetworks=null;
            
        if (listOfHosts!=null && listOfHosts.size()>0)
        {
           for (Host host:listOfHosts)
           {
        System.out.println("");
        System.out.println("Host: "+host.getName());
        listOfDS=host.loadDatastores();
        if (listOfDS!=null && listOfDS.size()>0)
           for (Datastore ds:listOfDS)
           {
              System.out.println("Datastore: "+ds.getName()+" /ID: "+ds.getMor().get_value()+" /NbParent: "+ds.getNbHosts());
           }
            
        listOfNetworks=host.getNetworks();
        if (listOfNetworks!=null && listOfNetworks.size()>0)
           for (Network network:listOfNetworks)
           {
              System.out.println("network: "+network.getName()+" /ID: "+network.getMor().get_value()); //+" /NbParent: "+ds.getNbHosts());
           }
           }
        }
        */

        /*
        //Host host=hostManager.getHost("esx01.siveo.net");
        //Host host=hostManager.getHost("jerakine.siveo.net");
        Host host1=hostManager.getHost("siveo-admesx01.siveo.net");
        Host host2=hostManager.getHost("siveo-admesx02.siveo.net");
            
        ArrayList<Datastore> listOfDS=host1.loadDatastores();
        System.out.println("");
        System.out.println("Host: "+host1.getName());
        for (Datastore ds:listOfDS)
        {
           System.out.println("Datastore: "+ds.getName()+" / "+ds.getMor().get_value());
        }
            
        ArrayList<Datastore> listOfDS2=host2.loadDatastores();
        System.out.println("");
        System.out.println("Host: "+host2.getName());
        for (Datastore ds:listOfDS2)
        {
           System.out.println("Datastore: "+ds.getName()+" /ID: "+ds.getMor().get_value()+" /NbParent: "+ds.getNbHosts());
        }
         */
        //System.out.println("Host: jerakine.siveo.net: "+host);
        //System.out.println("-Mor:: "+host.getMor());
        //System.out.println("-Networking"+host.getNetworking());

        //host.loadNetworks();

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();
    }

    /**
     * 
     * @param vmName
     * @throws VMwareException
     */
    public void getVMHardware(String vmName) throws VMwareException {
        //String vmWareHostName="vcenter.siveo.net";
        //VMware vmware=new VMware(vmWareHostName,443,"Administrateur","Gd@jJ2009$",false,480000L,1000L);
        String vmWareHostName = "10.251.5.14";
        VMware vmware = new VMware(vmWareHostName, 443, "Administrateur", "Clmdp@09", false, 480000L, 1000L);

        //String vmWareHostName="vpshere-4-1";
        //VMware vmware=new VMware(vmWareHostName,443,"Administrateur","Gd@jJ2009$",false,480000L,1000L);
        WSManager wsManager = WSManager.getInstance();

        //System.out.println("API Full Version: "+wsManager.getWS(vmWareHostName).getAPIFullVersion());
        //System.out.println("API Version: "+wsManager.getWS(vmWareHostName).getAPIVersion());
        //System.out.println("Version: "+wsManager.getWS(vmWareHostName).getVersion());

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(vmWareHostName, vmName);

        //VirtualDeviceManager virtualDeviceManager=vm.getVirtualDeviceManager();

        //VirtualDevice[] listOfVirtualDevices=virtualDeviceManager.getAllVirtualDevices();
        VirtualDevice[] listOfVirtualDevices = vm.getVirtualDeviceManager().getListOfVirtualDevices();

        if (listOfVirtualDevices != null) {
            int nb = 0;
            VirtualEthernetCard virtualEthernetCard = null;
            VirtualController virtualController = null;
            String virtualDeviceClassName = null;
            String keys = new String();

            for (VirtualDevice virtualdevice : listOfVirtualDevices) {
                System.out.println("\nvirtual Device n" + nb++);
                System.out.println("- Device Class: " + virtualdevice.getClass());
                System.out.println("- Key    : " + virtualdevice.getKey());
                System.out.println("- ControllerKey: " + virtualdevice.getControllerKey());
                System.out.println("- Label  : " + virtualdevice.getDeviceInfo().getLabel());
                System.out.println("- Summary: " + virtualdevice.getDeviceInfo().getSummary());
                System.out.println("- Unit Number: " + virtualdevice.getUnitNumber());

                virtualDeviceClassName = virtualdevice.getClass().getName();
                if (virtualDeviceClassName.equals("com.vmware.vim25.VirtualIDEController")
                        || virtualDeviceClassName.equals("com.vmware.vim25.VirtualPS2Controller")
                        || virtualDeviceClassName.equals("com.vmware.vim25.VirtualPCIController")
                        || virtualDeviceClassName.equals("com.vmware.vim25.VirtualLsiLogicController"))

                {
                    virtualController = (VirtualController) virtualdevice;
                    System.out.println("- BusNumber: " + virtualController.getBusNumber());
                    if (virtualController.getDevice() != null && virtualController.getDevice().length > 0) {
                        System.out.println("- List of devices currently controlled by this controller:");
                        for (int key : virtualController.getDevice()) {
                            keys = keys + String.valueOf(key) + ",";
                        }
                        System.out.println(" - keys: " + keys);
                        keys = new String();
                    }
                }

                if (virtualdevice.getClass().getName().equals("com.vmware.vim25.VirtualE1000")) {
                    virtualEthernetCard = (VirtualEthernetCard) virtualdevice;
                    System.out.println("- virtualEthernetCard Class: " + virtualEthernetCard.getClass());
                    System.out.println("  - AddressType: " + virtualEthernetCard.getAddressType());
                    System.out.println("  - MacAddress: " + virtualEthernetCard.getMacAddress());
                    System.out.println("  - WakeOnLanEnabled: " + virtualEthernetCard.getWakeOnLanEnabled());
                }

                if (virtualdevice.getClass().getName().equals("com.vmware.vim25.VirtualDisk")) {
                    com.vmware.vim25.VirtualDisk virtualDisk = (com.vmware.vim25.VirtualDisk) virtualdevice;
                    System.out.println("-Key: " + virtualDisk.getKey());
                    if (virtualDisk.getDeviceInfo() != null) {
                        System.out.println("-Label: " + virtualDisk.getDeviceInfo().getLabel());
                        System.out.println("-Summary: " + virtualDisk.getDeviceInfo().getSummary());
                    }

                    System.out.println("-Capacity In KB: " + virtualDisk.getCapacityInKB());

                    if (virtualDisk.getConnectable() != null) {
                        System.out.println("-Connectable Class" + virtualDisk.getConnectable().getClass());
                    }

                    if (virtualDisk.getShares() != null) {
                        System.out.println("-Share Level: " + virtualDisk.getShares().getLevel());
                        System.out.println("-Share Value: " + virtualDisk.getShares().getShares());
                    }

                    if (virtualDisk.getStorageIOAllocation() != null) {
                        System.out.println("-Storage Level: " + virtualDisk.getStorageIOAllocation().getLimit());

                    }

                }

                if (virtualdevice.getBacking() != null) {
                    System.out.println("- Backing: " + virtualdevice.getBacking().getClass());

                    if (virtualdevice.getBacking().getClass().getName()
                            .equals("com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo")) {
                        VirtualEthernetCardNetworkBackingInfo vEthernetBacking = (VirtualEthernetCardNetworkBackingInfo) virtualdevice
                                .getBacking();
                        System.out.println("- DeviceName: " + vEthernetBacking.getDeviceName());
                        //System.out.println("- InPassthroughMode: "+vEthernetBacking.getInPassthroughMode());
                        System.out.println("- network: " + vEthernetBacking.getNetwork().get_value());
                    }

                    if (virtualdevice.getBacking().getClass().getName()
                            .equals("com.vmware.vim25.VirtualDiskFlatVer2BackingInfo")) {
                        VirtualDiskFlatVer2BackingInfo virtualdiskFlatVer2BackinfInfo = (VirtualDiskFlatVer2BackingInfo) virtualdevice
                                .getBacking();

                        System.out.println("- Disk Mode: " + virtualdiskFlatVer2BackinfInfo.getDiskMode());
                        System.out.println("- File Name: " + virtualdiskFlatVer2BackinfInfo.getFileName());
                        System.out.println("- Split: " + virtualdiskFlatVer2BackinfInfo.getSplit());
                        System.out.println(
                                "- Thin Provisioned: " + virtualdiskFlatVer2BackinfInfo.getThinProvisioned());
                        System.out.println("- Write Through: " + virtualdiskFlatVer2BackinfInfo.getWriteThrough());

                        if (virtualdiskFlatVer2BackinfInfo.getDatastore() != null)
                            System.out.println(
                                    "- Datastore: " + virtualdiskFlatVer2BackinfInfo.getDatastore().get_value());

                        if (virtualdiskFlatVer2BackinfInfo.getParent() != null) {
                            System.out.println("- Parent: ");
                            System.out.println(
                                    "  - Disk Mode: " + virtualdiskFlatVer2BackinfInfo.getParent().getDiskMode());
                            System.out.println(
                                    "  - File Name: " + virtualdiskFlatVer2BackinfInfo.getParent().getFileName());
                            System.out
                                    .println("  - Split: " + virtualdiskFlatVer2BackinfInfo.getParent().getSplit());
                            System.out.println("  - Thin Provisioned: "
                                    + virtualdiskFlatVer2BackinfInfo.getParent().getThinProvisioned());
                            System.out.println("  - Write Through: "
                                    + virtualdiskFlatVer2BackinfInfo.getParent().getWriteThrough());

                        }

                    }

                }

                if (virtualdevice.getConnectable() != null) {
                    if (virtualdevice.getConnectable().getClass().getName()
                            .equals("com.vmware.vim25.VirtualDeviceConnectInfo")) {
                        VirtualDeviceConnectInfo vDeviceConnectInfo = (VirtualDeviceConnectInfo) virtualdevice
                                .getConnectable();
                        System.out.println("- Connectable: " + virtualdevice.getConnectable().getClass());
                        System.out.println("- Status: " + vDeviceConnectInfo.getStatus());
                        System.out.println("- AllowGuestControl: " + vDeviceConnectInfo.isAllowGuestControl());
                        System.out.println("- Connected: " + vDeviceConnectInfo.isConnected());
                        System.out.println("- StartConnected: " + vDeviceConnectInfo.isStartConnected());
                    }
                }
            }

        }

        //vm.getHardware().getAlldevices();

        // Get Datastore
        /*
        String datastoreID="datastore-11";
        DataStoreManager dsManager=DataStoreManager.getInstance();
        Datastore ds=dsManager.getDatastoreByID(datastoreID, vmWareHostName);
        String name="["+ds.getName()+"]"+" test-depuis-main12/test-depuis-main12.vmdk";
        System.out.println("Datastore name: "+name);
        */

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();

    }

    public void getVMInfo(String vmName) throws VMwareException {
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="10.0.12.6";
        //VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,-1L,1000L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L,1000L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="10.251.5.14";
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L,1000L);

        //String hostName="192.168.101.110";
        //VMware.create(hostName,443,"root","mandriva",false,-1L);

        String hostName = "192.168.101.58";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        //System.out.println("Creation !!");

        //String hostName="10.246.5.10";
        //VMware.create(hostName,443,"instantvm\\siveo-admin","Sive0@dmin",false,-1L);

        //System.out.println("fin Creation !!");

        VMManager vmManager = VMManager.getInstance();
        //InventoryManager inventoryMng=InventoryManager.getInstance();

        //ArrayList<VirtualMachine> listOfVm=vmManager.getAllVM(hostName);
        //System.out.println("Nb VM: "+listOfVm.size());

        //for (VirtualMachine vm1:listOfVm)
        //{
        //   System.out.println("VM: "+vm1.getName());
        //}

        VirtualMachine vm = null;
        vm = vmManager.getVmByName(hostName, vmName);

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();
        listOfMors.add(vm.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfMors);

        //vm=vmManager.getVmByID(hostName,"vm-1993");

        //System.out.println("vm: "+vm);

        VMConfiguration vmConfiguration = vm.getConfiguration();

        GuestInfo guestInfo = vm.getGuestInfo();

        //System.out.println("GuestInfo: "+guestInfo);

        /*
        if (guestInfo.getNet()!=null)
        {
           for (GuestNicInfo guestNicInfo:guestInfo.getNet())
           {
        if (guestNicInfo.getIpAddress()!=null)
        {
           System.out.println("IP:");
           for (String ip:guestNicInfo.getIpAddress())
           {
              System.out.println(" - "+ip);
           }
        }
        System.out.println("Device ID: "+guestNicInfo.getDeviceConfigId());
        System.out.println("Mac Address: "+guestNicInfo.getMacAddress());
        System.out.println("Network: "+guestNicInfo.getNetwork());
        System.out.println("IP Config: "+guestNicInfo.getIpConfig());
           }
        }
        */
        //ArrayList<String> toto=new ArrayList<String>(){{ add("toto");}};

        System.out.println("");
        System.out.println("");
        System.out.println("");

        System.out.println("************** " + vmName + " Detailled Configuration **************");
        System.out.println("- Name: " + vm.getName());
        System.out.println("- ID: " + vm.getMor().get_value());
        System.out.println("- Version: " + vm.getConfigInfo().getVersion());

        if (vmConfiguration.getVirtualCPU() != null) {
            System.out.println("- CPU");
            System.out.println(" - Nb vCPU: " + vmConfiguration.getVirtualCPU().getNbCPU());
            System.out.println(" - Mghz: " + vmConfiguration.getVirtualCPU().getMghz());
            System.out.println(" - Reservation: " + vmConfiguration.getVirtualCPU().getReservation());
            System.out.println(" - Limit: " + vmConfiguration.getVirtualCPU().getLimit());
        }

        System.out.println("");

        if (vmConfiguration.getVirtualMemory() != null) {
            System.out.println("- Memory");
            System.out.println(" - Memory: " + vmConfiguration.getVirtualMemory().getMemory());
            System.out.println(" - Memory Size: " + vmConfiguration.getVirtualMemory().getMemorySize());
            System.out.println(" - Memory Reservation: " + vmConfiguration.getVirtualMemory().getReservation());
            System.out.println(" - Memory Limit: " + vmConfiguration.getVirtualMemory().getLimit());
        }

        System.out.println("- Guest Information");
        System.out.println("  - Host Name: " + vm.getGuest().getHostName());
        System.out.println("  - IP       : " + vm.getGuest().getIpAddress());
        System.out.println("  - OS");
        System.out.println("    - Family   : " + vm.getGuest().getOSFamily());
        System.out.println("    - Full Name: " + vm.getGuest().getOSFullName());
        System.out.println("    - ID       : " + vm.getGuest().getOSId());
        System.out.println("");
        System.out.println("  - VMware Tools");
        System.out.println("    - Status        : " + vm.getGuest().getToolsStatus());
        System.out.println("    - Running Status: " + vm.getGuest().getToolsRunningStatus());
        System.out.println("    - Version       : " + vm.getGuest().getToolsVersion());
        System.out.println("    - Version Status: " + vm.getGuest().getToolsVersionStatus());
        System.out.println("\n  - Disk");
        if (!vm.getGuest().getDisk().isEmpty()) {
            int nbGuestDisk = 1;
            for (GuestDisk guestDisk : vm.getGuest().getDisk()) {
                System.out.println("    - Disk n" + nbGuestDisk++);
                System.out.println("      - Capacit    : " + guestDisk.getCapacity());
                System.out.println("      - Taille libre: " + guestDisk.getFreeSpace());
                System.out.println("      - Label       : " + guestDisk.getDiskPath());
            }
        }
        System.out.println("\n- Network Adapter Info");

        VMNetwork vmNetwork = vm.getVMNetwork();
        ArrayList<VirtualNetwork> listOfVirtualNetworks = null;
        ArrayList<VirtualDVSwitch> listOfVirtualDVSwitchs = null;

        if (vmNetwork != null) {

            System.out.println("  - Virtual Network");
            listOfVirtualNetworks = vmNetwork.getListOfVirtualNetwork();
            if (listOfVirtualNetworks != null && !listOfVirtualNetworks.isEmpty()) {
                for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {
                    System.out.println("    - Label: " + virtualNetwork.getLabel());
                    System.out.println("    - Name: " + virtualNetwork.getNetwork().getName());
                    System.out.println("    - Vlan ID: " + virtualNetwork.getNetwork().getVlanId());
                    System.out.println("    - Mac Address: " + virtualNetwork.getMacAddress());
                    System.out.println("");

                    ArrayList<String> listOfIPAddresses = virtualNetwork.getListOfIPAddress();
                    if (listOfIPAddresses != null && !listOfIPAddresses.isEmpty()) {
                        for (String ip : listOfIPAddresses) {
                            System.out.println("    - IP Address: " + ip);
                        }
                    }

                }
            }

            listOfVirtualDVSwitchs = vmNetwork.getListOfVirtualDVSwitch();
            if (listOfVirtualDVSwitchs != null && !listOfVirtualDVSwitchs.isEmpty()) {
                System.out.println("  - Virtual DVSwitch");
                for (VirtualDVSwitch virtualDVSwitch : listOfVirtualDVSwitchs) {
                    System.out.println("    - Label: " + virtualDVSwitch.getLabel());
                    System.out.println("    - Name: " + virtualDVSwitch.getDvSwitch().getName());
                    System.out.println("    - DVPortgroup: " + virtualDVSwitch.getDvPortGroup().getName());
                    System.out.println("    - Port: " + virtualDVSwitch.getPortKey());
                    System.out.println("    - Mac Address: " + virtualDVSwitch.getMacAddress());
                    //System.out.println("    - Primary Ip Address: "+virtualDVSwitch.getPrimaryIpAddress());

                    if (virtualDVSwitch.getGuestNic() != null && virtualDVSwitch.getGuestNic().getIpConfig() != null
                            && virtualDVSwitch.getGuestNic().getIpConfig().getListOfAssignedIpAddress() != null
                            && !virtualDVSwitch.getGuestNic().getIpConfig().getListOfAssignedIpAddress()
                                    .isEmpty()) {
                        System.out.println("    - Assigned Ip Address: ");

                        for (IpConfigInfoIpAddress ipConfigInfoIpAddress : virtualDVSwitch.getGuestNic()
                                .getIpConfig().getListOfAssignedIpAddress()) {
                            System.out.println("    - Assigned Ip Address: ");
                            System.out.println("      - " + ipConfigInfoIpAddress.getIpAddress());

                        }
                    }

                    System.out.println("");
                }
            }

        } // fin if network==null;

        if (vm.getGuestInfo() != null && vm.getGuestInfo().getIpStack() != null
                && vm.getGuestInfo().getIpStack().length > 0) {
            GuestStackInfo[] arrayOfGuestStackInfos = null;

            arrayOfGuestStackInfos = vm.getGuestInfo().getIpStack();

            for (GuestStackInfo guestStackInfo : arrayOfGuestStackInfos) {
                System.out.println("Internet Protocol stack as configured in the guest operating system");
                System.out.println("");
                System.out.println("");

                if (guestStackInfo.getIpRouteConfig() != null
                        && guestStackInfo.getIpRouteConfig().getIpRoute() != null
                        && guestStackInfo.getIpRouteConfig().getIpRoute().length > 0) {
                    for (NetIpRouteConfigInfoIpRoute netIpRouteConfigInfoIpRoute : guestStackInfo.getIpRouteConfig()
                            .getIpRoute()) {
                        System.out.println("Gateway: " + netIpRouteConfigInfoIpRoute.getGateway().getIpAddress());
                    }
                }

            }

        }

        /*
            
        if (!vm.getGuest().getListOfNetworkAdapter().isEmpty())
        {
           //GuestInfo guestInfo_=vmConfiguration.getGuestInfo().getGuestInfoo();
           //System.out.println("IPSTACK: "+guestInfo_);
           //System.out.println("IPSTACK: "+guestInfo_.getIpStack());
               
               
               
           int nbGuestnicInfo=1;
           for (GuestNic guestNic:vm.getGuest().getListOfNetworkAdapter())
           {
        System.out.println("    - Network Adapter n"+nbGuestnicInfo++);
        System.out.println("      - Connected: "+guestNic.isConnected());
        System.out.println("      - DeviceConfig Id: "+guestNic.getDeviceConfigId());
        System.out.println("      - Network: "+guestNic.getNetwork());
        System.out.println("      - Network ID: "+guestNic.getNetworkID());
        if (!guestNic.getListOfIPAddress().isEmpty())
        {
           System.out.println("      - IP Address:");
               
           for (String ip:guestNic.getListOfIPAddress())
           {
              System.out.println("        - "+ip);
           }
               
        }
        System.out.println("      - Mac Address: "+guestNic.getMacAddress());
        if (guestNic.getDnsConfig()!=null)
        {
           System.out.println("      - DNS Config:");
           System.out.println("        - Dhcp: "+guestNic.getDnsConfig().isDhcp());
           System.out.println("        - Domain Name: "+guestNic.getDnsConfig().getDomainName());
           System.out.println("        - Host Name: "+guestNic.getDnsConfig().getHostName());
           System.out.println("        - Ip Address:");
           if (!guestNic.getDnsConfig().getIpAddress().isEmpty())
           {
              for (String ipAddress:guestNic.getDnsConfig().getIpAddress())
              {
                 System.out.println("          - "+ipAddress);
              }
           }
           System.out.println("        - Search Domain:");
           if (!guestNic.getDnsConfig().getSearchDomain().isEmpty())
           {
              for (String searchDomain:guestNic.getDnsConfig().getSearchDomain())
              {
                 System.out.println("          - "+searchDomain);
              }
           }
            
           System.out.println("");
            
        }
            
        if (guestNic.getIpConfig()!=null)
        {
           System.out.println("      - IP Config:");
           System.out.println("        - autoConfigurationEnabled: "+guestNic.getIpConfig().isAutoConfigurationEnabled());
        }
            
            
           }
        }
            
        */

        System.out.println("");
        System.out.println("");

        //VirtualDevice[] listOfVirtualDevice=vm.getVirtualDeviceManager().getAllVirtualDevices();
        VirtualDevice[] listOfVirtualDevice = vm.getVirtualDeviceManager().getListOfVirtualDevices();
        int nbDevice = 1;
        VirtualEthernetCard virtualEthernetCard = null;
        VirtualController virtualController = null;

        for (VirtualDevice device : listOfVirtualDevice) {
            System.out.println("Device n" + nbDevice++);
            System.out.println("- Device: " + device);
            System.out.println("- Device Class: " + device.getClass());
            System.out.println("- Device Super Class: " + device.getClass().getSuperclass());
            System.out.println("- Key: " + device.getKey());
            System.out.println("- ControllerKey: " + device.getControllerKey());
            System.out.println("- Label : " + device.getDeviceInfo().getLabel());
            System.out.println("- Summary: " + device.getDeviceInfo().getSummary());
            System.out.println("- Unit Number: " + device.getUnitNumber());
            if (device.getBacking() != null) {
                System.out.println("- Backing: " + device.getBacking().getClass());

                if (device.getBacking() instanceof VirtualCdromRemoteAtapiBackingInfo) {
                    VirtualCdromRemoteAtapiBackingInfo virtualCdromRemoteAtapiBackingInfo = (VirtualCdromRemoteAtapiBackingInfo) device
                            .getBacking();
                    System.out.println("- CD-Rom Bakcing");
                    System.out.println("  - Device Name: " + virtualCdromRemoteAtapiBackingInfo.getDeviceName());
                    System.out.println(
                            "  - Use Auto Detect: " + virtualCdromRemoteAtapiBackingInfo.getUseAutoDetect());
                }

                if (device.getBacking() instanceof VirtualCdromIsoBackingInfo) {
                    VirtualCdromIsoBackingInfo virtualCdromIsoBackingInfo = (VirtualCdromIsoBackingInfo) device
                            .getBacking();
                    System.out.println("- CD-Rom Bakcing");
                    System.out.println("  - File Name: " + virtualCdromIsoBackingInfo.getFileName());
                    ManagedObjectReference dsMor = virtualCdromIsoBackingInfo.getDatastore();
                    if (dsMor != null) {
                        System.out.println("  - Datastore: ");
                        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
                        Datastore ds = dataStoreManager.getDatastoreByID(dsMor.get_value(), hostName);
                        if (ds != null) {
                            System.out.println("    - Name: " + ds.getName());
                        }
                    }

                }

                if (device.getBacking() instanceof VirtualEthernetCardNetworkBackingInfo) {
                    VirtualEthernetCardNetworkBackingInfo virtualEthernetCardNetworkBackingInfo = (VirtualEthernetCardNetworkBackingInfo) device
                            .getBacking();
                    System.out.println("- Virtual Network Card Bakcing");
                    System.out.println("  - Device Name: " + virtualEthernetCardNetworkBackingInfo.getDeviceName());
                    System.out.println(
                            "  - Use Auto Detect: " + virtualEthernetCardNetworkBackingInfo.getUseAutoDetect());
                    System.out.println(
                            "  - Network: " + virtualEthernetCardNetworkBackingInfo.getNetwork().get_value());

                }

            }

            if (device instanceof com.vmware.vim25.VirtualLsiLogicSASController) {
                VirtualLsiLogicSASController virtualLsiLogicSASController = (VirtualLsiLogicSASController) device;
                System.out.println(
                        "- Scsi Ctlr Unit Number: " + virtualLsiLogicSASController.getScsiCtlrUnitNumber());
                System.out.println("- Bus Number: " + virtualLsiLogicSASController.getBusNumber());
            }

            if (device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualEthernetCard.class)
                    || device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualVmxnet.class)) {
                virtualEthernetCard = (VirtualEthernetCard) device;
                System.out.println("- Device Class: " + device.getClass());
                System.out.println("- Device Super Class: " + device.getClass().getSuperclass());
                System.out.println("- virtualEthernetCard Class: " + virtualEthernetCard.getClass());
                System.out.println("  - AddressType: " + virtualEthernetCard.getAddressType());
                System.out.println("  - MacAddress: " + virtualEthernetCard.getMacAddress());
                System.out.println("  - WakeOnLanEnabled: " + virtualEthernetCard.getWakeOnLanEnabled());
                System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());

                if (virtualEthernetCard
                        .getBacking() instanceof com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo) {
                    VirtualEthernetCardNetworkBackingInfo virtualEthernetCardNetworkBackingInfo = (VirtualEthernetCardNetworkBackingInfo) virtualEthernetCard
                            .getBacking();
                    System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());
                    System.out
                            .println("    - Device Name: " + virtualEthernetCardNetworkBackingInfo.getDeviceName());
                    System.out.println(
                            "    - Use AutoDetect: " + virtualEthernetCardNetworkBackingInfo.getUseAutoDetect());
                    System.out.println(
                            "    - inPassthroughMode: " + virtualEthernetCardNetworkBackingInfo.inPassthroughMode);
                    System.out.println(
                            "    - Network: " + virtualEthernetCardNetworkBackingInfo.getNetwork().get_value());

                }

                if (virtualEthernetCard.getBacking().getClass()
                        .equals(com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo.class)) {
                    VirtualEthernetCardDistributedVirtualPortBackingInfo backing = (VirtualEthernetCardDistributedVirtualPortBackingInfo) virtualEthernetCard
                            .getBacking();
                    System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());
                    System.out.println("    - PortgroupKey: " + backing.getPort().getPortgroupKey());
                    System.out.println("    - PortKey: " + backing.getPort().getPortKey());
                    System.out.println("    - SwitchUuid: " + backing.getPort().getSwitchUuid());
                }
                //

            }

            if (device.getConnectable() != null) {
                System.out.println("- allowGuestControl: " + device.getConnectable().isAllowGuestControl());
                System.out.println("- connected: " + device.getConnectable().isConnected());
                System.out.println("- startConnected: " + device.getConnectable().isStartConnected());
                if (device.getConnectable().getStatus() != null)
                    System.out.println("- status: " + device.getConnectable().getStatus());

            }

            if (device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualController.class)) {
                virtualController = (VirtualController) device;
                if (virtualController.getDevice() != null && virtualController.getDevice().length > 0) {
                    String devicesControlled = "- Devices Controlled: ";
                    String keys = "";
                    for (int deviceKey : virtualController.getDevice()) {
                        keys = deviceKey + "," + keys;
                    }

                    keys = keys.substring(0, keys.length() - 1);
                    System.out.println(devicesControlled + keys);
                }
            }

        }

        //System.out.println("Taille disk: "+vm.getHardware().getTotalDiskSpace());

        /*
        WS ws=wsManager.getWS(vmWareHostName);
        ManagedObjectReference mor=null;
        mor=MorManager.getMorRef(ws, ws.getVIMService().getRootFolder(), "VirtualMachine", "ActiBox05");
            
        System.out.println("mor: "+mor.get_value());
            
        ArrayList<VirtualMachine> listOfVM=inventoryMng.getAllVM(vmWareHostName);
        for (VirtualMachine vm_:listOfVM)
        {
           System.out.println("vm: "+vm_.getName()+" / "+vm_.getMor().get_value());
        }
        */

        /*
        vm=vmManager.getVmByName(vmWareHostName, "ActiBox05");
        System.out.println("VirtualMachine: "+vm.getName());
        System.out.println("-CPU Reservation: "+vm.getConfiguration().getVirtualCPU().getReservation());
        System.out.println("-CPU Limit: "+vm.getConfiguration().getVirtualCPU().getLimit());
        System.out.println("-CPU: "+vm.getConfiguration().getVirtualCPU().getMghz());
            
        System.out.println("-Memory Reservation: "+vm.getConfiguration().getVirtualMemory().getReservation());
        System.out.println("-Memory Limit: "+vm.getConfiguration().getVirtualMemory().getLimit());
        System.out.println("-Memory: "+vm.getConfiguration().getVirtualMemory().getMemorySize());
        */

        //Host host=vm.getHost();
        //System.out.println("Host Name: "+host.getName());
        //vm.getHardware().getAlldevices();

        //vmManager.configureVMMemory("ActiBox05", 256L);

        //vm.replaceNetwork("network-14");
        //vm.addNetwork("network-14");
        //vm.removeNetwork("network-14");
        //vmManager.updateNetwork("ActiBox05", "networkID");

        //vm.setNetwork();

        /*
        ArrayList<Network> listOfNetwork=host.getNetworks();
            
        for (Network network:listOfNetwork)
        {
           System.out.println("Network Name: "+network.getName());
           System.out.println("Network ID: "+network.getMor().get_value());
        }
        */

        //HardwareDevice hardware=vm.getHardware();
        //ArrayList<VirtualNetwork> listOfVirtualNetwork=hardware.getNetworks();
        //VirtualNetwork virtualNetwork=listOfVirtualNetwork.get(0);
        //virtualNetwork.getvDevice().getBacking().

        /*
        ArrayList<Network> listOfNet=vm.getAvailableNetwork();
            
        for (Network network:listOfNet)
        {
           System.out.println("Network: "+network.getName());
        }
        */

        /*
        try
        {
           System.in.read();
        }
        catch (IOException e)
            
        {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }
         */

        //AuthorizationManager authorManager=AuthorizationManager.getInstance();
        //authorManager.addPermission("SIVEO\\TestGP", true,"test2", "VMSuperPowerUser","vcenter.siveo.net");

        VMware.delete(hostName);
    }

    public void playNet() throws VMwareException {
        String vmWareHostName = "vcenter.siveo.net";
        VMware vmware = new VMware(vmWareHostName, 443, "Administrateur", "Clmdp@09", false, 48000L, 1000L);
        WSManager wsManager = WSManager.getInstance();
        VMManager vmManager = VMManager.getInstance();

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();

    }

    public void getCounterInfo() throws VMwareException {
        String hostName = "10.0.12.6";
        VMware.create(hostName, 443, "siveo_admin", "s1v3oP0C", false, -1L, 1000L);

        PerformanceManager performanceManager = PerformanceManager.getInstance();
        HashMap<Integer, Counter> mapOfCounter = performanceManager.getAllCountersByID(hostName);

        for (Map.Entry<Integer, Counter> counterById : mapOfCounter.entrySet()) {
            //counterById.getValue().g

        }

        VMware.delete(hostName);

    }

    public void getDiskInfos() throws VMwareException {
        String hostName = "10.0.12.6";
        VMware.create(hostName, 443, "siveo_admin", "s1v3oP0C", false, -1L, 1000L);

        DataStoreManager dsManager = DataStoreManager.getInstance();
        Datastore ds = dsManager.getDatastoreByName("ds-EMC_TC3-siveo_poc-Pognon", hostName);

        System.out.println("Maximum Capacity: " + ds.getCapacity());
        System.out.println("FreeSpace: " + ds.getFreeSpace());
        //System.out.println("Uncommitted: "+ds.getVMSpaceUsed());
        System.out.println("Accessible: " + ds.isAccessible());

        VirtualDiskFlatVer2BackingInfo backingInfo = null;
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "TestVM");

        long totalDisksize = 0l;

        ArrayList<net.siveo.virtualization.vmware.virtualdevice.VirtualDisk> listOfDisk = vm.getDisk();
        if (!listOfDisk.isEmpty()) {
            for (net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk : listOfDisk) {
                totalDisksize = totalDisksize + vDisk.getDiskSize();
                backingInfo = (VirtualDiskFlatVer2BackingInfo) vDisk.getBacking();
                System.out.println(vDisk.getLabel() + " backing: " + vDisk.getBacking().getClass()
                        + " thinProvisioned: " + backingInfo.thinProvisioned);

            }
        }

        System.out.println("Taille totale de la VM: " + totalDisksize);

        System.out.println("Virtual Machine CDO01 disk Space Available: " + vm.getDiskSpaceAvalaible());

        VMware.delete(hostName);

    }

    public void getInfos() throws VMwareException {
        String hostName = "10.0.12.6";
        VMware.create(hostName, 443, "siveo_admin", "s1v3oP0C", false, -1L, 1000L);

        //

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("tc3-cli-esx01.hosts.vdc", hostName);

        HostConfigManager hostConfigManager = host.getConfigManager();

        ManagedObjectReference hostStorageSystem = hostConfigManager.getStorageSystem();

        HostStorageDeviceInfo hostStorageDeviceInfo = null;
        hostStorageDeviceInfo = (HostStorageDeviceInfo) MorManager.getMorProperty(ws, hostStorageSystem,
                new String[] { "storageDeviceInfo" });

        HostHostBusAdapter[] arrayOfHostHostBusAdapter = hostStorageDeviceInfo.getHostBusAdapter();

        System.out.println("****** HostHostBusAdapter ******");
        int nbHostBusAdapter = 1;

        for (HostHostBusAdapter hostHostBusAdapter : arrayOfHostHostBusAdapter) {
            System.out.println("HostHostBusAdapter n" + nbHostBusAdapter++);
            System.out.println("-Bus: " + hostHostBusAdapter.getBus());
            System.out.println("-Device: " + hostHostBusAdapter.getDevice());
            System.out.println("-Driver: " + hostHostBusAdapter.getDriver());
            System.out.println("-Key: " + hostHostBusAdapter.getKey());
            System.out.println("-Model: " + hostHostBusAdapter.getModel());
            System.out.println("-PCI: " + hostHostBusAdapter.getPci());
            System.out.println("-PCI: " + hostHostBusAdapter.getStatus());
            System.out.println("");
        }

        System.out.println("");
        System.out.println("");
        System.out.println("****** ScsiLun ******");
        int nbScsiLun = 1;

        ScsiLun[] arrayOfScsiLun = hostStorageDeviceInfo.getScsiLun();

        for (ScsiLun scsiLun : arrayOfScsiLun) {
            System.out.println("SCSI Lun n" + nbScsiLun++);
            System.out.println("-Canonical Name: " + scsiLun.getCanonicalName());
            System.out.println("-Device Name: " + scsiLun.getDeviceName());
            System.out.println("-Device Type: " + scsiLun.getDeviceType());
            System.out.println("-Display Name: " + scsiLun.getDisplayName());
            System.out.println("-Key: " + scsiLun.getKey());
            System.out.println("-Lun Type: " + scsiLun.getLunType());
            System.out.println("-Model: " + scsiLun.getModel());
            System.out.println("-Revision: " + scsiLun.getRevision());
            System.out.println("-Serial Number: " + scsiLun.getSerialNumber());
            System.out.println("-Uuid: " + scsiLun.getUuid());
            System.out.println("-Vendor: " + scsiLun.getVendor());
            //System.out.println("-VStorageSupport: "+scsiLun.getvStorageSupport());
            System.out.println("-Queue Depth: " + scsiLun.getQueueDepth());
            System.out.println("-Scsi Level: " + scsiLun.getScsiLevel());
            //System.out.println("-VStorageSupport: "+scsiLun.getDurableName().getNamespace());
            System.out.println("");
        }

        HostMultipathInfo hostMultipathInfo = hostStorageDeviceInfo.getMultipathInfo();

        HostMultipathInfoLogicalUnit[] hostMultipathInfoLogicalUnits = hostMultipathInfo.getLun();
        HostMultipathInfoPath[] arrOfHostMultipathInfoPaths = null;

        if (hostMultipathInfoLogicalUnits != null && hostMultipathInfoLogicalUnits.length > 0) {
            System.out.println("Multipathing Policy Configuration");
            int nbMultiPathInfo = 1;

            for (HostMultipathInfoLogicalUnit infoLogicalUnit : hostMultipathInfoLogicalUnits) {
                System.out.println("HostMultipathInfoPath n" + nbMultiPathInfo++);
                System.out.println("-ID: " + infoLogicalUnit.getId());
                System.out.println("-Key: " + infoLogicalUnit.getKey());
                System.out.println("-Lun: " + infoLogicalUnit.getLun());

                arrOfHostMultipathInfoPaths = infoLogicalUnit.getPath();
                if (arrOfHostMultipathInfoPaths != null && arrOfHostMultipathInfoPaths.length > 0) {
                    System.out.println("-Paths Available:");
                    int nbPathsAvailable = 1;

                    for (HostMultipathInfoPath hostMultipathInfoPath : arrOfHostMultipathInfoPaths) {
                        //nbPathsAvailable
                        System.out.println(" Path n" + nbPathsAvailable++);
                        System.out.println(" -Adapter: " + hostMultipathInfoPath.getAdapter());
                        System.out.println(" -Key: " + hostMultipathInfoPath.getKey());
                        System.out.println(" -Lun: " + hostMultipathInfoPath.getLun());
                        System.out.println(" -Name: " + hostMultipathInfoPath.getName());
                        System.out.println(" -Path State: " + hostMultipathInfoPath.getPathState());
                        System.out.println(" -State: " + hostMultipathInfoPath.getState());
                        System.out.println(" -Is Working Path: " + hostMultipathInfoPath.isWorkingPath);
                        //System.out.println("");
                    }
                }
                System.out.println("");
            }
        }

        HostScsiTopology hostScsiTopology = hostStorageDeviceInfo.getScsiTopology();
        HostScsiTopologyInterface[] arrayOfHostScsiTopologyInterface = hostScsiTopology.getAdapter();

        HostScsiTopologyTarget[] arrayOfHostScsiTopologyTarget = null;

        HostScsiTopologyLun[] hostScsiTopologyLuns = null;

        if (arrayOfHostScsiTopologyInterface != null && arrayOfHostScsiTopologyInterface.length > 0) {

            System.out.println("\n****** HostScsiTopologyInterface ******");
            int nbScsiTopoInterface = 1;

            for (HostScsiTopologyInterface hostScsiTopologyInterface : arrayOfHostScsiTopologyInterface) {
                System.out.println("\nHostScsiTopologyInterface n" + nbScsiTopoInterface++);
                System.out.println("-Adapter: " + hostScsiTopologyInterface.getAdapter());
                System.out.println("-Key: " + hostScsiTopologyInterface.getKey());

                arrayOfHostScsiTopologyTarget = hostScsiTopologyInterface.getTarget();
                if (arrayOfHostScsiTopologyTarget != null) {
                    System.out.println("-HostScsiTopologyTarget:");
                    for (HostScsiTopologyTarget hostScsiTopologyTarget : arrayOfHostScsiTopologyTarget) {
                        //System.out.println("-HostScsiTopologyTarget: ");
                        System.out.println(" -Key: " + hostScsiTopologyTarget.getKey());
                        System.out.println(" -Target: " + hostScsiTopologyTarget.getTarget());
                        System.out.println(" -Transport: " + hostScsiTopologyTarget.getTransport().toString());

                        hostScsiTopologyLuns = hostScsiTopologyTarget.getLun();

                        if (hostScsiTopologyLuns != null) {
                            for (HostScsiTopologyLun hostScsiTopologyLun : hostScsiTopologyLuns) {
                                System.out.println(" -HostScsiTopologyLun:");
                                System.out.println("  -Key: " + hostScsiTopologyLun.getKey());
                                System.out.println("  -Lun: " + hostScsiTopologyLun.getLun());
                                System.out.println("  -Scsi Lun: " + hostScsiTopologyLun.getScsiLun());
                            }
                        }
                    }
                }
            }

        }

        //Get Datastore Information
        DataStoreManager dataStoreManager = DataStoreManager.getInstance();

        //      Datastore ds=dataStoreManager.getDatastoreByName("datastore1", hostName);
        //      System.out.println("Datastore "+ds.getName()+" / Type: "+ds.getType()+" / URL: "+ds.getURL());
        //      
        //      System.out.println("Datastore info Class: "+ds.getInfo().getClass());
        //      
        //      VmfsDatastoreInfo vmfsDatastoreInfo=(VmfsDatastoreInfo)ds.getInfo();
        //      System.out.println("Datastore UUID: "+vmfsDatastoreInfo.getVmfs().getUuid());
        //      
        //      ds=dataStoreManager.getDatastoreByName("datastore1 (1)", hostName);
        //      System.out.println("Datastore "+ds.getName()+" URL: "+ds.getURL());
        //
        //      ds=dataStoreManager.getDatastoreByName("ds-EMC_TC3-siveo_poc-Pognon", hostName);
        //      System.out.println("Datastore "+ds.getName()+" URL: "+ds.getURL());
        //
        //      ds=dataStoreManager.getDatastoreByName("ds-EMC_TC3-siveo_poc-Lapin", hostName);
        //      System.out.println("Datastore "+ds.getName()+" URL: "+ds.getURL());
        //
        //      ds=dataStoreManager.getDatastoreByName("ds-EMC_TC3-siveo_poc-Grodaf", hostName);
        //      System.out.println("Datastore "+ds.getName()+" URL: "+ds.getURL());

        //datastore1 (1)
        //ds-EMC_TC3-siveo_poc-Pognon
        //ds-EMC_TC3-siveo_poc-Lapin
        //ds-EMC_TC3-siveo_poc-Grodaf

        VMware.delete(hostName);

    }

    public void performanceCounter() throws VMwareException {

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L,1000L);

        String hostName = "10.0.12.6";
        VMware.create(hostName, 443, "siveo_admin", "s1v3oP0C", false, -1L, 1000L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L,1000L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        PerformanceManager performanceManager = PerformanceManager.getInstance();

        Calendar curTime = null;
        try {
            curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance());
        } catch (RuntimeFault e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        //System.out.println("curTime: "+curTime);
        //System.out.println("curTime: "+curTime.getTime());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName());
        //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID());
        //System.out.println("curTime lenient: "+curTime.isLenient());

        Calendar startTime = (Calendar) curTime.clone();
        //startTime.roll(Calendar.DATE, -1);
        //startTime.roll(Calendar.DATE, -4);

        //startTime.add(Calendar.HOUR_OF_DAY, -30);

        //startTime.add(Calendar.MINUTE, -70);
        //startTime.add(Calendar.MINUTE, -60);

        startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1);

        /*
        startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1);
        startTime.set(Calendar.MINUTE, 00);
        startTime.set(Calendar.SECOND, 00);
        startTime.set(Calendar.MILLISECOND, 00);
        //startTime.s
        //startTime.set(Calendar.DAY_OF_MONTH,6);
        //startTime.set(Calendar.MONTH,5);
        */

        //System.out.println("StartTime timezone: "+startTime.getTimeZone());
        //System.out.println("StartTime timezone: "+startTime.getTimeZone().getDisplayName());
        //System.out.println("StartTime timezone id: "+startTime.getTimeZone().getID());
        //System.out.println("StartTime lenient: "+startTime.isLenient());

        Calendar endTime = (Calendar) curTime.clone();
        //endTime.roll(Calendar.DATE, -1);
        //endTime.roll(Calendar.DATE, -3);

        /*
        //endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY)-1);
        endTime.set(Calendar.MINUTE, 00);
        endTime.set(Calendar.SECOND, 00);
        endTime.set(Calendar.MILLISECOND, 00);
        //endTime.set(Calendar.DAY_OF_MONTH,6);
        //endTime.set(Calendar.MONTH,5);
        */
        //System.out.println("StartTime: "+startTime.toString());
        //System.out.println("EndTime: "+endTime);

        ArrayList<TreeNode> listOfTreeNode = new ArrayList<TreeNode>();

        HostManager hostManager = HostManager.getInstance();

        Host host = hostManager.getHostByName("tc3-cli-esx01.hosts.vdc", hostName);
        //listOfTreeNode.add(host);

        //host=hostManager.getHostByName("tc3-cli-esx02.hosts.vdc", hostName);
        //listOfTreeNode.add(host);

        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        //Datastore ds=dataStoreManager.getDatastoreByID("datastore-1194", hostName);
        Datastore ds = dataStoreManager.getDatastoreByName("ds-EMC_TC3-siveo_poc-Grodaf", hostName);

        DatacenterManager datacenterManager = DatacenterManager.getInstance();
        Datacenter dc = datacenterManager.getDatacenterByName("Siveo", hostName);

        VMManager vmManager = VMManager.getInstance();
        //VirtualMachine vm=vmManager.getVmByName(hostName, "Tevst_VM_Grodaf");
        VirtualMachine vm = vmManager.getVmByName(hostName, "TestVM");

        startTime.roll(Calendar.DATE, -1);
        //endTime.roll(Calendar.DATE, -1);
        System.out.println(
                "Ecart entre dbut et fin: " + (endTime.getTime().getTime() - startTime.getTime().getTime()));

        ResourceManager resourceManager = ResourceManager.getInstance();
        ClusterComputeResource cluster = resourceManager.getClusterComputeResourceByName("POC-Siveo", hostName);

        ManagedObjectReference mor = new ManagedObjectReference();
        mor.setType("ClusterComputeResource");
        mor.set_value("domain-c1066");

        ResourcePoolManager resourcePoolManager = ResourcePoolManager.getInstance();
        ResourcePool rs = resourcePoolManager.getResourcePoolByName(hostName, "TestResourcePool");

        PerfProviderSummary perfProviderSummary = performanceManager.buildPerformance(rs);
        System.out.println("Historical Statistics: " + perfProviderSummary.isSummarySupported());
        System.out.println("Realtime Statistics: " + perfProviderSummary.isCurrentSupported());
        System.out.println("Refresh Rate: " + perfProviderSummary.getRefreshRate());

        ArrayList<String> listOfClusterCounters = new ArrayList<String>();
        listOfClusterCounters.add("clusterServices.effectivecpu.average");
        listOfClusterCounters.add("clusterServices.effectivemem.average");
        listOfClusterCounters.add("clusterServices.failover.latest");

        listOfTreeNode.add(cluster);
        //performanceManager.getPerformanceDS(listOfTreeNode, PerformanceMetric.CLUSTER_COUNTERS, startTime, null,300);
        performanceManager.getPerformance(listOfTreeNode, listOfClusterCounters, null, null, 300);

        //performanceManager.getPerformance(ds,null, null, null, null,300);
        performanceManager.getPerformance(rs, null, null, null, null, 300);

        //performanceManager.getPerformance(cluster,"clusterServices.effectivecpu.average", null, null, null,300);
        //performanceManager.getPerformance(cluster,"clusterServices.effectivemem.average", null, null, null,300);
        //performanceManager.getPerformance(cluster,"clusterServices.cpufairness.latest", null, null, null,300);
        //performanceManager.getPerformance(cluster,"clusterServices.failover.latest", null, null, null,300);
        //performanceManager.getPerformance(cluster,"clusterServices.memfairness.latest", null, null, null,300);

        //performanceManager.getPerformance(ds,"disk.used.latest", null, startTime, null,300);
        //performanceManager.getPerformance(ds,"disk.capacity.latest", null, startTime, null);
        //performanceManager.getPerformance(ds,null, null, startTime, endTime);

        /*
        HashMap<Integer,Counter> listOfCounters=performanceManager.getAllCounters(hostName);
        String counterName=null;
        String counterUpperName=null;
        for (Map.Entry<Integer,Counter> counterbyId:listOfCounters.entrySet())
        {
           counterName=counterbyId.getValue().getGroupKey()+"."+counterbyId.getValue().getNameKey()+"."+counterbyId.getValue().getRollupType();
               
           counterUpperName=counterName.toUpperCase();
           counterUpperName=counterUpperName.replace(".", "_");
            
           System.out.println("public static String "+ counterUpperName+"="+"\""+counterName+"\";");
        }
        */

        /*
        ArrayList<Counter> listOfCounters=performanceManager.getCountersByLevel(hostName, 4);
        for (Counter counter:listOfCounters)
        {
           System.out.println(counter.getGroupKey()+"."+counter.getNameKey()+"."+counter.getRollupType()+";"+
           counter.getGroupKey()+";"+counter.getGroupName()+";"+
           counter.getId()+";"+counter.getNameKey()+";"+counter.getName()+";"+counter.getDescription()+
           ";"+counter.getRollupType()+";"+counter.getStatisticsType()+";"+counter.getUnitKey()+";"+counter.getUnit()+
           ";"+counter.getUnitDescription());
        }
            
            
        HashMap<String, HistoricalInterval> mapOfHistoInterval=performanceManager.getMapOfHistoricalIntervalByName();
            
        for (Map.Entry<String, HistoricalInterval> histo:mapOfHistoInterval.entrySet())
        {
           System.out.println("- Name: "+histo.getKey()+" / Sampling Period: "+histo.getValue().getSamplingPeriod());
        }
        */

        //VMManager vmManager=VMManager.getInstance();
        //VirtualMachine vm=vmManager.getVmByName(hostName, "Test_VM_Grodaf");

        //ResourceManager resourceManager=ResourceManager.getInstance();
        //ClusterComputeResource clusterComputeResource=resourceManager.g

        //HostManager hostManager=HostManager.getInstance();
        //Host host=hostManager.getHostByName("esx01.siveo.net", hostName);
        //Host host=hostManager.getHostByName("tc3-cli-esx01.hosts.vdc", hostName);

        //tc3-cli-esx01.hosts.vdc

        ////performanceManager.getPerformance(host, null, null,startTime,endTime);
        //performanceManager.getPerformance(host, null, null,null,null);
        //performanceManager.getPerformance(vm, null, null,null,null);

        //performanceManager.getPerformance(host, null, null);

        //performanceManager.getPerformance(host, "cpu.usagemhz.maximum", null);

        //performanceManager.getPerformance(host, "disk.usage.maximum", null);

        /*      
              PerformanceDescription performanceDescription=null;
              performanceDescription=(PerformanceDescription)MorManager.getMorPorperty(ws, ws.getPerformanceManager(), new String[] {"description"});
            
              if (performanceDescription!=null)
              {
                 System.out.println("***** Counter Type *****");
                 for (ElementDescription elementDescription:performanceDescription.getCounterType())
                 {
        System.out.println("- Key: "+elementDescription.getKey());
        System.out.println("- Label: "+elementDescription.getLabel());
        System.out.println("- Summary: "+elementDescription.getSummary());
        System.out.println("");
                 }
            
                 System.out.println("***** Statistic Type *****");
                 for (ElementDescription elementDescription:performanceDescription.getStatsType())
                 {
        System.out.println("- Key: "+elementDescription.getKey());
        System.out.println("- Label: "+elementDescription.getLabel());
        System.out.println("- Summary: "+elementDescription.getSummary());
        System.out.println("");
                 }
              }
        */

        /*
        ArrayOfPerfInterval arrayOfPerfInterval=null;
        arrayOfPerfInterval=(ArrayOfPerfInterval)MorManager.getMorPorperty(ws, ws.getPerformanceManager(), new String[] {"historicalInterval"});
            
        if (arrayOfPerfInterval!=null)
        {
           System.out.println("***** Performance Interval *****");
           for (PerfInterval perfInterval:arrayOfPerfInterval.getPerfInterval())
           {
        System.out.println("-Key: "+perfInterval.getKey());
        System.out.println("-Name: "+perfInterval.getName());
        System.out.println("-Level: "+perfInterval.getLevel());
        System.out.println("-Length: "+perfInterval.getLength());
        System.out.println("-Sampling Period: "+perfInterval.getSamplingPeriod());
        System.out.println("");
           }
        }
        */

        /*      
              HashMap<Integer, Counter> mapOfAllCounters=performanceManager.getAllCounters(hostName);
              Counter counter=null;
                  
              for (Map.Entry<Integer, Counter> counterbyID:mapOfAllCounters.entrySet())
              {
                 counter=counterbyID.getValue();
                 System.out.println(counterbyID.getKey()+";"+counter.getGroupKey()+"."+counter.getNameKey()+"."+counter.getRollupType()+";"+counter.getLevel()+";"+counter.getName()+";"+counter.getDescription()+";"+counter.getStatisticsType()+";"+counter.getUnitKey()+";"+counter.getUnit()+";"+counter.getUnitDescription());
              }
        */

        //      HostManager hostManager=HostManager.getInstance();
        //      Host host=hostManager.getHostByName("tc3-cli-esx01.hosts.vdc", hostName);

        //      VMManager vmManager=VMManager.getInstance();
        //      VirtualMachine vm=vmManager.getVmByName(hostName, "ESSAI2");

        //      HashMap<Integer, Counter> mapOfCOunterByID=null;
        //      mapOfCOunterByID=performanceManager.getAllCounters(hostName);

        /*      
              System.out.println("***** Performance Counters *****\n");
              for (Map.Entry<Integer, Counter> counterByID:mapOfCOunterByID.entrySet())
              {
                 System.out.println("-ID: "+counterByID.getValue().getId());
                 System.out.println("-Group Key: "+counterByID.getValue().getGroupKey());
                 System.out.println("-Group Name: "+counterByID.getValue().getGroupName());
                 System.out.println("-Level: "+counterByID.getValue().getLevel());
                 System.out.println("-Name Key: "+counterByID.getValue().getNameKey());
                 System.out.println("-Name: "+counterByID.getValue().getName());
                 System.out.println("-Description: "+counterByID.getValue().getDescription());
                 System.out.println("-Rollup Type: "+counterByID.getValue().getRollupType());
                 System.out.println("-Statistics Type: "+counterByID.getValue().getStatisticsType());
                 System.out.println("-Unit Key: "+counterByID.getValue().getUnitKey());
                 System.out.println("-Unit: "+counterByID.getValue().getUnit());
                 System.out.println("-Unit Description: "+counterByID.getValue().getUnitDescription());
                 System.out.println("");
              }
        */

        //      System.out.println("***** Performance Provider *****\n");
        //      performanceManager.getPerformanceProvider(vm);

        //performanceManager.getPerformanceProvider(vm);
        //      System.out.println("***** Available Performance Counters *****\n");
        //      performanceManager.getAvailablePerfCounter(vm);

        //System.out.println("***** Available Performance Counters *****\n");
        //performanceManager.getAvailablePerfCounter(host);

        //System.out.println("\n***** Performance *****\n");
        //performanceManager.getPerformance(host);

        /*      
             ArrayOfPerfCounterInfo arrOfPerfCounterInfo=null;
             PerfCounterInfo[] counterInfoArr=null;
                 
             arrOfPerfCounterInfo=(ArrayOfPerfCounterInfo)MorManager.getMorPorperty(ws, ws.getPerformanceManager(), new String[] {"perfCounter"});
                 
             if (arrOfPerfCounterInfo!=null && arrOfPerfCounterInfo.getPerfCounterInfo() !=null && arrOfPerfCounterInfo.getPerfCounterInfo().length>0)
             {
                counterInfoArr=arrOfPerfCounterInfo.getPerfCounterInfo();
                int nb=1;
                String level=null;
                    
                for (PerfCounterInfo perfcounterInfo:counterInfoArr)
                {
            
        if (perfcounterInfo.getLevel()!=null)
        {
           level=String.valueOf(perfcounterInfo.getLevel());
           //System.out.println("Level: ");
           //System.out.println("- value: "+perfcounterInfo.getLevel());
        }
        else
           level="N/A";
            
        System.out.println(perfcounterInfo.getGroupInfo().getKey()+";"+perfcounterInfo.getGroupInfo().getLabel()+";"+perfcounterInfo.getGroupInfo().getSummary()+";"+
        perfcounterInfo.getKey()+";"+level+";"+perfcounterInfo.getNameInfo().getKey()+";"+perfcounterInfo.getNameInfo().getLabel()+";"+perfcounterInfo.getNameInfo().getSummary()+
        ";"+perfcounterInfo.getRollupType().name()+";"+perfcounterInfo.getStatsType().name()+";"+perfcounterInfo.getUnitInfo().getKey()+";"+perfcounterInfo.getUnitInfo().getLabel()+
        ";"+perfcounterInfo.getUnitInfo().getSummary()
        );
            
        //            System.out.println("\nN"+nb++);
        //            System.out.println("GroupInfo");
        //            System.out.println("- Key: "+perfcounterInfo.getGroupInfo().getKey());
        //            System.out.println("- Label  : "+perfcounterInfo.getGroupInfo().getLabel());
        //            System.out.println("- Summary: "+perfcounterInfo.getGroupInfo().getSummary());
        //            System.out.println("Key: ");
        //            System.out.println("- value: "+perfcounterInfo.getKey());
        //            if (perfcounterInfo.getLevel()!=null)
        //            {
        //               level=String.valueOf(perfcounterInfo.getLevel());
        //               System.out.println("Level: ");
        //               System.out.println("- value: "+perfcounterInfo.getLevel());
        //            }
        //
        //            System.out.println("NameInfo:");
        //            System.out.println("- Key: "+perfcounterInfo.getNameInfo().getKey());
        //            System.out.println("- Label  : "+perfcounterInfo.getNameInfo().getLabel());
        //            System.out.println("- Summary: "+perfcounterInfo.getNameInfo().getSummary());
        //            
        //            System.out.println("RollupType: ");
        //            System.out.println("- value: "+perfcounterInfo.getRollupType().toString());
        //
        //            System.out.println("StatsType: ");
        //            System.out.println("- value: "+perfcounterInfo.getStatsType().toString());
        //
        //            System.out.println("unitInfo: ");
        //            System.out.println("- Key: "+perfcounterInfo.getUnitInfo().getKey());
        //            System.out.println("- Label  : "+perfcounterInfo.getUnitInfo().getLabel());
        //            System.out.println("- Summary: "+perfcounterInfo.getUnitInfo().getSummary());
                }
            
             }
        */
        //PerformanceManagerUnit

        VMware.delete(hostName);

    }

    public void getTemplateInfo(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //String hostName="10.1.109.236";
        //VMware.create(hostName,443,"Administrator","8x63-K/!/",false,-1L);
        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        WSManager wsManager = WSManager.getInstance();
        VMManager vmManager = VMManager.getInstance();
        VMConfiguration vmConfiguration = null;

        //vmManager.re

        //VirtualMachine vm=vmManager.getVmByName(vmwareServerName, "Template_Windows2008");
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);
        //VirtualMachine vm=vmManager.getVmByName(vmwareServerName, "Test_Template");

        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();
        listOfManagedObjectReferences.add(vm.getMor());

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);

        ArrayList<Network> listOfNetwork = null;

        vmConfiguration = vm.getConfiguration();

        com.vmware.vim25.GuestInfo guestInfo = vm.getGuest5();
        System.out.println("com.vmware.vim25.GuestInfo: " + guestInfo);

        System.out.println("Template: " + vm.getName());
        System.out.println("- ID      : " + vm.getMor().get_value());

        System.out.println("- Guest OS: " + vm.getGuest().getOSFullName());
        System.out.println("- OS Family: " + vm.getGuest().getOSFamily());
        System.out.println("- Guest ID: " + vm.getGuest().getOSId());

        System.out.println("- Tools Version: " + vm.getGuest().getToolsVersion());
        System.out.println("- Tools Running Status: " + vm.getGuest().getToolsRunningStatus().getName());
        System.out.println("- Tools Version Status: " + vm.getGuest().getToolsVersionStatus().getName());
        System.out.println("- Tools Status: " + vm.getGuest().getToolsStatus().toString());

        System.out.println("- CPU Information");
        System.out.println("  - Mghz: " + vmConfiguration.getVirtualCPU().getMghz());
        System.out.println("  - Nb CPU: " + vmConfiguration.getVirtualCPU().getNbCPU());
        System.out.println("  - Limit :" + vmConfiguration.getVirtualCPU().getLimit());
        System.out.println("  - Reservation: " + vmConfiguration.getVirtualCPU().getReservation());
        System.out.println("  - Share Level: " + vmConfiguration.getVirtualCPU().getShareLevel());
        System.out.println("  - shares: " + vmConfiguration.getVirtualCPU().getShares());
        System.out.println("- Memory Information");
        System.out.println("  - Size: " + vmConfiguration.getVirtualMemory().getMemorySize());
        System.out.println("  - Limit: " + vmConfiguration.getVirtualMemory().getLimit());
        System.out.println("  - Reservation: " + vmConfiguration.getVirtualMemory().getReservation());
        System.out.println("  - Share Level: " + vmConfiguration.getVirtualMemory().getShareLevel());
        System.out.println("  - Shares: " + vmConfiguration.getVirtualMemory().getShares());
        //System.out.println("-Taille Disque: "+vmConfiguration.getDiskSize());

        System.out.println("-Network: ");
        listOfNetwork = vm.getNetwork();
        if (listOfNetwork != null && !listOfNetwork.isEmpty()) {
            for (Network network : listOfNetwork) {
                System.out.println("- Name: " + network.getName());
                System.out.println("- ID: " + network.getMor().get_value());
                System.out.println("- Gateway: " + network.getGateway());
                if (network.getSubnets() != null && network.getSubnets().size() > 0) {
                    for (String subnet : network.getSubnets()) {
                        System.out.println("- Subnet: " + subnet);
                    }
                }

                System.out.println("");
            }

        }

        ArrayList<VirtualDisk> listOfVirtualDisks = vm.getDisk();

        if (listOfVirtualDisks != null) {
            System.out.println("-Disk: ");
            for (VirtualDisk virtualDisk : listOfVirtualDisks) {
                System.out.println(" - Label: " + virtualDisk.getLabel());
                System.out.println(" - Size: " + virtualDisk.getDiskSize());

                //virtualDisk.getBacking().;

            }
        }

        //vm.getDatastores()

        //String[] toto=new String[]{};
        //System.out.println("longueur toto: "+toto.length);
        //System.out.println("toto: "+toto);

        /*
            
        ArrayList<VirtualMachine> listOfTemplate=vmManager.getTemplates(vmwareServerName);
        ArrayList<Network> listOfNetwork=null;
            
        if (listOfTemplate!=null)
        {
           System.out.println("Affichage de la configuration des templates\n");
           for (VirtualMachine vm:listOfTemplate)
           {
        vmConfiguration=vm.getConfiguration();
            
        System.out.println("Template: "+vm.getName());
        System.out.println("- ID      : "+vm.getMor().get_value());
        System.out.println("- Guest OS: "+vmConfiguration.getGuestInfo().guestFullName);
        System.out.println("- OS Family: "+vmConfiguration.getGuestInfo().guestFamily);
        System.out.println("- CPU Information");
        System.out.println("  - Mghz: "+vmConfiguration.getVirtualCPU().getMghz());
        System.out.println("  - Nb CPU: "+vmConfiguration.getVirtualCPU().getNbCPU());
        System.out.println("  - Limit :"+vmConfiguration.getVirtualCPU().getLimit());
        System.out.println("  - Reservation: "+vmConfiguration.getVirtualCPU().getReservation());
        System.out.println("  - Share Level: "+vmConfiguration.getVirtualCPU().getShareLevel());
        System.out.println("  - shares: "+vmConfiguration.getVirtualCPU().getShares());
        System.out.println("- Memory Information");
        System.out.println("  - Size: "+vmConfiguration.getVirtualMemory().getMemorySize());
        System.out.println("  - Limit: "+vmConfiguration.getVirtualMemory().getLimit());
        System.out.println("  - Reservation: "+vmConfiguration.getVirtualMemory().getReservation());
        System.out.println("  - Share Level: "+vmConfiguration.getVirtualMemory().getShareLevel());
        System.out.println("  - Shares: "+vmConfiguration.getVirtualMemory().getShares());
        System.out.println("-Taille Disque: "+vmConfiguration.getDiskSize());
            
        System.out.println("-Network: ");
        listOfNetwork=vm.getNetwork();
        for (Network network:listOfNetwork)
        {
           System.out.println("- Name: "+network.getName());
           System.out.println("- ID: "+network.getMor().get_value());
           System.out.println("- Gateway: "+network.getGateway());
           if (network.getSubnets()!=null && network.getSubnets().size()>0)
           {
              for (String subnet:network.getSubnets())
              {
                 System.out.println("- Subnet: "+subnet);
              }
           }
            
        System.out.println("");   
        }
            
           }
               
        }
        */

        /*
        System.out.println("Affichage de la configuration des VM\n");
        VirtualMachine vm=vmManager.getVmByName("Win2003SP2");
        vmConfiguration=vm.getConfiguration();
            
        System.out.println("VirtualMachine: "+vm.getName());
        System.out.println("-Guest OS:"+vmConfiguration.getGuestInfo().guestFullName);
        System.out.println("-Nb CPU:"+vmConfiguration.getVirtualCPU().getNumCPUs());
        System.out.println("-Memoire:"+vmConfiguration.getVirtualMemory().getMemorySize());
        System.out.println("-Taille Disque:"+vmConfiguration.getDiskSize());
        */

        //vmware.getTaskMonitor().interrupt();
        //wsManager.deleteVIM();

        VMware.delete(hostName);

    }

    /*
       public void configVM(String vmName,String vmwareServerName,long diskSize) throws VMwareException
       {
          VMware vmware=new VMware(vmwareServerName,443,"Administrateur","Clmdp@09",false,48000L,1000L);
          //VMware vmware=new VMware("siveo-admvc.siveo.net",443,"Administrateur","Gd@jJ2009$",false,48000L,1000L);
          WSManager wsManager=WSManager.getInstance(); 
              
          VMManager vmManager=VMManager.getInstance();
          VirtualMachine vm=vmManager.getVmByName(vmwareServerName, vmName);
              
          vmManager.configureVMDisk(vm.getMor().get_value(), vmwareServerName, diskSize);
              
          vmware.getTaskMonitor().interrupt();
          wsManager.deleteVIM();
        
       }
    */

    /*   
       public void addHost(String targetName,String hostName,String userName,String password) throws VMwareException
       {
          //String vmwareServerName="vcenter.siveo.net";
          String vmwareServerName="vcenter.siveo.net";
          VMware vmware=new VMware(vmwareServerName,443,"Administrateur","Gd@jJ2009$",false,48000L,1000L);
          //VMware vmware=new VMware("siveo-admvc.siveo.net",443,"Administrateur","Gd@jJ2009$",false,48000L,1000L);
          HostManager hostManager=HostManager.getInstance();
          WS ws=null;
          WSManager wsManager=WSManager.getInstance();
        
          hostManager.addHost(vmwareServerName, targetName, hostName, userName, password);
              
              
          vmware.getTaskMonitor().interrupt();
          wsManager.deleteVIM();
        
              
       }
    */

    public void getHostInfo() throws VMwareException {
        //String vmwareServerName="vcenter.siveo.net";
        String vmwareServerName = "srvcenter.siveo.net";
        VMware vmware = new VMware(vmwareServerName, 443, "Administrateur", "Clmdp@09", false, 48000L, 1000L);
        //VMware vmware=new VMware("siveo-admvc.siveo.net",443,"Administrateur","Gd@jJ2009$",false,48000L,1000L);
        HostManager hostManager = HostManager.getInstance();
        WS ws = null;
        WSManager wsManager = WSManager.getInstance();

        //VirtualMachineGuestOsIdentifier.

        Host host = hostManager.getHostByName("jerakine.siveo.net", vmwareServerName);
        System.out.println("Host: " + host.getName());
        //ComputeResourceSummary computeResourceSummary=host.getComputeResource().getComputeResourceSummary();
        //System.out.println("- Aggregated CPU resources   : "+computeResourceSummary.getTotalCpu()+" MHz");
        //System.out.println("- Aggregated Memory resources: "+computeResourceSummary.getTotalMemory()/1024/1024+" Mb");
        ////System.out.println("- CPU Capacity   : "+host.getCPUCapacity()+" MHz");
        ////System.out.println("- Memory Capacity: "+host.getMemoryCapacity()+" Mb");
        //System.out.println("- Effective CPU Available  : "+computeResourceSummary.getEffectiveCpu()+" MHz");
        //System.out.println("- Effective MemoryAvailable: "+computeResourceSummary.getEffectiveMemory()+" Mb");
        System.out.println("- System Resources Allocation");
        System.out.println("    CPU:    - limit      : " + host.getCPUAllocation().getLimit() + " MHz");
        System.out.println("            - reservation: " + host.getCPUAllocation().getReservation() + " MHz");
        System.out.println("    Memory: - limit      : " + host.getMemoryAllocation().getLimit() + " Mb");
        System.out.println("            - reservation: " + host.getMemoryAllocation().getReservation() + " Mb");
        System.out.println("- Runtime Resources Info");
        System.out.println(
                "    CPU:    - max usage: " + host.getRuntimeResourcesInfo().getCpu().getMaxUsage() + " MHz");
        System.out.println("            - overall usage: "
                + host.getRuntimeResourcesInfo().getCpu().getOverallUsage() + " MHz");
        System.out.println("            - reservation used: "
                + host.getRuntimeResourcesInfo().getCpu().getReservationUsed() + " MHz");
        System.out.println("            - reservation used for vm: "
                + host.getRuntimeResourcesInfo().getCpu().getReservationUsedForVm() + " MHz");
        System.out.println("            - unreserved for pool: "
                + host.getRuntimeResourcesInfo().getCpu().getUnreservedForPool() + " MHz");
        System.out.println("            - unreserved for vm: "
                + host.getRuntimeResourcesInfo().getCpu().getUnreservedForVm() + " MHz");
        System.out.println("    Memory: - max usage: "
                + host.getComputeResource().getRootResourcePool().getRuntimeInfo().getMemory().getMaxUsage()
                + " Mb");
        System.out.println("            - overall usage: "
                + host.getComputeResource().getRootResourcePool().getRuntimeInfo().getMemory().getOverallUsage()
                + " Mb");
        System.out.println("            - reservation used: "
                + host.getComputeResource().getRootResourcePool().getRuntimeInfo().getMemory().getReservationUsed()
                + " Mb");
        System.out.println("            - reservation used for vm: " + host.getComputeResource()
                .getRootResourcePool().getRuntimeInfo().getMemory().getReservationUsedForVm() + " Mb");
        System.out.println("            - unreserved for pool: " + host.getComputeResource().getRootResourcePool()
                .getRuntimeInfo().getMemory().getUnreservedForPool() + " Mb");
        System.out.println("            - unreserved for vm: "
                + host.getComputeResource().getRootResourcePool().getRuntimeInfo().getMemory().getUnreservedForVm()
                + " Mb");
        System.out.println("- Used Resources for All VMs");
        System.out.println("  - CPU: " + host.getTotalVMUsedCpu() + " MHz");
        System.out.println("  - Memory: " + host.getTotalVmMemory() + " Mo");
        System.out.println("- Used Resources for All ResourcePool");
        System.out.println("  - CPU: " + host.getComputeResource().getTotalResourcePoolUsedCpu());
        System.out.println("  - Memory: " + host.getComputeResource().getTotalResourcePoolUsedMemory());
        System.out.println("- Total Used Resources");
        System.out.println("  - CPU: " + host.getComputeResource().getTotalCpuUsed());
        System.out.println("  - Memory: " + host.getComputeResource().getTotalMemUsed());
        System.out.println("- Total Available Resources");
        System.out.println("  - CPU: " + host.getComputeResource().getAvailableCPU());
        System.out.println("  - Memory: " + host.getComputeResource().getAvailableMemory());
        /*
        // Rcupration du root ResourcePool
        ResourceConfigSpec[] resourceconfigspecArr=host.getComputeResource().getRootResourcePool().getChildConfiguration();
        if (resourceconfigspecArr!=null && resourceconfigspecArr.length>0)
        {
           int nbChild=1;
           String name=null;
           System.out.println("- Child Resources for Root ResourcePool");
           for (ResourceConfigSpec resourceConfigSpec:resourceconfigspecArr)
           {
        name=(String)MorManager.getMorPorperty(host.getWs(), resourceConfigSpec.getEntity(), new String[] {"name"});
        System.out.println("  - Child n"+nbChild++);
        System.out.println("    Entity: "+name+" / "+resourceConfigSpec.getEntity().getType()+" / "+resourceConfigSpec.getEntity().get_value());
        System.out.println("    CPU Allocation");
        System.out.println("      - Limit: "+resourceConfigSpec.getCpuAllocation().getLimit());
        System.out.println("      - Reservation: "+resourceConfigSpec.getCpuAllocation().getReservation());
        System.out.println("    Mem Allocation");
        System.out.println("      - Limit: "+resourceConfigSpec.getMemoryAllocation().getLimit());
        System.out.println("      - Reservation: "+resourceConfigSpec.getMemoryAllocation().getReservation());
           }
        }
        */

        //System.out.println("Cpu OverHead: "+host.getCPUAllocation().getOverheadLimit());
        //System.out.println("Compute Resource Total Cpu Used: "+host.getComputeResource().getTotalCpuUsed());
        //System.out.println("Compute Resource Total Memory Used: "+host.getComputeResource().getTotalMemUsed());
        //System.out.println("Available CPU: "+host.getComputeResource().getAvailableCPU());
        //System.out.println("Available Memory: "+host.getComputeResource().getAvailableMemory());
        //System.out.println("ResourcePool Available Cpu Used: "+host.getComputeResource().getResourcePool().getAvailableCPU());
        //System.out.println("ResourcePool Available Memory Used: "+host.getComputeResource().getResourcePool().getAvailableMemory());

        //host=hostManager.getHostByName("dskesxi.siveo.net", vmwareServerName);
        //System.out.println("\ndskesxi.siveo.net");
        //System.out.println("Host Total Cpu Used: "+host.getTotalCpuUsed());
        //System.out.println("Host Total Memory Used: "+host.getTotalMemUsed());
        //System.out.println("Compute Resource Total Cpu Used: "+host.getComputeResource().getTotalCpuUsed());
        //System.out.println("Compute Resource Total Memory Used: "+host.getComputeResource().getTotalMemUsed());
        //System.out.println("Effective Available Cpu: "+host.getComputeResource().getComputeResourceSummary().getEffectiveCpu());
        //System.out.println("Effective Available Memory: "+host.getComputeResource().getComputeResourceSummary().getEffectiveMemory());
        //System.out.println("ResourcePool Available Cpu Used: "+host.getComputeResource().getResourcePool().getTotalCpuUsed());
        //System.out.println("ResourcePool Available Memory Used: "+host.getComputeResource().getResourcePool().getTotalMemUsed());
        //System.out.println("ResourcePool Available Cpu: "+host.getComputeResource().getResourcePool().getAvailableCPU());
        //System.out.println("ResourcePool Available Memory: "+host.getComputeResource().getResourcePool().getAvailableMemory());
        //System.out.println("");

        ResourcePoolManager resPoolManager = ResourcePoolManager.getInstance();
        ResourcePool resPool = resPoolManager.getResourcePoolByName(vmwareServerName, "Test1");
        System.out.println("");
        System.out.println("ResourcePool: " + resPool.getName());
        //System.out.println("- Parent: "+((ResourcePool)resPool.getParent()).getName()+" / "+(ResourcePool)resPool.getParent());
        //System.out.println("- ComputeResource: "+resPool.getComputeResource().getName()+" / "+resPool.getComputeResource());
        System.out.println("- Host: " + resPool.getHost().get(0).getName() + " / " + resPool.getHost());
        System.out.println("- NbCPU: " + resPool.getNbCPU());
        System.out.println("- CPU Allocation");
        System.out.println("  - Expandable Reservation: " + resPool.getCpuAllocation().getExpandableReservation());
        System.out.println("  - Limit: " + resPool.getCpuAllocation().getLimit());
        System.out.println("  - OverheadLimit: " + resPool.getCpuAllocation().getOverheadLimit());
        System.out.println("  - Reservation: " + resPool.getCpuAllocation().getReservation());
        System.out.println("  - Mghz: " + resPool.getCpuAllocation().getMghz());
        System.out.println("- Memory Allocation");
        System.out
                .println("  - Expandable Reservation: " + resPool.getMemoryAllocation().getExpandableReservation());
        System.out.println("  - Limit: " + resPool.getMemoryAllocation().getLimit());
        System.out.println("  - OverheadLimit: " + resPool.getMemoryAllocation().getOverheadLimit());
        System.out.println("  - Reservation: " + resPool.getMemoryAllocation().getReservation());
        System.out.println("  - Mb: " + resPool.getMemoryAllocation().getMb());
        System.out.println("- Resources Allocatino");
        System.out.println("  - CPU");
        System.out.println("    - CPU Allocation: " + resPool.getCpuAllocation().getMghz());
        System.out.println("    - CPU used: " + resPool.getTotalCpuUsed());
        System.out.println("    - CPU Available: " + resPool.getAvailableCPU());
        System.out.println("  - Memory");
        System.out.println("    - Memory Allocation: " + resPool.getMemoryAllocation().getMb());
        System.out.println("    - Memory used: " + resPool.getTotalMemUsed());
        System.out.println("    - Memory used: " + resPool.getTotalResourceUsedMemory());
        System.out.println("    - Memory Available: " + resPool.getAvailableMemory());

        System.out.println("");
        resPool = resPoolManager.getResourcePoolByName(vmwareServerName, "Test2");
        System.out.println("ResourcePool: " + resPool.getName());
        System.out.println("- Parent: " + ((ResourcePool) resPool.getParent()).getName() + " / "
                + (ResourcePool) resPool.getParent());
        System.out.println("- ComputeResource: " + resPool.getComputeResource().getName() + " / "
                + resPool.getComputeResource());
        System.out.println("- Host: " + resPool.getHost().get(0).getName() + " / " + resPool.getHost());
        System.out.println("- NbCPU: " + resPool.getNbCPU());
        System.out.println("- CPU Allocation");
        System.out.println("  - Expandable Reservation: " + resPool.getCpuAllocation().getExpandableReservation());
        System.out.println("  - Limit: " + resPool.getCpuAllocation().getLimit());
        System.out.println("  - OverheadLimit: " + resPool.getCpuAllocation().getOverheadLimit());
        System.out.println("  - Reservation: " + resPool.getCpuAllocation().getReservation());
        System.out.println("- Memory Allocation");
        System.out
                .println("  - Expandable Reservation: " + resPool.getMemoryAllocation().getExpandableReservation());
        System.out.println("  - Limit: " + resPool.getMemoryAllocation().getLimit());
        System.out.println("  - OverheadLimit: " + resPool.getMemoryAllocation().getOverheadLimit());
        System.out.println("  - Reservation: " + resPool.getMemoryAllocation().getReservation());
        System.out.println("- CPU");
        System.out.println("  - CPU Allocation: " + resPool.getCpuAllocation().getMghz());
        System.out.println("  - CPU used: " + resPool.getTotalCpuUsed());
        System.out.println("  - CPU Avlaible: " + resPool.getAvailableCPU());
        System.out.println("- Memory");
        System.out.println("  - Memory Allocation: " + resPool.getMemoryAllocation().getMb());
        System.out.println("  - Memory used: " + resPool.getTotalMemUsed());
        System.out.println("  - Memory Avlaible: " + resPool.getAvailableMemory());

        /*
            
        ArrayList<Host> listOfHosts=hostManager.getAllHostByVC("vcenter.siveo.net");
        //ComputeResource computeResource=null;
        ComputeResourceSummary computeResourceSummary=null;
            
        if (listOfHosts!=null && listOfHosts.size()>0)
        {
           for (Host host:listOfHosts)
           {
        computeResourceSummary=host.getComputeResource().getComputeResourceSummary();
            
        System.out.println("");
        System.out.println("Host: "+host.getName());
        System.out.println("- Compute Resource Summary");
        System.out.println("  -Effective Cpu: "+computeResourceSummary.getEffectiveCpu());
        System.out.println("  -EffectiveMemory: "+computeResourceSummary.getEffectiveMemory());
        System.out.println("  -Num Cpu Cores: "+computeResourceSummary.getNumCpuCores());
        System.out.println("  -Num Cpu Threads: "+computeResourceSummary.getNumCpuThreads());
        System.out.println("  -Num Effective Hosts: "+computeResourceSummary.getNumEffectiveHosts());
        System.out.println("  -Total Cpu: "+computeResourceSummary.getTotalCpu());
        System.out.println("  -Total Memory: "+computeResourceSummary.getTotalMemory());
            
        System.out.println("");
        System.out.println("- CPU Allocation");
        System.out.println("  -Limit      : "+host.getCPUAllocation().getLimit());
        System.out.println("  -Reservation: "+host.getCPUAllocation().getReservation());
        System.out.println("  -Overhead Limit: "+host.getCPUAllocation().getOverheadLimit());
            
        System.out.println("");
        System.out.println("- Memory Allocation");
        System.out.println("  -Limite     : "+host.getMemoryAllocation().getLimit());
        System.out.println("  -Reservation: "+host.getMemoryAllocation().getReservation());
        System.out.println("  -Overhead Limit: "+host.getMemoryAllocation().getOverheadLimit());
            
        System.out.println("");
        System.out.println("- ResourcePool Info");
        //System.out.println("host parent: "+host.getParent());
            
        System.out.println("  -CPU unreservedForVm     : "+host.getAvailableCPU());
        System.out.println("  -MEM unreservedForVm     : "+host.getAvailableMemory());
            
        System.out.println("  -CPU Max Usage: "+host.getResourcePool().getRuntimeInfo().getCpu().getMaxUsage());
        System.out.println("  -CPU Overall Usage: "+host.getResourcePool().getRuntimeInfo().getCpu().getOverallUsage());
        System.out.println("  -CPU Reservation Used: "+host.getResourcePool().getRuntimeInfo().getCpu().getReservationUsed());
        System.out.println("  -CPU Reservation Used For Vm: "+host.getResourcePool().getRuntimeInfo().getCpu().getReservationUsedForVm());
        System.out.println("  -CPU Unreserved For Pool: "+host.getResourcePool().getRuntimeInfo().getCpu().getUnreservedForPool());
        System.out.println("  -CPU Unreserved For Vm: "+host.getResourcePool().getRuntimeInfo().getCpu().getUnreservedForVm());
            
        System.out.println("  -MEM Max Usage: "+host.getResourcePool().getRuntimeInfo().getMemory().getMaxUsage());
        System.out.println("  -MEM Overall Usage: "+host.getResourcePool().getRuntimeInfo().getMemory().getOverallUsage());
        System.out.println("  -MEM Reservation Used: "+host.getResourcePool().getRuntimeInfo().getMemory().getReservationUsed());
        System.out.println("  -MEM Reservation Used For Vm: "+host.getResourcePool().getRuntimeInfo().getMemory().getReservationUsedForVm());
        System.out.println("  -MEM Unreserved For Pool: "+host.getResourcePool().getRuntimeInfo().getMemory().getUnreservedForPool());
        System.out.println("  -MEM Unreserved For Vm: "+host.getResourcePool().getRuntimeInfo().getMemory().getUnreservedForVm());
            
            
           }
        }
        */

        //ArrayList<Network> listOfNetworks=host_.loadNetworks();

        //this.getNetworkInfo(host_);

        /*
            
        ArrayList<Datastore> listOfDS=null;
        ArrayList<Network> listOfNetworks=null;
            
        if (listOfHosts!=null && listOfHosts.size()>0)
        {
           for (Host host:listOfHosts)
           {
        System.out.println("");
        System.out.println("Host: "+host.getName());
        listOfDS=host.loadDatastores();
        if (listOfDS!=null && listOfDS.size()>0)
           for (Datastore ds:listOfDS)
           {
              System.out.println("Datastore: "+ds.getName()+" /ID: "+ds.getMor().get_value()+" /NbParent: "+ds.getNbHosts());
           }
            
        listOfNetworks=host.getNetworks();
        if (listOfNetworks!=null && listOfNetworks.size()>0)
           for (Network network:listOfNetworks)
           {
              System.out.println("network: "+network.getName()+" /ID: "+network.getMor().get_value()); //+" /NbParent: "+ds.getNbHosts());
           }
           }
        }
        */

        /*
        //Host host=hostManager.getHost("jerakine.siveo.net");
        Host host=hostManager.getHost("siveo-admesx01.siveo.net");
        HostConfiguration hostConfiguration=host.loadConfiguration();
        //1000000000
        System.out.println("CPU: ");
        System.out.println(" -Model                             : "+hostConfiguration.getCpu().getCpuPackage()[0].getDescription());
        System.out.println(" -Bus Speed                         : "+hostConfiguration.getCpu().getCpuPackage()[0].getBusHz());
        System.out.println(" -Vitesse du processeur             : "+hostConfiguration.getCpu().getHz());
        System.out.println(" -Nb Sockets                        : "+hostConfiguration.getCpu().getNumCpuPackages());
        System.out.println(" -Nb Coeurs de processeur par socket: "+hostConfiguration.getCpu().getNumCpuCores());
        System.out.println(" -Processeurs logiques              : "+hostConfiguration.getCpu().getNumCpuThreads());
            
            
        System.out.println("");
        System.out.println("Memory: ");
        System.out.println(" -Total              : "+hostConfiguration.getMemory().getMemorySize());
        System.out.println(" -Systme            : ");
        System.out.println(" -Console de service : "+hostConfiguration.getMemory().getConsoleReservationInfo().getServiceConsoleReserved());
        //System.out.println(" -Machines virtuelles: "+hostConfiguration.getMemory().getVirtualMachineReservationInfo().getVirtualMachineReserved());
        //System.out.println("  -Min: "+hostConfiguration.getMemory().getVirtualMachineReservationInfo().getVirtualMachineMin());
        //System.out.println("  -Max: "+hostConfiguration.getMemory().getVirtualMachineReservationInfo().getVirtualMachineMax());
            
        System.out.println("");
        System.out.println("CPU Allocation");
        System.out.println(" -Limite     : "+host.getCPUAllocation().getLimit());
        System.out.println(" -Reservation: "+host.getCPUAllocation().getReservation());
            
        System.out.println("");
        System.out.println("Memory Allocation");
        System.out.println(" -Limite     : "+host.getMemoryAllocation().getLimit());
        System.out.println(" -Reservation: "+host.getMemoryAllocation().getReservation());
            
        System.out.println("");
        System.out.println("ResourcePool Info");
        //System.out.println("host parent: "+host.getParent());
            
         System.out.println("  -CPU unreservedForVm     : "+host.getAvailableCPU());
         System.out.println("  -MEM unreservedForVm     : "+host.getAvailableMemory());
            
         System.out.println("");
            
            
        if (host.getParent() instanceof ComputeResource)
        {
           ComputeResource computeRes=(ComputeResource)host.getParent();
            ArrayList<TreeNode> childs=computeRes.getChilds();
            for (int nbChilds=0;nbChilds<childs.size();nbChilds++)
            {
         if (childs.get(nbChilds) instanceof ResourcePool)
         {
            ResourcePool resourcePool=(ResourcePool)childs.get(nbChilds);
            System.out.println("-Config");
            System.out.println(" -CPU Allocation");
            System.out.println("  -Limit      : "+resourcePool.getConfig().getCpuAllocation().getLimit());
            System.out.println("  -Reservation: "+resourcePool.getConfig().getCpuAllocation().getReservation());
            
            System.out.println("");
            System.out.println(" -Memory Allocation");
            System.out.println("  -Limit      : "+resourcePool.getConfig().getMemoryAllocation().getLimit());
            System.out.println("  -Reservation: "+resourcePool.getConfig().getMemoryAllocation().getReservation());
            
            System.out.println("");
            System.out.println("-Runtime");
            System.out.println(" -Runtime resource usage for CPU");
            System.out.println("  -maxUsage            : "+resourcePool.getRuntimeInfo().getCpu().getMaxUsage());
            System.out.println("  -overallUsage        : "+resourcePool.getRuntimeInfo().getCpu().getOverallUsage());
            System.out.println("  -reservationUsed     : "+resourcePool.getRuntimeInfo().getCpu().getReservationUsed());
            System.out.println("  -reservationUsedForVm: "+resourcePool.getRuntimeInfo().getCpu().getReservationUsedForVm());
            System.out.println("  -unreservedForPool   : "+resourcePool.getRuntimeInfo().getCpu().getUnreservedForPool());
            System.out.println("  -unreservedForVm     : "+resourcePool.getRuntimeInfo().getCpu().getUnreservedForVm());
            System.out.println("");
            System.out.println(" -Runtime resource usage for Memory");
            System.out.println("  -maxUsage            : "+resourcePool.getRuntimeInfo().getMemory().getMaxUsage());
            System.out.println("  -overallUsage        : "+resourcePool.getRuntimeInfo().getMemory().getOverallUsage());
            System.out.println("  -reservationUsed     : "+resourcePool.getRuntimeInfo().getMemory().getReservationUsed());
            System.out.println("  -reservationUsedForVm: "+resourcePool.getRuntimeInfo().getMemory().getReservationUsedForVm());
            System.out.println("  -unreservedForPool   : "+resourcePool.getRuntimeInfo().getMemory().getUnreservedForPool());
            System.out.println("  -unreservedForVm     : "+resourcePool.getRuntimeInfo().getMemory().getUnreservedForVm());
                
                
         }
            }
                
        }
        */

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();
    }

    /*   
       public void testhostListByVC() throws VMwareException
       {
              
          HostManager hostManager=HostManager.getInstance();
          WS ws=null;
          WSManager wsManager=WSManager.getInstance();
        
          // Connexion VirtualCenter 4.1
          try
          {
     //ws=wsManager.createVIM("vcenter.siveo.net",443,"Administrateur","Clmdp@09",false,48000L);
     ws=wsManager.createVIM("discworld.siveo.net",9445,"Administrateur","Clmdp@09",false,48000L);
     System.out.println("connexion Vsphere 4.0.1 -> OK");
          }
          catch (VMwareException e)
          {
     // TODO Auto-generated catch block
     e.printStackTrace();
          }
        
          System.out.println("computereource de jerakine.siveo.net");
          ManagedObjectReference mor=new ManagedObjectReference();
          mor.set_value("domain-s8");
          mor.setType("ComputeResource");
              
          ComputeResource computeResource=new ComputeResource(ws, mor);
          ResourcePool rsPool=computeResource.loadRootResourcePool();
              
          ArrayList<VirtualMachine> vmList=rsPool.loadVirtualMachines();
              
          if (vmList!=null && vmList.size()>0)
          {
     for (int nbVM=0;nbVM<vmList.size();nbVM++)
     {
        System.out.println("VM: "+vmList.get(nbVM).getName()+" - "+vmList.get(nbVM).getMor().get_value());
     }
          }
              
          System.out.println("");
          System.out.println("Computereource de dskesxi.siveo.net");
          mor=new ManagedObjectReference();
          mor.set_value("domain-s25");
          mor.setType("ComputeResource");
              
          computeResource=new ComputeResource(ws, mor);
          rsPool=computeResource.loadRootResourcePool();
              
          vmList=rsPool.loadVirtualMachines();
              
          if (vmList!=null && vmList.size()>0)
          {
     for (int nbVM=0;nbVM<vmList.size();nbVM++)
     {
        System.out.println("VM: "+vmList.get(nbVM).getName()+" - "+vmList.get(nbVM).getMor().get_value());
     }
          }
        
              
          System.out.println("");
          System.out.println("Host: dskesxi.siveo.net");
          mor=new ManagedObjectReference();
          mor.set_value("host-27");
          mor.setType("HostSystem");
        
          Host host=new Host(ws, mor);
          vmList=host.loadVirtualMachines();
          if (vmList!=null && vmList.size()>0)
          {
     for (int nbVM=0;nbVM<vmList.size();nbVM++)
     {
        System.out.println("VM: "+vmList.get(nbVM).getName()+" - "+vmList.get(nbVM).getMor().get_value());
     }
          }
              
              
          // VirtualCenter 3.5
        
    //      try
    //      {
    //         wsManager.createVIM("vcenter25u6",443,"Administrateur","Gd@jJ2009$",false,48000L);
    //         System.out.println("connexion VirtualCenter 3.5 -> OK");
    //      }
    //      catch (VMwareException e)
    //      {
    //         // TODO Auto-generated catch block
    //         e.printStackTrace();
    //      }
        
              
          wsManager.deleteVIM();
       }
    */

    public void reconnect() throws VMwareException {
        String vmwareServerName = "vcenter.siveo.net";
        VMware vmware = new VMware(vmwareServerName, 443, "Administrateur", "Clmdp@09", false, 480000L, 1000L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(vmwareServerName);
        ws.getVIMService().getService().getWsc().getCookie();

        System.out.println("Cookie: " + ws.getVIMService().getService().getWsc().getCookie());
        System.out.println("Cookie: " + ws.getVIMService().getServiceContent().getSessionManager());

        try {
            System.in.read();
        } catch (IOException e)

        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();

    }

    public void getVMConfigInfo() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.251.5.14";
        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "evalinux");

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMor = new ArrayList<ManagedObjectReference>();
        listOfMor.add(vm.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfMor);

        Host host = vm.getHost();

        VirtualMachineConfigInfo virtualMachineConfigInfo = vm.getConfigInfo();
        System.out.println("Display VirtualMachine Config Info: " + virtualMachineConfigInfo);

        VirtualMachineFileInfo virtualMachineFileInfo = virtualMachineConfigInfo.getFiles();
        if (virtualMachineFileInfo != null) {
            System.out.println("- VM Path Name: " + virtualMachineFileInfo.getVmPathName());

        }

        System.out.println("- VM Version: " + virtualMachineConfigInfo.getVersion());
        System.out.println("- Guest Full Name: " + virtualMachineConfigInfo.getGuestFullName());
        System.out.println("- Guest ID: " + virtualMachineConfigInfo.getGuestId());

        // -------------------------------------------------------
        // Retrieve the Environment  presents for creating and
        // configuring a virtual machine
        // -------------------------------------------------------
        ManagedObjectReference environmentBrowser = null;
        environmentBrowser = (ManagedObjectReference) MorManager.getMorProperty(vm.getWS(),
                host.getComputeResource().getMor(), new String[] { "environmentBrowser" });

        // -------------------------------------------------------
        // Retrieve the Environment  presents for creating and
        // configuring a virtual machine
        // -------------------------------------------------------
        VirtualMachineConfigOption vmConfigOption = null;

        try {
            vmConfigOption = vm.getWS().getVIMService().getService().queryConfigOption(environmentBrowser, null,
                    host.getMor());
        } catch (RuntimeFault runtimeFault) {
            throw runtimeFault;
        } catch (RemoteException remoteException) {
            throw remoteException;
        }

        VirtualDevice[] listOfDefaultDevices = vmConfigOption.getDefaultDevice();

        if (listOfDefaultDevices != null) {
            for (VirtualDevice virtualDevice : listOfDefaultDevices) {
                System.out.println(
                        "- " + virtualDevice.getDeviceInfo().getLabel() + " / " + virtualDevice.getClass());
                System.out.println("  - " + virtualDevice.getBacking());
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void listISO() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // Browse a datastore
        // =========================================================================================
        ISOManager isoManager = ISOManager.getInstance();
        List<ISO> listOfIsos = isoManager.retrieveISOsByDSName("datastore1", "ISO", hostName);

        if (listOfIsos != null && !listOfIsos.isEmpty()) {
            for (ISO iso : listOfIsos) {
                System.out.println("- Name: " + iso.getName());
                System.out.println("- ID: " + iso.getId());
                System.out.println("- Size: " + iso.getSize());
                System.out.println("- Path: " + iso.getPath());
                System.out.println("- Full Path: " + iso.getFullPath());
                System.out.println("");
            }
        } else {
            System.out.println("Pas d'ISO trouvs");
        }

        //      //[datastore3] /
        //      String datastoreName="datastore3";
        //      String datastorePath="["+datastoreName+"] /";
        //      
        //      System.out.println("DataStore Path: "+datastorePath);
        //      
        //      DataStoreManager dataStoreManager=DataStoreManager.getInstance();
        //      Datastore ds=dataStoreManager.getDatastoreByName(datastoreName, hostName);
        //      
        //      ManagedObjectReference dsBrowser=null;
        //      HostDatastoreBrowserSearchSpec datastoreBrowserSearchSpec=null;
        //      
        //      FileQueryFlags fileQueryFlags=null;
        //      ManagedObjectReference taskMor=null;
        //      PropertyFilterSpec[] propertyFilter=null;
        //      TaskInfo taskInfo=null;
        //      FileInfo[] filesInfo=null;
        //      IsoImageFileInfo isoImageFileInfo=null;
        //      
        //      if(ds!=null)
        //      {
        //         dsBrowser=(ManagedObjectReference)MorManager.getMorProperty(ds.getWS().getVIMService(),ds.getMor(), new String[] {"browser"});
        //
        //         datastoreBrowserSearchSpec=new HostDatastoreBrowserSearchSpec();
        //         
        //         fileQueryFlags=new FileQueryFlags();
        //         fileQueryFlags.setFileOwner(false);
        //         fileQueryFlags.setFileSize(true);
        //         fileQueryFlags.setFileType(true);
        //         fileQueryFlags.setModification(false);
        //         datastoreBrowserSearchSpec.setDetails(fileQueryFlags);
        //         
        //         datastoreBrowserSearchSpec.setQuery(new FileQuery[]{new IsoImageFileQuery()});
        //         //datastoreBrowserSearchSpec.setMatchPattern(new String[]{"*.iso"});
        //         datastoreBrowserSearchSpec.setSearchCaseInsensitive(false);
        //         //datastoreBrowserSearchSpec.setSortFoldersFirst(false);
        //         
        //         taskMor=ds.getWS().getVIMService().getService().searchDatastore_Task(dsBrowser, datastorePath, datastoreBrowserSearchSpec);
        //
        //         propertyFilter=MorManager.setPropertySpec(taskMor, new String[] {"info"});;
        //         taskInfo=(TaskInfo)MorManager.getMorProperty(ds.getWS().getVIMService(), propertyFilter);
        //         
        //         if (taskInfo!=null)
        //         {
        //            while(taskInfo.getState()==TaskInfoState.running)
        //            {
        //               taskInfo=(TaskInfo)MorManager.getMorProperty(ds.getWS().getVIMService(), propertyFilter);
        //            }
        //            
        //            HostDatastoreBrowserSearchResults browserSearchResults=(HostDatastoreBrowserSearchResults)taskInfo.getResult();
        //            filesInfo=browserSearchResults.getFile();
        //         }
        //         
        //         for (FileInfo fileInfo:filesInfo)
        //         {
        //            isoImageFileInfo=(IsoImageFileInfo)fileInfo;
        //            System.out.println("- Name: "+isoImageFileInfo.getPath());
        //            System.out.println("- size: "+isoImageFileInfo.getFileSize());
        //            System.out.println("");
        //         }
        //         
        //         //
        //         
        //      }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void retrieveLicenceInfo() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        //      Host host=hostManager.getHostByName("SIVEO-ESX3.siveo.dev", hostName);
        Host host = hostManager.getHostByID("ha-host", hostName);

        //System.out.println("host: "+host);

        ManagedObjectReference licenceManager = null;
        licenceManager = host.getWS().getVIMService().getServiceContent().getLicenseManager();

        ArrayOfLicenseManagerLicenseInfo arrayOfLicenseManagerLicenseInfo = (ArrayOfLicenseManagerLicenseInfo) MorManager
                .getMorProperty(host.getWS(), licenceManager, new String[] { "licenses" });
        if (arrayOfLicenseManagerLicenseInfo != null) {
            LicenseManagerLicenseInfo[] licenseManagerLicenseInfos = arrayOfLicenseManagerLicenseInfo
                    .getLicenseManagerLicenseInfo();

            for (LicenseManagerLicenseInfo licenseManagerLicenseInfo : licenseManagerLicenseInfos) {
                KeyValue[] keyValues = licenseManagerLicenseInfo.getLabels();
                KeyAnyValue[] keyAnyValues = licenseManagerLicenseInfo.getProperties();

                System.out.println("\n------- Licence -------");
                System.out.println("- Cost Unit: " + licenseManagerLicenseInfo.getCostUnit());
                System.out.println("- Edition Key: " + licenseManagerLicenseInfo.getEditionKey());
                System.out.println("- License Key: " + licenseManagerLicenseInfo.getLicenseKey());
                System.out.println("- Name: " + licenseManagerLicenseInfo.getName());
                System.out.println("- Total: " + licenseManagerLicenseInfo.getTotal());
                System.out.println("- Used: " + licenseManagerLicenseInfo.getUsed());

                if (keyValues != null && keyValues.length > 0) {
                    System.out.println("- Labels:");
                    for (KeyValue keyValue : keyValues) {
                        System.out.println("  - Key: " + keyValue.getKey() + " / Value: " + keyValue.getValue());
                    }
                }

                if (keyAnyValues != null && keyAnyValues.length > 0) {
                    System.out.println("- Properties:");
                    for (KeyAnyValue keyAnyValue : keyAnyValues) {
                        if (keyAnyValue.getKey().equals("feature")) {
                            KeyValue keyValue = (KeyValue) keyAnyValue.getValue();
                            System.out.println("  - Feature: " + keyValue.getKey() + " / " + keyValue.getValue());
                        } else {
                            System.out.println(
                                    "  - Key: " + keyAnyValue.getKey() + " / Value: " + keyAnyValue.getValue());
                        }
                    }
                }

            }

        }

        //LicenseAssignmentManagerLicenseAssignment[] licenseAssignmentManagerLicenseAssignments=null;
        //licenseAssignmentManagerLicenseAssignments=host.getWS().getVIMService().getService().queryAssignedLicenses(licenceManager, host.getMor().get_value());
        //LicenseFeatureInfo[] licenseFeatureInfos=host.getWS().getVIMService().getService().querySupportedFeatures(licenceManager, host.getMor());
        //LicenseUsageInfo licenseUsageInfo=host.getWS().getVIMService().getService().queryLicenseUsage(licenceManager, null);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getLicenceInfo() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        LicenceManager licenseManager = LicenceManager.getInstance();
        List<License> listOfLicenses = licenseManager.getLicencesInfo(hostName);
        List<Feature> listOfFeatures = null;

        if (listOfLicenses != null && !listOfLicenses.isEmpty()) {
            for (License license : listOfLicenses) {
                System.out.println("\n------- Licence -------");
                System.out.println("- Cost Unit: " + license.getCostUnit());
                System.out.println("- Edition Key: " + license.getEditionKey());
                System.out.println("- License Key: " + license.getLicenseKey());
                System.out.println("- Name: " + license.getName());
                System.out.println("- Total: " + license.getTotal());
                System.out.println("- Used: " + license.getUsed());

                listOfFeatures = license.getListOfFeatures();
                if (listOfFeatures != null && !listOfFeatures.isEmpty()) {
                    for (Feature feature : listOfFeatures) {
                        System.out.println("- Feature: " + feature.getName());
                    }
                }

            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getSyntheseOnESXi() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VirtualCenter virtualCenter = new VirtualCenter(hostName);
        System.out.println("");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void convertVMToTemplateOnESXi() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$", false, -1L);

        //      String hostName="163.172.7.95";
        //      VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "TPL_MANU");

        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        Datastore ds = dataStoreManager.getDatastoreByName("SIVEO_POC", hostName);

        vmManager.convertVMToTemplateOnESXi(vm.getMor().get_value(), "TPL_CDOMANU", hostName,
                ds.getMor().get_value(), "D:\\Siveo\\script");

        vmManager.cloneVMToVMOnESXi(vm.getMor().get_value(), "MY_VMCDO", hostName, ds.getMor().get_value(), null,
                "D:/Siveo/script");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getBackinfInfo() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VM-JTH-TEST");

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<String> listOfMorIDs = new ArrayList<String>();
        listOfMorIDs.add(vm.getMor().get_value());

        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);
        VirtualDisk virtualDisk = vm.getVirtualDeviceManager().getVirtualDiskByKey(2001);

        String fileName = vm.getVirtualDeviceManager().getVirtualDiskFileName(virtualDisk);
        System.out.println("FileName: " + fileName);

        //            //vDisk=vm.getVirtualDeviceManager().getVirtualDiskByName("Disque dur 2");
        //            vDisk=vm.getVirtualDeviceManager().getVirtualDiskByKey(2002);
        //            vDisk.setAction(VirtualDeviceOperation.edit);
        //            vDisk.setDiskSize(3*1024);
        //            listOfVirtualDisk.add(vDisk);

        vm.getVirtualDeviceManager().getVirtualDiskFileName(virtualDisk);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void deleteVM() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // Delete VM
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "ToDel2");

        vmManager.deleteVMByID(vm.getMor().get_value(), hostName);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void configureOnESXi() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        //      String hostName="163.172.7.95";
        //      VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L);

        //      String hostName="192.168.101.122";
        //      VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "10.10.0.64";
        VMware.create(hostName, 443, "root", "Keonys123", false, -1L);

        // -------------------------------------------------------------
        // =========================================================================================
        // 
        // =========================================================================================
        ArrayList<String> listOfMorIDs = new ArrayList<String>();

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VJTH-00000-01");
        listOfMorIDs.add(vm.getMor().get_value());

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        // -------------------------------------------------------------
        // VirtualCPU
        // -------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setLimit(1500);
        virtualCPU.setReservation(1000);

        virtualCPU.setNbCPU(2);

        // -------------------------------------------------------------
        // VirtualMemory
        // -------------------------------------------------------------
        VirtualMemory virtualMemory = new VirtualMemory();
        virtualMemory.setLimit(2176);
        virtualMemory.setReservation(1536);
        virtualMemory.setExpandableReservation(false);
        virtualMemory.setMemory(2048);

        // -------------------------------------------------------------
        // VirtualDisk
        // -------------------------------------------------------------
        ArrayList<VirtualDisk> listOfVirtualDisks = new ArrayList<VirtualDisk>();

        //      net.siveo.virtualization.vmware.virtualdevice.VirtualDisk virtualDisk=vm.getVirtualDeviceManager().getVirtualDiskByKey(2001);
        //      virtualDisk.setAction(VirtualDeviceOperation.edit);
        //      virtualDisk.setDiskSize(5);
        //      listOfVirtualDisks.add(virtualDisk);

        // Add a DISK
        VirtualDisk vDisk = new VirtualDisk();
        vDisk.setAction(VirtualDeviceOperation.add);
        vDisk.setDiskSize(1024 * 1);
        //vDisk.setLabel("Hard disk 3");
        listOfVirtualDisks.add(vDisk);
        //
        //      vDisk=new VirtualDisk();
        //      vDisk.setAction(VirtualDeviceOperation.add);
        //      vDisk.setDiskSize(1024*4);
        //      //vDisk.setLabel("Hard disk 3");
        //      listOfVirtualDisks.add(vDisk);

        // -------------------------------------------------------------
        // VirtualNetwork
        // -------------------------------------------------------------
        ArrayList<VirtualNetwork> listOfVirtualNetworks = new ArrayList<VirtualNetwork>();
        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = networkManager.getNetworkByID("HaNetwork-VM Network", hostName);

        VirtualNetwork virtualNetwork = new VirtualNetwork();

        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.add);
        listOfVirtualNetworks.add(virtualNetwork);

        //      virtualNetwork=vm.getVMNetwork().getVirtualNetworkByID("HaNetwork-VM Network");
        //      virtualNetwork.setAction(VirtualDeviceOperation.remove);
        //      listOfVirtualNetworks.add(virtualNetwork);

        ArrayList<VirtualDVSwitch> listOfDVSwitch = new ArrayList<>();

        //vm.configureOnESXi(virtualCPU, virtualMemory,null, listOfVirtualNetworks, null, "12345678");
        vm.configure(null, null, listOfVirtualDisks, listOfVirtualNetworks, listOfDVSwitch, "12345678");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void unMarshallVmx() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // UnMarshall
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VM-JTH-TEST");

        String vmxFileContent = "config.version = \"8\"\r\n" + "virtualHW.version = \"11\"\r\n"
                + "nvram = \"VM-JTH-TEST.nvram\"\r\n" + "pciBridge0.present = \"TRUE\"\r\n"
                + "svga.present = \"TRUE\"\r\n" + "pciBridge4.present = \"TRUE\"\r\n"
                + "pciBridge4.virtualDev = \"pcieRootPort\"\r\n" + "pciBridge4.functions = \"8\"\r\n"
                + "pciBridge5.present = \"TRUE\"\r\n" + "pciBridge5.virtualDev = \"pcieRootPort\"\r\n"
                + "pciBridge5.functions = \"8\"\r\n" + "pciBridge6.present = \"TRUE\"\r\n"
                + "pciBridge6.virtualDev = \"pcieRootPort\"\r\n" + "pciBridge6.functions = \"8\"\r\n"
                + "pciBridge7.present = \"TRUE\"\r\n" + "pciBridge7.virtualDev = \"pcieRootPort\"\r\n"
                + "pciBridge7.functions = \"8\"\r\n" + "vmci0.present = \"TRUE\"\r\n"
                + "hpet0.present = \"TRUE\"\r\n" + "floppy0.present = \"FALSE\"\r\n" + "memSize = \"2048\"\r\n"
                + "sched.cpu.units = \"mhz\"\r\n" + "powerType.powerOff = \"soft\"\r\n"
                + "powerType.suspend = \"hard\"\r\n" + "powerType.reset = \"soft\"\r\n" +

                //                       "scsi0.virtualDev = \"pvscsi\"\r\n"+
                //                       "scsi0.present = \"TRUE\"\r\n"+
                //                       "scsi1.virtualDev = \"scsiVirtualDev1\"\r\n"+
                //                       "scsi1.present = \"FALSE\"\r\n"+
                //"ide1:0.deviceType = \"cdrom-image\"\r\n"+
                //"ide1:0.fileName = \"/usr/lib/vmware/isoimages/linux.iso\"\r\n"+
                //"ide1:0.present = \"TRUE\"\r\n"+
                //                       "ethernet0.virtualDev = \"vmxnet3\"\r\n"+
                //                       "ethernet0.networkName = \"Interne\"\r\n"+
                //                       "ethernet0.addressType = \"generated\"\r\n"+
                //                       "ethernet0.uptCompatibility = \"TRUE\"\r\n"+
                //                       "ethernet0.present = \"TRUE\"\r\n"+
                //                       "scsi0:0.deviceType = \"scsi-hardDisk\"\r\n"+
                //                       "scsi0:0.fileName = \"VM-JTH-TEST-000006.vmdk\"\r\n"+
                //                       "scsi0:0.present = \"TRUE\"\r\n"+
                //                       "scsi0:1.deviceType = \"scsi-cdRom\"\r\n"+
                //                       "scsi0:1.fileName = \"cdROM-000006.vmdk\"\r\n"+
                //                       "scsi0:1.present = \"FALSE\"\r\n"+
                //                       "scsi1:0.deviceType = \"scsi1\"\r\n"+
                //                       "scsi1:0.fileName = \"scsi1-000006.vmdk\"\r\n"+

                //                       "displayName = \"VM-JTH-TEST\"\r\n"+
                //                       "guestOS = \"debian8-64\"\r\n"+

                "";

        //      String correlID="123456";
        //      VirtualCPU virtualCPU=null;
        //      VirtualMemory virtualMemory=null;
        //      List<VirtualDisk> listOfVirtualDisks=null;
        //      List<VirtualNetwork> listOfVirtualNetworks=null;
        //      List<VirtualDVSwitch> listOfVirtualVirtualDVSwitches=null;
        //      
        //      vm.configureEx(virtualCPU, virtualMemory, listOfVirtualDisks, listOfVirtualNetworks, listOfVirtualVirtualDVSwitches, correlID);

        Vmx vmx = VmxBuilder.unMarshall(VmxBuilder.loadVmx(vmxFileContent));
        System.out.println(vmx);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void marshallVmx(Vmx vmx) throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // UnMarshall
        // =========================================================================================

        String sortie = VmxBuilder.marshall(this.unMarshallVmxTest());
        System.out.println("sortie: \r\n" + sortie);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public Vmx unMarshallVmxTest() throws Exception {
        // =========================================================================================
        // UnMarshall
        // =========================================================================================
        String vmxFileContent = "config.version = \"8\"\r\n" + "virtualHW.version = \"11\"\r\n"
                + "nvram = \"VM-JTH-TEST.nvram\"\r\n" + "pciBridge0.present = \"TRUE\"\r\n"
                + "svga.present = \"TRUE\"\r\n" + "pciBridge4.present = \"TRUE\"\r\n"
                + "pciBridge4.virtualDev = \"pcieRootPort\"\r\n" + "pciBridge4.functions = \"8\"\r\n"
                + "pciBridge5.present = \"TRUE\"\r\n" + "pciBridge5.virtualDev = \"pcieRootPort\"\r\n"
                + "pciBridge5.functions = \"8\"\r\n" + "pciBridge6.present = \"TRUE\"\r\n"
                + "pciBridge6.virtualDev = \"pcieRootPort\"\r\n" + "pciBridge6.functions = \"8\"\r\n"
                + "pciBridge7.present = \"TRUE\"\r\n" + "pciBridge7.virtualDev = \"pcieRootPort\"\r\n"
                + "pciBridge7.functions = \"8\"\r\n" + "config.readOnly = \"FALSE\"\r\n"
                + "vmci0.present = \"TRUE\"\r\n" + "hpet0.present = \"TRUE\"\r\n"
                + "floppy0.present = \"FALSE\"\r\n" + "memSize = \"2048\"\r\n" + "sched.cpu.units = \"mhz\"\r\n"
                + "powerType.powerOff = \"soft\"\r\n" + "powerType.suspend = \"hard\"\r\n"
                + "powerType.reset = \"soft\"\r\n" +

                "scsi0.virtualDev = \"pvscsi\"\r\n" + "scsi0.present = \"TRUE\"\r\n"
                + "scsi1.virtualDev = \"scsiVirtualDev1\"\r\n" + "scsi1.present = \"FALSE\"\r\n"
                + "ide1:0.deviceType = \"cdrom-image\"\r\n"
                + "ide1:0.fileName = \"/usr/lib/vmware/isoimages/linux.iso\"\r\n" + "ide1:0.present = \"TRUE\"\r\n"
                + "ethernet0.virtualDev = \"vmxnet3\"\r\n" + "ethernet0.networkName = \"Interne\"\r\n"
                + "ethernet0.addressType = \"generated\"\r\n" + "ethernet0.uptCompatibility = \"TRUE\"\r\n"
                + "ethernet0.present = \"TRUE\"\r\n" + "scsi0:0.deviceType = \"scsi-hardDisk\"\r\n"
                + "scsi0:0.fileName = \"VM-JTH-TEST-000006.vmdk\"\r\n" + "scsi0:0.present = \"TRUE\"\r\n"
                + "scsi0:1.deviceType = \"scsi-cdRom\"\r\n" + "scsi0:1.fileName = \"cdROM-000006.vmdk\"\r\n"
                + "scsi0:1.present = \"FALSE\"\r\n" + "scsi1:0.deviceType = \"scsi1\"\r\n"
                + "scsi1:0.fileName = \"scsi1-000006.vmdk\"\r\n" + "displayName = \"VM-JTH-TEST\"\r\n"
                + "guestOS = \"debian8-64\"\r\n" +

                "ethernet3.virtualDev = \"e1000\"\r\n" + "ethernet3.networkName = \"VM Network\"\r\n"
                + "ethernet3.addressType = \"generated\"\r\n" + "ethernet3.uptCompatibility = \"TRUE\"\r\n"
                + "ethernet3.present = \"TRUE\"\r\n" +

                "toolScripts.afterPowerOn = \"TRUE\"\r\n" + "toolScripts.afterResume = \"TRUE\"\r\n"
                + "toolScripts.beforeSuspend = \"TRUE\"\r\n" + "toolScripts.beforePowerOff = \"TRUE\"\r\n" +

                "uuid.bios = \"56 4d 2e 4a b3 58 ec 0a-7f b6 07 09 b8 85 64 4b\"\r\n"
                + "uuid.location = \"56 4d 2e 4a b3 58 ec 0a-7f b6 07 09 b8 85 64 4b\"\r\n"
                + "vc.uuid = \"52 fe 99 c0 68 ea 8f 74-49 31 74 77 95 55 c7 05\"\r\n" +

                "chipset.onlineStandby = \"FALSE\"\r\n" + "sched.cpu.min = \"700\"\r\n"
                + "sched.cpu.shares = \"normal\"\r\n" + "sched.mem.min = \"600\"\r\n"
                + "sched.mem.minSize = \"600\"\r\n" + "sched.mem.shares = \"normal\"\r\n"
                + "virtualHW.productCompatibility = \"hosted\"\r\n"
                + "sched.swap.derivedName = \"/vmfs/volumes/561cd9b3-f5eca0e4-c887-204747805988/VM-JTH-TEST/VM-JTH-TEST-a649b0f8.vswp\"\r\n"
                + "replay.supported = \"FALSE\"\r\n" + "replay.filename = \"\"\r\n" +

                "migrate.hostlog = \"./VM-JTH-TEST-a649b0f8.hlog\"\r\n" + "scsi0:0.redo = \"\"\r\n"
                + "pciBridge0.pciSlotNumber = \"17\"\r\n" + "pciBridge4.pciSlotNumber = \"21\"\r\n"
                + "pciBridge5.pciSlotNumber = \"22\"\r\n" + "pciBridge6.pciSlotNumber = \"23\"\r\n"
                + "pciBridge7.pciSlotNumber = \"24\"\r\n" + "scsi0.pciSlotNumber = \"160\"\r\n"
                + "ethernet0.pciSlotNumber = \"192\"\r\n" + "vmci0.pciSlotNumber = \"32\"\r\n"
                + "scsi0.sasWWID = \"50 05 05 6a b3 58 ec 00\"\r\n"
                + "ethernet0.generatedAddress = \"00:0c:29:85:64:4b\"\r\n"
                + "ethernet0.generatedAddressOffset = \"0\"\r\n" + "vmci0.id = \"-1199217589\"\r\n"
                + "monitor.phys_bits_used = \"42\"\r\n" +

                "vmotion.checkpointFBSize = \"4194304\"\r\n" + "vmotion.checkpointSVGAPrimarySize = \"4194304\"\r\n"
                + "softPowerOff = \"FALSE\"\r\n" + "ide1:0.startConnected = \"FALSE\"\r\n"
                + "toolsInstallManager.lastInstallError = \"0\"\r\n" + "tools.remindInstall = \"FALSE\"\r\n"
                + "toolsInstallManager.updateCounter = \"2\"\r\n"
                + "ide1:0.allowGuestConnectionControl = \"TRUE\"\r\n" + "tools.syncTime = \"FALSE\"\r\n"
                + "extendedConfigFile = \"VM-JTH-TEST.vmxf\"\r\n" + "sched.cpu.max = \"1000\"\r\n"
                + "sched.mem.max = \"2048\"\r\n"
                + "RemoteDisplay.vnc.key = \"Dy8iGBc2FxYuPRkDNzIsBS8dJTAfMgwlBx0tAh87IQ4XGTQgLzsrFzcbHzgvKwESNxs6FD8tAR03EwcUOz0SGz07KCA6DzwmOT88IzodEAM5NzkROh0pIzknETI8HwA/Oy4/EjQfCgw6LgQcNx4LDzovNQgXNgMYLiwJJjczGCM=\"\r\n"
                + "RemoteDisplay.vnc.enabled = \"true\"\r\n" + "RemoteDisplay.vnc.port = \"5905\"\r\n"
                + "RemoteDisplay.vnc.password = \"mandriva\"\r\n" + "RemoteDisplay.vnc.keyMap = \"fr\"\r\n"
                + "config.readOnly = \"FALSE\"\r\n" + "ethernet1.pciSlotNumber = \"33\"\r\n"
                + "ethernet1.virtualDev = \"e1000\"\r\n" + "ethernet1.networkName = \"VM Network\"\r\n"
                + "ethernet1.addressType = \"generated\"\r\n" + "ethernet1.present = \"TRUE\"\r\n"
                + "ethernet1.generatedAddress = \"00:0c:29:85:64:55\"\r\n"
                + "ethernet1.generatedAddressOffset = \"10\"\r\n" + "numvcpus = \"2\"\r\n"
                + "scsi0:1.deviceType = \"scsi-hardDisk1\"\r\n" + "scsi0:1.fileName = \"VM-JTH-TEST_7.vmdk\"\r\n"
                + "scsi0:1.present = \"TRUE\"\r\n" + "scsi0:1.redo = \"\"\r\n" + "cleanShutdown = \"TRUE\"\r\n"
                + "checkpoint.vmState = \"\"\r\n" +

                "";

        String correlID = "123456";
        VirtualCPU virtualCPU = null;
        VirtualMemory virtualMemory = null;
        List<VirtualDisk> listOfVirtualDisks = null;
        List<VirtualNetwork> listOfVirtualNetworks = null;
        List<VirtualDVSwitch> listOfVirtualVirtualDVSwitches = null;
        //      
        //      vm.configureEx(virtualCPU, virtualMemory, listOfVirtualDisks, listOfVirtualNetworks, listOfVirtualVirtualDVSwitches, correlID);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VM-JTH-TEST");

        //vm.configureOnESXi(virtualCPU, virtualMemory, listOfVirtualDisks, listOfVirtualNetworks, listOfVirtualVirtualDVSwitches, correlID);

        Vmx vmx = null;
        //      Vmx vmx=VmxBuilder.unMarshall(VmxBuilder.loadVmx(vmxFileContent));
        //      System.out.println(vmx);

        return vmx;
    }

    public Vmx unMarshallVmx1() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // UnMarshall
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VM-JTH-TEST");

        String vmxFileContent = "config.version = \"8\"\r\n" + "virtualHW.version = \"11\"\r\n"
                + "nvram = \"VM-JTH-TEST.nvram\"\r\n" + "pciBridge0.present = \"TRUE\"\r\n"
                + "svga.present = \"TRUE\"\r\n" + "pciBridge4.present = \"TRUE\"\r\n"
                + "pciBridge4.virtualDev = \"pcieRootPort\"\r\n" + "pciBridge4.functions = \"8\"\r\n"
                + "pciBridge5.present = \"TRUE\"\r\n" + "pciBridge5.virtualDev = \"pcieRootPort\"\r\n"
                + "pciBridge5.functions = \"8\"\r\n" + "pciBridge6.present = \"TRUE\"\r\n"
                + "pciBridge6.virtualDev = \"pcieRootPort\"\r\n" + "pciBridge6.functions = \"8\"\r\n"
                + "pciBridge7.present = \"TRUE\"\r\n" + "pciBridge7.virtualDev = \"pcieRootPort\"\r\n"
                + "pciBridge7.functions = \"8\"\r\n" + "config.readOnly = \"FALSE\"\r\n"
                + "vmci0.present = \"TRUE\"\r\n" + "hpet0.present = \"TRUE\"\r\n"
                + "floppy0.present = \"FALSE\"\r\n" + "memSize = \"2048\"\r\n" + "sched.cpu.units = \"mhz\"\r\n"
                + "powerType.powerOff = \"soft\"\r\n" + "powerType.suspend = \"hard\"\r\n"
                + "powerType.reset = \"soft\"\r\n" +

                "scsi0.virtualDev = \"pvscsi\"\r\n" + "scsi0.present = \"TRUE\"\r\n"
                + "scsi1.virtualDev = \"scsiVirtualDev1\"\r\n" + "scsi1.present = \"FALSE\"\r\n"
                + "ide1:0.deviceType = \"cdrom-image\"\r\n"
                + "ide1:0.fileName = \"/usr/lib/vmware/isoimages/linux.iso\"\r\n" + "ide1:0.present = \"TRUE\"\r\n"
                + "ethernet0.virtualDev = \"vmxnet3\"\r\n" + "ethernet0.networkName = \"Interne\"\r\n"
                + "ethernet0.addressType = \"generated\"\r\n" + "ethernet0.uptCompatibility = \"TRUE\"\r\n"
                + "ethernet0.present = \"TRUE\"\r\n" + "scsi0:0.deviceType = \"scsi-hardDisk\"\r\n"
                + "scsi0:0.fileName = \"VM-JTH-TEST-000006.vmdk\"\r\n" + "scsi0:0.present = \"TRUE\"\r\n"
                + "scsi0:1.deviceType = \"scsi-cdRom\"\r\n" + "scsi0:1.fileName = \"cdROM-000006.vmdk\"\r\n"
                + "scsi0:1.present = \"FALSE\"\r\n" + "scsi1:0.deviceType = \"scsi1\"\r\n"
                + "scsi1:0.fileName = \"scsi1-000006.vmdk\"\r\n" + "displayName = \"VM-JTH-TEST\"\r\n"
                + "guestOS = \"debian8-64\"\r\n" +

                "ethernet3.virtualDev = \"e1000\"\r\n" + "ethernet3.networkName = \"VM Network\"\r\n"
                + "ethernet3.addressType = \"generated\"\r\n" + "ethernet3.uptCompatibility = \"TRUE\"\r\n"
                + "ethernet3.present = \"TRUE\"\r\n" +

                "toolScripts.afterPowerOn = \"TRUE\"\r\n" + "toolScripts.afterResume = \"TRUE\"\r\n"
                + "toolScripts.beforeSuspend = \"TRUE\"\r\n" + "toolScripts.beforePowerOff = \"TRUE\"\r\n" +

                "uuid.bios = \"56 4d 2e 4a b3 58 ec 0a-7f b6 07 09 b8 85 64 4b\"\r\n"
                + "uuid.location = \"56 4d 2e 4a b3 58 ec 0a-7f b6 07 09 b8 85 64 4b\"\r\n"
                + "vc.uuid = \"52 fe 99 c0 68 ea 8f 74-49 31 74 77 95 55 c7 05\"\r\n" +

                "chipset.onlineStandby = \"FALSE\"\r\n" + "sched.cpu.min = \"700\"\r\n"
                + "sched.cpu.shares = \"normal\"\r\n" + "sched.mem.min = \"600\"\r\n"
                + "sched.mem.minSize = \"600\"\r\n" + "sched.mem.shares = \"normal\"\r\n"
                + "virtualHW.productCompatibility = \"hosted\"\r\n"
                + "sched.swap.derivedName = \"/vmfs/volumes/561cd9b3-f5eca0e4-c887-204747805988/VM-JTH-TEST/VM-JTH-TEST-a649b0f8.vswp\"\r\n"
                + "replay.supported = \"FALSE\"\r\n" + "replay.filename = \"\"\r\n" +

                "migrate.hostlog = \"./VM-JTH-TEST-a649b0f8.hlog\"\r\n" + "scsi0:0.redo = \"\"\r\n"
                + "pciBridge0.pciSlotNumber = \"17\"\r\n" + "pciBridge4.pciSlotNumber = \"21\"\r\n"
                + "pciBridge5.pciSlotNumber = \"22\"\r\n" + "pciBridge6.pciSlotNumber = \"23\"\r\n"
                + "pciBridge7.pciSlotNumber = \"24\"\r\n" + "scsi0.pciSlotNumber = \"160\"\r\n"
                + "ethernet0.pciSlotNumber = \"192\"\r\n" + "vmci0.pciSlotNumber = \"32\"\r\n"
                + "scsi0.sasWWID = \"50 05 05 6a b3 58 ec 00\"\r\n"
                + "ethernet0.generatedAddress = \"00:0c:29:85:64:4b\"\r\n"
                + "ethernet0.generatedAddressOffset = \"0\"\r\n" + "vmci0.id = \"-1199217589\"\r\n"
                + "monitor.phys_bits_used = \"42\"\r\n" +

                "vmotion.checkpointFBSize = \"4194304\"\r\n" + "vmotion.checkpointSVGAPrimarySize = \"4194304\"\r\n"
                + "softPowerOff = \"FALSE\"\r\n" + "ide1:0.startConnected = \"FALSE\"\r\n"
                + "toolsInstallManager.lastInstallError = \"0\"\r\n" + "tools.remindInstall = \"FALSE\"\r\n"
                + "toolsInstallManager.updateCounter = \"2\"\r\n"
                + "ide1:0.allowGuestConnectionControl = \"TRUE\"\r\n" + "tools.syncTime = \"FALSE\"\r\n"
                + "extendedConfigFile = \"VM-JTH-TEST.vmxf\"\r\n" + "sched.cpu.max = \"1000\"\r\n"
                + "sched.mem.max = \"2048\"\r\n"
                + "RemoteDisplay.vnc.key = \"Dy8iGBc2FxYuPRkDNzIsBS8dJTAfMgwlBx0tAh87IQ4XGTQgLzsrFzcbHzgvKwESNxs6FD8tAR03EwcUOz0SGz07KCA6DzwmOT88IzodEAM5NzkROh0pIzknETI8HwA/Oy4/EjQfCgw6LgQcNx4LDzovNQgXNgMYLiwJJjczGCM=\"\r\n"
                + "RemoteDisplay.vnc.enabled = \"true\"\r\n" + "RemoteDisplay.vnc.port = \"5905\"\r\n"
                + "RemoteDisplay.vnc.password = \"mandriva\"\r\n" + "RemoteDisplay.vnc.keyMap = \"fr\"\r\n"
                + "config.readOnly = \"FALSE\"\r\n" + "ethernet1.pciSlotNumber = \"33\"\r\n"
                + "ethernet1.virtualDev = \"e1000\"\r\n" + "ethernet1.networkName = \"VM Network\"\r\n"
                + "ethernet1.addressType = \"generated\"\r\n" + "ethernet1.present = \"TRUE\"\r\n"
                + "ethernet1.generatedAddress = \"00:0c:29:85:64:55\"\r\n"
                + "ethernet1.generatedAddressOffset = \"10\"\r\n" + "numvcpus = \"2\"\r\n"
                + "scsi0:1.deviceType = \"scsi-hardDisk1\"\r\n" + "scsi0:1.fileName = \"VM-JTH-TEST_7.vmdk\"\r\n"
                + "scsi0:1.present = \"TRUE\"\r\n" + "scsi0:1.redo = \"\"\r\n" + "cleanShutdown = \"TRUE\"\r\n"
                + "checkpoint.vmState = \"\"\r\n" +

                "";

        //      String correlID="123456";
        //      VirtualCPU virtualCPU=null;
        //      VirtualMemory virtualMemory=null;
        //      List<VirtualDisk> listOfVirtualDisks=null;
        //      List<VirtualNetwork> listOfVirtualNetworks=null;
        //      List<VirtualDVSwitch> listOfVirtualVirtualDVSwitches=null;
        //      
        //      vm.configureEx(virtualCPU, virtualMemory, listOfVirtualDisks, listOfVirtualNetworks, listOfVirtualVirtualDVSwitches, correlID);

        Vmx vmx = VmxBuilder.unMarshall(VmxBuilder.loadVmx(vmxFileContent));
        System.out.println(vmx);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

        return vmx;
    }

    public void loadVMX() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        //      String vmxParams="config.version = \"8\"\n"+
        //                     "virtualHW.version = \"11\"\n"+
        //                     "nvram = \"VM-JTH-TEST.nvram\"";
        /*
           \n     \u000a: linefeed LF
           \r     \u000d: carriage return CR
         * 
         */
        String vmxParams = "config.version = \"8\"\r\n" + "virtualHW.version = \"11\"\r\n"
                + "vmci0.present = \"TRUE\"\r\n" + "floppy0.present = \"FALSE\"\r\n" + "memSize = \"800\"\r\n"
                + "sched.cpu.units = \"mhz\"\r\n" + "powerType.powerOff = \"soft\"\r\n"
                + "powerType.suspend = \"hard\"\r\n" + "powerType.reset = \"soft\"\r\n"
                + "scsi0.virtualDev = \"pvscsi\"\r\n" + "scsi0.present = \"TRUE\"\r\n"
                + "ide1:0.startConnected = \"FALSE\"\r\n" + "ide1:0.deviceType = \"cdrom-image\"\r\n"
                + "ide1:0.fileName = \"/usr/lib/vmware/isoimages/linux.iso\"\r\n" + "ide1:0.present = \"TRUE\"\r\n"
                + "scsi0:0.deviceType = \"scsi-hardDisk\"\r\n" + "scsi0:0.fileName = \"VM-MANU-000001.vmdk\"\r\n"
                + "scsi0:0.present = \"TRUE\"\r\n" + "displayName = \"VM-MANU\"\r\n"
                + "guestOS = \"debian7-64\"\r\n" + "toolScripts.afterPowerOn = \"TRUE\"\r\n"
                + "toolScripts.afterResume = \"TRUE\"\r\n" + "toolScripts.beforeSuspend = \"TRUE\"\r\n"
                + "toolScripts.beforePowerOff = \"TRUE\"\r\n"
                + "uuid.bios = \"56 4d 31 7a cc c5 ca a8-f9 5b f7 10 1e 80 9a 19\"\r\n"
                + "uuid.location = \"56 4d 31 7a cc c5 ca a8-f9 5b f7 10 1e 80 9a 19\"\r\n"
                + "vc.uuid = \"52 a2 ef 65 1c 00 82 86-29 11 22 99 91 37 90 7e\"\r\n"
                + "chipset.onlineStandby = \"FALSE\"\r\n" + "sched.cpu.min = \"700\"\r\n"
                + "sched.cpu.shares = \"normal\"\r\n" + "sched.mem.min = \"100\"\r\n"
                + "sched.mem.minSize = \"100\"\r\n" + "sched.mem.shares = \"normal\"\r\n"
                + "vmci0.id = \"110825755\"\r\n" + "ide1:0.allowGuestConnectionControl = \"TRUE\"\r\n"
                + "tools.syncTime = \"FALSE\"\r\n" + "extendedConfigFile = \"VM-MANU.vmxf\"\r\n"
                + "numvcpus = \"3\"\r\n" + "sched.cpu.max = \"1100\"\r\n" + "sched.mem.max = \"1200\"\r\n"
                + "config.readOnly = \"FALSE\"\r\n" + "cleanShutdown = \"TRUE\"\r\n"
                + "nvram = \"VM-MANU.nvram\"\r\n" + "pciBridge0.present = \"TRUE\"\r\n"
                + "svga.present = \"TRUE\"\r\n" + "pciBridge4.present = \"TRUE\"\r\n"
                + "pciBridge4.virtualDev = \"pcieRootPort\"\r\n" + "pciBridge4.functions = \"8\"\r\n"
                + "pciBridge5.present = \"TRUE\"\r\n" + "pciBridge5.virtualDev = \"pcieRootPort\"\r\n"
                + "pciBridge5.functions = \"8\"\r\n" + "pciBridge6.present = \"TRUE\"\r\n"
                + "pciBridge6.virtualDev = \"pcieRootPort\"\r\n" + "pciBridge6.functions = \"8\"\r\n"
                + "pciBridge7.present = \"TRUE\"\r\n" + "pciBridge7.virtualDev = \"pcieRootPort\"\r\n"
                + "pciBridge7.functions = \"8\"\r\n" + "hpet0.present = \"true\"\r\n"
                + "virtualHW.productCompatibility = \"hosted\"\r\n"
                + "sched.swap.derivedName = \"/vmfs/volumes/561cd9b3-f5eca0e4-c887-204747805988/VM-MANU/VM-MANU-210b39d6.vswp\"\r\n"
                + "replay.supported = \"false\"\r\n" + "pciBridge0.pciSlotNumber = \"17\"\r\n"
                + "pciBridge4.pciSlotNumber = \"21\"\r\n" + "pciBridge5.pciSlotNumber = \"22\"\r\n"
                + "pciBridge6.pciSlotNumber = \"23\"\r\n" + "pciBridge7.pciSlotNumber = \"24\"\r\n"
                + "scsi0.pciSlotNumber = \"160\"\r\n" + "vmci0.pciSlotNumber = \"32\"\r\n"
                + "scsi0.sasWWID = \"50 05 05 6a cc c5 ca a0\"\r\n" + "monitor.phys_bits_used = \"42\"\r\n"
                + "vmotion.checkpointFBSize = \"4194304\"\r\n"
                + "vmotion.checkpointSVGAPrimarySize = \"4194304\"\r\n" + "softPowerOff = \"FALSE\"\r\n"
                + "toolsInstallManager.lastInstallError = \"0\"\r\n" + "tools.remindInstall = \"FALSE\"\r\n"
                + "toolsInstallManager.updateCounter = \"2\"\r\n"
                + "migrate.hostLog = \"./VM-MANU-65eae829.hlog\"\r\n" + "sched.scsi0:0.throughputCap = \"off\"\r\n"
                + "RemoteDisplay.vnc.key = \"Fy0lETUECAQjPQcBFDcwIA8YACc7GgUkMC0MAg87CDAfGwICNiEtAScHISQvHggQMxkqABEtIAYVMjQkPzoEAxw5MAA7HQYgOQcAGiozNAIlPxAhNA0oCDsACDA+HjIgMj8oKxEbAAkZKgkAPzQKIy4HEQoGPxAFLAcABT8CEBU=\"\r\n"
                + "replay.filename = \"\"\r\n" + "scsi0:0.redo = \"\"\r\n" + "sched.scsi0:0.shares = \"normal\"\r\n"
                + "scsi0:1.deviceType = \"scsi-hardDisk\"\r\n" + "scsi0:1.fileName = \"VM-MANU_1-000001.vmdk\"\r\n"
                + "scsi0:1.present = \"true\"\r\n" + "scsi0:1.redo = \"\"\r\n"
                + "scsi0:2.deviceType = \"scsi-hardDisk\"\r\n" + "scsi0:2.fileName = \"VM-MANU_2-000001.vmdk\"\r\n"
                + "scsi0:2.present = \"TRUE\"\r\n" + "ethernet2.virtualDev = \"e1000\"\r\n"
                + "ethernet2.networkName = \"Interne\"\r\n" + "ethernet2.addressType = \"generated\"\r\n"
                + "ethernet2.present = \"TRUE\"\r\n" + "scsi0:2.redo = \"\"\r\n"
                + "ethernet2.pciSlotNumber = \"35\"\r\n" + "ethernet2.generatedAddress = \"00:0c:29:80:9a:2d\"\r\n"
                + "ethernet2.generatedAddressOffset = \"20\"\r\n" + "RemoteDisplay.vnc.enabled = \"true\"\r\n"
                + "RemoteDisplay.vnc.port = \"5901\"\r\n"
                + "RemoteDisplay.vnc.password = \"li9AH06bAQiXPaW3hV9nkQ==\"\r\n"
                + "RemoteDisplay.vnc.keyMap = \"fr\"\r\n" + "scsi0:3.deviceType = \"scsi-hardDisk\"\r\n"
                + "scsi0:3.fileName = \"VM-MANU_5.vmdk\"\r\n" + "scsi0:3.present = \"TRUE\"\r\n"
                + "scsi0:4.deviceType = \"scsi-hardDisk\"\r\n" + "scsi0:4.fileName = \"VM-MANU_10.vmdk\"\r\n"
                + "scsi0:4.present = \"TRUE\"\r\n" + "scsi0:4.redo = \"\"\r\n" + "scsi0:3.redo = \"\"\r\n"
                + "ethernet3.pciSlotNumber = \"192\"\r\n" + "ethernet3.virtualDev = \"vmxnet3\"\r\n"
                + "ethernet3.uptCompatibility = \"true\"\r\n" + "ethernet3.present = \"TRUE\"\r\n"
                + "ethernet3.addressType = \"generated\"\r\n"
                + "ethernet3.generatedAddress = \"00:0c:29:80:9a:37\"\r\n"
                + "ethernet3.generatedAddressOffset = \"30\"\r\n";

        StreamFactory factory = StreamFactory.newInstance();
        factory.loadResource("vmxfile.xml");

        InputStream in = new ByteArrayInputStream(vmxParams.getBytes());
        BeanReader reader = factory.createReader("vmx", new InputStreamReader(in));
        Object record = null;
        Vmx2 vmx = null;

        while ((record = reader.read()) != null) {
            vmx = (Vmx2) record;
            System.out.println("record: " + vmx.getKey() + " / " + vmx.getValue());
        }

        String text = "sched.cpu.max = \"1100\"\r\n" + "sched.cpu.min = \"50\"";
        String key = "sched.cpu.max\r\n" + "sched.cpu.min";
        String value = "\"1100\"";

        Map<String, String> mapOfValuesByKeys = new HashMap<String, String>();

        //mapOfValuesByKeys.put("sched.cpu.max", "\"1100\"");
        //mapOfValuesByKeys.put("sched.cpu.min", "50");

        //mapOfValuesByKeys.put(svga.present = "TRUE");
        mapOfValuesByKeys.put("pciBridge0.present", "TRUE");
        mapOfValuesByKeys.put("nvram", "VM-JTH-TEST.nvram");
        mapOfValuesByKeys.put("virtualHW.version", "11");
        mapOfValuesByKeys.put("config.version", "8");

        mapOfValuesByKeys.put("pciBridge4.present", "TRUE");
        mapOfValuesByKeys.put("pciBridge4.virtualDev", "pcieRootPort");
        mapOfValuesByKeys.put("pciBridge4.functions", "8");

        //        mapOfValuesByKeys.put("vmci0.present", "TRUE");
        //        mapOfValuesByKeys.put("memSize", "800");
        //        mapOfValuesByKeys.put("vmci0.id", "110825755");
        //        mapOfValuesByKeys.put("pciBridge0.present", "TRUE");

        //String subClass=null;
        //String property=null;
        Class<?> myClass = null;

        Constructor<?> constructor = null;
        String paramClass = null;
        String vmxParam = null;
        String vmxValue = null;

        Vmx vmx1 = new Vmx();
        Object myObject = null;
        Object myParentObject = vmx1;
        Class<?>[] types = null;
        Object[] varargs = null;
        List<String> paramsList = new ArrayList<String>();
        int index = -1;
        //Object addListMethod=null;
        paramsList.add("vmci");
        paramsList.add("pciBridge");

        HashMap<String, Object> mapOfParamObjectByParamName = new HashMap<String, Object>();

        for (Map.Entry<String, String> entry : mapOfValuesByKeys.entrySet()) {
            vmxParam = entry.getKey();
            vmxValue = entry.getValue();
            myParentObject = vmx1;
            index = -1;

            if (vmxParam.contains(".")) {
                while (vmxParam.contains(".")) {
                    paramClass = vmxParam.substring(0, vmxParam.indexOf("."));
                    vmxParam = vmxParam.substring(vmxParam.indexOf(".") + 1);

                    for (String prefix : paramsList) {
                        if (paramClass.startsWith(prefix)) {
                            index = Integer.parseInt(paramClass.substring(prefix.length()));
                            paramClass = paramClass.substring(0, paramClass.length() - 1);
                        }

                    }

                    if (index != -1) {
                        myObject = mapOfParamObjectByParamName.get(paramClass + String.valueOf(index));
                    } else {
                        // Get the class, create one if doesn't exist 
                        myObject = PropertyUtils.getSimpleProperty(myParentObject, paramClass);
                    }

                    if (myObject == null) {
                        myClass = Class.forName("net.siveo.virtualization.vmware.vmx."
                                + paramClass.substring(0, 1).toUpperCase() + paramClass.substring(1));
                        //constructor=myClass.getConstructor(null);
                        //myObject=constructor.newInstance(null);
                        constructor = myClass.getConstructor(types);
                        myObject = constructor.newInstance(varargs);

                        if (index == -1) {
                            PropertyUtils.setSimpleProperty(myParentObject, paramClass, myObject);
                        } else {
                            if (!mapOfParamObjectByParamName.containsKey(paramClass + String.valueOf(index))) {
                                mapOfParamObjectByParamName.put(paramClass + String.valueOf(index), myObject);
                                PropertyUtils.setSimpleProperty(myParentObject, paramClass, myObject);
                                PropertyUtils.setSimpleProperty(myObject, "index", index);
                            }

                            //addListMethod=PropertyUtils.getSimpleProperty(myParentObject, paramClass+"s");
                            //vmx1.getVmcis().add(myObject);
                        }
                    }

                    myParentObject = myObject;

                }

                PropertyUtils.setSimpleProperty(myParentObject, vmxParam, vmxValue);

            } else {
                //myObject=PropertyUtils.getSimpleProperty(vmx1, vmxParam);
                PropertyUtils.setSimpleProperty(vmx1, vmxParam, vmxValue);

                //               if(myObject==null)
                //               {
                //                  myClass=Class.forName("net.siveo.virtualization.vmware.vmx."+paramClass.substring(0,1).toUpperCase()+paramClass.substring(1));
                //                  constructor=myClass.getConstructor(null);
                //                  myObject=constructor.newInstance(null);
                //                  PropertyUtils.setSimpleProperty(myParentObject, paramClass, myObject);
                //               }

                //myParentObject=myObject;

            }

        }

        System.out.println("" + vmx1);

        //        while(key.contains("."))
        //        {
        //           mainClass=key.substring(0,key.indexOf("."));
        //           key=key.substring(key.indexOf(".")+1);
        //           
        //           // Get the class, create one if doesn't exist 
        //           myObject=PropertyUtils.getSimpleProperty(myParentObject, mainClass);
        //           
        //           if(myObject==null)
        //           {
        //              myClass=Class.forName("net.siveo.virtualization.vmware.vmx."+mainClass.substring(0,1).toUpperCase()+mainClass.substring(1));
        //              constructor=myClass.getConstructor(null);
        //              myObject=constructor.newInstance(null);
        //              PropertyUtils.setSimpleProperty(myParentObject, mainClass, myObject);
        //           }
        //           else
        //           {
        //              //myObject=PropertyUtils.getProperty(bean, name);
        //           }
        //
        //          myParentObject=myObject;
        //
        //        }
        //        
        //        PropertyUtils.setSimpleProperty(myParentObject, key, "50");

        //        String classe=null;
        //        property=key.substring(key.lastIndexOf(".")+1);
        //        key=key.substring(0,key.lastIndexOf("."));
        //        
        //        while(key.contains("."))
        //        {
        //           classe=key.substring(key.lastIndexOf(".")+1);
        //           
        //           
        //           
        //           key=key.substring(0,key.lastIndexOf("."));
        //        }

        List<String> listOfKeys = new ArrayList<String>();
        String temp = null;

        //        String className = "Class1";
        //        Object xyz = Class.forName(className).newInstance();
        //        
        //        import java.lang.reflect.*;
        //
        //        Param1Type param1;
        //        Param2Type param2;
        //        String className = "Class1";
        //        Class cl = Class.forName(className);
        //        Constructor con = cl.getConstructor(Param1Type.class, Param2Type.class);
        //        Object xyz = con.newInstance(param1, param2);

        //

        //        vmx1=new Vmx1();
        //        Config config=new Config();
        //
        //        PropertyUtils.setSimpleProperty(config, "version", "12345");
        //        PropertyUtils.setSimpleProperty(vmx1, "config", config);
        //
        //        
        ////        PropertyUtils.setMappedProperty(vmx1, "config", config);
        ////        PropertyUtils.setMappedProperty(vmx1, "config", "version", "12");
        //
        //
        ////        PropertyUtils.setMappedProperty(vmx1, "config", config);
        ////        PropertyUtils.setSimpleProperty(vmx1, "config", config);
        ////        PropertyUtils.setNestedProperty(vmx1, "config.version", "12345");
        //        
        //
        //        
        //        System.out.println("config.version: "+vmx1.getConfig().getVersion());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVMPath() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        //String hostName="10.62.16.35";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        //String hostName="163.172.7.95";
        //VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L);

        String hostName = "192.168.101.122";
        VMware.create(hostName, 443, "root", "cahh4gee$", false, -1L);

        // Keonys ESXi Ingenieur 
        //String hostName="10.10.0.64";
        //VMware.create(hostName,443,"root","Keonys123",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "testvm");

        System.out.println("VM Path: " + VmxBuilder.getVMPath(vm));
        //vm.rename("LaVMCDO","12345");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getVMByName() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        //String hostName="10.62.16.35";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        //String hostName="163.172.7.95";
        //VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L);

        String hostName = "192.168.101.122";
        VMware.create(hostName, 443, "root", "cahh4gee$", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "testvm1");

        System.out.println("Press a key");
        System.in.read();

        VMware.refresh(hostName);

        vm = vmManager.getVmByName(hostName, "testvm2");
        System.out.println("vm: " + vm);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void renameOnESXi() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        //String hostName="10.62.16.35";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        //String hostName="163.172.7.95";
        //VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L);

        String hostName = "192.168.101.122";
        VMware.create(hostName, 443, "root", "cahh4gee$", false, -1L);

        //      // Keonys ESXi Ingenieur 
        //      String hostName="10.10.0.64";
        //      VMware.create(hostName,443,"root","Keonys123",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "test");

        //vm.rename("LaVMCDO","12345");
        vm.rename("TestCDO", "D:/Siveo/script");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void gereVMX() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // Get the Full Path to the VirtualMachine Config file (.vmx) 
        // =========================================================================================
        String vmName = "VM-MANU";
        String vmPathName = null;
        String vmPathVmx = null;
        String vmPathCfg = null;

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        vmPathName = (String) MorManager.getMorProperty(vm.getWS(), vm.getMor(),
                new String[] { "summary.config.vmPathName" });
        System.out.println("Vm Path: " + vmPathName);

        //Vm Path: [SIVEO_POC] JTH-TESTCRE/JTH-TESTCRE.vmx

        vmPathVmx = vmPathName.substring(vmPathName.indexOf("]") + 2);
        System.out.println("Vm VMX Path: " + vmPathVmx);

        String dsName = vmPathName.substring(vmPathName.indexOf("[") + 1, vmPathName.indexOf("]"));
        System.out.println("Datastore Name: " + dsName);

        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        Datastore ds = dataStoreManager.getDatastoreByName(dsName, hostName);
        String dsURL = (String) MorManager.getMorProperty(vm.getWS(), ds.getMor(), new String[] { "info.url" });
        System.out.println("Datastore URL: " + dsURL);
        //Datastore URL: /vmfs/volumes/50178a9f-0339acdc-80d9-e61f1347e4d7

        vmPathCfg = dsURL + "/" + vmPathVmx;

        System.out.println("Vm FullPath to Cfg file: " + vmPathCfg);

        // =========================================================================================
        // Read the vmx File 
        // =========================================================================================
        Jsch jsch = new Jsch(hostName, vm.getWS().getUserName(), vm.getWS().getPassword());
        jsch.connectKerberos();

        //String command="vmware-cmd "+vmPathCfg+" start";
        String command = "cat " + vmPathCfg;

        int exitCode = jsch.executeCmd(command);

        if (exitCode != 0) {
            jsch.disconnect();
            throw new Exception("Error: Retieve Guest OS failed.");
        }

        String sortie = jsch.getStdOut();
        System.out.println("JSCH StdOut: " + sortie);
        //System.out.println("JSCH StdErr: "+sortie);
        String txt = "";

        Scanner scanner = new Scanner(sortie);
        while (scanner.hasNext()) {
            txt = txt + this.processLine(scanner.nextLine());
        }

        System.out.println("Valeurs:\n" + txt);

        jsch.disconnect();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public String processLine(String aLine) {
        Scanner scanner = new Scanner(aLine);
        scanner.useDelimiter("=");

        String parameter = null;
        String value = null;
        String txt = "";

        if (scanner.hasNext()) {
            parameter = scanner.next().trim();
            value = scanner.next().trim();

            if (parameter.equalsIgnoreCase("numvcpus") || parameter.equalsIgnoreCase("sched.cpu.min")
                    || parameter.equalsIgnoreCase("sched.cpu.max") || parameter.equalsIgnoreCase("memSize")
                    || parameter.equalsIgnoreCase("sched.mem.min") || parameter.equalsIgnoreCase("sched.mem.max")) {
                txt = txt + parameter + "=" + value + "\n";
            }

        }

        return txt;

    }

    public void vmwareCmd() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // Get the Full Path to the VirtualMachine Config file (.vmx) 
        // =========================================================================================
        String vmName = "VM-JTH-TEST";
        String vmPathName = null;
        String vmPathVmx = null;
        String vmPathCfg = null;

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        vmPathName = (String) MorManager.getMorProperty(vm.getWS(), vm.getMor(),
                new String[] { "summary.config.vmPathName" });
        System.out.println("Vm Path: " + vmPathName);

        //Vm Path: [SIVEO_POC] JTH-TESTCRE/JTH-TESTCRE.vmx

        vmPathVmx = vmPathName.substring(vmPathName.indexOf("]") + 2);
        System.out.println("Vm VMX Path: " + vmPathVmx);

        String dsName = vmPathName.substring(vmPathName.indexOf("[") + 1, vmPathName.indexOf("]"));
        System.out.println("Datastore Name: " + dsName);

        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        Datastore ds = dataStoreManager.getDatastoreByName(dsName, hostName);
        String dsURL = (String) MorManager.getMorProperty(vm.getWS(), ds.getMor(), new String[] { "info.url" });
        System.out.println("Datastore URL: " + dsURL);
        //Datastore URL: /vmfs/volumes/50178a9f-0339acdc-80d9-e61f1347e4d7

        vmPathCfg = dsURL + "/" + vmPathVmx;

        System.out.println("Vm FullPath to Cfg file: " + vmPathCfg);

        // =========================================================================================
        // Run a vmware-cmd 
        // =========================================================================================
        Jsch jsch = new Jsch(hostName, vm.getWS().getUserName(), vm.getWS().getPassword());
        Date dt01 = new Date();
        jsch.connectKerberos();
        Date dt02 = new Date();
        System.out.println("JSCH Connect in: " + (dt02.getTime() - dt01.getTime()));

        //String command="vmware-cmd "+vmPathCfg+" start";
        String command = "vim-cmd vmsvc/power.on " + vm.getMor().get_value();
        System.out.println("command jsch: " + command);

        int exitCode = jsch.executeCmd(command);

        if (exitCode != 0) {
            jsch.disconnect();
            throw new Exception("Error: Retieve Guest OS failed.");
        }

        String sortie = jsch.getStdOut();
        System.out.println("Sortie JSCH: " + sortie);

        jsch.disconnect();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getCurrentTasks() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // Get the Full Path to the VirtualMachine Config file (.vmx) 
        // =========================================================================================
        net.siveo.virtualization.vmware.task.TaskManager taskManager = net.siveo.virtualization.vmware.task.TaskManager
                .getInstance();
        List<Task> listOfTasks = taskManager.getAllTasks(hostName);
        //taskManager.getTaskByVMID(hostName, "12","createSnapshot");
        WS ws = WSManager.getInstance().getWS(hostName);

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");

        ////      //Task task=taskManager.getTask(hostName, "12", "PowerOffVM_Task");
        //      Task task=taskManager.getTask(hostName, "12", "PowerOnVM_Task");
        ////      Task task1=taskManager.getTask(hostName, "31", "PowerOnVM_Task");
        //      
        //      //"PowerOffVM_Task"
        //      //"PowerOnVM_Task"
        //      //RebootGuest
        //      //ResetVM_Task
        //      //SuspendVM_Task
        //      //CreateSnapshot_Task synchrone
        //RevertToSnapshot_Task
        //RemoveSnapshot_Task
        //RemoveAllSnapshots_Task stnchrone
        ////
        //      TaskInfo taskInfo=(TaskInfo)MorManager.getMorProperty(ws,task.getMor(), new String[] {"info"});
        //
        //      System.out.println("\n- Key: "+taskInfo.getKey());
        //      System.out.println("- Name: "+taskInfo.getName());
        //      System.out.println("- Entity Name: "+taskInfo.getEntityName());
        //      System.out.println("- Entity: "+taskInfo.getEntity().get_value()+"/"+taskInfo.getEntity().getType());
        //      System.out.println("- Start Time: "+simpleDateFormat.format(taskInfo.getStartTime().getTime()));
        //      System.out.println("- Complete Time: "+simpleDateFormat.format(taskInfo.getCompleteTime().getTime()));
        //      System.out.println("- State: "+taskInfo.getState().toString());
        //      
        //
        //      taskInfo=(TaskInfo)MorManager.getMorProperty(ws,task1.getMor(), new String[] {"info"});
        //
        //      System.out.println("\n- Key: "+taskInfo.getKey());
        //      System.out.println("- Name: "+taskInfo.getName());
        //      System.out.println("- Entity Name: "+taskInfo.getEntityName());
        //      System.out.println("- Entity: "+taskInfo.getEntity().get_value()+"/"+taskInfo.getEntity().getType());
        //      System.out.println("- Start Time: "+simpleDateFormat.format(taskInfo.getStartTime().getTime()));
        //      System.out.println("- Complete Time: "+simpleDateFormat.format(taskInfo.getCompleteTime().getTime()));
        //      System.out.println("- State: "+taskInfo.getState().toString());

        TaskInfo taskInfo = null;

        for (Task task2 : listOfTasks) {
            taskInfo = (TaskInfo) MorManager.getMorProperty(ws, task2.getMor(), new String[] { "info" });
            System.out.println("\n- Key: " + taskInfo.getKey());
            System.out.println("- Name: " + taskInfo.getName());
            System.out.println("- Entity Name: " + taskInfo.getEntityName());
            System.out.println(
                    "- Entity: " + taskInfo.getEntity().get_value() + "/" + taskInfo.getEntity().getType());
            System.out.println("- Start Time: " + simpleDateFormat.format(taskInfo.getStartTime().getTime()));
            System.out.println("- Complete Time: " + simpleDateFormat.format(taskInfo.getCompleteTime().getTime()));
            System.out.println("- State: " + taskInfo.getState().toString());

            //         System.out.println("- Activation: "+taskInfo.getActivationId());
            //         System.out.println("- ChangeTag: "+taskInfo.getChangeTag());
            //         System.out.println("- ChangeTag: "+taskInfo.getDescriptionId());
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void runCmd() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        //      String hostName="163.172.7.95";
        //      VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L);

        //Keonys eva-Client
        String hostName = "10.10.0.64";
        //VMware.create(hostName,443,"evaadmin","@dmin123",false,-1L);
        VMware.create(hostName, 443, "root", "Keonys123", false, -1L);

        // =========================================================================================
        // Get the Full Path to the VirtualMachine Config file (.vmx) 
        // =========================================================================================
        String vmName = "LaVMCDO";
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        // =========================================================================================
        // Run a vmware-cmd 
        // =========================================================================================
        vm.powerOff();
        //vm.powerOn(correlID);
        //vm.pause(correlID);
        //vm.rebootGuest(correlID);
        //vm.shutdownGuest(correlID);
        //vm.reset(correlID);
        //      
        //      vmManager.deleteVMByID(vm.getMor().get_value(),hostName, correlID);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void createVM() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //String hostName="192.168.101.58";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L, 1000L);

        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        ISOManager isoManager = ISOManager.getInstance();
        isoManager.retrieveISOsByDSName("datastore1", "ISO", hostName);
        ISO iso = isoManager.getISOByName("ubuntu-14.04.3-desktop-amd64.iso", hostName);

        VMConfiguration vmConfiguration = new VMConfiguration();
        vmConfiguration.setName("CreateVMCDO00");

        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(550);
        virtualCPU.setReservation(450);

        VirtualMemory virtualMemory = new VirtualMemory();
        virtualMemory.setLimit(1024L);
        virtualMemory.setReservation(1024);
        virtualMemory.setMemory(1024);

        vmConfiguration.setVirtualMemory(virtualMemory);
        vmConfiguration.setVirtualCPU(virtualCPU);
        //vmConfiguration.setGuestID(VirtualMachineGuestOsIdentifier.centos64Guest.name());
        vmConfiguration.setGuestID(VirtualMachineGuestOsIdentifier.debian8_64Guest.name());

        //Network
        VirtualNetwork virtualNetwork = new VirtualNetwork();
        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = networkManager.getNetworkByID("HaNetwork-VM Network", hostName);
        virtualNetwork.setNetwork(network);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        //Disk
        VirtualDisk virtualDisk = new VirtualDisk();
        virtualDisk.setDiskSize(4L);
        vmConfiguration.getListOfVirtualDisk().add(virtualDisk);

        String hostID = "ha-host"; //siveo-esx4.siveo.net
        String datastoreID = "561cd9b3-f5eca0e4-c887-204747805988"; //SIVEO_POC

        VMManager vmManager = VMManager.getInstance();
        //vmManager.createVM(hostName, vmConfiguration, hostID, datastoreID,"resgroup-1881",null,null);
        vmManager.createVM(hostName, vmConfiguration, hostID, datastoreID, null, null, iso);

        System.out.println("Press a key to continue...");
        System.in.read();

        //vmConfiguration.s(500);

        //ResourcePoolManager rsPoolManager=ResourcePoolManager.getInstance();
        //HashMap<String, HashMap<String, ResourcePool>> listOfResourcePoolIDByVC=rsPoolManager.getListOfResourcePoolIdByVC();
        //HashMap<String, ResourcePool> listOfResourcePoolID=listOfResourcePoolIDByVC.get(vmwareServerName);

        //ResourcePool rsPoolTest=rsPoolManager.getResourcePoolByID(vmwareServerName, "resgroup-187");

        //for (Map.Entry<String, ResourcePool> rsPool:listOfResourcePoolID.entrySet())
        //{
        //   System.out.println("Resource Pool / ID: "+rsPool.getKey()+" / Name: "+rsPool.getValue().getName());
        //}

        //System.out.println("");
        //System.out.println("ResourcePool de Test: "+rsPoolTest.getName());

        //vmManager.createVM(vmConfiguration, true);

        //InventoryManager inventoryManager=InventoryManager.getInstance();
        //inventoryManager.loadInventory("vsphere-4-0-1");

        //FolderManager folderManager=FolderManager.getInstance();
        //folderManager.getRootFolder("vsphere-4-0-1");

        //InventoryManager inventoryManager=InventoryManager.getInstance();
        //inventoryManager.browseInventory("vsphere-4-0-1");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    /*   
       public void getESXfromVM(String vmName) throws VMwareException 
       {
          VMware vmware=new VMware();
          WSManager wsManager=WSManager.getInstance();
              
          VMManager vmManager=VMManager.getInstance();
          VirtualMachine vm=vmManager.getVmByName(vmName);
          System.out.println("VM: "+vmName);
          System.out.println(" - Host: "+vm.getHost_().getName());
          wsManager.deleteVIM();
       }
        
           
       public void testUser() throws VMwareException
       {
          WSManager wsManager=WSManager.getInstance();
          WS ws=null;
          try
          {
     //ws = wsManager.createVIM("vpshere-4-1", 443, "Administrateur", "Gd@jJ2009$", null, false, 480000);
     //ws = wsManager.createVIM("vpshere-4-1", 443, "christophe", "christophe", null, false, 480000);
     ws = wsManager.createVIM("vsphere-4-0-1", 443, "actidev1", "P@ssw0rd", null, false, 480000);
          }
          catch (VMwareException e)
          {
     // TODO Auto-generated catch block
     e.printStackTrace();
          }
        
          ManagedObjectReference mor=MorManager.getMorRef(ws, null, "VirtualMachine", "ActiBox05");
          ManagedObject managedObject=new ManagedObject(ws, mor);
          VMManager vmManager=VMManager.getInstance();
          vmManager.addVM(ws, mor);
          VirtualMachine vm=vmManager.getVmByMor(mor);
          vm.powerOn();
              
              
       }
    */

    /*
       public void test() throws VMwareException
       {
          WSManager wsManager=WSManager.getInstance();
          WS ws=null;
          try
          {
     ws = wsManager.createVIM("vpshere-4-1", 443, "Administrateur", "Gd@jJ2009$", null, false, 480000);
          }
          catch (VMwareException e)
          {
     // TODO Auto-generated catch block
     e.printStackTrace();
          }
        
          System.out.println("ws: "+ws);
          System.out.println("ws: "+ws.getHostName());
              
        
              
          ArrayList<Host> hostList=null;
          Host host=null;
          InventoryManager inventoryManager=InventoryManager.getInstance();
              
          hostList=inventoryManager.getHost(ws.getHostName());
          HostManager hostManager=HostManager.getInstance();
        
          System.out.println("hostList: "+hostList);
              
          for (int nbHost=0;nbHost<hostList.size();nbHost++)
          {
     host=hostList.get(nbHost);
     System.out.println("\nHost n"+nbHost);
     System.out.println("name:"+host.getName());
     System.out.println("type"+host.getType());
     //System.out.println("\nHost n"+nbHost);
     //System.out.println("name:"+mngObj.getName());
     //System.out.println("type"+mngObj.getType());
     //System.out.println("value"+mngObj.getValue());
     //MorManager.addHost(ws, mngObj);
     hostManager.putHost(host);
          }
        
          host=hostManager.getHost("esx01.siveo.net");
          System.out.println("host: "+host.getMorRef());
        
          wsManager.deleteWS(ws);
              
       }
    */

    public void browsePermission() throws VMwareException {
        String hostName = "10.0.12.6";
        VMware.create(hostName, 443, "dgme_admin", "s1v3oP0C", false, -1L, 1000L);

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        ArrayList<net.siveo.virtualization.vmware.authorization.Permission> listOfPermission = null;

        System.out.println("Affichage des Permissions pour tous les objets de l'Arbre d'Inventaire");

        /*
              for (Map.Entry<String, TreeNode> treenodeByName:inventory.getMapOfTreeNodeByName().entrySet())
              {
                 System.out.println("Entity: "+treenodeByName.getKey()+ " / "+treenodeByName.getValue().getMor().getType()+"/"+treenodeByName.getValue().getMor().get_value());
                 listOfPermission=authorizationManager.getPermissions(treenodeByName.getValue());
                 if (listOfPermission!=null && !listOfPermission.isEmpty())
                 {
        for (net.siveo.virtualization.vmware.authorization.Permission perm:listOfPermission)
        {
           System.out.println("-User: "+perm.getPrincipal());
           System.out.println("-Role Id: "+perm.getRoleId());
           System.out.println("-Nb Priv: "+perm.getPrivileges().size());
        }
                 }
                     
                 System.out.println("");
                     
              }
           */

        VMware.delete(hostName);

    }

    public void getDatastoreByVM() throws VMwareException {
        String vmwareServerName = "srvcenter.siveo.net";
        VMware vmware = new VMware(vmwareServerName, 443, "Administrateur", "Clmdp@09", false, 48000L, 1000L);
        WSManager wsManager = WSManager.getInstance();

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(vmwareServerName, "ActiBox15");
        ArrayList<Datastore> listOfDS = vm.getDatastores();

        for (Datastore ds : listOfDS) {
            System.out.println("Datastore Name: " + ds.getName());
        }

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();
    }

    public void getAllPrivilege_() throws VMwareException {
        WSManager wsManager = WSManager.getInstance();
        WS ws = null;
        try {
            ws = wsManager.createVIM("192.168.1.12", 443, "Administrateur", "GdmjJ2009$", null, false, 480000);
        } catch (VMwareException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        AuthorizationManager authorManager = AuthorizationManager.getInstance();
        ManagedObjectReference authorizationManager = null;
        AuthorizationDescription authorizationDescription = null;

        authorizationManager = ws.getVIMService().getServiceContent().getAuthorizationManager();
        authorizationDescription = (AuthorizationDescription) MorManager.getMorProperty(ws, authorizationManager,
                new String[] { "description" });

        if (authorizationDescription.getPrivilege() != null && authorizationDescription.getPrivilege().length > 0) {
            for (int nbPriv = 0; authorizationDescription.getPrivilege().length > nbPriv; nbPriv++) {
                //System.out.println("Privilge "+nbPriv);
                //System.out.println("-Label  : "+authorizationDescription.getPrivilege()[nbPriv].getLabel());
                //System.out.println("-Summary: "+authorizationDescription.getPrivilege()[nbPriv].getSummary());
                //System.out.println("-Key    : "+authorizationDescription.getPrivilege()[nbPriv].getKey());
                System.out.println(authorizationDescription.getPrivilege()[nbPriv].getKey());

                ////System.out.println("public static String "+authorizationDescription.getPrivilege()[nbPriv].getKey().toUpperCase().replace(".", "_")+"=\""+authorizationDescription.getPrivilege()[nbPriv].getKey()+"\";");
                //String val=authorizationDescription.getPrivilege()[nbPriv].getKey().toUpperCase().replace(".", "_");
                //String value=val.replace(".", "_");
                //System.out.println(authorizationDescription.getPrivilege()[nbPriv].getLabel()+";"+authorizationDescription.getPrivilege()[nbPriv].getSummary()+";"+authorizationDescription.getPrivilege()[nbPriv].getKey()+";"+authorizationDescription.getPrivilege()[nbPriv].getKey().toUpperCase().replace(".", "_"));
            }
        }

        System.out.println("");
        System.out.println("");

        //authorManager.getAllSystemPrivilege();

        wsManager.deleteWS(ws);
    }

    public void getProperty() throws VMwareException {

        String vmwareServerName = "vcenter.siveo.net";
        //VMware vmware=new VMware(vmwareServerName,443,"Administrateur","Gd@jJ2009$",false,480000L,1000L);
        VMware vmware = new VMware(vmwareServerName, 443, "Administrateur", "Clmdp@09", false, 480000L, 1000L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(vmwareServerName);

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("jerakine.siveo.net", vmwareServerName);

        ManagedObjectReference mor = new ManagedObjectReference();
        mor.setType("HostSystem");
        mor.set_value("host-132");

        // Get Datacenter
        DatacenterManager dcManager = DatacenterManager.getInstance();
        //Datacenter dc=dcManager.g

        //DynamicProperty[] dynPropArr=(DynamicProperty[])MorManager.getMorPorperty(ws.getVIMService(),mor, new String[] {"name","parent"},true);
        Date dtStart = new Date();
        System.out.println("Start: " + dtStart.getTime());
        //DynamicProperty[] dynPropArr=(DynamicProperty[])MorManager.getMorPorperty(ws.getVIMService(),mor, new String[] {"name","parent"},true);
        //DynamicProperty[] dynPropArr=(DynamicProperty[])MorManager.getProperties(ws,mor,new String[]{"vm","config.product.fullName","hardware"});
        //DynamicProperty[] dynPropArr=(DynamicProperty[])MorManager.getAllProperties(vmwareServerName, host.getMor().getType(), host.getMor().get_value());

        ObjectContent[] tabOfObjectContents = MorManager.getAllPropertiesEx(ws, host.getMor());

        if (tabOfObjectContents != null && tabOfObjectContents.length > 0) {
            for (ObjectContent objectContent : tabOfObjectContents) {
                System.out.println("-Object: " + objectContent.getObj().get_value() + " / "
                        + objectContent.getObj().getType());
                DynamicProperty[] tabOfDynamicProperties = objectContent.getPropSet();
                if (tabOfDynamicProperties != null && tabOfDynamicProperties.length > 0) {
                    for (DynamicProperty dynamicProperty : tabOfDynamicProperties) {
                        System.out.println(" - " + dynamicProperty.getName() + " / " + dynamicProperty.getVal());
                    }
                }

            }
        }

        Date dtEnd = new Date();
        System.out.println("End: " + dtEnd.getTime());

        System.out.println("Duration: " + (dtEnd.getTime() - dtStart.getTime()));

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();
    }

    public void waitForUpdate(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L,1000L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        ManagedObjectReference filterMor = null;
        UpdateSet update = null;

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // Get a new InventoryMonitor
        InventoryManager inventoryManager = InventoryManager.getInstance();

        // =========================================================================================
        // Create the Filter
        // =========================================================================================
        ArrayList<ManagedObject> listOfVMs = inventoryManager.getVirtualMachines(hostName);

        ArrayList<ManagedObject> listOfDCs = inventoryManager.getDatacenters(hostName);
        listOfVMs.addAll(listOfDCs);

        ArrayList<ManagedObject> listOfFolders = inventoryManager.getFolders(hostName);
        listOfVMs.addAll(listOfFolders);

        filterMor = inventoryManager.createFilter(listOfVMs);

        // Initialize the waitUpdates() and get the first version 
        update = inventoryManager.Init(hostName, "");

        InventoryMonitor inventoryMonitor = null;

        // If the fisrt waitUpdate is ok then call a second waitupdate with the previous version
        if (update != null) {
            System.out.println("\nDeuxime wait");
            inventoryMonitor = new InventoryMonitor(ws, update.getVersion());
            inventoryMonitor.start();
        }

        try {
            System.in.read();
        } catch (IOException e)

        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // Destroy the filter 
        try {
            ws.getVIMService().getService().destroyPropertyFilter(filterMor);
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        inventoryMonitor.interrupt();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    /*   
       public void taskMonitor_(String vmName) throws VMwareException 
       {
          VMware vmware=new VMware();
          WSManager wsManager=WSManager.getInstance();
              
          VMManager vmManager=VMManager.getInstance();
          VirtualMachine vm=vmManager.getVmByName(vmName);
          vm.powerOn();
              
          wsManager.deleteVIM();
       }
    */

    /*   
       public void taskMonitor(String vmName) throws VMwareException 
       {
          VMware vmware=new VMware();
          WSManager wsManager=WSManager.getInstance();
          VMManager vmManager=VMManager.getInstance();
          VirtualMachine vm=null;
          //TaskMonitor taskMonitor=new TaskMonitor(500L);
          //taskMonitor.start();
              
          // Start VM
          vm=vmManager.getVmByName("ActiBox05");
          vm.powerOn();
        
          // Start VM
          vm=vmManager.getVmByName("ActiBox2");
          vm.powerOn();
        
          try
          {
     System.in.read();
          }
          catch (IOException e)
              
          {
     // TODO Auto-generated catch block
     e.printStackTrace();
          }
              
          vmware.getTaskMonitor().interrupt();
          wsManager.deleteVIM();
       }
    */

    public void taskCollector() throws VMwareException {
        VMware vmware = new VMware();
        WSManager wsManager = WSManager.getInstance();

        TaskCollector taskCollector = new TaskCollector();
        taskCollector.getHistoryTask();

        wsManager.deleteVIM();
    }

    /*   
       public void networkCRUD() throws VMwareException
       {
          String vmWareHostName="vcenter.siveo.net";
          VMware vmware=new VMware(vmWareHostName,443,"Administrateur","Gd@jJ2009$",false,48000L,1000L);
          WSManager wsManager=WSManager.getInstance();
          VMManager vmManager=VMManager.getInstance();
        
          VMConfiguration vmConfiguration=new VMConfiguration();
          ArrayList<String> networkToAdd=new ArrayList<String>();
        
        
    //      Entity n7
    //      -Name : VM Network 3
    //       -Type : Network
    //       -Value: network-161
    //       -Parent name : network
    //        -Type : Folder
    //        -Value: group-n7
    //
    //      Entity n8
    //      -Name : VM Network
    //       -Type : Network
    //       -Value: network-14
    //       -Parent name : network
    //        -Type : Folder
    //        -Value: group-n7
    //
    //      Entity n9
    //      -Name : VM Network2
    //       -Type : Network
    //       -Value: network-13
    //       -Parent name : network
    //        -Type : Folder
    //        -Value: group-n7
        
              
              
          networkToAdd.add("network-13");
          networkToAdd.add("network-161");
          vmConfiguration.setListOfNetworkID(networkToAdd);
        
          //VirtualMachine vm=vmManager.getVmByName(vmWareHostName, "Windows2003SP2");
          VirtualMachine vm=vmManager.getVmByName(vmWareHostName, "ActiBox15");
              
          vmManager.network(vm, vmConfiguration);
              
          vmware.getTaskMonitor().interrupt();
          wsManager.deleteVIM();
       }
           
    */

    public void getNetworkInfo(String esxName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Initialize Variables
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName(esxName, hostName);
        this.getNetworkInfo(host);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getNetworkInfo(Host host) throws VMwareException {
        HostNetworkSystem hostNetworkSystem = host.getNetworkSystem();

        System.out.println("******** Host Networking Information ********\n");

        System.out.println("----------------------");
        System.out.println("---- Capabilities ----");
        System.out.println("----------------------");
        System.out.println("- canSetPhysicalNicLinkSpeed: "
                + hostNetworkSystem.getCapabilities().isCanSetPhysicalNicLinkSpeed());
        System.out.println(
                "- dhcpOnVnicSupported       : " + hostNetworkSystem.getCapabilities().isDhcpOnVnicSupported());
        System.out.println(
                "- dnsConfigSupported        : " + hostNetworkSystem.getCapabilities().isDnsConfigSupported());
        System.out.println(
                "- ipRouteConfigSupported    : " + hostNetworkSystem.getCapabilities().isIpRouteConfigSupported());

        if (host.getWS().getAPIVersion().equals("4.0") || host.getWS().getAPIVersion().equals("4.1"))
            System.out
                    .println("- ipV6Supported             : " + hostNetworkSystem.getCapabilities().ipV6Supported);

        if (hostNetworkSystem.getCapabilities().getMaxPortGroupsPerVswitch() != null)
            System.out.println("- maxPortGroupsPerVswitch   : "
                    + hostNetworkSystem.getCapabilities().isIpRouteConfigSupported());

        if (hostNetworkSystem.getCapabilities().getNicTeamingPolicy() != null
                && hostNetworkSystem.getCapabilities().getNicTeamingPolicy().length > 0) {
            for (int nbPolicy = 0; nbPolicy < hostNetworkSystem.getCapabilities()
                    .getNicTeamingPolicy().length; nbPolicy++) {
                System.out.println("- nicTeamingPolicy n" + nbPolicy + "      : "
                        + hostNetworkSystem.getCapabilities().getNicTeamingPolicy()[nbPolicy]);
            }
        }

        System.out.println(
                "- ipRouteConfigSupported    : " + hostNetworkSystem.getCapabilities().isIpRouteConfigSupported());
        System.out.println(
                "- supportsNetworkHints      : " + hostNetworkSystem.getCapabilities().isSupportsNetworkHints());
        System.out.println(
                "- supportsNicTeaming        : " + hostNetworkSystem.getCapabilities().isSupportsNicTeaming());
        System.out.println("- supportsVlan              : " + hostNetworkSystem.getCapabilities().isSupportsVlan());
        System.out.println(
                "- usesServiceConsoleNic     : " + hostNetworkSystem.getCapabilities().isUsesServiceConsoleNic());
        System.out.println(
                "- vnicConfigSupported       : " + hostNetworkSystem.getCapabilities().isVnicConfigSupported());
        System.out.println(
                "- vswitchConfigSupported    : " + hostNetworkSystem.getCapabilities().isVswitchConfigSupported());

        System.out.println("");
        System.out.println("-------------------------------------------------------");
        System.out.println("---- IP route configuration of the service console ----");
        System.out.println("-------------------------------------------------------");
        System.out.println("- defaultGateway: "
                + hostNetworkSystem.getNetworkInfo().getConsoleIpRouteConfig().getDefaultGateway());
        System.out.println("- gatewayDevice : "
                + hostNetworkSystem.getNetworkInfo().getConsoleIpRouteConfig().getGatewayDevice());
        if (host.getWS().getAPIVersion().equals("4.0") || host.getWS().getAPIVersion().equals("4.1")) {
            System.out.println("- IpV6DefaultGateway: "
                    + hostNetworkSystem.getNetworkInfo().getConsoleIpRouteConfig().getIpV6DefaultGateway());
            System.out.println("- IpV6GatewayDevice : "
                    + hostNetworkSystem.getNetworkInfo().getConsoleIpRouteConfig().getIpV6GatewayDevice());
        }

        System.out.println("");
        System.out.println("----------------------------------------------------------------------------");
        System.out.println("---- Virtual network adapters configured for use by the service console ----");
        System.out.println("----------------------------------------------------------------------------");
        if (hostNetworkSystem.getNetworkInfo().getConsoleVnic() != null
                && hostNetworkSystem.getNetworkInfo().getConsoleVnic().length > 0) {
            for (int nbVnic = 0; nbVnic < hostNetworkSystem.getNetworkInfo().getConsoleVnic().length; nbVnic++) {
                System.out.println("- VirtualNic n" + nbVnic);
                System.out.println("  - Device   : "
                        + hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getDevice());
                System.out.println(
                        "  - Key      : " + hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getKey());
                if (hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getPort() != null)
                    System.out.println("  - Port     : "
                            + hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getPort());

                System.out.println("  - Portgroup: "
                        + hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getPortgroup());
                System.out.println("  - VirtualNic configuration");
                System.out.println("    - Dhcp: "
                        + hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getSpec().getIp().isDhcp());
                System.out.println("    - IP  : " + hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic]
                        .getSpec().getIp().getIpAddress());
                System.out
                        .println("    - SubnetMask: " + hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic]
                                .getSpec().getIp().getSubnetMask());
                System.out.println("    - Mac : "
                        + hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getSpec().getMac());
                System.out.println("    - PortGroup : "
                        + hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getSpec().getPortgroup());

            }
        }

        System.out.println("");
        System.out.println("-------------------------------------------------------");
        System.out.println("---- DHCP Service instances configured on the host ----");
        System.out.println("-------------------------------------------------------");
        if (hostNetworkSystem.getNetworkInfo().getDhcp() != null
                && hostNetworkSystem.getNetworkInfo().getDhcp().length > 0) {
            for (int nbDhcp = 0; nbDhcp < hostNetworkSystem.getNetworkInfo().getDhcp().length; nbDhcp++) {
                System.out.println("- DHCP n" + nbDhcp);
                System.out
                        .println("  - Key      : " + hostNetworkSystem.getNetworkInfo().getDhcp()[nbDhcp].getKey());
            }
        }

        System.out.println("");
        System.out.println("----------------------------------------------------");
        System.out.println("---- Client-side DNS configuration for the host ----");
        System.out.println("----------------------------------------------------");
        if (hostNetworkSystem.getNetworkInfo().getDnsConfig() != null) {
            if (hostNetworkSystem.getNetworkInfo().getDnsConfig().getAddress() != null
                    && hostNetworkSystem.getNetworkInfo().getDnsConfig().getAddress().length > 0) {
                for (int nbAdress = 0; nbAdress < hostNetworkSystem.getNetworkInfo().getDnsConfig()
                        .getAddress().length; nbAdress++) {
                    System.out.println(" - DNS n" + nbAdress + ": "
                            + hostNetworkSystem.getNetworkInfo().getDnsConfig().getAddress()[nbAdress]);
                }
            }

            System.out.println(" - Is DHCP used to determine DNS configuration automatically: "
                    + hostNetworkSystem.getNetworkInfo().getDnsConfig().isDhcp());
            System.out
                    .println(" - DomainName: " + hostNetworkSystem.getNetworkInfo().getDnsConfig().getDomainName());
            System.out.println(" - HostName: " + hostNetworkSystem.getNetworkInfo().getDnsConfig().getHostName());
            if (hostNetworkSystem.getNetworkInfo().getDnsConfig().getSearchDomain() != null
                    && hostNetworkSystem.getNetworkInfo().getDnsConfig().getSearchDomain().length > 0) {
                for (int nbDomain = 0; nbDomain < hostNetworkSystem.getNetworkInfo().getDnsConfig()
                        .getSearchDomain().length; nbDomain++) {
                    System.out.println(" - SearchDomain n" + nbDomain + ": "
                            + hostNetworkSystem.getNetworkInfo().getDnsConfig().getSearchDomain()[nbDomain]);
                }

            }
            System.out.println(" - virtualNicDevice: "
                    + hostNetworkSystem.getNetworkInfo().getDnsConfig().getVirtualNicDevice());

        }

        System.out.println("");
        System.out.println("--------------------------------------------");
        System.out.println("---- IP route configuration of the host ----");
        System.out.println("--------------------------------------------");
        System.out.println(
                "- defaultGateway: " + hostNetworkSystem.getNetworkInfo().getIpRouteConfig().getDefaultGateway());
        System.out.println(
                "- gatewayDevice : " + hostNetworkSystem.getNetworkInfo().getIpRouteConfig().getGatewayDevice());
        if (host.getWS().getAPIVersion().equals("4.0") || host.getWS().getAPIVersion().equals("4.1")) {
            System.out.println("- IpV6DefaultGateway: "
                    + hostNetworkSystem.getNetworkInfo().getIpRouteConfig().getIpV6DefaultGateway());
            System.out.println("- IpV6GatewayDevice : "
                    + hostNetworkSystem.getNetworkInfo().getIpRouteConfig().getIpV6GatewayDevice());
        }

        System.out.println("");
        System.out.println("---------------------------------------------------------");
        System.out.println("---- Virtual network adapters configured on the host ----");
        System.out.println("---------------------------------------------------------");
        if (hostNetworkSystem.getNetworkInfo().getVnic() != null
                && hostNetworkSystem.getNetworkInfo().getVnic().length > 0) {
            for (int nbVnicAd = 0; nbVnicAd < hostNetworkSystem.getNetworkInfo().getVnic().length; nbVnicAd++) {
                System.out.println("Virtual NIC n" + nbVnicAd);
                System.out
                        .println("- Device: " + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getDevice());
                System.out.println("- Key   : " + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getKey());
                System.out.println("- Port  : " + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getPort());
                System.out.println(
                        "- Portgroup: " + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getPortgroup());
                System.out.println("- Configuration: "
                        + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getPortgroup());
                System.out.println("    - Dhcp: "
                        + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getIp().isDhcp());
                System.out.println("    - IP  : "
                        + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getIp().getIpAddress());
                System.out.println("    - SubnetMask: "
                        + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getIp().getSubnetMask());
                System.out.println(
                        "    - Mac : " + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getMac());
                System.out.println("    - PortGroup : "
                        + hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getPortgroup());
            }
        }

        System.out.println("");
        System.out.println("-------------------------------------------------");
        System.out.println("---- Virtual switches configured on the host ----");
        System.out.println("-------------------------------------------------");
        if (hostNetworkSystem.getNetworkInfo().getVswitch() != null
                && hostNetworkSystem.getNetworkInfo().getVswitch().length > 0) {
            for (int nbSwitch = 0; nbSwitch < hostNetworkSystem.getNetworkInfo().getVswitch().length; nbSwitch++) {
                System.out.println("Switch n" + nbSwitch);
                System.out.println("- Key : " + hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getKey());
                System.out.println("- mtu : " + hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getMtu());
                System.out
                        .println("- name: " + hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getName());
                System.out.println(
                        "- numPorts: " + hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getNumPorts());
                System.out.println("- numPortsAvailable: "
                        + hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getNumPortsAvailable());
                if (hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPnic() != null
                        && hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPnic().length > 0) {
                    for (int nbPnic = 0; nbPnic < hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch]
                            .getPnic().length; nbPnic++) {
                        System.out.println("- Physical Network Adapters n" + nbPnic + ": "
                                + hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPnic()[nbPnic]);
                    }
                }

                if (hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPortgroup() != null
                        && hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPortgroup().length > 0) {
                    for (int nbPortGroup = 0; nbPortGroup < hostNetworkSystem.getNetworkInfo()
                            .getVswitch()[nbSwitch].getPortgroup().length; nbPortGroup++) {
                        System.out.println("- Portgroup n" + nbPortGroup + ": "
                                + hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch]
                                        .getPortgroup()[nbPortGroup]);
                    }
                }

            }
        }

        System.out.println("");
        System.out.println("--------------------------------------------");
        System.out.println("---- Port groups configured on the host ----");
        System.out.println("--------------------------------------------");
        HostPortGroup[] hostPortGroupList = hostNetworkSystem.getNetworkInfo().getPortgroup();
        if (hostPortGroupList != null && hostPortGroupList.length > 0) {
            for (int nbPortGroup = 0; nbPortGroup < hostPortGroupList.length; nbPortGroup++) {
                System.out.println("PortGroup n" + nbPortGroup);
                System.out.println("- key: " + hostPortGroupList[nbPortGroup].getKey());
                if (hostPortGroupList[nbPortGroup].getPort() != null
                        && hostPortGroupList[nbPortGroup].getPort().length > 0) {
                    for (int nbPort = 0; nbPort < hostPortGroupList[nbPortGroup].getPort().length; nbPort++) {
                        System.out.println("- Port n" + nbPort);
                        System.out
                                .println("  - Key : " + hostPortGroupList[nbPortGroup].getPort()[nbPort].getKey());
                        if (hostPortGroupList[nbPortGroup].getPort()[nbPort].getMac() != null
                                && hostPortGroupList[nbPortGroup].getPort()[nbPort].getMac().length > 0) {
                            for (int nbMac = 0; nbMac < hostPortGroupList[nbPortGroup].getPort()[nbPort]
                                    .getMac().length; nbMac++) {
                                System.out.println("  - Mac n" + nbMac + ": "
                                        + hostPortGroupList[nbPortGroup].getPort()[nbPort].getMac()[nbMac]);
                            }
                        }
                        System.out
                                .println("  - Type: " + hostPortGroupList[nbPortGroup].getPort()[nbPort].getType());
                    }
                }

                if (hostPortGroupList[nbPortGroup].getSpec() != null) {
                    System.out.println("- Spec");
                    System.out.println("  - Name   : " + hostPortGroupList[nbPortGroup].getSpec().getName());
                    System.out.println("  - vlanId : " + hostPortGroupList[nbPortGroup].getSpec().getVlanId());
                    System.out.println("  - Virtual Switch Name: "
                            + hostPortGroupList[nbPortGroup].getSpec().getVswitchName());
                }

                System.out.println("- vSwitch: " + hostPortGroupList[nbPortGroup].getVswitch());

            }
        }

        System.out.println("");
        System.out.println("-----------------------------------");
        System.out.println("---- Physical network adapters ----");
        System.out.println("-----------------------------------");
        if (hostNetworkSystem.getNetworkInfo().getPnic() != null
                && hostNetworkSystem.getNetworkInfo().getPnic().length > 0) {
            PhysicalNic[] pnicTab = hostNetworkSystem.getNetworkInfo().getPnic();
            PhysicalNicHintInfo[] pTabNicHintInfo = null;
            PhysicalNicHintInfo pnicHintInfo = null;

            for (int nbPnic = 0; nbPnic < pnicTab.length; nbPnic++) {
                System.out.println("Physical network adapter n" + nbPnic);
                System.out.println("- device : " + pnicTab[nbPnic].getDevice());
                System.out.println("- driver : " + pnicTab[nbPnic].getDriver());
                System.out.println("- key    : " + pnicTab[nbPnic].getKey());
                System.out.println("- duplex : " + pnicTab[nbPnic].getLinkSpeed().isDuplex());
                System.out.println("- speedMb: " + pnicTab[nbPnic].getLinkSpeed().getSpeedMb());
                System.out.println("- mac    : " + pnicTab[nbPnic].getMac());
                System.out.println("- IP     : " + pnicTab[nbPnic].getSpec().getIp().getIpAddress());
                System.out.println("- Subnet Mask: " + pnicTab[nbPnic].getSpec().getIp().getSubnetMask());

                pTabNicHintInfo = hostNetworkSystem.queryNetworkHint(new String[] { pnicTab[nbPnic].getDevice() });
                if (pTabNicHintInfo != null && pTabNicHintInfo.length > 0) {
                    PhysicalNicNameHint[] networkNameList = null;
                    PhysicalNicIpHint[] subnetList = null;

                    for (int nbHit = 0; nbHit < pTabNicHintInfo.length; nbHit++) {
                        pnicHintInfo = pTabNicHintInfo[nbHit];
                        networkNameList = pnicHintInfo.getNetwork();
                        if (networkNameList != null && networkNameList.length > 0) {
                            for (int nbNetworkName = 0; nbNetworkName < networkNameList.length; nbNetworkName++) {
                                System.out.println("- Network Name n" + nbNetworkName + ": "
                                        + networkNameList[nbNetworkName].getNetwork());
                            }
                        }

                        subnetList = pnicHintInfo.getSubnet();
                        if (subnetList != null && subnetList.length > 0) {
                            for (int nbsubnet = 0; nbsubnet < subnetList.length; nbsubnet++) {
                                System.out.println(
                                        "- Subnet Range n" + nbsubnet + ": " + subnetList[nbsubnet].getIpSubnet());
                            }
                        }

                    }

                    System.out.println("");
                }

            }

        }

    }

    /*   
       public void getHostNetworkInfo(String hostName) throws VMwareException 
       {
          VMware vmware=new VMware();
          WSManager wsManager=WSManager.getInstance();
        
          HostManager hostManager=HostManager.getInstance();
          Host host=hostManager.getHost(hostName);
              
          HostNetworkSystem hostNetworkSystem=host.getNetworkSystem();
        
          System.out.println("******** Host Networking Information ********\n");
        
          System.out.println("----------------------");
          System.out.println("---- Capabilities ----");
          System.out.println("----------------------");
          System.out.println("- canSetPhysicalNicLinkSpeed: "+hostNetworkSystem.getCapabilities().isCanSetPhysicalNicLinkSpeed());
          System.out.println("- dhcpOnVnicSupported       : "+hostNetworkSystem.getCapabilities().isDhcpOnVnicSupported());
          System.out.println("- dnsConfigSupported        : "+hostNetworkSystem.getCapabilities().isDnsConfigSupported());
          System.out.println("- ipRouteConfigSupported    : "+hostNetworkSystem.getCapabilities().isIpRouteConfigSupported());
              
          if (host.getWS().getAPIVersion().equals("4.0") || host.getWS().getAPIVersion().equals("4.1"))
     System.out.println("- ipV6Supported             : "+hostNetworkSystem.getCapabilities().ipV6Supported);
              
          if (hostNetworkSystem.getCapabilities().getMaxPortGroupsPerVswitch()!=null)
     System.out.println("- maxPortGroupsPerVswitch   : "+hostNetworkSystem.getCapabilities().isIpRouteConfigSupported());
        
          if (hostNetworkSystem.getCapabilities().getNicTeamingPolicy()!=null && hostNetworkSystem.getCapabilities().getNicTeamingPolicy().length>0)
          {
     for (int nbPolicy=0;nbPolicy<hostNetworkSystem.getCapabilities().getNicTeamingPolicy().length;nbPolicy++)
     {
        System.out.println("- nicTeamingPolicy n"+nbPolicy+"      : "+hostNetworkSystem.getCapabilities().getNicTeamingPolicy()[nbPolicy]);
     }
          }
        
          System.out.println("- ipRouteConfigSupported    : "+hostNetworkSystem.getCapabilities().isIpRouteConfigSupported());
          System.out.println("- supportsNetworkHints      : "+hostNetworkSystem.getCapabilities().isSupportsNetworkHints());
          System.out.println("- supportsNicTeaming        : "+hostNetworkSystem.getCapabilities().isSupportsNicTeaming());
          System.out.println("- supportsVlan              : "+hostNetworkSystem.getCapabilities().isSupportsVlan());
          System.out.println("- usesServiceConsoleNic     : "+hostNetworkSystem.getCapabilities().isUsesServiceConsoleNic());
          System.out.println("- vnicConfigSupported       : "+hostNetworkSystem.getCapabilities().isVnicConfigSupported());
          System.out.println("- vswitchConfigSupported    : "+hostNetworkSystem.getCapabilities().isVswitchConfigSupported());
        
        
          System.out.println("");
          System.out.println("-------------------------------------------------------");
          System.out.println("---- IP route configuration of the service console ----");
          System.out.println("-------------------------------------------------------");
          System.out.println("- defaultGateway: "+hostNetworkSystem.getNetworkInfo().getConsoleIpRouteConfig().getDefaultGateway());
          System.out.println("- gatewayDevice : "+hostNetworkSystem.getNetworkInfo().getConsoleIpRouteConfig().getGatewayDevice());
          if (host.getWS().getAPIVersion().equals("4.0") || host.getWS().getAPIVersion().equals("4.1"))
          {
     System.out.println("- IpV6DefaultGateway: "+hostNetworkSystem.getNetworkInfo().getConsoleIpRouteConfig().getIpV6DefaultGateway());
     System.out.println("- IpV6GatewayDevice : "+hostNetworkSystem.getNetworkInfo().getConsoleIpRouteConfig().getIpV6GatewayDevice());
          }
        
        
          System.out.println("");
          System.out.println("----------------------------------------------------------------------------");
          System.out.println("---- Virtual network adapters configured for use by the service console ----");
          System.out.println("----------------------------------------------------------------------------");
          if (hostNetworkSystem.getNetworkInfo().getConsoleVnic()!=null && hostNetworkSystem.getNetworkInfo().getConsoleVnic().length>0)
          {
     for (int nbVnic=0;nbVnic<hostNetworkSystem.getNetworkInfo().getConsoleVnic().length;nbVnic++)
     {
        System.out.println("- VirtualNic n"+nbVnic);
        System.out.println("  - Device   : "+hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getDevice());
        System.out.println("  - Key      : "+hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getKey());
        if (hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getPort()!=null)
           System.out.println("  - Port     : "+hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getPort());
            
        System.out.println("  - Portgroup: "+hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getPortgroup());
        System.out.println("  - VirtualNic configuration");
        System.out.println("    - Dhcp: "+hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getSpec().getIp().isDhcp());
        System.out.println("    - IP  : "+hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getSpec().getIp().getIpAddress());
        System.out.println("    - SubnetMask: "+hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getSpec().getIp().getSubnetMask());
        System.out.println("    - Mac : "+hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getSpec().getMac());
        System.out.println("    - PortGroup : "+hostNetworkSystem.getNetworkInfo().getConsoleVnic()[nbVnic].getSpec().getPortgroup());
            
     }
          }
        
          System.out.println("");
          System.out.println("-------------------------------------------------------");
          System.out.println("---- DHCP Service instances configured on the host ----");
          System.out.println("-------------------------------------------------------");
          if (hostNetworkSystem.getNetworkInfo().getDhcp()!=null && hostNetworkSystem.getNetworkInfo().getDhcp().length>0)
          {
     for (int nbDhcp=0;nbDhcp<hostNetworkSystem.getNetworkInfo().getDhcp().length;nbDhcp++)
     {
        System.out.println("- DHCP n"+nbDhcp);
        System.out.println("  - Key      : "+hostNetworkSystem.getNetworkInfo().getDhcp()[nbDhcp].getKey());
     }
          }
        
              
          System.out.println("");
          System.out.println("----------------------------------------------------");
          System.out.println("---- Client-side DNS configuration for the host ----");
          System.out.println("----------------------------------------------------");
          if (hostNetworkSystem.getNetworkInfo().getDnsConfig()!=null)
          {
     if (hostNetworkSystem.getNetworkInfo().getDnsConfig().getAddress()!=null && hostNetworkSystem.getNetworkInfo().getDnsConfig().getAddress().length>0)
     {
        for (int nbAdress=0;nbAdress<hostNetworkSystem.getNetworkInfo().getDnsConfig().getAddress().length;nbAdress++)
        {
           System.out.println(" - DNS n"+nbAdress+": "+hostNetworkSystem.getNetworkInfo().getDnsConfig().getAddress()[nbAdress]);   
        }
     }   
        
     System.out.println(" - Is DHCP used to determine DNS configuration automatically: "+hostNetworkSystem.getNetworkInfo().getDnsConfig().isDhcp());   
     System.out.println(" - DomainName: "+hostNetworkSystem.getNetworkInfo().getDnsConfig().getDomainName());   
     System.out.println(" - HostName: "+hostNetworkSystem.getNetworkInfo().getDnsConfig().getHostName());   
     if (hostNetworkSystem.getNetworkInfo().getDnsConfig().getSearchDomain()!=null && hostNetworkSystem.getNetworkInfo().getDnsConfig().getSearchDomain().length>0)
     {
        for (int nbDomain=0;nbDomain<hostNetworkSystem.getNetworkInfo().getDnsConfig().getSearchDomain().length;nbDomain++)
        {
           System.out.println(" - SearchDomain n"+nbDomain+": "+hostNetworkSystem.getNetworkInfo().getDnsConfig().getSearchDomain()[nbDomain]);   
        }
               
     }
     System.out.println(" - virtualNicDevice: "+hostNetworkSystem.getNetworkInfo().getDnsConfig().getVirtualNicDevice());   
        
        
          }
        
          System.out.println("");
          System.out.println("--------------------------------------------");
          System.out.println("---- IP route configuration of the host ----");
          System.out.println("--------------------------------------------");
          System.out.println("- defaultGateway: "+hostNetworkSystem.getNetworkInfo().getIpRouteConfig().getDefaultGateway());
          System.out.println("- gatewayDevice : "+hostNetworkSystem.getNetworkInfo().getIpRouteConfig().getGatewayDevice());
          if (host.getWS().getAPIVersion().equals("4.0") || host.getWS().getAPIVersion().equals("4.1"))
          {
     System.out.println("- IpV6DefaultGateway: "+hostNetworkSystem.getNetworkInfo().getIpRouteConfig().getIpV6DefaultGateway());
     System.out.println("- IpV6GatewayDevice : "+hostNetworkSystem.getNetworkInfo().getIpRouteConfig().getIpV6GatewayDevice());
          }
              
        
          System.out.println("");
          System.out.println("---------------------------------------------------------");
          System.out.println("---- Virtual network adapters configured on the host ----");
          System.out.println("---------------------------------------------------------");
          if (hostNetworkSystem.getNetworkInfo().getVnic()!=null && hostNetworkSystem.getNetworkInfo().getVnic().length>0)
          {
     for (int nbVnicAd=0;nbVnicAd<hostNetworkSystem.getNetworkInfo().getVnic().length;nbVnicAd++)
     {
        System.out.println("Virtual NIC n"+nbVnicAd);
        System.out.println("- Device: "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getDevice());
        System.out.println("- Key   : "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getKey());
        System.out.println("- Port  : "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getPort());
        System.out.println("- Portgroup: "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getPortgroup());
        System.out.println("- Configuration: "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getPortgroup());
        System.out.println("    - Dhcp: "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getIp().isDhcp());
        System.out.println("    - IP  : "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getIp().getIpAddress());
        System.out.println("    - SubnetMask: "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getIp().getSubnetMask());
        System.out.println("    - Mac : "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getMac());
        System.out.println("    - PortGroup : "+hostNetworkSystem.getNetworkInfo().getVnic()[nbVnicAd].getSpec().getPortgroup());
     }
          }
              
              
          System.out.println("");
          System.out.println("-------------------------------------------------");
          System.out.println("---- Virtual switches configured on the host ----");
          System.out.println("-------------------------------------------------");
          if (hostNetworkSystem.getNetworkInfo().getVswitch()!=null && hostNetworkSystem.getNetworkInfo().getVswitch().length>0)
          {
     for (int nbSwitch=0;nbSwitch<hostNetworkSystem.getNetworkInfo().getVswitch().length;nbSwitch++)
     {
        System.out.println("Switch n"+nbSwitch);
        System.out.println("- Key : "+hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getKey());
        System.out.println("- mtu : "+hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getMtu());
        System.out.println("- name: "+hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getName());
        System.out.println("- numPorts: "+hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getNumPorts());
        System.out.println("- numPortsAvailable: "+hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getNumPortsAvailable());
        if (hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPnic()!=null && hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPnic().length>0)
        {
           for (int nbPnic=0;nbPnic<hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPnic().length;nbPnic++)
           {
              System.out.println("- Physical Network Adapters n"+nbPnic+": "+hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPnic()[nbPnic]);
           }
        }
        
        
        if (hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPortgroup()!=null && hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPortgroup().length>0)
        {
           for (int nbPortGroup=0;nbPortGroup<hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPortgroup().length;nbPortGroup++)
           {
              System.out.println("- Portgroup n"+nbPortGroup+": "+hostNetworkSystem.getNetworkInfo().getVswitch()[nbSwitch].getPortgroup()[nbPortGroup]);
           }
        }
        
                     
         
     }
          }
        
              
          System.out.println("");
          System.out.println("--------------------------------------------");
          System.out.println("---- Port groups configured on the host ----");
          System.out.println("--------------------------------------------");
          HostPortGroup[] hostPortGroupList=hostNetworkSystem.getNetworkInfo().getPortgroup(); 
          if (hostPortGroupList!=null && hostPortGroupList.length>0)
          {
     for (int nbPortGroup=0;nbPortGroup<hostPortGroupList.length;nbPortGroup++)
     {
        System.out.println("PortGroup n"+nbPortGroup);
        System.out.println("- key: "+hostPortGroupList[nbPortGroup].getKey());
        if (hostPortGroupList[nbPortGroup].getPort()!=null && hostPortGroupList[nbPortGroup].getPort().length>0)
        {
           for (int nbPort=0;nbPort<hostPortGroupList[nbPortGroup].getPort().length;nbPort++)
           {
              System.out.println("- Port n"+nbPort);
              System.out.println("  - Key : "+hostPortGroupList[nbPortGroup].getPort()[nbPort].getKey());
              if (hostPortGroupList[nbPortGroup].getPort()[nbPort].getMac()!=null && hostPortGroupList[nbPortGroup].getPort()[nbPort].getMac().length>0)
              {
                 for (int nbMac=0;nbMac<hostPortGroupList[nbPortGroup].getPort()[nbPort].getMac().length;nbMac++)
                 {
                    System.out.println("  - Mac n"+nbMac+": "+hostPortGroupList[nbPortGroup].getPort()[nbPort].getMac()[nbMac]);
                 }
              }
              System.out.println("  - Type: "+hostPortGroupList[nbPortGroup].getPort()[nbPort].getType());
           }
        }
        
        if (hostPortGroupList[nbPortGroup].getSpec()!=null)
        {
           System.out.println("- Spec");
           System.out.println("  - Name   : "+hostPortGroupList[nbPortGroup].getSpec().getName());
           System.out.println("  - vlanId : "+hostPortGroupList[nbPortGroup].getSpec().getVlanId());
           System.out.println("  - Virtual Switch Name: "+hostPortGroupList[nbPortGroup].getSpec().getVswitchName());
        }
        
        System.out.println("- vSwitch: "+hostPortGroupList[nbPortGroup].getVswitch());
         
     }
          }
              
              
              
        
          System.out.println("");
          System.out.println("-----------------------------------");
          System.out.println("---- Physical network adapters ----");
          System.out.println("-----------------------------------");
          if (hostNetworkSystem.getNetworkInfo().getPnic()!=null && hostNetworkSystem.getNetworkInfo().getPnic().length>0)
          {
     PhysicalNic[] pnicTab=hostNetworkSystem.getNetworkInfo().getPnic();
     PhysicalNicHintInfo[] pTabNicHintInfo=null;
     PhysicalNicHintInfo pnicHintInfo=null;
         
         
     for (int nbPnic=0;nbPnic<pnicTab.length;nbPnic++)
     {
        System.out.println("Physical network adapter n"+nbPnic);
        System.out.println("- device : "+pnicTab[nbPnic].getDevice());
        System.out.println("- driver : "+pnicTab[nbPnic].getDriver());
        System.out.println("- key    : "+pnicTab[nbPnic].getKey());
        System.out.println("- duplex : "+pnicTab[nbPnic].getLinkSpeed().isDuplex());
        System.out.println("- speedMb: "+pnicTab[nbPnic].getLinkSpeed().getSpeedMb());
        System.out.println("- mac    : "+pnicTab[nbPnic].getMac());
        System.out.println("- IP     : "+pnicTab[nbPnic].getSpec().getIp().getIpAddress());
        System.out.println("- Subnet Mask: "+pnicTab[nbPnic].getSpec().getIp().getSubnetMask());
              
            
        pTabNicHintInfo=hostNetworkSystem.queryNetworkHint(new String[]{pnicTab[nbPnic].getDevice()});
        if (pTabNicHintInfo!=null && pTabNicHintInfo.length>0)
        {
           PhysicalNicNameHint[] networkNameList=null;
           PhysicalNicIpHint[] subnetList=null;
               
           for (int nbHit=0;nbHit<pTabNicHintInfo.length;nbHit++)
           {
              pnicHintInfo=pTabNicHintInfo[nbHit];
              networkNameList=pnicHintInfo.getNetwork();
              if (networkNameList!=null && networkNameList.length>0)
              {
                 for (int nbNetworkName=0;nbNetworkName<networkNameList.length;nbNetworkName++)
                 {
                    System.out.println("- Network Name n"+nbNetworkName+": "+networkNameList[nbNetworkName].getNetwork());
                 }
              }
                  
              subnetList=pnicHintInfo.getSubnet();
              if (subnetList!=null && subnetList.length>0)
              {
                 for (int nbsubnet=0;nbsubnet<subnetList.length;nbsubnet++)
                 {
                    System.out.println("- Subnet Range n"+nbsubnet+": "+subnetList[nbsubnet].getIpSubnet());
                 }
              }
                  
           }
               
           System.out.println("");
        }
            
     }
              
              
              
          }
              
              
              
          vmware.getTaskMonitor().interrupt();
          wsManager.deleteVIM();
       }
    */

    public void createInventoryview() throws VMwareException {
        VMware vmware = new VMware();
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getAllWS().get(0);

        ArrayOfManagedObjectReference arrOfEntity = null;
        ManagedObjectReference[] entityView = null;
        ManagedObjectReference[] entityArr = null;
        //ArrayOfManagedObjectReference morArr=new ArrayOfManagedObjectReference();
        ArrayOfManagedObjectReference morArr = null;
        String name = null;

        // Get the ViewManager
        ManagedObjectReference viewManager = ws.getVIMService().getServiceContent().getViewManager();

        System.out.println("ViewManager: " + viewManager);

        // Create the InventoryView
        ManagedObjectReference inventoryView = null;
        try {
            inventoryView = ws.getVIMService().getService().createInventoryView(viewManager);
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("InventoryView: " + inventoryView);
        System.out.println("Root Folder: " + ws.getVIMService().getServiceContent().getRootFolder().get_value());

        // Get ManagedObjectReference of an invetory objetc
        //ManagedObjectReference mor=MorManager.getMorRef(ws, null, "VirtualMachine", "VMTest2");
        //ManagedObjectReference mor=MorManager.getMorRef(ws, null, "Datacenter", "SiveoDC");
        //ManagedObjectReference mor=MorManager.getMorRef(ws, null, "Folder", "SIVEO");
        ManagedObjectReference mor = ws.getVIMService().getServiceContent().getRootFolder();
        System.out.println("Object ManagedObjectReference: " + mor);

        //ManagedObjectReference morDC=MorManager.getMorRef(ws, null, "Datacenter", "SiveoDC");
        //Datacenter dc=new Datacenter(ws, morDC);

        // Open the view associated to the object

        //entityArr=new ManagedObjectReference[] {mor};
        //morArr.setManagedObjectReference(entityArr);

        try {
            ws.getVIMService().getService().closeInventoryViewFolder(inventoryView,
                    new ManagedObjectReference[] { ws.getVIMService().getServiceContent().getRootFolder() });
        } catch (RuntimeFault e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        entityArr = new ManagedObjectReference[1];
        //entityArr[0]=mor;
        //entityArr[0]=dc.getDatastoreFolder();
        entityArr[0] = ws.getVIMService().getServiceContent().getRootFolder();

        try {
            //arrOfEntity=ws.getVIMService().getService().openInventoryViewFolder(inventoryView, morArr);
            entityView = ws.getVIMService().getService().openInventoryViewFolder(inventoryView, entityArr);
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("entity view Size: " + entityView);
        //System.out.println("entity view Size: "+arrOfEntity.getManagedObjectReference().length);
        //System.out.println("entity view Size: "+entityView.length);

        morArr = (ArrayOfManagedObjectReference) MorManager.getMorProperty(ws, inventoryView,
                new String[] { "view" });

        System.out.println("morArr: " + morArr);
        name = null;
        if (morArr != null && morArr.getManagedObjectReference() != null
                && morArr.getManagedObjectReference().length > 0) {
            entityArr = morArr.getManagedObjectReference();
            for (int nbEntity = 0; nbEntity < entityArr.length; nbEntity++) {
                System.out.println("Entity n" + nbEntity);
                name = (String) MorManager.getMorProperty(ws, entityArr[nbEntity], new String[] { "name" });
                System.out.println("-name : " + name);
                System.out.println("-type : " + entityArr[nbEntity].getType());
                System.out.println("-value: " + entityArr[nbEntity].get_value());
            }
        }

        wsManager.deleteVIM();
    }

    public void listContainerView() throws VMwareException {
        ManagedObjectReference containerView = null;
        ManagedObjectReference parent = null;
        String parentName = null;

        WSManager wsManager = WSManager.getInstance();
        WS ws = null;

        try {
            //ws=wsManager.createVIM("vcenter25u6",443,"Administrateur","Gd@jJ2009$",false,48000L);
            //System.out.println("connexion VirtualCenter 3.5 -> OK");

            //ws=wsManager.createVIM("10.251.5.14",443,"Administrateur","Clmdp@09",false,480000L);
            ws = wsManager.createVIM("10.0.12.6", 443, "siveo_admin", "s1v3oP0C", false, 480000L);

            //ws=wsManager.createVIM("vpshere-4-1",443,"Administrateur","Gd@jJ2009$",false,480000L);
            //System.out.println("connexion Vsphere 4.0.1 -> OK");

        } catch (VMwareException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        ArrayOfManagedObjectReference arrOfEntity = null;
        ManagedObjectReference[] entityView = null;
        ManagedObjectReference[] entityArr = null;
        //ArrayOfManagedObjectReference morArr=new ArrayOfManagedObjectReference();
        ArrayOfManagedObjectReference morArr = null;
        String name = null;

        // Get the ViewManager
        ManagedObjectReference viewManager = ws.getVIMService().getServiceContent().getViewManager();

        //System.out.println("ViewManager: "+viewManager);

        // Get the mor
        //ManagedObjectReference mor=MorManager.getMorRef(ws, null, "Datacenter", "SiveoDC");
        ManagedObjectReference mor = ws.getVIMService().getServiceContent().getRootFolder();
        //ManagedObjectReference mor=MorManager.getMorRef(ws, null, "Folder", "BULL_FOLDER");

        //Create the container view
        try {
            containerView = ws.getVIMService().getService().createContainerView(viewManager, mor, new String[] {},
                    true);
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        morArr = (ArrayOfManagedObjectReference) MorManager.getMorProperty(ws, containerView,
                new String[] { "view" });

        //System.out.println("morArr: "+morArr);
        name = null;
        if (morArr != null && morArr.getManagedObjectReference() != null
                && morArr.getManagedObjectReference().length > 0) {
            entityArr = morArr.getManagedObjectReference();
            for (int nbEntity = 0; nbEntity < entityArr.length; nbEntity++) {

                name = (String) MorManager.getMorProperty(ws, entityArr[nbEntity], new String[] { "name" });
                //if (!name.equals("vm") && !name.equals("host") && !name.equals("datastore") && !name.equals("network") && !name.equals("Resources"))
                //{
                parent = (ManagedObjectReference) MorManager.getMorProperty(ws, entityArr[nbEntity],
                        new String[] { "parent" });
                parentName = (String) MorManager.getMorProperty(ws, parent, new String[] { "name" });

                System.out.println("Entity n" + nbEntity);
                System.out.println("-Name : " + name);
                System.out.println(" -Type : " + entityArr[nbEntity].getType());
                System.out.println(" -Value: " + entityArr[nbEntity].get_value());
                System.out.println(" -Parent name : " + parentName);
                System.out.println("  -Type : " + parent.getType());
                System.out.println("  -Value: " + parent.get_value());
                System.out.println("");

                //}
            }
        }

        wsManager.deleteVIM();

    }

    public void createContainerView() throws VMwareException {
        // Retrieve all the roles defined and the privileges associated
        // Build a HashMpap<String (roleID),Role>

        // Retrieve all permissions defined
        // Build HashMaps:
        // vmList=HashMap<String (VMname),VirtualMachine>
        // 

        WS ws = null;
        WSManager wsManager = WSManager.getInstance();

        //String hostName="10.251.5.15";
        //ManagedObjectReference containerView=null;
        ManagedObjectReference parent = null;
        String parentName = null;

        //VMware vmware=new VMware("10.251.5.14",443,"Administrateur","Clmdp@09",false,480000L,1000L);
        //VMware vmware=new VMware("10.251.5.14",443,"Administrateur","Clmdp@09",false,480000L,1000L);
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L,1000L);
        //VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,-1L,1000L);
        //VMware.create(hostName,443,"dgme_admin","s1v3oP0C",false,-1L,1000L);
        //VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,-1L,1000L);
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        // ===================================================================================
        // Create the VMware WebService 
        // ===================================================================================
        //String hostName="10.0.12.6";
        //ws=wsManager.createVIM(hostName,443,"siveo_admin","s1v3oP0C",false,-1L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);
        //ws=wsManager.createVIM(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="192.168.101.79";
        //ws=wsManager.createVIM(hostName,443,"svc-siveo","S1v30d6m3",false,-1L);

        //String hostName="10.62.16.34";
        //ws=wsManager.createVIM(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //System.out.println("API version: "+APIVersion.getAPI(hostName, 443));
        // ESXi 6
        //      String hostName="163.172.7.95";
        //      ws=wsManager.createVIM(hostName,443,"eva","cahh4gee$2015",false,-1L);

        //      String hostName="192.168.101.122";
        //      ws=wsManager.createVIM(hostName,443,"root","cahh4gee$",false,-1L);

        //String hostName="192.168.101.110";
        //ws=wsManager.createVIM(hostName,443,"root","mandriva",false,-1L);

        //      String hostName="10.62.16.33";
        //      ws=wsManager.createVIM(hostName,443,"root","cahh4gee$2012",false,-1L);

        //String hostName="192.168.101.58";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        //String hostName="10.62.16.35";
        //ws=wsManager.createVIM(hostName,443,"root","cahh4gee$2012",false,-1L);

        //String hostName="10.62.16.31";
        //ws=wsManager.createVIM(hostName,443,"root","cahh4gee$",false,-1L);

        // Keonys ESX ING2
        String hostName = "10.10.0.64";
        ws = wsManager.createVIM(hostName, 443, "root", "Keonys123", false, -1L);

        ws = wsManager.getWS(hostName);

        String name = null;

        ManagedObjectReference rootFolder = ws.getVIMService().getServiceContent().getRootFolder();
        System.out.println("RootFolder: " + rootFolder.get_value() + " / " + rootFolder.getType());

        //name=(String)MorManager.getMorProperty(ws.getVIMService(),rootFolder, new String[] {"name"});

        //      ManagedObjectReference hostMor=new ManagedObjectReference();
        //      hostMor.set_value("host-28");
        //      hostMor.setType("HostSystem");
        //      
        //      ManagedObjectReference computeResourceMor=new ManagedObjectReference();
        //      computeResourceMor.set_value("domain-c77");
        //      computeResourceMor.setType("ClusterComputeResource");
        //
        //      
        //      ArrayOfManagedObjectReference morArrOf=null;
        //      Date dta01=new Date(); 
        //      morArrOf=(ArrayOfManagedObjectReference)MorManager.getMorProperty(ws.getVIMService(), hostMor, new String[] {"vm"});
        //      Date dta02=new Date(); 
        //      
        //      System.out.println("Rcup Host VM Property: "+(dta02.getTime()-dta01.getTime()));

        //Create the container view
        ViewManager viewManager = ViewManager.getInstance();
        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();

        Date dt01 = new Date();
        listOfManagedObjectReferences = viewManager.createContainerView(hostName, rootFolder);
        Date dt02 = new Date();

        /*
        try
        {
           dt03=new Date();
           containerView=ws.getVIMService().getService().createContainerView(viewManager,hostMor, new String[]{}, true);
           dt04=new Date();
        }
        catch (RuntimeFault e)
        {
           // TODO Auto-generated catch block
           e.printStackTrace();
        } catch (RemoteException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }
            
        Date dt05=new Date();
        morArr=(ArrayOfManagedObjectReference)MorManager.getMorProperty(ws.getVIMService(),containerView, new String[] {"view"});
        Date dt06=new Date();
        */

        //System.out.println("Temps d'appel: ");
        //System.out.println("- Get the ViewManager : "+(dt02.getTime()-dt01.getTime()));
        //System.out.println("- Create ContainerView: "+(dt04.getTime()-dt03.getTime()));
        //System.out.println("- GetMorProperty      : "+(dt06.getTime()-dt05.getTime()));

        //System.out.println("");

        //System.out.println("RootFolder: "+name+" / "+rootFolder.getType() + " / "+rootFolder.get_value());

        //System.out.println("morArr: "+morArr);
        name = null;
        Date dt03 = null;
        Date dt04 = null;

        if (listOfManagedObjectReferences != null && !listOfManagedObjectReferences.isEmpty()) {
            int nbEntity = 1;

            dt03 = new Date();

            for (ManagedObjectReference mor : listOfManagedObjectReferences) {
                //name=(String)MorManager.getMorProperty(ws.getVIMService(),mor, new String[] {"name"});
                name = (String) MorManager.getMorProperty(ws, mor, new String[] { "name" });
                //if (!name.equals("vm") && !name.equals("host") && !name.equals("datastore") && !name.equals("network") && !name.equals("Resources"))
                //{
                //parent=(ManagedObjectReference)MorManager.getMorProperty(ws.getVIMService(),mor, new String[] {"parent"});
                parent = (ManagedObjectReference) MorManager.getMorProperty(ws, mor, new String[] { "parent" });
                if (parent != null)
                    //parentName=(String)MorManager.getMorProperty(ws.getVIMService(),parent, new String[] {"name"});
                    parentName = (String) MorManager.getMorProperty(ws, parent, new String[] { "name" });

                System.out.println("Entity n" + nbEntity++);
                System.out.println("-Name : " + name);
                System.out.println(" -Type : " + mor.getType());
                System.out.println(" -Value: " + mor.get_value());
                System.out.println(" -Parent name : " + parentName);
                if (parent != null) {
                    System.out.println("  -Type : " + parent.getType());
                    System.out.println("  -Value: " + parent.get_value());
                }
                System.out.println("");

            }

            dt04 = new Date();
        }

        System.out.println("createContainerView: " + (dt02.getTime() - dt01.getTime()));
        //System.out.println("Browse Nodes: "+(dt04.getTime()-dt03.getTime()));

        VMware.delete(hostName);

        //ws.getVIMService().logout();
        //wsManager.deleteWS(ws);

        //vmware.getTaskMonitor().interrupt();
        //wsManager.deleteVIM();
    }

    public void createDCContainerView() throws VMwareException {

        WS ws = null;
        WSManager wsManager = WSManager.getInstance();

        //String hostName="10.251.5.15";
        //ManagedObjectReference containerView=null;
        ManagedObjectReference parent = null;
        String parentName = null;

        // ===================================================================================
        // Create the VMware WebService 
        // ===================================================================================
        //String hostName="10.0.12.6";
        //ws=wsManager.createVIM(hostName,443,"siveo_admin","s1v3oP0C",false,-1L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);
        //ws=wsManager.createVIM(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="192.168.101.79";
        //ws=wsManager.createVIM(hostName,443,"svc-siveo","S1v30d6m3",false,-1L);

        String hostName = "10.251.5.14";
        ws = wsManager.createVIM(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //ws=wsManager.createVIM(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        ws = wsManager.getWS(hostName);

        String name = null;

        ManagedObjectReference rootFolder = ws.getVIMService().getServiceContent().getRootFolder();
        //name=(String)MorManager.getMorProperty(ws.getVIMService(),rootFolder, new String[] {"name"});

        //      ManagedObjectReference hostMor=new ManagedObjectReference();
        //      hostMor.set_value("host-28");
        //      hostMor.setType("HostSystem");
        //      
        //      ManagedObjectReference computeResourceMor=new ManagedObjectReference();
        //      computeResourceMor.set_value("domain-c77");
        //      computeResourceMor.setType("ClusterComputeResource");
        //
        //      
        //      ArrayOfManagedObjectReference morArrOf=null;
        //      Date dta01=new Date(); 
        //      morArrOf=(ArrayOfManagedObjectReference)MorManager.getMorProperty(ws.getVIMService(), hostMor, new String[] {"vm"});
        //      Date dta02=new Date(); 
        //      
        //      System.out.println("Rcup Host VM Property: "+(dta02.getTime()-dta01.getTime()));

        //Create the container view
        String[] type = new String[] { "Datacenter", "Folder" };
        ViewManager viewManager = ViewManager.getInstance();
        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();

        listOfManagedObjectReferences = viewManager.createContainerView(hostName, rootFolder, type);

        if (!listOfManagedObjectReferences.isEmpty()) {
            for (ManagedObjectReference managedObjectReference : listOfManagedObjectReferences) {
                name = (String) MorManager.getMorProperty(ws, managedObjectReference, new String[] { "name" });
                System.out.println("Name: " + name);
                System.out.println(" - Type: " + managedObjectReference.getType());
                System.out.println(" - Value: " + managedObjectReference.get_value());
            }
        }

        /*
        try
        {
           dt03=new Date();
           containerView=ws.getVIMService().getService().createContainerView(viewManager,hostMor, new String[]{}, true);
           dt04=new Date();
        }
        catch (RuntimeFault e)
        {
           // TODO Auto-generated catch block
           e.printStackTrace();
        } catch (RemoteException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }
            
        Date dt05=new Date();
        morArr=(ArrayOfManagedObjectReference)MorManager.getMorProperty(ws.getVIMService(),containerView, new String[] {"view"});
        Date dt06=new Date();
        */

        //System.out.println("Temps d'appel: ");
        //System.out.println("- Get the ViewManager : "+(dt02.getTime()-dt01.getTime()));
        //System.out.println("- Create ContainerView: "+(dt04.getTime()-dt03.getTime()));
        //System.out.println("- GetMorProperty      : "+(dt06.getTime()-dt05.getTime()));

        //System.out.println("");

        //System.out.println("RootFolder: "+name+" / "+rootFolder.getType() + " / "+rootFolder.get_value());

        //System.out.println("morArr: "+morArr);

        /*
        name=null;
        if (listOfManagedObjectReferences!=null && !listOfManagedObjectReferences.isEmpty())
        {
           int nbEntity=1;
               
           for (ManagedObjectReference mor:listOfManagedObjectReferences)
           {
        name=(String)MorManager.getMorProperty(ws.getVIMService(),mor, new String[] {"name"});
        //if (!name.equals("vm") && !name.equals("host") && !name.equals("datastore") && !name.equals("network") && !name.equals("Resources"))
        //{
           parent=(ManagedObjectReference)MorManager.getMorProperty(ws.getVIMService(),mor, new String[] {"parent"});
           if (parent!=null)
              parentName=(String)MorManager.getMorProperty(ws.getVIMService(),parent, new String[] {"name"});
               
           System.out.println("Entity n"+nbEntity++);
           System.out.println("-Name : "+name);
           System.out.println(" -Type : "+mor.getType());
           System.out.println(" -Value: "+mor.get_value());
           System.out.println(" -Parent name : "+parentName);
           if (parent!=null)
           {
              System.out.println("  -Type : "+parent.getType());
              System.out.println("  -Value: "+parent.get_value());
           }
           System.out.println("");
            
           }
            
        }
        */

        VMware.delete(hostName);

        //ws.getVIMService().logout();
        //wsManager.deleteWS(ws);

        //vmware.getTaskMonitor().interrupt();
        //wsManager.deleteVIM();
    }

    public void testPerm() throws VMwareException {
        String vmwareServerName = "10.0.12.6";
        VMware vmware = new VMware(vmwareServerName, 443, "siveo_admin", "s1v3oP0C", false, 480000L, 1000L);
        WSManager wsManager = WSManager.getInstance();

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(vmwareServerName, "testvswitch");

        //AuthorizationManager authorizationManager=AuthorizationManager.getInstance();
        //authorizationManager.getAllRoles();
        //authorizationManager.getPermissions(vm);

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();

    }

    public void getSnapshot() throws VMwareException {
        String vmwareServerName = "10.0.12.6";
        VMware vmware = new VMware(vmwareServerName, 443, "siveo_admin", "s1v3oP0C", false, 480000L, 1000L);
        WSManager wsManager = WSManager.getInstance();

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(vmwareServerName, "testvm-centos55");

        SnapshotManager snapshotManager = SnapshotManager.getInstance();
        Snapshot rootSnapshot = snapshotManager.getSnapShotTree(vm);
        Snapshot currentSnapshot = snapshotManager.getCurrentSnapShot(vm);

        ArrayList<Snapshot> listOfsnap = snapshotManager.getAllSnapShot(vm);

        for (Snapshot snap : listOfsnap) {
            System.out.println("Snap ID: " + snap.getMor().get_value());
            System.out.println("Snap Name: " + snap.getName());
        }

        System.out.println("vmSnapTree");

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();
    }

    /*   
       public void getESXfromVM(String vmName) throws VMwareException 
       {
     VMware vmware=new VMware();
     WSManager wsManager=WSManager.getInstance();
         
     VMManager vmManager=VMManager.getInstance();
     VirtualMachine vm=vmManager.getVmByName(vmName);
     System.out.println("VM: "+vmName);
     System.out.println(" - Host: "+vm.getHost_().getName());
     wsManager.deleteVIM();
       }
        
           
       public void testUser() throws VMwareException
       {
     WSManager wsManager=WSManager.getInstance();
     WS ws=null;
     try
     {
        //ws = wsManager.createVIM("vpshere-4-1", 443, "Administrateur", "Gd@jJ2009$", null, false, 480000);
        //ws = wsManager.createVIM("vpshere-4-1", 443, "christophe", "christophe", null, false, 480000);
        ws = wsManager.createVIM("vsphere-4-0-1", 443, "actidev1", "P@ssw0rd", null, false, 480000);
     }
     catch (VMwareException e)
     {
        // TODO Auto-generated catch block
        e.printStackTrace();
     }
        
     ManagedObjectReference mor=MorManager.getMorRef(ws, null, "VirtualMachine", "ActiBox05");
     ManagedObject managedObject=new ManagedObject(ws, mor);
     VMManager vmManager=VMManager.getInstance();
     vmManager.addVM(ws, mor);
     VirtualMachine vm=vmManager.getVmByMor(mor);
     vm.powerOn();
         
         
       }
    */

    /*
       public void test() throws VMwareException
       {
     WSManager wsManager=WSManager.getInstance();
     WS ws=null;
     try
     {
        ws = wsManager.createVIM("vpshere-4-1", 443, "Administrateur", "Gd@jJ2009$", null, false, 480000);
     }
     catch (VMwareException e)
     {
        // TODO Auto-generated catch block
        e.printStackTrace();
     }
        
     System.out.println("ws: "+ws);
     System.out.println("ws: "+ws.getHostName());
         
        
         
     ArrayList<Host> hostList=null;
     Host host=null;
     InventoryManager inventoryManager=InventoryManager.getInstance();
         
     hostList=inventoryManager.getHost(ws.getHostName());
     HostManager hostManager=HostManager.getInstance();
        
     System.out.println("hostList: "+hostList);
         
     for (int nbHost=0;nbHost<hostList.size();nbHost++)
     {
        host=hostList.get(nbHost);
        System.out.println("\nHost n"+nbHost);
        System.out.println("name:"+host.getName());
        System.out.println("type"+host.getType());
        //System.out.println("\nHost n"+nbHost);
        //System.out.println("name:"+mngObj.getName());
        //System.out.println("type"+mngObj.getType());
        //System.out.println("value"+mngObj.getValue());
        //MorManager.addHost(ws, mngObj);
        hostManager.putHost(host);
     }
        
     host=hostManager.getHost("esx01.siveo.net");
     System.out.println("host: "+host.getMorRef());
        
     wsManager.deleteWS(ws);
         
       }
    */

    public void getListOfVM() throws VMwareException {
        String vmwareServerName = "siveo-vce";
        VMware vmware = new VMware(vmwareServerName, 443, "SIVEO\\Administrator", "siveo", false, 480000L, 1000L);
        WSManager wsManager = WSManager.getInstance();
        //WS ws=wsManager.getWS(vmwareServerName);

        VMManager vmManager = VMManager.getInstance();
        HashMap<String, ArrayList<VirtualMachine>> listOfVMByVC = vmManager.getListOfVMByVC();
        ArrayList<VirtualMachine> listOfVM = null;

        for (Map.Entry<String, ArrayList<VirtualMachine>> vmListByVC : listOfVMByVC.entrySet()) {
            listOfVM = vmListByVC.getValue();
            if (listOfVM != null) {
                for (VirtualMachine vm : listOfVM) {
                    System.out.println("VirtualMacine: " + vm.getName());
                    System.out.println("VirtualMacine: " + vm.getMor().get_value());
                    System.out.println("VirtualMacine: " + vm.getHost().getName());
                    System.out.println("VirtualMacine: " + vm.getHost().getName());
                }
            }

        }

        //HostManager hostManager=HostManager.getInstance();
        //Host host=hostManager.getHostByID("host-902", vmwareServerName);

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();

    }

    public void getListOfNetwork() throws VMwareException {
        String vmwareServerName = "10.0.12.6";
        VMware vmware = new VMware(vmwareServerName, 443, "siveo", "s1v3oP0C", false, 480000L, 1000L);
        WSManager wsManager = WSManager.getInstance();
        //WS ws=wsManager.getWS(vmwareServerName);

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByID("host-902", vmwareServerName);

        ArrayList<Network> listOfNetwork = host.getNetworks();

        int nbNet = 1;

        System.out.println("");
        System.out.println("--------------------------------------------");
        System.out.println("----          Host Network              ----");
        System.out.println("--------------------------------------------");

        for (Network net : listOfNetwork) {
            System.out.println("Network n" + nbNet++);
            System.out.println("- Name: " + net.getName());
            System.out.println("- Gateway: " + net.getGateway());
            System.out.println("- IpPoolName: " + net.getIpPoolName());
            System.out.println("- SubnetMask: " + net.getSubnetMask());
            System.out.println("- VlanID: " + net.getVlanId());
            System.out.println("");
        }

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByID(vmwareServerName, "vm-1202");

        listOfNetwork = vm.getNetwork();
        nbNet = 1;

        System.out.println("");
        System.out.println("");
        System.out.println("--------------------------------------------");
        System.out.println("----      VirtualMachine Network        ----");
        System.out.println("--------------------------------------------");
        for (Network net : listOfNetwork) {
            System.out.println("Network n" + nbNet++);
            System.out.println("- Name: " + net.getName());
            System.out.println("- Gateway: " + net.getGateway());
            System.out.println("- IpPoolName: " + net.getIpPoolName());
            System.out.println("- SubnetMask: " + net.getSubnetMask());
            System.out.println("- VlanID: " + net.getVlanId());
            System.out.println("");
        }

        /*
        HostConfigManager hostConfigManager=(HostConfigManager)MorManager.getMorPorperty(host.getWS().getVIMService(), host.getMor(), new String[] {"configManager"});
        System.out.println("hostConfigManager: "+hostConfigManager);
            
        HostNetworkSystem hostNetworkSystem=host.getNetworkSystem();
            
        Networking networking=host.getNetworking();
        HashMap<String, HostPortGroup> listOfHostPortGroup=networking.getPortgroupList();
            
        int numPorGroup=1;
        System.out.println("");
        System.out.println("--------------------------------------------");
        System.out.println("---- Port groups configured on the host ----");
        System.out.println("--------------------------------------------");
        for (Map.Entry<String, HostPortGroup> hostPortGroup:listOfHostPortGroup.entrySet())
        {
           System.out.println("PortGroup n"+numPorGroup+++" / "+hostPortGroup.getKey());
           System.out.println("- key: "+hostPortGroup.getValue().getKey());
           if (hostPortGroup.getValue().getPort()!=null && hostPortGroup.getValue().getPort().length>0)
           {
        for (int nbPort=0;nbPort<hostPortGroup.getValue().getPort().length;nbPort++)
        {
           System.out.println("- Port n"+nbPort);
           System.out.println("  - Key : "+hostPortGroup.getValue().getPort()[nbPort].getKey());
           if (hostPortGroup.getValue().getPort()[nbPort].getMac()!=null && hostPortGroup.getValue().getPort()[nbPort].getMac().length>0)
           {
              for (int nbMac=0;nbMac<hostPortGroup.getValue().getPort()[nbPort].getMac().length;nbMac++)
              {
                 System.out.println("  - Mac n"+nbMac+": "+hostPortGroup.getValue().getPort()[nbPort].getMac()[nbMac]);
              }
           }
           System.out.println("  - Type: "+hostPortGroup.getValue().getPort()[nbPort].getType());
        }
           }
            
           if (hostPortGroup.getValue().getSpec()!=null)
           {
        System.out.println("- Spec");
        System.out.println("  - Name   : "+hostPortGroup.getValue().getSpec().getName());
        System.out.println("  - vlanId : "+hostPortGroup.getValue().getSpec().getVlanId());
        System.out.println("  - Virtual Switch Name: "+hostPortGroup.getValue().getSpec().getVswitchName());
           }
            
           System.out.println("- vSwitch: "+hostPortGroup.getValue().getVswitch());
               
        }
        */

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();

    }

    public void getObjectPermission(String objectID) throws VMwareException {

        String vmWareHostName = "vcenter.siveo.net";
        VMware vmware = new VMware(vmWareHostName, 443, "Administrateur", "Clmdp@09", false, 480000L, 1000L);
        WSManager wsManager = WSManager.getInstance();
        VMManager vmManager = VMManager.getInstance();

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(vmWareHostName);

        HashMap<String, TreeNode> treeID = inventory.getMapOfTreeNodeByID();

        for (Map.Entry<String, TreeNode> e : treeID.entrySet()) {
            System.out.println("Object Id: " + e.getKey());
            System.out.println("Object Class: " + e.getValue().getClass());
        }

        TreeNode treenode = inventory.getMapOfTreeNodeByID().get(objectID);

        ArrayList<net.siveo.virtualization.vmware.authorization.Permission> listOfPermission = treenode
                .getPermission();

        System.out.println("");
        System.out.println("***** Affichage des permissions *****");
        System.out.println("");
        for (net.siveo.virtualization.vmware.authorization.Permission permission : listOfPermission) {
            System.out.println("\nPermission");
            System.out.println("- Principal: " + permission.getPrincipal());
            System.out.println("- Group: " + permission.isGroup());
            //System.out.println("- EntityName: "+permission.getEntityName());

            //if (permission.getPrivileges()!=null && permission.getPrivileges().size()>0)
            //{
            //   for (String privilege:permission.getPrivileges())
            //   {
            //      System.out.println("- Privilege: "+privilege);
            //   }
            //}

        }

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();
    }

    public void getNetwork() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "192.168.101.79";
        VMware.create(hostName, 443, "svc-siveo", "S1v30d6m3", false, -1L, 1000L);

        DatacenterManager dcManager = DatacenterManager.getInstance();
        Datacenter dc = dcManager.getDatacenterByName("BULL", hostName);

        ArrayOfManagedObjectReference arrayOfMor = null;
        ManagedObjectReference[] morArray = null;
        ManagedObjectReference mor = null;
        String name = null;

        arrayOfMor = (ArrayOfManagedObjectReference) MorManager.getMorProperty(dc.getWS(), dc.getMor(),
                new String[] { "network" });

        if (arrayOfMor != null && arrayOfMor.getManagedObjectReference() != null
                && arrayOfMor.getManagedObjectReference().length > 0) {
            System.out.println("Datacenter Network");
            morArray = arrayOfMor.getManagedObjectReference();
            for (int nbNetwok = 0; nbNetwok < morArray.length; nbNetwok++) {
                mor = morArray[nbNetwok];
                name = (String) MorManager.getMorProperty(dc.getWS(), mor, new String[] { "name" });
                System.out.println("Network n" + nbNetwok);
                System.out.println("- Name: " + name);

            }
        }

        System.out.println("");
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "ActiBox05");

        arrayOfMor = (ArrayOfManagedObjectReference) MorManager.getMorProperty(vm.getWS(), vm.getMor(),
                new String[] { "network" });
        if (arrayOfMor != null && arrayOfMor.getManagedObjectReference() != null
                && arrayOfMor.getManagedObjectReference().length > 0) {
            System.out.println("VM Network");
            morArray = arrayOfMor.getManagedObjectReference();
            for (int nbNetwok = 0; nbNetwok < morArray.length; nbNetwok++) {
                mor = morArray[nbNetwok];
                name = (String) MorManager.getMorProperty(vm.getWS(), mor, new String[] { "name" });
                System.out.println("Network n" + nbNetwok);
                System.out.println("- Name: " + name);

            }
        }

        VMware.delete(hostName);
    }

    public void getHostFolder() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "192.168.101.79";
        VMware.create(hostName, 443, "svc-siveo", "S1v30d6m3", false, -1L, 1000L);

        DatacenterManager dcManager = DatacenterManager.getInstance();
        Datacenter dc = dcManager.getDatacenterByName("SiveoDC", hostName);

        ManagedObjectReference hostFolder = (ManagedObjectReference) MorManager.getMorProperty(dc.getWS(),
                dc.getMor(), new String[] { "hostFolder" });

        System.out.println("SiveoDC hostFolder= " + hostFolder);

        ArrayOfManagedObjectReference arrayOfMor = null;
        ManagedObjectReference[] morArray = null;
        ManagedObjectReference mor = null;
        String name = null;

        arrayOfMor = (ArrayOfManagedObjectReference) MorManager.getMorProperty(dc.getWS(), hostFolder,
                new String[] { "childEntity" });
        if (arrayOfMor != null && arrayOfMor.getManagedObjectReference() != null
                && arrayOfMor.getManagedObjectReference().length > 0) {
            morArray = arrayOfMor.getManagedObjectReference();
            for (int nbChild = 0; nbChild < morArray.length; nbChild++) {
                mor = morArray[nbChild];
                name = (String) MorManager.getMorProperty(dc.getWS(), mor, new String[] { "name" });
                System.out.println("Entity n" + nbChild);
                System.out.println("-name: " + name);
                System.out.println("-type: " + mor.getType());
                System.out.println("-val : " + mor.get_value());
            }

        }

        System.out.println("");
        //System.out.println("Enfant de ComputeResource/domain-s1101");      
        //System.out.println("Parent de ComputeResource/domain-s1101");      
        //System.out.println("Parent de HostSystem/host-1054");      
        System.out.println("Parent de ResourcePool/Test");

        mor = new ManagedObjectReference();
        //mor.setType("ComputeResource");
        //mor.set_value("domain-s1101");
        //mor.setType("HostSystem");
        ////mor.set_value("host-1054");
        //mor.set_value("host-29");

        /*
        mor.setType("Folder");
        //mor.set_value("host-1054");
        mor.set_value("group-h370");
            
        ManagedObjectReference parent=(ManagedObjectReference)MorManager.getMorPorperty(dc.getWs(), mor, new String[] {"parent"});
        name=(String)MorManager.getMorPorperty(dc.getWs(), parent, new String[] {"name"});
        System.out.println("-Name: "+name);
        System.out.println("-Type: "+parent.getType());
        System.out.println("-Val : "+parent.get_value());
            
        mor=new ManagedObjectReference();
        System.out.println("");      
        //System.out.println("Enfant de ComputeResource/domain-s1101");      
        //mor.setType("ComputeResource");
        //mor.set_value("domain-s1101");
         */
        System.out.println("Enfant de SiveoFolder");
        mor.setType("Folder");
        mor.set_value("group-h81");

        arrayOfMor = (ArrayOfManagedObjectReference) MorManager.getMorProperty(dc.getWS(), mor,
                new String[] { "childEntity" });
        if (arrayOfMor != null && arrayOfMor.getManagedObjectReference() != null
                && arrayOfMor.getManagedObjectReference().length > 0) {
            morArray = arrayOfMor.getManagedObjectReference();
            for (int nbChild = 0; nbChild < morArray.length; nbChild++) {
                mor = morArray[nbChild];
                name = (String) MorManager.getMorProperty(dc.getWS(), mor, new String[] { "name" });
                System.out.println("Host n" + nbChild);
                System.out.println("-name: " + name);
                System.out.println("-type: " + mor.getType());
                System.out.println("-val : " + mor.get_value());
            }

        }

        //VMManager vmManager=VMManager.getInstance();
        //VirtualMachine vm=vmManager.getVm("Win2003SP2");
        //System.out.println("VM Mor: "+vm.getMor());

        VMware.delete(hostName);
    }

    public void setPermission(String user, boolean isGroup, String vmName, String roleName) throws VMwareException {
        VMware vmware = new VMware("vcenter.siveo.net", 443, "Administrateur", "Clmdp@09", false, 48000L, 1000L);
        //VMware vmware=new VMware("siveo-admvc.siveo.net",443,"Administrateur","Gd@jJ2009$",false,48000L,1000L);
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS("vcenter.siveo.net");

        //VMManager vmManager=VMManager.getInstance();
        //ManagedObjectReference vmMor=vmManager.getVmMor(ws, "test-depuis-main3");
        //System.out.println("vmMor: "+vmMor);
        //System.out.println("vmMor Value: "+vmMor.get_value());
        //System.out.println("vmMor Type: "+vmMor.getType());

        AuthorizationManager authorManager = AuthorizationManager.getInstance();
        //authorManager.addPermission(user, isGroup,vmName, roleName,"vcenter.siveo.net");

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();
    }

    public void customizeVM(String vmName) throws VMwareException {
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L,1000);
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L,1000);

        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "192.168.101.110";
        VMware.create(hostName, 443, "root", "mandriva", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        VMManager vmManager = VMManager.getInstance();

        // =========================================================================================
        // Initialize the Sysprep
        // =========================================================================================
        System.out.println("\n*****  Customize VM *****");
        //String vmName=null;
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        vmConfiguration.setUserName("actidev1");
        vmConfiguration.setSocietyName("Actimage");
        vmConfiguration.setName(vmName);

        //      // ---------------------------------------------------------------
        //      // Initialize the GuiUnattended Section
        //      // ---------------------------------------------------------------
        //      GuiUnattended guiUnattended=new GuiUnattended();
        //      guiUnattended.setAdminPassword("Gd@jJ2009$");
        //      guiUnattended.setEncryptedAdminPassword(false);
        //      guiUnattended.setAutoLogon(true);
        //      guiUnattended.setAutoLogonCount(3);
        //      guiUnattended.setTimeZone(105);
        //      
        //      // ---------------------------------------------------------------
        //      // Initialize the LicenseFilePrintData Section
        //      // ---------------------------------------------------------------
        //      LicenseFilePrintData licenseData=new LicenseFilePrintData();
        //      licenseData.setAutoMode("PerServer");
        //      licenseData.setAutoUsers(5);
        //
        //      // ---------------------------------------------------------------
        //      // Initialize the UserData Section
        //      // ---------------------------------------------------------------
        //      UserData userData=new UserData();
        //      userData.setComputerName(vmConfiguration.getName());
        //      userData.setFullName("Windows");
        //      userData.setOrgName("MS");
        //      userData.setProductId("Q66VX-8TBQ3-2JC46-MDQFC-94CMB");
        //
        //      // ---------------------------------------------------------------
        //      // Initialize the Identification Section
        //      // ---------------------------------------------------------------
        //      Identification identification =new Identification();
        //      identification.setDomainAdmin("SIVEO\\administrateur");
        //      identification.setDomainAdminPassword("Clmdp@09");
        //      identification.setJoinDomain("SIVEO");
        //      //identification.setJoinWorkgroup("WORKGROUP");
        //      
        //      // ---------------------------------------------------------------
        //      // Initialize the GuiRunOnce Section
        //      // ---------------------------------------------------------------
        //      GuiRunOnce guiRunOnce = new GuiRunOnce();
        //      //String command="\"net localgroup Administrateurs "+identification.getJoinDomain()+"\\"+vmConfiguration.getUserName()+" /add\"";
        //      //String command="net localgroup Administrateurs "+identification.getJoinDomain()+"\\"+vmConfiguration.getUserName()+" /add";
        //      String command="\"net localgroup Administrateurs "+identification.getJoinDomain()+"\\"+vmConfiguration.getUserName()+" /add\"";
        //      guiRunOnce.setCommandList(new String[]{command});
        //      System.out.println("command: "+command);
        //      
        //      //test hudson
        //      // ---------------------------------------------------------------
        //      // Initialize the Sysprep
        //      // ---------------------------------------------------------------
        //      SysprepWindows winSysPrep=new SysprepWindows();
        //      winSysPrep.setGuiRunOnce(guiRunOnce);
        //      winSysPrep.setGuiUnattended(guiUnattended);
        //      winSysPrep.setIdentification(identification);
        //      winSysPrep.setLicenseFilePrintData(licenseData);
        //      winSysPrep.setUserData(userData);

        // ---------------------------------------------------------------
        // Initialize the Sysprep
        // ---------------------------------------------------------------
        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("siveo.dev");
        sysprepLinux.setHostname(vmConfiguration.getName());

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        vmConfiguration.setSysprepLinux(sysprepLinux);
        //vmConfiguration.setSysprepWindows(winSysPrep);
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        // =========================================================================================
        // Define networking 
        // =========================================================================================
        NetworkAdapter networkAdapter = new NetworkAdapter();
        //networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});
        networkAdapter.setDnsServerList(new String[] { "10.62.16.12" });
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("192.168.101.115");
        networkAdapter.setSubnetMask("255.255.255.0");
        ////networkAdapter.setGateway(new String[]{"192.168.0.254"});
        networkAdapter.setGateway(new String[] { "192.168.101.1" });
        ////networkAdapter.setMacAddress(null);
        //vmConfiguration.setNetworkAdpater(networkAdapter);

        vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        ////vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"10.62.16.12","194.133.125.66"});
        vmConfiguration.setDnsServerList(new String[] { "10.62.16.12" });
        //vmConfiguration.setDnsSuffixList(new String[]{});
        vmConfiguration.setDnsSuffixList(new String[] {});

        vmManager.customizeGuestOS(vm.getMor().get_value(), hostName, vmConfiguration);

        System.out.println("Press a key to continue...");
        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void cloneTemplateToVirtualMachine() throws VMwareException {

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        //VMware vmware=new VMware(hostName,443,"siveo_admin","s1v3oP0C",false,480000L,1000L);

        WSManager wsManager = WSManager.getInstance();
        VMManager vmManager = VMManager.getInstance();

        // =========================================================================================
        // Initialize the Sysprep
        // =========================================================================================
        System.out.println("\n*****  Clone Template to VM *****");
        //String vmName=null;
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        vmConfiguration.setUserName("actidev1");
        //vmConfiguration.setUserName("siveo_test");   
        vmConfiguration.setSocietyName("Navaho");
        vmConfiguration.setName("VMCrossDC");

        // ---------------------------------------------------------------
        // Initialize the GuiUnattended Section
        // ---------------------------------------------------------------
        GuiUnattended guiUnattended = new GuiUnattended();
        guiUnattended.setAdminPassword("Clmdp@09");
        guiUnattended.setEncryptedAdminPassword(false);
        guiUnattended.setAutoLogon(true);
        guiUnattended.setAutoLogonCount(3);
        guiUnattended.setTimeZone(105);

        // ---------------------------------------------------------------
        // Initialize the LicenseFilePrintData Section
        // ---------------------------------------------------------------
        LicenseFilePrintData licenseData = new LicenseFilePrintData();
        licenseData.setAutoMode("PerServer");
        licenseData.setAutoUsers(5);

        // ---------------------------------------------------------------
        // Initialize the UserData Section
        // ---------------------------------------------------------------
        UserData userData = new UserData();
        userData.setComputerName(vmConfiguration.getName());
        userData.setFullName("WinVMUser");
        userData.setOrgName("NAVAHO");
        //userData.setProductId("MBKJF-QXT8P-RXWBG-FG687-C79GP");
        // Windows 2003
        userData.setProductId("Q66VX-8TBQ3-2JC46-MDQFC-94CMB");

        //

        // ---------------------------------------------------------------
        // Initialize the Identification Section
        // ---------------------------------------------------------------
        Identification identification = new Identification();

        //Activation du mode WORKGROUP
        //identification.setDomainAdmin("SIVEO\\Administrateur");
        //identification.setDomainAdminPassword("Clmdp@09");
        //identification.setJoinDomain(null);
        //identification.setJoinWorkgroup("WORKGROUP");

        //Activation du mode Domain
        identification.setDomainAdmin("SIVEO\\Administrateur");
        identification.setDomainAdminPassword("Clmdp@09");
        identification.setJoinDomain("SIVEO");
        ////identification.setJoinWorkgroup("WORKGROUP");

        // ---------------------------------------------------------------
        // Initialize the GuiRunOnce Section
        // ---------------------------------------------------------------
        GuiRunOnce guiRunOnce = new GuiRunOnce();
        String command = "\"net localgroup Administrateurs " + identification.getJoinDomain() + "\\"
                + vmConfiguration.getUserName() + " /add\"";
        System.out.println("command: " + command);
        guiRunOnce.setCommandList(new String[] { command });

        //test hudson
        // ---------------------------------------------------------------
        // Initialize the Sysprep for Windows
        // ---------------------------------------------------------------
        SysprepWindows winSysPrep = new SysprepWindows();
        winSysPrep.setGuiRunOnce(guiRunOnce);
        winSysPrep.setGuiUnattended(guiUnattended);
        winSysPrep.setIdentification(identification);
        winSysPrep.setLicenseFilePrintData(licenseData);
        winSysPrep.setUserData(userData);

        // ---------------------------------------------------------------
        // Initialize the Linux Sysprep 
        // ---------------------------------------------------------------
        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("siveo.net");
        sysprepLinux.setHostname("VMCrossDC");

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        vmConfiguration.setSysprepWindows(winSysPrep);
        //vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------

        NetworkAdapter networkAdapter = new NetworkAdapter();
        //networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});
        networkAdapter.setDnsServerList(new String[] { "10.251.5.30" });
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.62.16.94");
        networkAdapter.setSubnetMask("255.255.252.0");
        ////networkAdapter.setGateway(new String[]{"192.168.0.254"});
        networkAdapter.setGateway(new String[] { "10.62.16.2" });
        ////networkAdapter.setMacAddress(null);
        vmConfiguration.setNetworkAdpater(networkAdapter);

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        vmConfiguration.setDnsServerList(new String[] { "10.251.5.30", "194.133.125.66" });
        //vmConfiguration.setDnsSuffixList(new String[]{});
        vmConfiguration.setDnsSuffixList(new String[] {});

        // set the second Network
        //networkAdapter=new NetworkAdapter();
        ////networkAdapter.setDnsDomain("siveo.net");
        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp(null);
        //networkAdapter.setSubnetMask("255.255.255.0");
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        //vmConfiguration.setNetworkAdpater(networkAdapter);

        // !!!
        ////vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        ////vmConfiguration.setDnsSuffixList(new String[]{});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // ---------------------------------------------------------------
        // Set the Network Traffic configuration
        // ---------------------------------------------------------------

        //NetworkTraffic netTraffic= new NetworkTraffic();
        //netTraffic.setAverageBps(0);
        //netTraffic.setBurstSize(0);
        //netTraffic.setPeakBps(0);
        //netTraffic.setShaper(false);

        vmConfiguration.setNetworkTraffic(null);

        // ---------------------------------------------------------------
        // Set the CPU configuration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(1024);
        virtualCPU.setReservation(1024);
        //virtualCPU.setShareLevel(null);
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setNbCPU(1);
        //vmConfiguration.setVirtualCPU(virtualCPU);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMem = new VirtualMemory();
        virtualMem.setLimit(4096);
        virtualMem.setReservation(4096);
        virtualMem.setExpandableReservation(false);
        // !!!
        //virtualMem.setMemorySize(256);

        //vmConfiguration.setVirtualMemory(virtualMem);

        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        // VirtualCenter VBLOCK
        //String dataStore="datastore-535";
        //String host="host-71";
        //String vm="vm-550";
        //String vmFolder=null;

        // VirtualCenter SIVEO
        //String dataStore="datastore-535";
        //String host="host-71";
        //String vm="vm-550";
        //String vmFolder=null;

        // Creation Cross DC
        String host = "host-66"; // siveo-esx3.siveo.net
        String dataStore = "datastore-523"; // SIVEO_POC
        String vm = "vm-550"; //template templ_rhel5
        String vmFolder = "group-v471"; // dossier SCVMM

        // VirtualCenter PROD Siveo
        //String dataStore="datastore-2920";
        //String host="host-123";
        //String vm="vm-8262";
        //String vmFolder="group-v2921";

        //FolderManager folderManager=FolderManager.getInstance();
        //Folder folder=folderManager.getFolderByID("group-v344", hostName);

        vmManager.cloneTemplateToVM(vm, hostName, vmConfiguration, host, dataStore, null, vmFolder);

        VMware.delete(hostName);
    }

    public void cloneTemplateToVM() throws VMwareException {
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        WSManager wsManager = WSManager.getInstance();
        VMManager vmManager = VMManager.getInstance();

        // =========================================================================================
        // Initialize the Sysprep
        // =========================================================================================
        System.out.println("\n*****  Clone Template to VM *****");
        //String vmName=null;
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        vmConfiguration.setUserName("actidev1");
        //vmConfiguration.setUserName("siveo_test");   
        vmConfiguration.setSocietyName("Navaho");
        vmConfiguration.setName("VM-2-NIC");

        // ---------------------------------------------------------------
        // Initialize the GuiUnattended Section
        // ---------------------------------------------------------------
        GuiUnattended guiUnattended = new GuiUnattended();
        guiUnattended.setAdminPassword("clmdpa");
        guiUnattended.setEncryptedAdminPassword(false);
        guiUnattended.setAutoLogon(true);
        guiUnattended.setAutoLogonCount(3);
        guiUnattended.setTimeZone(105);

        // ---------------------------------------------------------------
        // Initialize the LicenseFilePrintData Section
        // ---------------------------------------------------------------
        LicenseFilePrintData licenseData = new LicenseFilePrintData();
        licenseData.setAutoMode("PerServer");
        licenseData.setAutoUsers(5);

        // ---------------------------------------------------------------
        // Initialize the UserData Section
        // ---------------------------------------------------------------
        UserData userData = new UserData();
        userData.setComputerName(vmConfiguration.getName());
        userData.setFullName("WinVMUser");
        userData.setOrgName("NAVAHO");
        //userData.setProductId("MBKJF-QXT8P-RXWBG-FG687-C79GP");
        // Windows 2003
        userData.setProductId("Q66VX-8TBQ3-2JC46-MDQFC-94CMB");

        //

        // ---------------------------------------------------------------
        // Initialize the Identification Section
        // ---------------------------------------------------------------
        Identification identification = new Identification();

        //Activation du mode WORKGROUP
        //identification.setDomainAdmin("SIVEO\\Administrateur");
        //identification.setDomainAdminPassword("Clmdp@09");
        //identification.setJoinDomain(null);
        //identification.setJoinWorkgroup("WORKGROUP");

        //Activation du mode Domain
        identification.setDomainAdmin("SIVEO\\Administrateur");
        identification.setDomainAdminPassword("Clmdp@09");
        identification.setJoinDomain("SIVEO");
        ////identification.setJoinWorkgroup("WORKGROUP");

        // ---------------------------------------------------------------
        // Initialize the GuiRunOnce Section
        // ---------------------------------------------------------------
        GuiRunOnce guiRunOnce = new GuiRunOnce();
        String command = "\"net localgroup Administrateurs " + identification.getJoinDomain() + "\\"
                + vmConfiguration.getUserName() + " /add\"";
        System.out.println("command: " + command);
        guiRunOnce.setCommandList(new String[] { command });

        //test hudson
        // ---------------------------------------------------------------
        // Initialize the Sysprep for Windows
        // ---------------------------------------------------------------
        SysprepWindows winSysPrep = new SysprepWindows();
        winSysPrep.setGuiRunOnce(guiRunOnce);
        winSysPrep.setGuiUnattended(guiUnattended);
        winSysPrep.setIdentification(identification);
        winSysPrep.setLicenseFilePrintData(licenseData);
        winSysPrep.setUserData(userData);

        // ---------------------------------------------------------------
        // Initialize the Linux Sysprep 
        // ---------------------------------------------------------------
        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("siveo.net");
        sysprepLinux.setHostname("VMCrossDC");

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        //vmConfiguration.setSysprepWindows(winSysPrep);
        vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set Boot Options
        //
        // If not set the default values are:
        //
        // EnterBIOSSetup -> false
        // BootDelay      -> 0L
        // ---------------------------------------------------------------
        //BootOptions vmBootOpt=new BootOptions();
        //vmBootOpt.setEnterBIOSSetup(false);
        //vmBootOpt.setBootDelay(0L);

        vmConfiguration.setBootOptions(null);

        // ---------------------------------------------------------------
        // Set Console Preferences
        //
        // If not set the default values are:
        //
        // CloseOnPowerOffOrSuspend -> false
        // EnterFullScreenOnPowerOn -> false
        // powerOnWhenOpened        -> false
        // ---------------------------------------------------------------
        //ConsolePreferences vmConsolePref=new ConsolePreferences();
        //vmConsolePref.setCloseOnPowerOffOrSuspend(true);
        //vmConsolePref.setEnterFullScreenOnPowerOn(true);
        //vmConsolePref.setPowerOnWhenOpened(true);

        vmConfiguration.setConsolePreference(null);

        // ---------------------------------------------------------------
        // Set the defaults for the power operations on a virtual machine
        //
        // If not set the default values are:
        //
        // defaultPowerOffType -> "soft" 
        // defaultResetType    -> "soft" 
        // defaultSuspendType  -> "soft"  
        // powerOffType        -> "soft" 
        // resetType           -> "soft"
        // standbyAction       -> null
        // suspendType         -> "soft"
        // ---------------------------------------------------------------
        //PowerOptions vmPowerOpt=new PowerOptions();
        //vmPowerOpt.setPowerOffType("soft");
        //vmPowerOpt.setResetType("soft");
        //vmPowerOpt.setSuspendType("soft");

        vmConfiguration.setPowerOptions(null);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------

        //NetworkAdapter networkAdapter=new NetworkAdapter();
        ////networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});

        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp("10.0.12.23");
        //networkAdapter.setSubnetMask("255.255.255.0");
        ////networkAdapter.setGateway(new String[]{"192.168.0.254"});
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        ////networkAdapter.setMacAddress(null);
        ////vmConfiguration.setNetworkAdpater(networkAdapter);

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        vmConfiguration.setDnsServerList(new String[] {});
        vmConfiguration.setDnsSuffixList(new String[] {});

        // set the second Network
        //networkAdapter=new NetworkAdapter();
        ////networkAdapter.setDnsDomain("siveo.net");
        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp(null);
        //networkAdapter.setSubnetMask("255.255.255.0");
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        //vmConfiguration.setNetworkAdpater(networkAdapter);

        // !!!
        ////vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        ////vmConfiguration.setDnsSuffixList(new String[]{});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // ---------------------------------------------------------------
        // Set the Network Traffic configuration
        // ---------------------------------------------------------------

        //NetworkTraffic netTraffic= new NetworkTraffic();
        //netTraffic.setAverageBps(0);
        //netTraffic.setBurstSize(0);
        //netTraffic.setPeakBps(0);
        //netTraffic.setShaper(false);

        vmConfiguration.setNetworkTraffic(null);

        // ---------------------------------------------------------------
        // Set the CPU configuration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(1024);
        virtualCPU.setReservation(1024);
        //virtualCPU.setShareLevel(null);
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setNbCPU(1);
        //vmConfiguration.setVirtualCPU(virtualCPU);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMem = new VirtualMemory();
        virtualMem.setLimit(4096);
        virtualMem.setReservation(4096);
        virtualMem.setExpandableReservation(false);
        // !!!
        //virtualMem.setMemorySize(256);

        //vmConfiguration.setVirtualMemory(virtualMem);

        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        // VirtualCenter VBLOCK
        //String dataStore="datastore-535";
        //String host="host-71";
        //String vm="vm-550";
        //String vmFolder=null;

        // VirtualCenter SIVEO
        //String dataStore="datastore-535";
        //String host="host-71";
        //String vm="vm-550";
        //String vmFolder=null;

        // Creation Cross DC
        String host = "host-66"; // siveo-esx3.siveo.net
        String dataStore = "datastore-523"; // SIVEO_POC
        String vm = "vm-1247"; //template templ_rhel5
        String vmFolder = "group-v1240"; // dossier SCVMM
        String resourcePoolID = "resgroup-1248";

        // VirtualCenter PROD Siveo
        //String dataStore="datastore-2920";
        //String host="host-123";
        //String vm="vm-8262";
        //String vmFolder="group-v2921";

        //FolderManager folderManager=FolderManager.getInstance();
        //Folder folder=folderManager.getFolderByID("group-v344", hostName);

        // Mise  jour des proprits 
        VirtualMachine virtualMachine = vmManager.getVmByID(hostName, vm);

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();

        listOfMors.add(virtualMachine.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfMors);

        //vmManager.cloneTemplateToVM(vm,hostName, vmConfiguration, host,dataStore,resourcePoolID,vmFolder);
        vmManager.cloneTemplateToVMEx(vm, hostName, vmConfiguration, host, dataStore, resourcePoolID, vmFolder);

        System.out.println("Press a key to continue");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        VMware.delete(hostName);
    }

    public void cloneTemplateToVMDHCP() throws VMwareException {
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        WSManager wsManager = WSManager.getInstance();
        VMManager vmManager = VMManager.getInstance();

        // =========================================================================================
        // Initialize the Sysprep
        // =========================================================================================
        System.out.println("\n*****  Clone Template to VM *****");
        //String vmName=null;
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        vmConfiguration.setUserName("actidev1");
        //vmConfiguration.setUserName("siveo_test");   
        vmConfiguration.setSocietyName("Navaho");
        vmConfiguration.setName("VM_0NIC_DHCP");

        // ---------------------------------------------------------------
        // Initialize the GuiUnattended Section
        // ---------------------------------------------------------------
        GuiUnattended guiUnattended = new GuiUnattended();
        guiUnattended.setAdminPassword("clmdpa");
        guiUnattended.setEncryptedAdminPassword(false);
        guiUnattended.setAutoLogon(true);
        guiUnattended.setAutoLogonCount(3);
        guiUnattended.setTimeZone(105);

        // ---------------------------------------------------------------
        // Initialize the LicenseFilePrintData Section
        // ---------------------------------------------------------------
        LicenseFilePrintData licenseData = new LicenseFilePrintData();
        licenseData.setAutoMode("PerServer");
        licenseData.setAutoUsers(5);

        // ---------------------------------------------------------------
        // Initialize the UserData Section
        // ---------------------------------------------------------------
        UserData userData = new UserData();
        userData.setComputerName(vmConfiguration.getName());
        userData.setFullName("WinVMUser");
        userData.setOrgName("NAVAHO");
        //userData.setProductId("MBKJF-QXT8P-RXWBG-FG687-C79GP");
        // Windows 2003
        userData.setProductId("Q66VX-8TBQ3-2JC46-MDQFC-94CMB");

        //

        // ---------------------------------------------------------------
        // Initialize the Identification Section
        // ---------------------------------------------------------------
        Identification identification = new Identification();

        //Activation du mode WORKGROUP
        //identification.setDomainAdmin("SIVEO\\Administrateur");
        //identification.setDomainAdminPassword("Clmdp@09");
        //identification.setJoinDomain(null);
        //identification.setJoinWorkgroup("WORKGROUP");

        //Activation du mode Domain
        identification.setDomainAdmin("SIVEO\\Administrateur");
        identification.setDomainAdminPassword("Clmdp@09");
        identification.setJoinDomain("SIVEO");
        ////identification.setJoinWorkgroup("WORKGROUP");

        // ---------------------------------------------------------------
        // Initialize the GuiRunOnce Section
        // ---------------------------------------------------------------
        GuiRunOnce guiRunOnce = new GuiRunOnce();
        String command = "\"net localgroup Administrateurs " + identification.getJoinDomain() + "\\"
                + vmConfiguration.getUserName() + " /add\"";
        System.out.println("command: " + command);
        guiRunOnce.setCommandList(new String[] { command });

        //test hudson
        // ---------------------------------------------------------------
        // Initialize the Sysprep for Windows
        // ---------------------------------------------------------------
        SysprepWindows winSysPrep = new SysprepWindows();
        winSysPrep.setGuiRunOnce(guiRunOnce);
        winSysPrep.setGuiUnattended(guiUnattended);
        winSysPrep.setIdentification(identification);
        winSysPrep.setLicenseFilePrintData(licenseData);
        winSysPrep.setUserData(userData);

        // ---------------------------------------------------------------
        // Initialize the Linux Sysprep 
        // ---------------------------------------------------------------
        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("siveo.net");
        sysprepLinux.setHostname("VMCrossDC");

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        //vmConfiguration.setSysprepWindows(winSysPrep);
        vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set Boot Options
        //
        // If not set the default values are:
        //
        // EnterBIOSSetup -> false
        // BootDelay      -> 0L
        // ---------------------------------------------------------------
        //BootOptions vmBootOpt=new BootOptions();
        //vmBootOpt.setEnterBIOSSetup(false);
        //vmBootOpt.setBootDelay(0L);

        vmConfiguration.setBootOptions(null);

        // ---------------------------------------------------------------
        // Set Console Preferences
        //
        // If not set the default values are:
        //
        // CloseOnPowerOffOrSuspend -> false
        // EnterFullScreenOnPowerOn -> false
        // powerOnWhenOpened        -> false
        // ---------------------------------------------------------------
        //ConsolePreferences vmConsolePref=new ConsolePreferences();
        //vmConsolePref.setCloseOnPowerOffOrSuspend(true);
        //vmConsolePref.setEnterFullScreenOnPowerOn(true);
        //vmConsolePref.setPowerOnWhenOpened(true);

        vmConfiguration.setConsolePreference(null);

        // ---------------------------------------------------------------
        // Set the defaults for the power operations on a virtual machine
        //
        // If not set the default values are:
        //
        // defaultPowerOffType -> "soft" 
        // defaultResetType    -> "soft" 
        // defaultSuspendType  -> "soft"  
        // powerOffType        -> "soft" 
        // resetType           -> "soft"
        // standbyAction       -> null
        // suspendType         -> "soft"
        // ---------------------------------------------------------------
        //PowerOptions vmPowerOpt=new PowerOptions();
        //vmPowerOpt.setPowerOffType("soft");
        //vmPowerOpt.setResetType("soft");
        //vmPowerOpt.setSuspendType("soft");

        vmConfiguration.setPowerOptions(null);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------

        //NetworkAdapter networkAdapter=new NetworkAdapter();
        //networkAdapter.setDhcp(true);
        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        ////networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});

        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp("10.0.12.23");
        //networkAdapter.setSubnetMask("255.255.255.0");
        ////networkAdapter.setGateway(new String[]{"192.168.0.254"});
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        ////networkAdapter.setMacAddress(null);
        ////vmConfiguration.setNetworkAdpater(networkAdapter);

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        vmConfiguration.setDnsServerList(new String[] {});
        vmConfiguration.setDnsSuffixList(new String[] {});

        // set the second Network
        //networkAdapter=new NetworkAdapter();
        ////networkAdapter.setDnsDomain("siveo.net");
        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp(null);
        //networkAdapter.setSubnetMask("255.255.255.0");
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        //vmConfiguration.setNetworkAdpater(networkAdapter);

        // !!!
        ////vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        ////vmConfiguration.setDnsSuffixList(new String[]{});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // ---------------------------------------------------------------
        // Set the Network Traffic configuration
        // ---------------------------------------------------------------

        //NetworkTraffic netTraffic= new NetworkTraffic();
        //netTraffic.setAverageBps(0);
        //netTraffic.setBurstSize(0);
        //netTraffic.setPeakBps(0);
        //netTraffic.setShaper(false);

        vmConfiguration.setNetworkTraffic(null);

        // ---------------------------------------------------------------
        // Set the CPU configuration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(1024);
        virtualCPU.setReservation(1024);
        //virtualCPU.setShareLevel(null);
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setNbCPU(1);
        //vmConfiguration.setVirtualCPU(virtualCPU);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMem = new VirtualMemory();
        virtualMem.setLimit(4096);
        virtualMem.setReservation(4096);
        virtualMem.setExpandableReservation(false);
        // !!!
        //virtualMem.setMemorySize(256);

        //vmConfiguration.setVirtualMemory(virtualMem);

        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        // VirtualCenter VBLOCK
        //String dataStore="datastore-535";
        //String host="host-71";
        //String vm="vm-550";
        //String vmFolder=null;

        // VirtualCenter SIVEO
        //String dataStore="datastore-535";
        //String host="host-71";
        //String vm="vm-550";
        //String vmFolder=null;

        // Creation Cross DC
        String host = "host-66"; // siveo-esx3.siveo.net
        String dataStore = "datastore-523"; // SIVEO_POC
        String vm = "vm-1243"; //template templ_rhel5
        String vmFolder = "group-v1240"; // dossier SCVMM
        String resourcePoolID = "resgroup-1248";

        // VirtualCenter PROD Siveo
        //String dataStore="datastore-2920";
        //String host="host-123";
        //String vm="vm-8262";
        //String vmFolder="group-v2921";

        //FolderManager folderManager=FolderManager.getInstance();
        //Folder folder=folderManager.getFolderByID("group-v344", hostName);

        // Mise  jour des proprits 
        VirtualMachine virtualMachine = vmManager.getVmByID(hostName, vm);

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();

        listOfMors.add(virtualMachine.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfMors);

        //vmManager.cloneTemplateToVM(vm,hostName, vmConfiguration, host,dataStore,resourcePoolID,vmFolder);
        vmManager.cloneTemplateToVMEx(vm, hostName, vmConfiguration, host, dataStore, resourcePoolID, vmFolder);

        System.out.println("Press a key to continue");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        VMware.delete(hostName);
    }

    /*   
       public void cloneTemplateToVM() throws VMwareException 
       {
          String hostName="10.0.12.6";
              
          VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,480000L,1000L);
          //VMware vmware=new VMware(hostName,443,"siveo_admin","s1v3oP0C",false,480000L,1000L);
          //VMware vmware=new VMware("vpshere-4-1",443,"Administrateur","Gd@jJ2009$",false,480000L,1000L);
        
          WSManager wsManager=WSManager.getInstance();
          VMManager vmManager=VMManager.getInstance();
        
              
          //CustomizationSysprepText syprepText=new CustomizationSysprepText();
          //syprepText.setValue("");
              
              
          //VirtualMachine vm=vmManager.getVmByName("vpshere-4-1", "VMTest1");
          //System.out.println("EnvironmentBrowser: "+vm.getEnvironmentBrowser());
        
              
            
              
          //String texte1="[GuiUnattended]\n";
          //String texte2="AdminPassword = \"Gd@jJ2009$\"\n";
          //String texte3="AutoLogon = Yes\n";
          //String texte4="AutoLogonCount = 3\n";
          //String texte5="TimeZone = 105\n\n";
          //String toto="EncryptedAdminPassword = No";
              
          //String texte6="[LicenseFilePrintData]\n";
          //String texte7="AutoMode = PerServer\n";
          //String texte8="AutoUsers = 5\n\n";
        
          //String texte9="[UserData]\n";
          //String texte10="ComputerName = ActiBox15\n";
          //String texte11="FullName = \"WinVMUser\"\n";
          //String texte12="OrgName = \"SIVEO\"\n";
          //String texte13="ProductKey = \"Q66VX-8TBQ3-2JC46-MDQFC-94CMB\"\n\n";
        
          //String texte14="[Identification]\n";
          //String texte15="DomainAdmin = SIVEO\\Administrateur\n";
          //String texte16="DomainAdminPassword = \"Clmdp@09\"\n";
          //String texte17="JoinDomain = \"SIVEO\"\n\n";
        
          //String texte18="[GuiRunOnce]\n";
          //String texte19="net localgroup Administrateurs SIVEO\\actidev1 /add\n";
              
        
        
          //String sysprepContent=texte1+texte2+texte3+texte4+texte5+texte6+texte7+texte8+texte9+texte10+texte11+texte12+
          //                 texte13+texte14+texte15+texte16+texte17+texte18+texte19;
        
        
        
        
        
        
        
              
              
          // =========================================================================================
          // Initialize the Sysprep
          // =========================================================================================
          System.out.println("\n*****  Clone Template to VM *****");
          //String vmName=null;
          VMConfiguration vmConfiguration=new VMConfiguration();
        
          // ---------------------------------------------------------------
          // Set the Society Name
          // ---------------------------------------------------------------
          //vmConfiguration.setUserName("actidev1");   
          vmConfiguration.setUserName("siveo_test");   
          vmConfiguration.setSocietyName("siveo");   
          vmConfiguration.setName("CDO01");
              
              
          // ---------------------------------------------------------------
          // Initialize the GuiUnattended Section
          // ---------------------------------------------------------------
          GuiUnattended guiUnattended=new GuiUnattended();
          guiUnattended.setAdminPassword("Clmdp@09");
          guiUnattended.setEncryptedAdminPassword(false);
          guiUnattended.setAutoLogon(true);
          guiUnattended.setAutoLogonCount(3);
          guiUnattended.setTimeZone(105);
              
          // ---------------------------------------------------------------
          // Initialize the LicenseFilePrintData Section
          // ---------------------------------------------------------------
          LicenseFilePrintData licenseData=new LicenseFilePrintData();
          licenseData.setAutoMode("PerServer");
          licenseData.setAutoUsers(5);
        
          // ---------------------------------------------------------------
          // Initialize the UserData Section
          // ---------------------------------------------------------------
          UserData userData=new UserData();
          userData.setComputerName(vmConfiguration.getName());
          userData.setFullName("WinVMUser");
          userData.setOrgName("SIVEO");
          userData.setProductId("MBKJF-QXT8P-RXWBG-FG687-C79GP");
        
          //TGXPV-C8PY4-VK2RP-Q9H9M-9KKP9
              
          // ---------------------------------------------------------------
          // Initialize the Identification Section
          // ---------------------------------------------------------------
          Identification identification =new Identification();
          identification.setDomainAdmin("SIVEO\\Administrateur");
          identification.setDomainAdminPassword("Clmdp@09");
          identification.setJoinDomain("SIVEO");
          //identification.setJoinWorkgroup("WORKGROUP");
              
          // ---------------------------------------------------------------
          // Initialize the GuiRunOnce Section
          // ---------------------------------------------------------------
          GuiRunOnce guiRunOnce = new GuiRunOnce();
          //String command="\"net localgroup Administrateurs "+identification.getJoinDomain()+"\\"+vmConfiguration.getUserName()+" /add\"";
          //String command="net localgroup Administrateurs "+identification.getJoinDomain()+"\\"+vmConfiguration.getUserName()+" /add";
          String command="\"net localgroup Administrateurs "+identification.getJoinDomain()+"\\"+vmConfiguration.getUserName()+" /add\"";
          guiRunOnce.setCommandList(new String[]{command});
          System.out.println("command: "+command);
              
          //test hudson
          // ---------------------------------------------------------------
          // Initialize the Sysprep
          // ---------------------------------------------------------------
          SysprepWindows winSysPrep=new SysprepWindows();
          winSysPrep.setGuiRunOnce(guiRunOnce);
          winSysPrep.setGuiUnattended(guiUnattended);
          winSysPrep.setIdentification(identification);
          winSysPrep.setLicenseFilePrintData(licenseData);
          winSysPrep.setUserData(userData);
              
              
          // ---------------------------------------------------------------
          // Initialize the Sysprep
          // ---------------------------------------------------------------
          //SysprepLinux sysprepLinux=new SysprepLinux();
          //sysprepLinux.setDomain("siveo.net");
          //sysprepLinux.setHostname(vmConfiguration.getName());
              
          // =========================================================================================
          // Initialize the VM Configuration
          // =========================================================================================
          // ---------------------------------------------------------------
          // Set the Sysprep
          // ---------------------------------------------------------------
          vmConfiguration.setSysprepWindows(winSysPrep);
          //vmConfiguration.setSysprepLinux(sysprepLinux);
              
          /*
          //String guiUnattended="\n[GuiUnattended]\nAdminPassword = \"Gd@jJ2009$\"\nAutoLogon = Yes\nAutoLogonCount = 3\nEncryptedAdminPassword = No\n" +
    "OEMSkipRegional = 1\nOEMSkipWelcome = 1\nTimeZone = 105\n\n";
        
          //String unattended="[Unattended]\nOEMSkipEula = Yes\n\n";
        
          //String licenseFilePrintData="[LicenseFilePrintData]\nAutoMode = PerServer\nAutoUsers = 5\n\n";
        
          //String userData="[UserData]\nComputerName = "+vmConfiguration.getName()+"\nFullName = \"WinVMUser\"\nOrgName = \"SIVEO\"\nProductKey = \"Q66VX-8TBQ3-2JC46-MDQFC-94CMB\"\n\n";
        
          ////String identification="[Identification]\nJoinDomain = SIVEO\nDomainAdmin = SIVEO\\Administrateur\nDomainAdminPassword = Clmdp@09\n\n";
        
          //String identification="[Identification]\nDomainAdmin = Administrateur\nDomainAdminPassword = \"Clmdp@09\"\nJoinDomain = SIVEO\n\n";
        
          //String networking="[Networking]\nInstallDefaultComponents = Yes\n\n";
        
          //String guiRunOnce="[GuiRunOnce]\ncommand0=\"net localgroup Administrateurs SIVEO\\actidev1 /add\"";
        
          //String sysprepContent=guiUnattended+unattended+licenseFilePrintData+userData+identification+networking+guiRunOnce;
              
          //vmConfiguration.setSysprepText(sysprepContent);
        
          System.out.println("Sysprep:");
          System.out.println(""+sysprepContent);
              
              
          // ---------------------------------------------------------------
          // Set Boot Options
          //
          // If not set the default values are:
          //
          // EnterBIOSSetup -> false
          // BootDelay      -> 0L
          // ---------------------------------------------------------------
          //BootOptions vmBootOpt=new BootOptions();
          //vmBootOpt.setEnterBIOSSetup(false);
          //vmBootOpt.setBootDelay(0L);
              
          vmConfiguration.setBootOptions(null);
              
          // ---------------------------------------------------------------
          // Set Console Preferences
          //
          // If not set the default values are:
          //
          // CloseOnPowerOffOrSuspend -> false
          // EnterFullScreenOnPowerOn -> false
          // powerOnWhenOpened        -> false
          // ---------------------------------------------------------------
          //ConsolePreferences vmConsolePref=new ConsolePreferences();
          //vmConsolePref.setCloseOnPowerOffOrSuspend(true);
          //vmConsolePref.setEnterFullScreenOnPowerOn(true);
          //vmConsolePref.setPowerOnWhenOpened(true);
        
          vmConfiguration.setConsolePreference(null);
              
          // ---------------------------------------------------------------
          // Set the defaults for the power operations on a virtual machine
          //
          // If not set the default values are:
          //
          // defaultPowerOffType -> "soft" 
          // defaultResetType    -> "soft" 
          // defaultSuspendType  -> "soft"  
          // powerOffType        -> "soft" 
          // resetType           -> "soft"
          // standbyAction       -> null
          // suspendType         -> "soft"
          // ---------------------------------------------------------------
          //PowerOptions vmPowerOpt=new PowerOptions();
          //vmPowerOpt.setPowerOffType("soft");
          //vmPowerOpt.setResetType("soft");
          //vmPowerOpt.setSuspendType("soft");
        
          vmConfiguration.setPowerOptions(null);
        
          // ---------------------------------------------------------------
          // Set the Network configuration
          //
          // If not set the default values are:
          //
          // DHCP
          // ---------------------------------------------------------------
              
          NetworkAdapter networkAdapter=new NetworkAdapter();
          //networkAdapter.setDnsDomain("siveo.net");
          ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
          //networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});
          //networkAdapter.setPrimaryWINS(null);
          //networkAdapter.setSecondaryWINS(null);
          //networkAdapter.setNetBIOS(null);
          //networkAdapter.setIp("192.168.1.99");
          //networkAdapter.setSubnetMask("255.255.255.0");
          ////networkAdapter.setGateway(new String[]{"192.168.0.254"});
          //networkAdapter.setGateway(new String[]{"192.168.1.1"});
          ////networkAdapter.setMacAddress(null);
          //vmConfiguration.setNetworkAdpater(networkAdapter);
              
          // !!!
          //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
          vmConfiguration.setDnsServerList(new String[]{});
          //vmConfiguration.setDnsSuffixList(new String[]{});
          vmConfiguration.setDnsSuffixList(new String[]{});
              
          // ---------------------------------------------------------------
          // Set the Network Traffic configuration
          // ---------------------------------------------------------------
              
          //NetworkTraffic netTraffic= new NetworkTraffic();
          //netTraffic.setAverageBps(0);
          //netTraffic.setBurstSize(0);
          //netTraffic.setPeakBps(0);
          //netTraffic.setShaper(false);
              
          vmConfiguration.setNetworkTraffic(null);
              
              
          // ---------------------------------------------------------------
          // Set the CPU configuration
          // ---------------------------------------------------------------
          VirtualCPU virtualCPU=new VirtualCPU();
          virtualCPU.setLimit(1024);
          virtualCPU.setReservation(1024);
          //virtualCPU.setShareLevel(null);
          virtualCPU.setExpandableReservation(false);
          virtualCPU.setNbCPU(1);
          vmConfiguration.setVirtualCPU(virtualCPU);
              
          // ---------------------------------------------------------------
          // Set the Memory confguration
          // ---------------------------------------------------------------
          VirtualMemory virtualMem=new VirtualMemory();
          virtualMem.setLimit(4096);
          virtualMem.setReservation(4096);
          virtualMem.setExpandableReservation(false);
          // !!!
          //virtualMem.setMemorySize(256);
          vmConfiguration.setVirtualMemory(virtualMem);
              
          vmConfiguration.setPowerOn(false);
        
          // ---------------------------------------------------------------
          // Set the Disk confguration
          // ---------------------------------------------------------------
          //vmConfiguration.setDiskSize(10);
              
          // ---------------------------------------------------------------
          // Set the Disk confguration
          // ---------------------------------------------------------------
          net.siveo.virtualization.vmware.virtualdevice.VirtualDisk virtualDisk=new VirtualDisk();
          virtualDisk.setDiskSize(10);
          vmConfiguration.getListOfVirtualDisk().add(virtualDisk);
          vmConfiguration.setDiskSize(virtualDisk.getDiskSize());
              
          // ---------------------------------------------------------------
          // Set the Network confguration
          // ---------------------------------------------------------------
          VirtualNetwork virtualNetwork=new VirtualNetwork();
          ////virtualNetwork.setVirtualnetworkID("network-104");
          virtualNetwork.setVirtualnetworkID("network-13");
          vmConfiguration.getListOfVirtualNetwork().add(virtualNetwork);
              
          vmConfiguration.setCorrelID("1234ABC");
              
              
          //vmManager.cloneTemplateToVM("Win2003SP2", vmConfiguration, true);
          //vmManager.cloneTemplateToVM("Windows2003SP2", vmConfiguration, "host-29","datastore-41");
          //vmManager.cloneTemplateToVM("Win2003SP2", vmConfiguration, "host-29","datastore-41");
        
              
          InventoryManager inventoryManager=InventoryManager.getInstance();
          Inventory inventory=inventoryManager.getInventoryByVC(hostName);
          inventory.getRootNode();
          System.out.println("Inventory 1");
        
              
          String dataStore="datastore-1194";
          String host="host-902";
          String vm="vm-8237";
              
              
          //vmManager.cloneTemplateToVM("Template_Windows2008", vmConfiguration, "host-918","datastore-1193");
          vmManager.cloneTemplateToVM(vm,hostName, vmConfiguration, host,dataStore);
          //datastore-1194
              
              
              
              
              
          // Pause
              
          System.out.println("Press a Key to continue...");
          try
          {
     System.in.read();
          }
          catch (IOException e)
          {
     // TODO Auto-generated catch block
     e.printStackTrace();
          }
              
              
          // new vmare
          //vmware=new VMware(hostName,443,"siveo_admin","s1v3oP0C",false,480000L,1000L);
          VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,480000L,1000L);
          inventoryManager=InventoryManager.getInstance();
          //inventory=inventoryManager.getInventoryByVC(hostName);
              
          //inventory.getRootNode();
          System.out.println("Inventory 2");
              
              
          vmManager=VMManager.getInstance();
          VirtualMachine vm=vmManager.getOldVmByName(hostName, "CDO01");
          ArrayList<VirtualDisk> listOfDisk=vm.getDisk();
              
          ArrayList<Network> listOfNetwork=vm.getNetwork();
        
          if (listOfNetwork!=null && !listOfNetwork.isEmpty())
          {
     for (Network network:listOfNetwork)
     {
        System.out.println("Network: "+network.getName()+"/VlanId: "+network.getVlanId());
     }
          }
        
              
          if (listOfNetwork!=null && !listOfNetwork.isEmpty())
          {
     for (Network network:listOfNetwork)
     {
        System.out.println("Network: "+network.getName()+"/VlanId: "+network.getVlanId());
     }
          }
              
          //vm.getConfiguration().getVirtualCPU()
              
              
              
          if (listOfDisk!=null && !listOfDisk.isEmpty())
          {
     for (net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk:listOfDisk)
     {
        System.out.println("Disk: "+vDisk.getLabel()+"/Key: "+vDisk.getKey()+"/Size: "+vDisk.getDiskSize());
     }
          }
              
          //vmManager.configureVMDisk("ActiBox15", 10);
              
          //vmware.getTaskMonitor().interrupt();
          //wsManager.deleteVIM();
              
              
              
          VMware.delete(hostName);
       }
    */

    public void configureTemplate(String tplName) throws VMwareException {

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();

        //System.out.println("breakPoint");

        VMManager vmManager = VMManager.getInstance();
        //VirtualMachine vm=vmManager.getOldVmByName(vmWareHostName, vmName);
        VirtualMachine vm = vmManager.getVmByName(hostName, tplName);

        listOfManagedObjectReferences.add(vm.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);

        vm.getVirtualDeviceManager().getNetworks();

        System.out.println("VM: " + vm.getMor().get_value());

        // ---------------------------------------------------------------
        // Set the CPU Confguration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setLimit(1000);
        virtualCPU.setReservation(700);

        virtualCPU.setNbCPU(2);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMemory = new VirtualMemory();
        virtualMemory.setLimit(2048);
        virtualMemory.setReservation(600);
        virtualMemory.setExpandableReservation(false);
        virtualMemory.setMemory(2048);

        // ---------------------------------------------------------------
        // Set the VirtualNetwork
        // ---------------------------------------------------------------
        ArrayList<VirtualNetwork> listOfVirtualNetwork = new ArrayList<VirtualNetwork>();
        VirtualNetwork virtualNetwork = null;

        //virtualNetwork=vm.getVMNetwork().getVirtualNetworkByID("network-248");
        //virtualNetwork.setAction(VirtualDeviceOperation.remove);
        //listOfVirtualNetwork.add(virtualNetwork);

        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = networkManager.getNetworkByID("network-210", hostName);

        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.add);
        listOfVirtualNetwork.add(virtualNetwork);

        // ---------------------------------------------------------------
        // Set the Distributed Virtual Switch
        // ---------------------------------------------------------------
        ArrayList<VirtualDVSwitch> listOfVirtualDVSwitch = new ArrayList<VirtualDVSwitch>();

        /*
        DVSwitchManager dvSwitchManager=DVSwitchManager.getInstance();
        DVSwitch dvSwitch=null;
        DVPortGroup dvPortGroup=null;
            
            
        VirtualDVSwitch virtualDVSwitch=null;
            
            
        //virtualDVSwitch=vm.getVMNetwork().getVirtualDVSwitchByUUIDByDvPortGroupKeyByPortKey("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", "dvportgroup-257", "2273");
            
        virtualDVSwitch=vm.getVMNetwork().getVirtualDVSwitchByUuidByDVPortGroupKey("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", "dvportgroup-202");
            
        //virtualDVSwitch=new VirtualDVSwitch();
        //virtualDVSwitch.setSwitchUuid("67 69 2d 50 b8 e5 40 4b-1c f0 c4 ac 38 54 ac 3d");
        //virtualDVSwitch.setPortGroupKey("dvportgroup-6421");
        virtualDVSwitch.setAction(VirtualDeviceOperation.remove);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
            
        //DVSwitchManager dvSwitchManager=DVSwitchManager.getInstance();
        dvSwitch=dvSwitchManager.getDVSwitchByUUID("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", hostName);
        dvPortGroup=dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-257");
            
        virtualDVSwitch=new VirtualDVSwitch();
        virtualDVSwitch.setDvSwitch(dvSwitch);
        virtualDVSwitch.setDvPortGroup(dvPortGroup);
        virtualDVSwitch.setAction(VirtualDeviceOperation.add);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
            
        //virtualDVSwitch.setSwitchUuid("67 69 2d 50 b8 e5 40 4b-1c f0 c4 ac 38 54 ac 3d");
        //virtualDVSwitch.setPortGroupKey("dvportgroup-201");
        //virtualDVSwitch.setAction(VirtualDeviceOperation.add);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
            
        // Edit a DVSwitch
        virtualDVSwitch=vm.getVMNetwork().getVirtualDVSwitchByUUID("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac");
            
        dvSwitch=dvSwitchManager.getDVSwitchByUUID("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", hostName);
        //dvPortGroup=dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-202");
        dvPortGroup=dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-257");
        System.out.println("dvPortGroup: "+dvPortGroup.getName());
            
        virtualDVSwitch.setDvPortGroup(dvPortGroup);
        virtualDVSwitch.setAction(VirtualDeviceOperation.edit);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
        */

        // ---------------------------------------------------------------
        // Set the VirtualDisk
        // ---------------------------------------------------------------
        ArrayList<net.siveo.virtualization.vmware.virtualdevice.VirtualDisk> listOfVirtualDisk = new ArrayList<net.siveo.virtualization.vmware.virtualdevice.VirtualDisk>();

        net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk = new VirtualDisk();

        // Add a DISK
        vDisk.setAction(VirtualDeviceOperation.add);
        vDisk.setDiskSize(1024L * 3L);
        //vDisk.setLabel("Hard disk 3");
        listOfVirtualDisk.add(vDisk);

        // Remove a DISK
        //vDisk=vm.getVirtualDeviceManager().getVirtualDiskByName("Disque dur 3");
        //vDisk.setAction(VirtualDeviceOperation.remove);
        //listOfVirtualDisk.add(vDisk);

        // Edit a Disk
        //vDisk=vm.getVirtualDeviceManager().getVirtualDiskByName("Disque dur 2");
        //vDisk.setAction(VirtualDeviceOperation.edit);
        //vDisk.setDiskSize(3*1024);
        //listOfVirtualDisk.add(vDisk);

        String correlID = "1234";

        //vm.configure(null, null, listOfVirtualDisk, listOfVirtualNetwork, listOfVirtualDVSwitch,correlID);
        vm.configure(virtualCPU, virtualMemory, null, null, null, correlID);

        System.out.println("Press a key to continue...");

        try {
            System.in.read();

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        VMware.delete(hostName);
    }

    public void configureVM(String vmName) throws VMwareException {
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //System.out.println("breakPoint");

        VMManager vmManager = VMManager.getInstance();
        //VirtualMachine vm=vmManager.getOldVmByName(vmWareHostName, vmName);
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        ArrayList<String> listOfMorIDs = new ArrayList<String>();
        listOfMorIDs.add(vm.getMor().get_value());
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        System.out.println("VM: " + vm.getMor().get_value());

        // ---------------------------------------------------------------
        // Set the CPU Confguration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setLimit(1500);
        virtualCPU.setReservation(900);

        virtualCPU.setNbCPU(1);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMemory = new VirtualMemory();
        virtualMemory.setLimit(2048);
        virtualMemory.setReservation(1024);
        virtualMemory.setExpandableReservation(false);
        virtualMemory.setMemory(1096);

        // ---------------------------------------------------------------
        // Set the VirtualNetwork
        // ---------------------------------------------------------------
        ArrayList<VirtualNetwork> listOfVirtualNetwork = new ArrayList<VirtualNetwork>();
        VirtualNetwork virtualNetwork = null;

        //      //virtualNetwork=vm.getVMNetwork().getVirtualNetworkByID("network-248");
        //      //virtualNetwork.setAction(VirtualDeviceOperation.remove);
        //      //listOfVirtualNetwork.add(virtualNetwork);
        //      
        //      
        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = networkManager.getNetworkByID("HaNetwork-VM Network", hostName);

        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.add);
        listOfVirtualNetwork.add(virtualNetwork);

        // ---------------------------------------------------------------
        // Set the Distributed Virtual Switch
        // ---------------------------------------------------------------
        ArrayList<VirtualDVSwitch> listOfVirtualDVSwitch = new ArrayList<VirtualDVSwitch>();

        /*
        DVSwitchManager dvSwitchManager=DVSwitchManager.getInstance();
        DVSwitch dvSwitch=null;
        DVPortGroup dvPortGroup=null;
            
            
        VirtualDVSwitch virtualDVSwitch=null;
            
            
        //virtualDVSwitch=vm.getVMNetwork().getVirtualDVSwitchByUUIDByDvPortGroupKeyByPortKey("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", "dvportgroup-257", "2273");
            
        virtualDVSwitch=vm.getVMNetwork().getVirtualDVSwitchByUuidByDVPortGroupKey("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", "dvportgroup-202");
            
        //virtualDVSwitch=new VirtualDVSwitch();
        //virtualDVSwitch.setSwitchUuid("67 69 2d 50 b8 e5 40 4b-1c f0 c4 ac 38 54 ac 3d");
        //virtualDVSwitch.setPortGroupKey("dvportgroup-6421");
        virtualDVSwitch.setAction(VirtualDeviceOperation.remove);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
            
        //DVSwitchManager dvSwitchManager=DVSwitchManager.getInstance();
        dvSwitch=dvSwitchManager.getDVSwitchByUUID("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", hostName);
        dvPortGroup=dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-257");
            
        virtualDVSwitch=new VirtualDVSwitch();
        virtualDVSwitch.setDvSwitch(dvSwitch);
        virtualDVSwitch.setDvPortGroup(dvPortGroup);
        virtualDVSwitch.setAction(VirtualDeviceOperation.add);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
            
        //virtualDVSwitch.setSwitchUuid("67 69 2d 50 b8 e5 40 4b-1c f0 c4 ac 38 54 ac 3d");
        //virtualDVSwitch.setPortGroupKey("dvportgroup-201");
        //virtualDVSwitch.setAction(VirtualDeviceOperation.add);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
            
        // Edit a DVSwitch
        virtualDVSwitch=vm.getVMNetwork().getVirtualDVSwitchByUUID("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac");
            
        dvSwitch=dvSwitchManager.getDVSwitchByUUID("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", hostName);
        //dvPortGroup=dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-202");
        dvPortGroup=dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-257");
        System.out.println("dvPortGroup: "+dvPortGroup.getName());
            
        virtualDVSwitch.setDvPortGroup(dvPortGroup);
        virtualDVSwitch.setAction(VirtualDeviceOperation.edit);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
        */

        // ---------------------------------------------------------------
        // Set the VirtualDisk
        // ---------------------------------------------------------------
        ArrayList<net.siveo.virtualization.vmware.virtualdevice.VirtualDisk> listOfVirtualDisk = new ArrayList<net.siveo.virtualization.vmware.virtualdevice.VirtualDisk>();

        net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk = new VirtualDisk();

        // Add a DISK
        vDisk.setAction(VirtualDeviceOperation.add);
        vDisk.setDiskSize(1024 * 1);
        //vDisk.setLabel("Hard disk 3");
        listOfVirtualDisk.add(vDisk);

        // Remove a DISK
        //vDisk=vm.getVirtualDeviceManager().getVirtualDiskByName("Disque dur 3");
        //vDisk.setAction(VirtualDeviceOperation.remove);
        //listOfVirtualDisk.add(vDisk);

        //      // Edit a Disk
        //      //vDisk=vm.getVirtualDeviceManager().getVirtualDiskByName("Disque dur 2");
        //      vDisk=vm.getVirtualDeviceManager().getVirtualDiskByKey(2002);
        //      vDisk.setAction(VirtualDeviceOperation.edit);
        //      vDisk.setDiskSize(3*1024);
        //      listOfVirtualDisk.add(vDisk);

        String correlID = "1234";

        //      ArrayList<String> listOfMorIDs=new ArrayList<String>();
        //      InventoryManager inventoryManager=InventoryManager.getInstance();
        //      Inventory inventory=inventoryManager.getInventoryByVC(hostName);
        //      listOfMorIDs.add(vm.getMor().get_value());
        //      inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        vm.configure(virtualCPU, virtualMemory, listOfVirtualDisk, listOfVirtualNetwork, listOfVirtualDVSwitch,
                correlID);

        //      System.out.println("Press a key to continue...");
        //      
        //      try
        //      {
        //         System.in.read();
        //      }
        //      catch (IOException e)
        //      {
        //         // TODO Auto-generated catch block
        //         e.printStackTrace();
        //      }

        VMware.delete(hostName);
    }
    // END Method confgiureVM

    public void moveVM(String vmName) throws VMwareException {
        String vmWareHostName = "10.251.5.15";
        VMware vmware = new VMware(vmWareHostName, 443, "Administrateur", "Clmdp@09", false, 480000L, 1000L);
        WSManager wsManager = WSManager.getInstance();

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(vmWareHostName, vmName);

        String hostID = null;
        String dataStoreID = null;
        String resourcePoolID = null;

        // dskesxi.siveo.net
        hostID = "host-87";
        dataStoreID = "datastore-70";
        resourcePoolID = null;

        // jerakine.siveo.net
        //hostID="host-24";
        //dataStoreID="datastore-50";
        //dataStoreID="datastore-53";
        //resourcePoolID="resgroup-32";

        System.out.println("Relocate VM");
        vm.move(hostID, dataStoreID, resourcePoolID, "1234");

        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();

    }

    public void browseDisk() throws VMwareException {
        String vmwareServerName = "10.0.12.6";
        VMware vmware = new VMware(vmwareServerName, 443, "siveo_admin", "s1v3oP0C", false, 480000L, 1000L);
        WSManager wsManager = WSManager.getInstance();

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(vmwareServerName, "JTH01");

        ArrayList<net.siveo.virtualization.vmware.virtualdevice.VirtualDisk> listOfDisk = vm.getDisk();

        int nbDisk = 1;
        for (net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk : listOfDisk) {
            System.out.println("\nDisk n" + nbDisk++);
            System.out.println("- Label: " + vDisk.getLabel());
            System.out.println("- Summary: " + vDisk.getSummary());
            System.out.println("- Size: " + vDisk.getDiskSize());
            System.out.println("- Controller Key: " + vDisk.getControllerKey());
            System.out.println("- Key: " + vDisk.getKey());
            System.out.println("- Unit Number: " + vDisk.getUnitNumber());
            System.out.println("- Backing: " + vDisk.getBacking().getClass());
            if (vDisk.getBacking() instanceof com.vmware.vim25.VirtualDiskFlatVer2BackingInfo) {
                com.vmware.vim25.VirtualDiskFlatVer2BackingInfo backing = (com.vmware.vim25.VirtualDiskFlatVer2BackingInfo) vDisk
                        .getBacking();
                System.out.println("- Disk Mode: " + backing.getDiskMode());
                System.out.println("- File Name: " + backing.getFileName());
                System.out.println("- Dynamic Type: " + backing.getDynamicType());
                System.out.println("- Eagerly Scrub: " + backing.getEagerlyScrub());
                System.out.println("- Split: " + backing.getSplit());
                System.out.println("- Thin Provisioned: " + backing.getThinProvisioned());
                System.out.println("- Write Through: " + backing.getWriteThrough());
            }
            //System.out.println(""+vDisk.getBacking());
        }

        System.out.println("\n\nMax UnitNumber: " + vm.getVirtualDeviceManager().getLastUnitNumber());
        System.out.println("\n\nDisk Mode: " + VirtualDiskMode.persistent.toString());
        vmware.getTaskMonitor().interrupt();
        wsManager.deleteVIM();

    }

    public void waitKey() throws VMwareException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Appuyer sur une touche 1");

        try {
            in.readLine();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("Appuyer sur une touche 2");

        try {
            in.readLine();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("Sortie !!");

    }

    public void reloadSession() throws VMwareException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String hostName = "10.251.5.15";

        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L, 1000L);
        WSManager wsManager = WSManager.getInstance();

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "ActiBox05");

        VMConfiguration vmConfiguration = vm.getConfiguration();

        System.out.println("Avant Reconnexion:");
        System.out.println("CPU:");
        System.out.println(" - Reservation: " + vmConfiguration.getVirtualCPU().getReservation());
        System.out.println(" - Limit: " + vmConfiguration.getVirtualCPU().getLimit());
        System.out.println(" - Mghz: " + vmConfiguration.getVirtualCPU().getMghz());
        System.out.println("Memory:");
        System.out.println(" - Reservation: " + vmConfiguration.getVirtualMemory().getReservation());
        System.out.println(" - Limit: " + vmConfiguration.getVirtualMemory().getLimit());
        System.out.println(" - Mem:: " + vmConfiguration.getVirtualMemory().getMemorySize());

        System.out.println("Arrter VMware et appuyer sur une touche 1");

        try {
            in.readLine();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        //Start VM
        try {
            vm.powerOn();
        } catch (VMwareException vMwareException) {
            System.out.println("PowerOn  plant");
        }

        //Stop VM
        try {
            vm.powerOff();
        } catch (VMwareException vMwareException) {
            System.out.println("PowerOff  plant");
        }

        System.out.println("Rdmarrer VMware et appuyer sur une touche");

        try {
            in.readLine();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        vm = vmManager.getVmByName(hostName, "ActiBox05");
        vmConfiguration = vm.getConfiguration();

        System.out.println("Aprs Reconnexion:");
        System.out.println("CPU:");
        System.out.println(" - Reservation: " + vmConfiguration.getVirtualCPU().getReservation());
        System.out.println(" - Limit: " + vmConfiguration.getVirtualCPU().getLimit());
        System.out.println(" - Mghz: " + vmConfiguration.getVirtualCPU().getMghz());
        System.out.println("Memory:");
        System.out.println(" - Reservation: " + vmConfiguration.getVirtualMemory().getReservation());
        System.out.println(" - Limit: " + vmConfiguration.getVirtualMemory().getLimit());
        System.out.println(" - Mem:: " + vmConfiguration.getVirtualMemory().getMemorySize());

        //wsManager.deleteVIM();
        VMware.delete(hostName);

    }

    public void cloneVMToTemplate() throws VMwareException {
        //String hostName="10.0.12.6";
        //VMware.create(hostName,443,"dgme_admin","s1v3oP0C",false,-1L,1000L);

        /*
        String hostName="192.168.101.179";
        VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);
            
            
        String vmID="vm-3809";
        String vmwareServerName=hostName;
        String templateName="TemplateCDO";
        String hostID="host-123";
        String datastoreID="datastore-2919";
        String correlID="1234";
        */

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        String vmID = "vm-324";
        String vmwareServerName = hostName;
        String templateName = "TemplateCDOO";
        String hostID = "host-246";
        String datastoreID = "datastore-247";
        String correlID = "1234";

        VMManager vmManager = VMManager.getInstance();
        //vmManager.cloneVMToTemplate(vmID, vmwareServerName, templateName, hostID, datastoreID, correlID);

        VMware.delete(hostName);

    }

    public void shutdownVM() throws VMwareException {
        String hostName = "10.0.12.6";
        VMware.create(hostName, 443, "siveo_admin", "s1v3oP0C", false, -1L, 1000L);

        VMManager vmManager = VMManager.getInstance();
        String vmName = "JTH02";

        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        try {
            vm.shutdownGuest();
        } catch (VMwareException vMwareException) {
            System.out.println("Erreur lors de l'arret");
        }

        vm.powerOff();

        VMware.delete(hostName);

    }

    public void convertVMToTemplateAndRename() throws VMwareException {

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        //String hostName="10.0.12.6";
        //VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,-1L,1000L);

        VMManager vmManager = VMManager.getInstance();
        String vmID = "vm-2129";

        vmManager.convertVMToTemplate(vmID, hostName, "JTA_Template", "1234");

        VMware.delete(hostName);

    }

    public void configureIP() throws VMwareException {

        // =========================================================================================
        // Connexion au VirtualCenter
        // =========================================================================================
        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // Initialize the Sysprep
        // =========================================================================================
        System.out.println("\n*****  Configure VM IP Settings*****");
        //String vmName=null;
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        //vmConfiguration.setUserName("actidev1");   
        vmConfiguration.setUserName("siveo_test");
        vmConfiguration.setSocietyName("siveo");
        vmConfiguration.setName("CDO");

        // ---------------------------------------------------------------
        // Initialize the GuiUnattended Section
        // ---------------------------------------------------------------
        GuiUnattended guiUnattended = new GuiUnattended();
        guiUnattended.setAdminPassword("Clmdp@09");
        guiUnattended.setEncryptedAdminPassword(false);
        guiUnattended.setAutoLogon(true);
        guiUnattended.setAutoLogonCount(3);
        guiUnattended.setTimeZone(105);

        // ---------------------------------------------------------------
        // Initialize the LicenseFilePrintData Section
        // ---------------------------------------------------------------
        LicenseFilePrintData licenseData = new LicenseFilePrintData();
        licenseData.setAutoMode("PerServer");
        licenseData.setAutoUsers(5);

        // ---------------------------------------------------------------
        // Initialize the UserData Section
        // ---------------------------------------------------------------
        UserData userData = new UserData();
        userData.setComputerName(vmConfiguration.getName());
        userData.setFullName("WinVMUser");
        userData.setOrgName("SIVEO");
        userData.setProductId("MBKJF-QXT8P-RXWBG-FG687-C79GP");

        //

        // ---------------------------------------------------------------
        // Initialize the Identification Section
        // ---------------------------------------------------------------
        Identification identification = new Identification();
        identification.setDomainAdmin("SIVEO\\Administrateur");
        identification.setDomainAdminPassword("Clmdp@09");
        identification.setJoinDomain(null);
        identification.setJoinWorkgroup("WORKGROUP");

        //identification.setDomainAdmin("SIVEO\\Administrateur");
        //identification.setDomainAdminPassword("Clmdp@09");
        //identification.setJoinDomain("SIVEO");
        ////identification.setJoinWorkgroup("WORKGROUP");

        // ---------------------------------------------------------------
        // Initialize the GuiRunOnce Section
        // ---------------------------------------------------------------
        GuiRunOnce guiRunOnce = new GuiRunOnce();
        String command = "\"net localgroup Administrateurs " + identification.getJoinDomain() + "\\"
                + vmConfiguration.getUserName() + " /add\"";
        //System.out.println("command: "+command);
        guiRunOnce.setCommandList(new String[] { command });

        //test hudson
        // ---------------------------------------------------------------
        // Initialize the Sysprep for Windows
        // ---------------------------------------------------------------
        SysprepWindows winSysPrep = new SysprepWindows();
        //winSysPrep.setGuiRunOnce(guiRunOnce);
        winSysPrep.setGuiUnattended(guiUnattended);
        winSysPrep.setIdentification(identification);
        winSysPrep.setLicenseFilePrintData(licenseData);
        winSysPrep.setUserData(userData);

        // ---------------------------------------------------------------
        // Initialize the Sysprep
        // ---------------------------------------------------------------
        //SysprepLinux sysprepLinux=new SysprepLinux();
        //sysprepLinux.setDomain("siveo.net");
        //sysprepLinux.setHostname(vmConfiguration.getName());

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        vmConfiguration.setSysprepWindows(winSysPrep);
        //vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------
        // Set IP for the first Network Adapter
        NetworkAdapter networkAdapter = new NetworkAdapter();
        networkAdapter.setDnsServerList(new String[] { "192.168.165.1", "194.133.125.66" });
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.0.12.25");
        networkAdapter.setSubnetMask("255.255.255.0");
        networkAdapter.setGateway(new String[] { "10.0.12.1" });
        networkAdapter.setMacAddress("00:50:56:ae:00:52");
        //networkAdapter.setMacAddress("00:50:56:81:00:40");
        vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // Set IP for the second Network Adapter
        networkAdapter = new NetworkAdapter();
        networkAdapter.setDnsServerList(new String[] { "192.168.165.1", "194.133.125.66" });
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.0.12.21");
        networkAdapter.setSubnetMask("255.255.255.0");
        networkAdapter.setGateway(new String[] { "10.0.12.1" });
        //networkAdapter.setMacAddress("00:50:56:81:00:3e");
        networkAdapter.setMacAddress("00:50:56:AE:00:52");
        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        vmConfiguration.setDnsServerList(new String[] { "192.168.165.1", "194.133.125.66" });
        vmConfiguration.setDnsSuffixList(new String[] {});

        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "TestCDORHEL");
        vmManager.configureIP(vm.getMor().get_value(), hostName, vmConfiguration);

        VMware.delete(hostName);

    }

    public void coinfigureIP() throws VMwareException {
        String hostName = "10.0.12.6";
        VMware.create(hostName, 443, "siveo_admin", "s1v3oP0C", false, -1L, 1000L);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "Windows2008");

        ArrayList<VirtualNetwork> listOfVirtualNetwork = new ArrayList<VirtualNetwork>();
        VirtualNetwork virtualNetwork = null;

        virtualNetwork = vm.getVMNetwork().getVirtualNetworkByID("network-1199");

        //virtualNetwork=new VirtualNetwork();
        //virtualNetwork.setVirtualnetworkID("network-3177");
        //!!!!!
        //virtualNetwork.setVirtualnetworkID("network-1199");
        //virtualNetwork.setIpAddress("169.254.35.83");

        virtualNetwork = vm.getVMNetwork().getVirtualNetworkByID("network-1199");
        virtualNetwork.getListOfIPAddress().add("169.254.35.83");
        //virtualNetwork.setIpAddress("169.254.35.83");
        listOfVirtualNetwork.add(virtualNetwork);

        //virtualNetwork=new VirtualNetwork();
        //!!!!!
        //virtualNetwork.setVirtualnetworkID("network-3176");
        //virtualNetwork.getListOfIpAddress().add("169.254.14.83");
        virtualNetwork = vm.getVMNetwork().getVirtualNetworkByID("network-3176");
        virtualNetwork.getListOfIPAddress().add("169.254.14.83");
        //listOfVirtualNetwork.add(virtualNetwork);

        //virtualNetwork.setIpAddress("169.254.14.83");
        //listOfVirtualNetwork.add(virtualNetwork);

        // Il faut que la VM soit teinte
        //vm.configIP(listOfVirtualNetwork);

        VMware.delete(hostName);

    }

    /*   
       public void displayHostNetwork() throws VMwareException
       {
          String hostName="192.168.101.79";
          VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);
        
          HostManager hostManager=HostManager.getInstance();
          Host host=hostManager.getHostByID("host-28", hostName);
              
          host.loadNetworks();
              
              
              
          VMware.delete(hostName);
       }
    */

    public void dvSwitchManager() throws VMwareException {
        String hostName = "192.168.101.79";

        WS ws = null;
        WSManager wsManager = WSManager.getInstance();

        // ===================================================================================
        // Create the VMware WebService 
        // ===================================================================================
        ws = wsManager.createVIM(hostName, 443, "svc-siveo", "S1v30d6m3", false, -1L);

        DVSManagerDvsConfigTarget dvsManagerDvsConfigTarget = null;
        ManagedObjectReference dvSwitchManager = null;
        ManagedObjectReference distributedVirtualSwitch = null;

        ManagedObjectReference host = new ManagedObjectReference();
        host.setType("HostSystem");
        host.set_value("host-28");

        dvSwitchManager = ws.getVIMService().getServiceContent().getDvSwitchManager();

        try {
            dvsManagerDvsConfigTarget = ws.getVIMService().getService().queryDvsConfigTarget(dvSwitchManager, host,
                    null);
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        DistributedVirtualPortgroupInfo[] tabDistributedVirtualPortgroupInfos = null;
        DistributedVirtualSwitchInfo[] tabDistributedVirtualSwitchInfos = null;

        tabDistributedVirtualPortgroupInfos = dvsManagerDvsConfigTarget.getDistributedVirtualPortgroup();
        tabDistributedVirtualSwitchInfos = dvsManagerDvsConfigTarget.getDistributedVirtualSwitch();

        System.out.println("Distributed VirtualSwitch Info:");
        int nbDvswitchInfo = 1;

        for (DistributedVirtualSwitchInfo dvswitchInfo : tabDistributedVirtualSwitchInfos) {
            System.out.println("Distributed Virtual Switch n" + nbDvswitchInfo++);
            System.out.println("-SwitchName: " + dvswitchInfo.getSwitchName());
            System.out.println("-UUID: " + dvswitchInfo.getSwitchUuid());

            distributedVirtualSwitch = dvswitchInfo.getDistributedVirtualSwitch();
        }

        System.out.println("/nDistributed Virtual Portgroup Info:");

        int nbPortgroupInfo = 1;
        ManagedObjectReference distributedVirtualPortgroup = null;
        ArrayOfString arrOfportKeys = null;
        String[] portKeys = null;

        for (DistributedVirtualPortgroupInfo portgroupInfo : tabDistributedVirtualPortgroupInfos) {
            System.out.println("Distributed Portgroup n" + nbPortgroupInfo++);
            System.out.println("-PortgroupName: " + portgroupInfo.getPortgroupName());
            System.out.println("-Key: " + portgroupInfo.getPortgroupKey());
            System.out.println("portgroupInfo: " + portgroupInfo.getClass());
            distributedVirtualPortgroup = portgroupInfo.getPortgroup();

            arrOfportKeys = (ArrayOfString) MorManager.getMorProperty(ws, distributedVirtualPortgroup,
                    new String[] { "portKeys" });

            portKeys = arrOfportKeys.getString();

            if (portKeys != null && portKeys.length > 0) {
                for (String portkey : portKeys) {
                    System.out.println("-PortKey: " + portkey);
                }
            }

            System.out.println("");
        }

        System.out.println("/nDistributedVirtualPort:");
        int nbDvPort = 1;

        DistributedVirtualSwitchPortCriteria distributedVirtualSwitchPortCriteria = new DistributedVirtualSwitchPortCriteria();
        distributedVirtualSwitchPortCriteria.setActive(true);
        distributedVirtualSwitchPortCriteria.setConnected(true);
        distributedVirtualSwitchPortCriteria.setInside(true);
        distributedVirtualSwitchPortCriteria.setPortgroupKey(new String[] { "dvportgroup-127" });
        distributedVirtualSwitchPortCriteria.setPortKey(new String[] { "64" });

        DistributedVirtualPort[] tabOfDistributedVirtualPorts = null;

        try {
            tabOfDistributedVirtualPorts = ws.getVIMService().getService().fetchDVPorts(distributedVirtualSwitch,
                    distributedVirtualSwitchPortCriteria);

            if (tabOfDistributedVirtualPorts != null && tabOfDistributedVirtualPorts.length > 0) {
                for (DistributedVirtualPort dvPort : tabOfDistributedVirtualPorts) {
                    System.out.println("dvPort n" + nbDvPort++);
                    System.out.println("-Key: " + dvPort.getKey());
                    System.out.println("-ConfigVersion: " + dvPort.getConfig().getConfigVersion());
                    System.out.println("-Description: " + dvPort.getConfig().getDescription());
                    System.out.println("-Name: " + dvPort.getConfig().getName());
                }
            }

        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        ws.getVIMService().logout();
        wsManager.deleteWS(ws);

    }

    public void addDVSwitchTOVM() throws VMwareException {
        String hostName = "192.168.101.79";

        VMware.create(hostName, 443, "svc-siveo", "S1v30d6m3", false, -1L, 1000L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByID(hostName, "vm-6594");

        ArrayList<VirtualDeviceConfigSpec> listOfVirtualDeviceConfigSpec = new ArrayList<VirtualDeviceConfigSpec>();

        // =========================================================================================
        // Dbut
        // =========================================================================================
        VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();

        // --------------------------------------------------------------------
        // Create the Backing Virtual Network Adapter  
        // --------------------------------------------------------------------
        DistributedVirtualSwitchPortConnection distributedVirtualSwitchPortConnection = new DistributedVirtualSwitchPortConnection();
        distributedVirtualSwitchPortConnection.setSwitchUuid("67 69 2d 50 b8 e5 40 4b-1c f0 c4 ac 38 54 ac 3d");
        distributedVirtualSwitchPortConnection.setPortgroupKey("dvportgroup-6421");
        VirtualEthernetCardDistributedVirtualPortBackingInfo virtualEthernetCardDistributedVirtualPortBackingInfo = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
        virtualEthernetCardDistributedVirtualPortBackingInfo.setPort(distributedVirtualSwitchPortConnection);

        // --------------------------------------------------------------------
        // Create a VirtualCard depending of the Virtual Network Device associated to the VM  
        // --------------------------------------------------------------------
        VirtualEthernetCard virtualCard = null;
        //virtualCard=new VirtualVmxnet3();
        virtualCard = new VirtualE1000();

        // --------------------------------------------------------------------
        // Set the Virtual Network Card Properties  
        // --------------------------------------------------------------------
        virtualCard.setBacking(virtualEthernetCardDistributedVirtualPortBackingInfo);
        virtualCard.setKey(-1);
        virtualCard.setAddressType(Constants.NETWORK_MAC_ADDRESS_TYPE_GENERATED);
        //virtualNetwork.getVirtualDevice().setBacking(virtualEthernetCardNetworkBackingInfo);

        // --------------------------------------------------------------------
        // Set the Virtual Device Config Spec  
        // --------------------------------------------------------------------
        VirtualDeviceConfigSpec vDeviceConfigSpec = new VirtualDeviceConfigSpec();
        vDeviceConfigSpec.setDevice(virtualCard);
        vDeviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.add);

        // --------------------------------------------------------------------
        // Create the network  
        // --------------------------------------------------------------------
        listOfVirtualDeviceConfigSpec.add(vDeviceConfigSpec);

        vmConfigSpec.setDeviceChange(listOfVirtualDeviceConfigSpec
                .toArray(new VirtualDeviceConfigSpec[listOfVirtualDeviceConfigSpec.size()]));

        try {
            ws.getVIMService().getService().reconfigVM_Task(vm.getMor(), vmConfigSpec);
        } catch (TaskInProgress e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (VmConfigFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ConcurrentAccess e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (FileFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidName e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (DuplicateName e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidState e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InsufficientResourcesFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidDatastore e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Fin
        // =========================================================================================

        VMware.delete(hostName);
    }

    public void getVMNetwork(String vmName) throws VMwareException {
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="10.0.12.6";
        //VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,-1L,1000L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L,1000L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L, 1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L,1000L);

        VMManager vmManager = VMManager.getInstance();
        //InventoryManager inventoryMng=InventoryManager.getInstance();

        VirtualMachine vm = null;
        vm = vmManager.getVmByName(hostName, vmName);

        VMNetwork vmNetwork = vm.getVMNetwork();

        if (vmNetwork != null) {
            if (!vmNetwork.getListOfVirtualNetwork().isEmpty()) {
                System.out.println("List Of Virtual Network");
                for (VirtualNetwork virtualNetwork : vmNetwork.getListOfVirtualNetwork()) {
                    System.out.println("-Name: " + virtualNetwork.getNetwork().getName());
                    System.out.println("-ID: " + virtualNetwork.getNetwork().getMor().get_value());
                    System.out.println("-Label: " + virtualNetwork.getVirtualDevice().getDeviceInfo().getLabel());
                    System.out.println("-MAC Address: " + virtualNetwork.getMacAddress());
                    if (virtualNetwork.getListOfIPAddress() != null
                            && !virtualNetwork.getListOfIPAddress().isEmpty()) {
                        System.out.println("-IP Address:");

                        for (String ip : virtualNetwork.getListOfIPAddress()) {
                            System.out.println(" - " + ip);
                        }
                    }
                    System.out.println("");
                }
            } else if (!vmNetwork.getListOfVirtualDVSwitch().isEmpty()) {
                System.out.println("\nList Of Virtual DVSwitch\n");
                for (VirtualDVSwitch virtualDVSwitch : vmNetwork.getListOfVirtualDVSwitch()) {
                    System.out.println("-Label: " + virtualDVSwitch.getLabel());
                    System.out.println(" -Name: " + virtualDVSwitch.getDvSwitch().getName());
                    System.out.println(" -UUID: " + virtualDVSwitch.getDvSwitch().getUuid());
                    System.out.println("-Port Group:");
                    System.out.println(" -Name: " + virtualDVSwitch.getDvPortGroup().getName());
                    System.out.println(" -Key: " + virtualDVSwitch.getDvPortGroup().getKey());
                    System.out.println("-Port Key: " + virtualDVSwitch.getPortKey());
                    System.out.println("-MAC Address: " + virtualDVSwitch.getMacAddress());
                    if (virtualDVSwitch.getListOfIPAddress() != null
                            && !virtualDVSwitch.getListOfIPAddress().isEmpty()) {
                        System.out.println("-IP Address:");

                        for (String ip : virtualDVSwitch.getListOfIPAddress()) {
                            System.out.println(" - " + ip);
                        }
                    }
                    System.out.println("");
                }
            }

        }

        System.out.println("");
        System.out.println("");
        System.out.println("Appuyer sur une touche");

        try {
            System.in.read();
        } catch (IOException e)

        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        vmNetwork = vm.refreshNetwork();

        if (vmNetwork != null) {
            if (!vmNetwork.getListOfVirtualNetwork().isEmpty()) {
                System.out.println("List Of Virtual Network");
                for (VirtualNetwork virtualNetwork : vmNetwork.getListOfVirtualNetwork()) {
                    System.out.println("-Name: " + virtualNetwork.getNetwork().getName());
                    System.out.println("-ID: " + virtualNetwork.getNetwork().getMor().get_value());
                    System.out.println("-Label: " + virtualNetwork.getVirtualDevice().getDeviceInfo().getLabel());
                    System.out.println("-MAC Address: " + virtualNetwork.getMacAddress());
                    if (virtualNetwork.getListOfIPAddress() != null
                            && !virtualNetwork.getListOfIPAddress().isEmpty()) {
                        System.out.println("-IP Address:");

                        for (String ip : virtualNetwork.getListOfIPAddress()) {
                            System.out.println(" - " + ip);
                        }
                    }
                    System.out.println("");
                }
            } else if (!vmNetwork.getListOfVirtualDVSwitch().isEmpty()) {
                System.out.println("\nList Of Virtual DVSwitch\n");
                for (VirtualDVSwitch virtualDVSwitch : vmNetwork.getListOfVirtualDVSwitch()) {
                    System.out.println("-Label: " + virtualDVSwitch.getLabel());
                    System.out.println(" -Name: " + virtualDVSwitch.getDvSwitch().getName());
                    System.out.println(" -UUID: " + virtualDVSwitch.getDvSwitch().getUuid());
                    System.out.println("-Port Group:");
                    System.out.println(" -Name: " + virtualDVSwitch.getDvPortGroup().getName());
                    System.out.println(" -Key: " + virtualDVSwitch.getDvPortGroup().getKey());
                    System.out.println("-Port Key: " + virtualDVSwitch.getPortKey());
                    System.out.println("-MAC Address: " + virtualDVSwitch.getMacAddress());
                    if (virtualDVSwitch.getListOfIPAddress() != null
                            && !virtualDVSwitch.getListOfIPAddress().isEmpty()) {
                        System.out.println("-IP Address:");

                        for (String ip : virtualDVSwitch.getListOfIPAddress()) {
                            System.out.println(" - " + ip);
                        }
                    }
                    System.out.println("");
                }
            }

        }

        /*      
              ArrayOfManagedObjectReference arrayOfManagedObjectReference=(ArrayOfManagedObjectReference)MorManager.getMorProperty(vm.getWS().getVIMService(),vm.getMor(), new String[] {"network"});
            
              if (arrayOfManagedObjectReference!=null && arrayOfManagedObjectReference.getManagedObjectReference()!=null && arrayOfManagedObjectReference.getManagedObjectReference().length>0)
              {
                 for (ManagedObjectReference mor:arrayOfManagedObjectReference.getManagedObjectReference())
                 {
        String name=(String)MorManager.getMorProperty(vm.getWS().getVIMService(),mor, new String[] {"name"});
        System.out.println("vm Network: "+name+" / "+mor.get_value()+":"+mor.getType());
                 }
              }
        */

        //MorManager.getMorProperty(ws.getVIMService(),containerView, new String[] {"view"})

        //
        //VirtualDVSwitch virtualDVSwitch=null;

        //virtualDVSwitch=vmNetwork.getVirtualDVSwitchByUuidByDVPortGroupKey("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", "dvportgroup-595");
        //System.out.println("Name: "+virtualDVSwitch.getDvSwitch().getName()+" / "+virtualDVSwitch.getDvPortGroup().getName());

        //virtualDVSwitch=vmNetwork.getVirtualDVSwitchByUuidByDVPortGroupKey("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", "dvportgroup-202");
        //System.out.println("Name: "+virtualDVSwitch.getDvSwitch().getName()+" / "+virtualDVSwitch.getDvPortGroup().getName());

        VMware.delete(hostName);

    }

    public void listDVSwitch() throws VMwareException {

        // =========================================================================================
        // Connexion au VirtualCenter
        // =========================================================================================
        String hostName = "192.168.101.79";

        Date start = new Date();
        VMware.create(hostName, 443, "svc-siveo", "S1v30d6m3", false, -1L, 1000L);
        Date end = new Date();

        System.out.println("Tempms Inti Infra: " + (end.getTime() - start.getTime()));

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        Date start1 = new Date();
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("vblockrm2001", hostName);
        Date end1 = new Date();
        System.out.println("Tempms GetHostByName: " + (end1.getTime() - start1.getTime()));

        Date start2 = new Date();
        ArrayList<DVSwitch> listOfDVSwitch = host.loadDVSwitch();
        Date end2 = new Date();
        System.out.println("Tempms Get DVSwitch: " + (end2.getTime() - start2.getTime()));

        DynamicProperty[] multiProp = null;
        Date dtSart20 = new Date();
        multiProp = (DynamicProperty[]) MorManager.getProperties(ws.getVIMService(), listOfDVSwitch.get(0).getMor(),
                new String[] { "config.uuid", "config.name", "config.description", "config.numPorts",
                        "config.maxPorts", "config.numStandalonePorts", "config.uplinkPortgroup", "portgroup" });
        Date dtEnd20 = new Date();

        System.out.println("Appel getProperties: " + (dtEnd20.getTime() - dtSart20.getTime()));

        if (multiProp != null) {
            for (DynamicProperty dynamicProperty : multiProp) {
                System.out.println("Property Name: " + dynamicProperty.getName());
                System.out.println("Property Value: " + dynamicProperty.getVal());
                System.out.println("");
            }
        }

        System.out.println("list of DistributedVirtualSwitch: " + listOfDVSwitch.size());

        for (DVSwitch dvSwitch : listOfDVSwitch) {
            System.out.println("-Name: " + dvSwitch.getName());
            System.out.println("-Description: " + dvSwitch.getDescription());
            System.out.println("-Uuid: " + dvSwitch.getUuid());
            System.out.println("-NumPorts: " + dvSwitch.getNumPorts());
            System.out.println("-NumStandalonePorts: " + dvSwitch.getNumStandalonePorts());
            System.out.println("-MaxPorts: " + dvSwitch.getMaxPorts());

            System.out.println("Configuration of the switch");
            System.out.println("-Configuration Version: " + dvSwitch.getConfig().getConfigVersion());

            if (!dvSwitch.getConfig().getListOfUplinkPortgroup().isEmpty()) {
                System.out.println("-Uplink Portgroups: ");
                for (DVPortGroup dvPortGroup : dvSwitch.getConfig().getListOfUplinkPortgroup()) {
                    //System.out.println("-Uplink Portgroup: ");
                    System.out.println(" -Key: " + dvPortGroup.getKey());
                    System.out.println(" -Name: " + dvPortGroup.getConfig().getName());
                    System.out.println(" -Num Ports: " + dvPortGroup.getConfig().getNumPorts());

                    if (!dvPortGroup.getListOfDVPort().isEmpty()) {
                        for (DVPort dvPort : dvPortGroup.getListOfDVPort()) {
                            System.out.println("" + dvPort.getKey());
                        }
                    }

                }
            } else {
                System.out.println("-Uplink Portgroups: No");
            }

            if (!dvSwitch.getListOfDVPortGroup().isEmpty()) {
                System.out.println("-Portgroups:");
                int nbDVPortgroup = 1;

                for (DVPortGroup dvPortGroup : dvSwitch.getListOfDVPortGroup()) {
                    System.out.println("Distributed Virtual Portgroup n" + nbDVPortgroup++);
                    System.out.println("-Name: " + dvPortGroup.getConfig().getName());
                    System.out.println("-Key: " + dvPortGroup.getKey());
                    System.out.println("-Description: " + dvPortGroup.getConfig().getDescription());
                    System.out.println("-Num Ports: " + dvPortGroup.getConfig().getNumPorts());
                    if (!dvPortGroup.getListOfDVPort().isEmpty()) {
                        int nbDvPort = 1;
                        for (DVPort dvPort : dvPortGroup.getListOfDVPort()) {
                            System.out.println("Distributed Virtual Port n" + nbDvPort++);
                            System.out.println(" - Key: " + dvPort.getKey());
                            System.out.println(" - Name: " + dvPort.getName());
                            if (dvPort.getRuntimeInfo() != null) {
                                System.out.println(" - LinkPeer" + dvPort.getRuntimeInfo().getLinkPeer());
                                System.out.println(" - Mac Address: " + dvPort.getRuntimeInfo().getMacAddress());
                                System.out
                                        .println(" - Status Detail: " + dvPort.getRuntimeInfo().getStatusDetail());

                                if (!dvPort.getRuntimeInfo().getListOfVlanIDs().isEmpty()) {
                                    int nbVlanIDs = 1;
                                    for (NumericRange numericRange : dvPort.getRuntimeInfo().getListOfVlanIDs()) {
                                        System.out.println(" - Vlan n" + nbVlanIDs++);
                                        System.out.println("   - Start ID: " + numericRange.getStart());
                                        System.out.println("   - End ID  : " + numericRange.getEnd());
                                    }
                                }

                            }
                        }
                    }

                }
            }

        }

        VMware.delete(hostName);
    }

    public void listVMNetwork(String vmName) throws VMwareException {

        // =========================================================================================
        // Connexion au VirtualCenter
        // =========================================================================================
        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        VMNetwork vmNetwork = vm.getVMNetwork();

        System.out.println("Affichage des informations rseau associ  la VM");

        if (!vmNetwork.getListOfVirtualNetwork().isEmpty()) {
            System.out.println("Network:");

            for (VirtualNetwork network : vmNetwork.getListOfVirtualNetwork()) {
                System.out.println(" - ID: " + network.getNetwork().getMor().get_value());
                System.out.println(" - Name: " + network.getNetwork().getName());
                System.out.println(" - Mac Address: " + network.getMacAddress());
                System.out.println(" - IP: " + network.getListOfIPAddress().get(0));
            }
        }

        if (!vmNetwork.getListOfVirtualDVSwitch().isEmpty()) {
            System.out.println("Distributed Virtual Switch:");
            DVSwitchManager dvSwitchManager = DVSwitchManager.getInstance();
            DVSwitch dvSwitch = null;

            DVPortGroup dvPortGroup = null;
            DVPort dvPort = null;

            //System.out.println("nb virtual Switch: "+vmNetwork.getListOfVirtualDVSwitch().size());

            for (VirtualDVSwitch virtualDVSwitch : vmNetwork.getListOfVirtualDVSwitch()) {
                //System.out.println(" - DVSwitch UUID: "+virtualDVSwitch.getSwitchUuid());
                //System.out.println(" - DVPortgroup Key: "+virtualDVSwitch.getPortGroupKey());
                //System.out.println(" - Port Key: "+virtualDVSwitch.getPortKey());

                dvSwitch = dvSwitchManager.getDVSwitchByUUID(virtualDVSwitch.getDvSwitch().getUuid(), hostName);
                dvPortGroup = virtualDVSwitch.getDvPortGroup();
                dvPort = dvPortGroup.getMapOfDVPort().get(virtualDVSwitch.getPortKey());

                if (!virtualDVSwitch.getListOfIPAddress().isEmpty())
                    System.out.println(" - IP Address: " + virtualDVSwitch.getListOfIPAddress().get(0));
                System.out.println(" - Mac Address: " + virtualDVSwitch.getMacAddress());

                System.out.println(" - DVSwitch Name: " + dvSwitch.getName());
                //System.out.println(" - DVSwitch ID: "+virtualDVSwitch.getVirtualnetworkID());
                System.out.println(" - DVSwitch UUID: " + dvSwitch.getUuid());

                System.out.println(" - DVPortgroup Name: " + dvPortGroup.getName());
                System.out.println(" - DVPortgroup ID: " + dvPortGroup.getMor().get_value());

                //System.out.println(" - DVPort Name: "+dvPort.getName());
                //System.out.println(" - DVPort Key: "+dvPort.getKey());

            }
        }

        VMware.delete(hostName);

    }

    public void getProperties(String vmName) throws VMwareException {

        // =========================================================================================
        // Connexion au VirtualCenter
        // =========================================================================================
        String hostName = "192.168.101.79";
        VMware.create(hostName, 443, "svc-siveo", "S1v30d6m3", false, -1L, 1000L);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        // =========================================================================================
        // Rcupration des proprits
        // =========================================================================================
        DynamicProperty[] multiProp = null;
        Date dt1 = new Date();
        multiProp = (DynamicProperty[]) MorManager.getProperties(vm.getWS().getVIMService(), vm.getMor(),
                new String[] { "config.cpuAllocation.expandableReservation", "config.cpuAllocation.limit",
                        "config.cpuAllocation.overheadLimit", "config.cpuAllocation.reservation",
                        "config.cpuAllocation.shares.level", "config.cpuAllocation.shares.shares" });
        Date dt2 = new Date();

        System.out.println("Temps rcup multi properties: " + (dt2.getTime() - dt1.getTime()));

        if (multiProp != null) {

            for (DynamicProperty dynamicProperty : multiProp) {
                System.out.println("Property: " + dynamicProperty.getName() + " / " + dynamicProperty.getVal());
            }

        }

        Date dt11 = new Date();
        VirtualMachineConfigInfo virtualMachineConfigInfo = (VirtualMachineConfigInfo) MorManager
                .getMorProperty(vm.getWS(), vm.getMor(), new String[] { "config" });
        virtualMachineConfigInfo.getCpuAllocation().getExpandableReservation();
        virtualMachineConfigInfo.getCpuAllocation().getLimit();
        virtualMachineConfigInfo.getCpuAllocation().getReservation();
        virtualMachineConfigInfo.getCpuAllocation().getShares().getLevel();
        virtualMachineConfigInfo.getCpuAllocation().getShares().getShares();
        Date dt22 = new Date();

        System.out.println("Temps rcup normal: " + (dt22.getTime() - dt11.getTime()));

        VMware.delete(hostName);

    }

    public void getMultiProperties() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "192.168.101.79";
        VMware.create(hostName, 443, "svc-siveo", "S1v30d6m3", false, -1L, 1000L);

        // =========================================================================================
        // Variables
        // =========================================================================================
        ArrayList<ManagedObjectReference> listOfManagedObjectReference = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObject> listOfManagedObjects = new ArrayList<ManagedObject>();

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Get Some VirtualMachines
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();

        ArrayList<VirtualMachine> listOfVM = vmManager.getAllVM(hostName);

        if (!listOfVM.isEmpty()) {

            for (VirtualMachine vm : listOfVM) {
                listOfManagedObjects.add(new ManagedObject(ws, vm.getMor(),
                        new String[] { "name", "config.template", "config.cpuAllocation.limit",
                                "config.cpuAllocation.reservation", "runtime.powerState" }));
            }

        }

        /*      
        VirtualMachine vm=null;
        VirtualMachine vm1=null;
            
        //vmManager.getv
            
        vm1=vmManager.getVmByName(hostName, "JTH02");
        listOfManagedObjectReference.add(vm1.getMor());
        listOfManagedObjects.add(new ManagedObject(ws, vm1.getMor(),new String[] {"config.name","config.cpuAllocation.limit","config.cpuAllocation.reservation"}));
            
        vm=vmManager.getVmByName(hostName, "CDO2");
        listOfManagedObjectReference.add(vm.getMor());
        //listOfManagedObjects.add(new ManagedObject(ws, vm.getMor(),new String[] {"config.name","config.cpuAllocation.limit","config.cpuAllocation.reservation","runtime.powerState"}));
        //listOfManagedObjects.add(new ManagedObject(ws, vm.getMor(),new String[] {"runtime.powerState"}));
        */

        // =========================================================================================
        // Get Some Hosts
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = null;

        host = hostManager.getHostByName("vblockrm2001", hostName);
        listOfManagedObjects.add(new ManagedObject(ws, host.getMor(),
                new String[] { "summary.hardware.cpuMhz", "summary.hardware.memorySize", "name" }));

        System.out.println("API Version: " + ws.getAPIVersion());

        // =========================================================================================
        // Rcupration des proprits 
        // =========================================================================================
        ArrayList<Results> listOfResults = null;
        DynamicProperty[] multiProp = null;
        //Date dt1=new Date();
        //listOfResults=(ArrayList<Results>)MorManager.getProperties(ws.getVIMService(), listOfManagedObjectReference, new String[] {"config.name","config.cpuAllocation.limit","config.cpuAllocation.reservation"});
        Date dt1 = new Date();
        listOfResults = (ArrayList<Results>) MorManager.getProperties1(ws, listOfManagedObjects);
        Date dt2 = new Date();

        System.out.println("Temps: " + (dt2.getTime() - dt1.getTime()));

        if (listOfResults != null && !listOfResults.isEmpty()) {
            for (Results results : listOfResults) {
                System.out.println("\nManagedObjectReference: " + results.getMor().getType() + " / "
                        + results.getMor().get_value());
                multiProp = results.getArrayOfDynamicProperty();

                if (multiProp != null) {
                    for (DynamicProperty dynamicProperty : multiProp) {
                        System.out.println(" - " + dynamicProperty.getName() + " / " + dynamicProperty.getVal());
                    }
                }

            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testVM() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        ArrayList<String> listOfMorIDs = new ArrayList<String>();
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        HostManager hostManager = HostManager.getInstance();
        ArrayList<Host> listOfHosts = hostManager.getAllHosts(hostName);

        if (listOfHosts != null && !listOfHosts.isEmpty()) {
            for (Host host : listOfHosts) {
                listOfMorIDs.add(host.getMor().get_value());
            }

            inventory.getHostPropertiesExFromIDs(listOfMorIDs);

        }

        // =========================================================================================
        // 
        // =========================================================================================

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = null;

        //vm=vmManager.getVmByName(hostName, "VMKS-12XSP1-66");
        vm = vmManager.getVmByName(hostName, "CentOSVM");

        listOfMorIDs.clear();
        listOfMorIDs.add(vm.getMor().get_value());

        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        Host host = vm.getHost();
        //listOfMorIDs.clear();
        //listOfMorIDs.add(host.getMor().get_value());
        //inventory.getHostPropertiesExFromIDs(listOfMorIDs);

        System.out.println("Host : " + host.getName());
        System.out.println("Host IP: " + host.getIP());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testVMDeleteState() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        //String vmName="testclonejth";
        String vmName = "testDeleteVM";
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        ManagedObjectReference mor = vm.getMor();

        VirtualMachineConnectionState vmConnState = null;

        vmConnState = (VirtualMachineConnectionState) MorManager.getMorProperty(ws, mor,
                new String[] { "runtime.connectionState" });
        System.out.println("vm State: " + vmConnState.name());

        /*
        vmManager.unregisterVMByID(vm.getMor().get_value(), hostName);
            
        System.out.println("Press a key to continue");
            
        try
        {
           System.in.read();
        }
        catch (IOException e)
        {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }
            
            
        InventoryManager inventoryManager=InventoryManager.getInstance();
        Inventory inventory=inventoryManager.loadInventoryEx(hostName);
            
        vm=vmManager.getVmByName(hostName, vmName);
            
        System.out.println("VM: "+vm);
        */

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void loadInventory() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@2013$",false,-1L);

        //String hostName="10.62.16.35";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        //      String hostName="10.62.16.33";
        //      VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        //      String hostName="10.62.16.34";
        //      VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //String hostName="192.100.2.13";
        //VMware.create(hostName,443,"JNW","GG@1dague",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.createEx(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.1.109.236";
        //VMware.create(hostName,443,"Administrator","8x63-K/!/",false,-1L);

        //      // KEONYS - ESXi Ing
        //      String hostName="10.10.0.64";
        //      VMware.create(hostName,443,"root","Keonys123",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L, 1000L);

        InventoryManager inventoryManager = InventoryManager.getInstance();
        //Inventory inventory=inventoryManager.loadInventory(hostName);
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        TreeNode rootNode = inventory.getRootNode();

        System.out.println("RootNode: " + rootNode);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void loadInventoryEX() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.35";
        //VMware.createEx(hostName,443,"root","cahh4gee$",false,-1L);

        //WSManager wsManager=WSManager.getInstance();
        //WS ws=null;

        //String hostName="10.62.16.34";
        //ws=wsManager.createVIM(hostName, 443, "SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.34";
        VMware.createEx(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Retrieve the Inventory Tree
        // =========================================================================================
        //      FolderManager folderManager=FolderManager.getInstance();
        //      Folder folder=folderManager.getFolderByID("group-v458", hostName);
        //      //ManagedObjectReference rootFolder=ws.getVIMService().getServiceContent().getRootFolder();
        //
        //      ManagedEntity[] childEntity=null;
        //      ManagedObjectReference[] tabOfManagedObjectReferences=null;
        //      ArrayOfManagedObjectReference arrayOfManagedObjectReference=null;
        //      
        //      Date dtMor01=new Date();
        //      arrayOfManagedObjectReference=(ArrayOfManagedObjectReference)MorManager.getMorProperty(folder.getWS().getVIMService(),folder.getMor(), new String[] {"childEntity"},false);
        //      Date dtMor02=new Date();
        //      
        //      System.out.println("Retrieve Folder Childs: "+(dtMor02.getTime()-dtMor01.getTime()));
        //      
        //      if(arrayOfManagedObjectReference!=null && arrayOfManagedObjectReference.getManagedObjectReference()!=null)
        //      {
        //         tabOfManagedObjectReferences=arrayOfManagedObjectReference.getManagedObjectReference();
        //         System.out.println("size: "+tabOfManagedObjectReferences.length);
        //         
        //         for(ManagedObjectReference mor:arrayOfManagedObjectReference.getManagedObjectReference())
        //         {
        //            System.out.println("Type: "+mor.getType()+" / Value: "+mor.get_value());
        //         }
        //         
        //      }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        //ws.getVIMService().logout();
        //wsManager.deleteWS(ws);

        //vmware.getTaskMonitor().interrupt();
        //wsManager.deleteVIM();
        VMware.delete(hostName);

    }

    public void loadVirtualMachines() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.35";
        //VMware.createEx(hostName,443,"root","cahh4gee$",false,-1L);

        //WSManager wsManager=WSManager.getInstance();
        //WS ws=null;

        //String hostName="10.62.16.34";
        //ws=wsManager.createVIM(hostName, 443, "SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.34";
        VMware.createEx(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Retrieve the Inventory Tree
        // =========================================================================================
        //      FolderManager folderManager=FolderManager.getInstance();
        //      Folder folder=folderManager.getFolderByID("group-v458", hostName);
        //      //ManagedObjectReference rootFolder=ws.getVIMService().getServiceContent().getRootFolder();
        //
        //      ManagedEntity[] childEntity=null;
        //      ManagedObjectReference[] tabOfManagedObjectReferences=null;
        //      ArrayOfManagedObjectReference arrayOfManagedObjectReference=null;
        //      
        //      Date dtMor01=new Date();
        //      arrayOfManagedObjectReference=(ArrayOfManagedObjectReference)MorManager.getMorProperty(folder.getWS().getVIMService(),folder.getMor(), new String[] {"childEntity"},false);
        //      Date dtMor02=new Date();
        //      
        //      System.out.println("Retrieve Folder Childs: "+(dtMor02.getTime()-dtMor01.getTime()));
        //      
        //      if(arrayOfManagedObjectReference!=null && arrayOfManagedObjectReference.getManagedObjectReference()!=null)
        //      {
        //         tabOfManagedObjectReferences=arrayOfManagedObjectReference.getManagedObjectReference();
        //         System.out.println("size: "+tabOfManagedObjectReferences.length);
        //         
        //         for(ManagedObjectReference mor:arrayOfManagedObjectReference.getManagedObjectReference())
        //         {
        //            System.out.println("Type: "+mor.getType()+" / Value: "+mor.get_value());
        //         }
        //         
        //      }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        //ws.getVIMService().logout();
        //wsManager.deleteWS(ws);

        //vmware.getTaskMonitor().interrupt();
        //wsManager.deleteVIM();
        VMware.delete(hostName);

    }

    public void loadRootNodeInventory() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.35";
        //VMware.createEx(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "10.62.16.34";
        VMware.createEx(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Retrieve the Inventory Tree
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        //Inventory inventory=inventoryManager.loadInventory(hostName);
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        TreeNode rootNode = inventory.getRootNode();

        System.out.println("RootNode: " + rootNode);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testRevertToSnapshot() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void cloneVMTOVMOnESX() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        String vmID = "11232"; //evanavaho
        String datastoreID = "4d122715-92c6a870-ddc8-e41f1342fab4"; //datastore-247
        String newVMName = "CDOClone";

        //siveo-esx1.siveo.dev/ IP: 10.62.16.31

        String esx = "10.62.16.31";
        String user = "root";
        String passwd = "cahh4gee$2012";
        String correlID = "12345";
        String pathToScripts = "D:/Siveo/script/vmware-esxi";

        VMManager vmManager = VMManager.getInstance();
        //vmManager.cloneVMToVMOnESXi(vmID,newVMName, hostName, datastoreID,esx,user,passwd,pathToScripts,correlID);
        vmManager.cloneVMToVMOnESXi(vmID, newVMName, hostName, datastoreID, null, pathToScripts);

        System.out.println("Press a key to continue....");
        System.in.read();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void listPermissions() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L,1000);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testJSCH() throws Exception {
        String pathToScripts = "D:/Siveo/script/vmware-esxi";
        String command = null;

        // ---------------------------------------------------------
        // Use JSCH: Script Remote copy and remote execute 
        // ---------------------------------------------------------
        Jsch jsch = null;
        int exitCode = -1;

        jsch = new Jsch("192.168.101.123", "root", "mandriva");
        jsch.connect();

        command = "cat /etc/hostname";
        exitCode = jsch.executeCmd(command);

        if (exitCode != 0) {
            jsch.disconnect();
            throw new Exception("Error: Clone VM to VM on ESXi failed.");
        }

        System.out.println("Sortie: " + jsch.getStdOut());
        jsch.disconnect();

        //      jsch=new Jsch("10.62.16.33", "root", "cahh4gee$2012");
        //      jsch.connectKerberos();
        //      
        //      
        //      jsch.remoteCopy(pathToScripts+"/"+"test.sh");
        //      
        //      // ===================================================================================
        //      // Set the scripts executable
        //      // ===================================================================================
        //      command="chmod u+x test.sh";
        //      exitCode=jsch.executeCmd(command);
        //
        //      if (exitCode!=0)
        //      {
        //         jsch.disconnect();
        //         throw new Exception("Error: Clone VM to VM on ESXi failed.");
        //      }
        //
        //      // ===================================================================================
        //      // Run the script in order to retrieve Guest OS information 
        //      // ===================================================================================
        //      command="./test.sh";
        //      exitCode=jsch.executeCmd(command);
        //      
        //      if(exitCode!=0)
        //      {
        //         jsch.disconnect();
        //         throw new Exception("Error: Clone VM to VM on ESXi failed. Scrip fail to execute");
        //      }
        //      
        //      jsch.disconnect();

    }

    public void queryAvailablePerfMetric() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L,1000);

        // =========================================================================================
        // 
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VJTH-WIND-01");

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getAllHosts(hostName).get(0);

        System.out.println("vm: " + vm);
        System.out.println("host: " + host);

        PerformanceManager performanceManager = PerformanceManager.getInstance();
        //performanceManager.init(hostName);

        // =========================================================================================
        // 
        // =========================================================================================

        HashMap<Integer, Counter> mapOfCounterByID = new HashMap<Integer, Counter>();
        ArrayList<Counter> listOfCounters = performanceManager.getAllCounters(hostName);
        if (listOfCounters != null) {
            for (Counter counter : listOfCounters) {
                mapOfCounterByID.put(counter.getId(), counter);

                //System.out.println("- "+counter.getId()+ " / "+counter.getFullName());
            }
        }

        ManagedObjectReference perfManager = ws.getVIMService().getPerformanceManager();
        PerfMetricId[] perfMetricIdArray = null;
        PerfMetricId[] perfMetricIVMdArray = null;

        //
        //      PerfCounterInfo[] perfCounterInfoArray=null;
        //      perfCounterInfoArray=vm.getWS().getVIMService().getService().queryPerfCounter(perfManager, new int[]{196609,327694});
        //      
        //      if (perfCounterInfoArray!=null)
        //      {
        //         for (PerfCounterInfo perfCounterInfo:perfCounterInfoArray)
        //         {
        //            System.out.println("- Name: "+perfCounterInfo.getNameInfo().getLabel());
        //            System.out.println("- Key: "+perfCounterInfo.getKey());
        //         }
        //         
        //      }

        perfMetricIdArray = ws.getVIMService().getService().queryAvailablePerfMetric(perfManager, host.getMor(),
                null, null, 20);
        perfMetricIVMdArray = ws.getVIMService().getService().queryAvailablePerfMetric(perfManager, vm.getMor(),
                null, null, 20);

        System.out.println("Array Of Metric Id: " + perfMetricIdArray);

        ArrayList<String> listOfCounterVrac = new ArrayList<String>();
        ArrayList<String> listOfCounterSort = new ArrayList<String>();
        HashMap<String, String> mapOfCounterInfo = new HashMap<String, String>();

        // Traitement des Hosts   
        if (perfMetricIdArray != null) {
            for (PerfMetricId perfMetricId : perfMetricIdArray) {

                //System.out.println("- Metric Id: "+perfMetricId.getCounterId());
                if (mapOfCounterByID.containsKey(perfMetricId.getCounterId())) {
                    //System.out.println("- Counter Name: "+mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName()+" / Instance= "+mapOfCounterByID.get(perfMetricId.getCounterId()).getInstance());
                    //System.out.println("- Counter Name: "+mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName());

                    //System.out.println(mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName()+" / Instance: "+perfMetricId.getInstance());
                    //System.out.println(mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName()+";"+perfMetricId.getInstance()+";"+mapOfCounterByID.get(perfMetricId.getCounterId()).getStatisticsType()+";"+mapOfCounterByID.get(perfMetricId.getCounterId()).getUnitKey());

                    listOfCounterVrac.add(mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName());
                    mapOfCounterInfo.put(mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName(),
                            ";" + mapOfCounterByID.get(perfMetricId.getCounterId()).getGroupKey() + ";"
                                    + perfMetricId.getInstance() + ";"
                                    + mapOfCounterByID.get(perfMetricId.getCounterId()).getStatisticsType() + ";"
                                    + mapOfCounterByID.get(perfMetricId.getCounterId()).getUnitKey() + ";"
                                    + mapOfCounterByID.get(perfMetricId.getCounterId()).getDescription());
                }
            }
        }

        // Traitement des VM   
        if (perfMetricIVMdArray != null) {

            System.out.println("");
            System.out.println("");
            System.out.println("################# Virtual Machine Counter #################");

            for (PerfMetricId perfMetricId : perfMetricIVMdArray) {

                //System.out.println("- Metric Id: "+perfMetricId.getCounterId());
                if (mapOfCounterByID.containsKey(perfMetricId.getCounterId())) {
                    //System.out.println("- Counter Name: "+mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName()+" / Instance= "+mapOfCounterByID.get(perfMetricId.getCounterId()).getInstance());
                    //System.out.println("- Counter Name: "+mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName());

                    //System.out.println(mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName()+" / Instance: "+perfMetricId.getInstance());
                    System.out.println(mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName() + ";"
                            + perfMetricId.getInstance() + ";"
                            + mapOfCounterByID.get(perfMetricId.getCounterId()).getStatisticsType() + ";"
                            + mapOfCounterByID.get(perfMetricId.getCounterId()).getUnitKey() + ";"
                            + mapOfCounterByID.get(perfMetricId.getCounterId()).getGroupKey());

                    listOfCounterVrac.add(mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName());
                    mapOfCounterInfo.put(mapOfCounterByID.get(perfMetricId.getCounterId()).getFullName(),
                            ";" + mapOfCounterByID.get(perfMetricId.getCounterId()).getGroupKey() + ";"
                                    + perfMetricId.getInstance() + ";"
                                    + mapOfCounterByID.get(perfMetricId.getCounterId()).getStatisticsType() + ";"
                                    + mapOfCounterByID.get(perfMetricId.getCounterId()).getUnitKey() + ";"
                                    + mapOfCounterByID.get(perfMetricId.getCounterId()).getDescription());
                }
            }
        }

        System.out.println("");
        System.out.println("");
        System.out.println("################# Liste Trie #################");

        //Collections.sort(listOfCounterSort);
        int nb = 700;
        String counterInf = null;
        String category = null;
        String stat_type = null;
        String unit = null;
        int id_infrastructure_type = 6;
        String instance = null;
        String description = null;

        String[] tabb = null;

        Set<String> set = new HashSet<String>();
        set.addAll(listOfCounterVrac);
        ArrayList<String> distinctList = new ArrayList<String>(set);

        Collections.sort(distinctList);

        for (String counterFullName : distinctList) {
            //System.out.println(counterFullName+mapOfCounterInfo.get(counterFullName));

            counterInf = mapOfCounterInfo.get(counterFullName);
            tabb = counterInf.split(";");
            category = tabb[1];
            instance = tabb[2];
            stat_type = tabb[3];
            unit = tabb[4];
            description = tabb[5];

            if (description.length() > 500) {
                description = description.substring(0, 499);
            }

            System.out.println(
                    "INSERT INTO counter (id_counter, name_counter, category, stat_type, unit, id_infrastructure_type, instance, description) VALUES"
                            + " (" + nb + "," + "'" + counterFullName + "'" + "," + "'" + category + "'" + "," + "'"
                            + stat_type + "'" + "," + "'" + unit + "'" + "," + id_infrastructure_type + "," + "'"
                            + instance + "'" + "," + "'" + description + "');");

            nb++;

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void registerVM() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L,1000);

        // =========================================================================================
        // 
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByID(hostName, "10320");
        String vmName = "CDOmyVM";

        ManagedObjectReference host = vm.getHost().getMor();

        ResourcePoolManager resourcepoolManager = ResourcePoolManager.getInstance();
        ResourcePool resourcePool = resourcepoolManager.getResourcePoolByID(hostName, "pool2");

        String path = "[SIVEO_POC] CDOmyVM/CDOmyVM.vmx";

        ws.getVIMService().getService().registerVM_Task(vm.getFolder().getMor(), path, vmName, false,
                resourcePool.getMor(), host);

        System.out.println("Press a key to continue....");
        System.in.read();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void simpleCloneVMTOVMOnESX() throws Exception {
        // =========================================================================================
        // Connexion au WebService
        // =========================================================================================
        //String hostName="10.251.5.14";
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L,1000);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        String vmID = "10320"; //VJTH-CHIN-01 //"vm-485"; //evanavaho
        String datastoreID = "50178a9f-0339acdc-80d9-e61f1347e4d7"; //SIVEO_POC "datastore-533"; //datastore-247
        String newVMName = "CDOmyVM";
        String resourcePoolID = "pool2";

        //siveo-esx1.siveo.dev/ IP: 10.62.16.31

        //      String esx="10.62.16.31";
        //      String user="root";
        //      String passwd="cahh4gee$2012";
        String correlID = "12345";
        String pathToScripts = "D:/Siveo/script/vmware-esxi";

        VMManager vmManager = VMManager.getInstance();
        //vmManager.cloneVMToVMOnESXi(vmID,newVMName, hostName, datastoreID,esx,user,passwd,pathToScripts,correlID);
        vmManager.cloneVMToVMOnESXi(vmID, newVMName, hostName, datastoreID, resourcePoolID, pathToScripts);

        System.out.println("Press a key to continue....");
        System.in.read();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void checkifESX() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        //String hostName="10.62.16.35";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        System.out.println("WS: ");
        System.out.println("- Name: " + ws.getName());
        System.out.println("- Full Name: " + ws.getFullName());
        System.out.println("- Product Line ID: " + ws.getProductLineId());
        System.out.println("- API Full Version: " + ws.getAPIFullVersion());
        System.out.println("- API Type: " + ws.getAPIType());
        System.out.println("- API Version: " + ws.getAPIVersion());

        System.out.println("Is ESX: " + ws.isEsx());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testDateiso() throws Exception {
        //NOTE: SimpleDateFormat uses GMT[-+]hh:mm for the TZ which breaks
        //things a bit.  Before we go on we have to repair this.
        String input = "2013-12-19T09:43:20+01:00";
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");

        //this is zero time so we need to add that TZ indicator for 
        if (input.endsWith("Z")) {
            input = input.substring(0, input.length() - 1) + "GMT-00:00";
        } else {
            int inset = 6;

            String s0 = input.substring(0, input.length() - inset);
            String s1 = input.substring(input.length() - inset, input.length());

            input = s0 + "GMT" + s1;
        }

        System.out.println("" + df.parse(input));

        //Date --> toString
        /*
        SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssz" );
            
        TimeZone tz = TimeZone.getTimeZone( "UTC" );
            
        df.setTimeZone( tz );
            
        String output = df.format( date );
            
        int inset0 = 9;
        int inset1 = 6;
            
        String s0 = output.substring( 0, output.length() - inset0 );
        String s1 = output.substring( output.length() - inset1, output.length() );
            
        String result = s0 + s1;
            
        result = result.replaceAll( "UTC", "+00:00" );
            
        return result;
        */

    }

    public void checkDatastore() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Data Store
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // 
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx3.siveo.net", hostName);

        HostConfigManager hostConfigManager = (HostConfigManager) MorManager.getMorProperty(ws, host.getMor(),
                new String[] { "configManager" });
        ;

        int nb = 1;

        HostConfigInfo hostConfigInfo = (HostConfigInfo) MorManager.getMorProperty(ws, host.getMor(),
                new String[] { "config" });
        if (hostConfigInfo != null) {
            HostStorageDeviceInfo hostStorageDeviceInfo = hostConfigInfo.getStorageDevice();

            if (hostStorageDeviceInfo != null) {
                HostHostBusAdapter[] hostBusAdapters = hostStorageDeviceInfo.getHostBusAdapter();
                if (hostBusAdapters != null && hostBusAdapters.length > 0) {
                    for (HostHostBusAdapter busAdapter : hostBusAdapters) {
                        System.out.println("Host Bus Adapter n :" + nb++);
                        System.out.println("- Bus: " + busAdapter.getBus());
                        System.out.println("- Device: " + busAdapter.getDevice());
                        System.out.println("- Driver: " + busAdapter.getDriver());
                        System.out.println("- Key: " + busAdapter.getKey());
                        System.out.println("- Model: " + busAdapter.getModel());
                        System.out.println("- PCI: " + busAdapter.getPci());
                        System.out.println("- Status: " + busAdapter.getStatus());
                    }
                }

                HostMultipathInfo hostMultipathInfo = hostStorageDeviceInfo.getMultipathInfo();
                if (hostMultipathInfo != null) {
                    HostMultipathInfoLogicalUnit[] hostMultipathInfoLogicalUnits = hostMultipathInfo.getLun();

                    if (hostMultipathInfoLogicalUnits != null && hostMultipathInfoLogicalUnits.length > 0) {
                        nb = 1;
                        for (HostMultipathInfoLogicalUnit hostMultipathInfoLogicalUnit : hostMultipathInfoLogicalUnits) {
                            System.out.println("Host Multipath Info :" + nb++);
                            System.out.println("- Id: " + hostMultipathInfoLogicalUnit.getId());
                            System.out.println("- Key: " + hostMultipathInfoLogicalUnit.getKey());
                            System.out.println("- Lun: " + hostMultipathInfoLogicalUnit.getLun());

                            HostMultipathInfoPath[] hostMultipathInfoPaths = hostMultipathInfoLogicalUnit.getPath();
                            if (hostMultipathInfoPaths != null && hostMultipathInfoPaths.length > 0) {
                                int nb1 = 1;
                                for (HostMultipathInfoPath hostMultipathInfoPath : hostMultipathInfoPaths) {
                                    System.out.println("- Host Multipath Info Path:" + nb1++);
                                    System.out.println("  - Adapter: " + hostMultipathInfoPath.getAdapter());
                                    System.out
                                            .println("  - Is Working Path: " + hostMultipathInfoPath.isWorkingPath);
                                    System.out.println("  - key: " + hostMultipathInfoPath.getKey());
                                    System.out.println("  - Lun: " + hostMultipathInfoPath.getLun());
                                    System.out.println("  - Name: " + hostMultipathInfoPath.getName());
                                    System.out.println("  - Path State: " + hostMultipathInfoPath.getPathState());
                                    System.out.println("  - State: " + hostMultipathInfoPath.getState());

                                    HostTargetTransport hostTargetTransport = hostMultipathInfoPath.getTransport();
                                    if (hostTargetTransport != null) {
                                        System.out.println("  - Transport:");
                                        if (hostTargetTransport.getClass()
                                                .equals(HostFibreChannelTargetTransport.class)) {
                                            HostFibreChannelTargetTransport hostFibreChannelTargetTransport = (HostFibreChannelTargetTransport) hostTargetTransport;
                                            System.out.println("  - " + hostTargetTransport.getClass());
                                            System.out.println("    - Node World Wide Name: "
                                                    + hostFibreChannelTargetTransport.getNodeWorldWideName());
                                            System.out.println("    - Port World Wide Name: "
                                                    + hostFibreChannelTargetTransport.getPortWorldWideName());
                                        }
                                    }

                                }
                            }

                        }

                    }

                }
            }
        }

        //hostConfigManager.getDatastoreSystem();

        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        Datastore datastore = dataStoreManager.getDatastoreByID("datastore-152", hostName);

        ArrayList<Datastore> listOfDataStores = dataStoreManager.getAllDatastore(hostName);

        ArrayOfDatastoreHostMount arrayOfDatastoreHostMount = (ArrayOfDatastoreHostMount) MorManager
                .getMorProperty(ws, datastore.getMor(), new String[] { "host" });

        //DatastoreHostMount dsHostInfo=(DatastoreHostMount)MorManager.getMorProperty(ws.getVIMService(),datastore.getMor(), new String[] {"host"});

        ManagedObjectReference resourceManager = ws.getVIMService().getServiceContent().getStorageResourceManager();

        if (arrayOfDatastoreHostMount != null && arrayOfDatastoreHostMount.getDatastoreHostMount() != null
                && arrayOfDatastoreHostMount.getDatastoreHostMount().length > 0) {
            for (DatastoreHostMount datastoreHostMount : arrayOfDatastoreHostMount.getDatastoreHostMount()) {
                ManagedObjectReference hostMor = datastoreHostMount.getKey();
                String path = datastoreHostMount.getMountInfo().getPath();
                String accessMode = datastoreHostMount.getMountInfo().getAccessMode();

                System.out.println("Host: " + hostMor.get_value());
                System.out.println("Path: " + path);
                System.out.println("access Mode: " + accessMode);

            }
        }

        //HostScsiDisk

        for (Datastore ds : listOfDataStores) {
            DatastoreInfo dsInfo = (DatastoreInfo) MorManager.getMorProperty(ws, ds.getMor(),
                    new String[] { "info" });
            System.out.println("DataStore Name: " + ds.getName() + " / Class: " + dsInfo.getClass());
            System.out.println("- URL: " + dsInfo.getUrl());
            //System.out.println("dsInfo: "+dsInfo.getClass());

            //dsInfo.g

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void deployVM() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Deploy a VM from a Template and add a new Virtual Network Card
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        // Creation Cross DC
        String hostID = "host-71"; // siveo-esx2.siveo.net
        String dataStoreID = "datastore-535"; // VMFSDEMO
        String vmID = "vm-1027"; //template SmallVM
        String vmFolderID = null; // dossier SCVMM
        String resourcePoolID = "resgroup-1004"; //TestCDO

        Host host = HostManager.getInstance().getHostByID(hostID, hostName);
        Datastore datastore = DataStoreManager.getInstance().getDatastoreByID(dataStoreID, hostName);
        VirtualMachine template = vmManager.getVmByID(hostName, vmID);

        System.out.println("Infos de Clonage:");
        System.out.println("- Host :" + host.getName());
        System.out.println("- Datastore :" + datastore.getName());
        System.out.println("- Template :" + template.getName());

        if (vmFolderID != null) {
            Folder folder = FolderManager.getInstance().getFolderByID(vmFolderID, hostName);
            System.out.println("- Folder :" + folder.getName());
        }

        if (resourcePoolID != null) {
            ResourcePool resourcePool = ResourcePoolManager.getInstance().getResourcePoolByID(hostName,
                    resourcePoolID);
            System.out.println("- ResourcePool :" + resourcePool.getName());
        }

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();
        listOfMors.add(template.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfMors);

        // =========================================================================================
        // Initialize the Sysprep Linux
        // =========================================================================================
        System.out.println("\n*****  Clone Template to VM *****");
        String vmName = "instantvmjpa";
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        //vmConfiguration.setUserName("instantvmcdo");   
        //vmConfiguration.setUserName("siveo_test");   
        //vmConfiguration.setSocietyName("Navaho");   
        vmConfiguration.setName(vmName);

        // ---------------------------------------------------------------
        // Initialize the Linux Sysprep 
        // ---------------------------------------------------------------
        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("siveo.net");
        sysprepLinux.setHostname(vmName);

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        //vmConfiguration.setSysprepWindows(winSysPrep);
        vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------

        NetworkAdapter networkAdapter = new NetworkAdapter();
        //networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});
        networkAdapter.setDnsServerList(new String[] { "194.133.14.66" });
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.62.16.73");
        networkAdapter.setSubnetMask("255.255.252.0");
        networkAdapter.setGateway(new String[] { "10.62.16.2" });
        ////networkAdapter.setMacAddress(null);
        vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        vmConfiguration.setDnsServerList(new String[] { "194.133.14.66" });
        //vmConfiguration.setDnsSuffixList(new String[]{});
        vmConfiguration.setDnsSuffixList(new String[] {});

        // set the second Network
        //networkAdapter=new NetworkAdapter();
        ////networkAdapter.setDnsDomain("siveo.net");
        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp(null);
        //networkAdapter.setSubnetMask("255.255.255.0");
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        //vmConfiguration.setNetworkAdpater(networkAdapter);

        // !!!
        ////vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        ////vmConfiguration.setDnsSuffixList(new String[]{});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // ---------------------------------------------------------------
        // Set the CPU configuration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(1024);
        virtualCPU.setReservation(1024);
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setNbCPU(2);
        vmConfiguration.setVirtualCPU(virtualCPU);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMem = new VirtualMemory();
        virtualMem.setLimit(4096);
        virtualMem.setReservation(2048);
        virtualMem.setMemory(2048);
        virtualMem.setExpandableReservation(false);
        vmConfiguration.setVirtualMemory(virtualMem);

        // ---------------------------------------------------------------
        // Add a new card
        // ---------------------------------------------------------------
        VirtualNetwork virtualNetwork = null;

        //Select a VMware Network
        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = networkManager.getNetworkByID("network-210", hostName);

        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.add);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        // ---------------------------------------------------------------
        // Extend the first Disk and add a new disk 
        // ---------------------------------------------------------------
        net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk = new VirtualDisk();

        // Extend the First Disk
        vDisk = template.getVirtualDeviceManager().getVirtualDisks().get(0);
        vDisk.setAction(VirtualDeviceOperation.edit);
        vDisk.setDiskSize(20 * 1024);
        vmConfiguration.getListOfVirtualDisk().add(vDisk);

        // Add a new DISK
        vDisk = new VirtualDisk();
        vDisk.setAction(VirtualDeviceOperation.add);
        vDisk.setDiskSize(1024 * 3);
        //vDisk.setLabel("Hard disk 2");
        vmConfiguration.getListOfVirtualDisk().add(vDisk);

        // ---------------------------------------------------------------
        // Set the additional fields 
        // ---------------------------------------------------------------
        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        // Clone Template to VM with reconfiguration and sysprep 
        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        vmManager.cloneTemplateToVMEx(vmID, hostName, vmConfiguration, hostID, dataStoreID, resourcePoolID,
                vmFolderID);

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Connect the card
        // =========================================================================================

        //Refresh the VM
        VMware.refresh(hostName);
        listOfMors.clear();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);
        listOfMors.add(vm.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfMors);

        vm.connectVirtualNetworkOnStart(vm.getVMNetwork().getListOfVirtualNetwork(), "ABCD");

        /*
        ArrayList<VirtualNetwork> listOfVirtualNetworks=vm.getVMNetwork().getListOfVirtualNetwork();
            
        for (VirtualNetwork virtualNetwork2:listOfVirtualNetworks)
        {
           System.out.println("VirtualNetwork: "+virtualNetwork2.getVirtualDevice().getDeviceInfo().getLabel());
               
               
           VirtualDeviceConnectInfo virtualDeviceConnectInfo=virtualNetwork2.getVirtualDevice().getConnectable();
           if (virtualDeviceConnectInfo!=null)
           {
        System.out.println("Connectable");
        System.out.println("AllowGuestControl: "+virtualDeviceConnectInfo.isAllowGuestControl());
        System.out.println("Connected: "+virtualDeviceConnectInfo.isConnected());
        System.out.println("Start Connected "+virtualDeviceConnectInfo.isStartConnected());
           }
        }
        */

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void deployInstantVM() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //      String hostName="10.251.5.14";
        //      VMware.create(hostName,443,"Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Deploy a VM from a Template and add a new Virtual Network Card
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        // Creation Cross DC
        String hostID = "host-246"; // siveo-esx3.siveo.net
        String dataStoreID = "datastore-523"; // 
        String vmID = "vm-1027"; //template SmallVM
        String vmFolderID = null; // dossier SCVMM
        String resourcePoolID = null; //TestCDO

        Host host = HostManager.getInstance().getHostByID(hostID, hostName);
        Datastore datastore = DataStoreManager.getInstance().getDatastoreByID(dataStoreID, hostName);
        VirtualMachine template = vmManager.getVmByID(hostName, vmID);

        System.out.println("Infos de Clonage:");
        System.out.println("- Host :" + host.getName());
        System.out.println("- Datastore :" + datastore.getName());
        System.out.println("- Template :" + template.getName());

        if (vmFolderID != null) {
            Folder folder = FolderManager.getInstance().getFolderByID(vmFolderID, hostName);
            System.out.println("- Folder :" + folder.getName());
        }

        if (resourcePoolID != null) {
            ResourcePool resourcePool = ResourcePoolManager.getInstance().getResourcePoolByID(hostName,
                    resourcePoolID);
            System.out.println("- ResourcePool :" + resourcePool.getName());
        }

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();
        listOfMors.add(template.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfMors);

        // =========================================================================================
        // Initialize the Sysprep Linux
        // =========================================================================================
        System.out.println("\n*****  Clone Template to VM *****");
        String vmName = "instantvmcdo";
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        //vmConfiguration.setUserName("instantvmcdo");   
        //vmConfiguration.setUserName("siveo_test");   
        //vmConfiguration.setSocietyName("Navaho");   
        vmConfiguration.setName(vmName);

        // ---------------------------------------------------------------
        // Initialize the Linux Sysprep 
        // ---------------------------------------------------------------
        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("siveo.net");
        sysprepLinux.setHostname(vmName);

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        //vmConfiguration.setSysprepWindows(winSysPrep);
        vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------

        NetworkAdapter networkAdapter = new NetworkAdapter();
        //networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});
        networkAdapter.setDnsServerList(new String[] { "194.133.14.66" });
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.62.16.75");
        networkAdapter.setSubnetMask("255.255.252.0");
        networkAdapter.setGateway(new String[] { "10.62.16.2" });
        ////networkAdapter.setMacAddress(null);
        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        vmConfiguration.setDnsServerList(new String[] { "194.133.14.66" });
        //vmConfiguration.setDnsSuffixList(new String[]{});
        vmConfiguration.setDnsSuffixList(new String[] {});

        // set the second Network
        //networkAdapter=new NetworkAdapter();
        ////networkAdapter.setDnsDomain("siveo.net");
        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp(null);
        //networkAdapter.setSubnetMask("255.255.255.0");
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        //vmConfiguration.setNetworkAdpater(networkAdapter);

        // !!!
        ////vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        ////vmConfiguration.setDnsSuffixList(new String[]{});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // ---------------------------------------------------------------
        // Set the CPU configuration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(1024);
        virtualCPU.setReservation(1024);
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setNbCPU(2);
        //vmConfiguration.setVirtualCPU(virtualCPU);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMem = new VirtualMemory();
        virtualMem.setLimit(4096);
        virtualMem.setReservation(2048);
        virtualMem.setMemory(2048);
        virtualMem.setExpandableReservation(false);
        //vmConfiguration.setVirtualMemory(virtualMem);

        // ---------------------------------------------------------------
        // Add a new card
        // ---------------------------------------------------------------
        //VirtualNetwork virtualNetwork=null;

        //Select a VMware Network
        //NetworkManager networkManager=NetworkManager.getInstance();
        //Network network=networkManager.getNetworkByID("network-210", hostName);

        //virtualNetwork=new VirtualNetwork();
        //virtualNetwork.setNetwork(network);
        //virtualNetwork.setAction(VirtualDeviceOperation.add);
        //vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        // ######################################################################
        VirtualNetwork virtualNetwork = null;

        //Select a VMware Network
        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = null;

        // Remove
        //network=networkManager.getNetworkByID("network-248", hostName);
        //virtualNetwork=new VirtualNetwork();
        //virtualNetwork.setNetwork(network);
        //virtualNetwork.setAction(VirtualDeviceOperation.remove);
        ////vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        network = networkManager.getNetworkByID("network-248", hostName);
        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.add);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        // ######################################################################

        // ---------------------------------------------------------------
        // Extend the first Disk and add a new disk 
        // ---------------------------------------------------------------
        //      net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk=new VirtualDisk();
        //
        //      // Extend the First Disk
        //      vDisk=template.getVirtualDeviceManager().getVirtualDisks().get(0);
        //      vDisk.setAction(VirtualDeviceOperation.edit);
        //      vDisk.setDiskSize(20*1024);
        //      //vmConfiguration.getListOfVirtualDisk().add(vDisk);
        //      
        //      // Add a new DISK
        //      vDisk=new VirtualDisk();
        //      vDisk.setAction(VirtualDeviceOperation.add);
        //      vDisk.setDiskSize(1024*3);
        //      //vDisk.setLabel("Hard disk 2");
        //      //vmConfiguration.getListOfVirtualDisk().add(vDisk);

        // ---------------------------------------------------------------
        // Set the additional fields 
        // ---------------------------------------------------------------
        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        // Clone Template to VM with reconfiguration and sysprep 
        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        vmManager.cloneTemplateToVMEx(vmID, hostName, vmConfiguration, hostID, dataStoreID, resourcePoolID,
                vmFolderID);

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Connect the card
        // =========================================================================================

        //      //Refresh the VM
        //      VMware.refresh(hostName);
        //      listOfMors.clear();
        //      VirtualMachine vm=vmManager.getVmByName(hostName, vmName);
        //      listOfMors.add(vm.getMor());
        //      inventory.getVirtualMachinePropertiesEx(listOfMors);
        //      
        //      vm.connectVirtualNetworkOnStart(vm.getVMNetwork().getListOfVirtualNetwork(), "ABCD");

        /*
        ArrayList<VirtualNetwork> listOfVirtualNetworks=vm.getVMNetwork().getListOfVirtualNetwork();
            
        for (VirtualNetwork virtualNetwork2:listOfVirtualNetworks)
        {
           System.out.println("VirtualNetwork: "+virtualNetwork2.getVirtualDevice().getDeviceInfo().getLabel());
               
               
           VirtualDeviceConnectInfo virtualDeviceConnectInfo=virtualNetwork2.getVirtualDevice().getConnectable();
           if (virtualDeviceConnectInfo!=null)
           {
        System.out.println("Connectable");
        System.out.println("AllowGuestControl: "+virtualDeviceConnectInfo.isAllowGuestControl());
        System.out.println("Connected: "+virtualDeviceConnectInfo.isConnected());
        System.out.println("Start Connected "+virtualDeviceConnectInfo.isStartConnected());
           }
        }
        */

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void deployInstantWindowsVM() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Deploy a VM from a Template and add a new Virtual Network Card
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        // Creation Cross DC
        String hostID = "host-71"; // siveo-esx2.siveo.net
        String dataStoreID = "datastore-536"; // VMFSDEMO
        String vmID = "vm-924"; //template SmallVM
        String vmFolderID = null; // dossier SCVMM
        String resourcePoolID = null; //TestCDO

        Host host = HostManager.getInstance().getHostByID(hostID, hostName);
        Datastore datastore = DataStoreManager.getInstance().getDatastoreByID(dataStoreID, hostName);
        VirtualMachine template = vmManager.getVmByID(hostName, vmID);

        System.out.println("Infos de Clonage:");
        System.out.println("- Host :" + host.getName());
        System.out.println("- Datastore :" + datastore.getName());
        System.out.println("- Template :" + template.getName());

        if (vmFolderID != null) {
            Folder folder = FolderManager.getInstance().getFolderByID(vmFolderID, hostName);
            System.out.println("- Folder :" + folder.getName());
        }

        if (resourcePoolID != null) {
            ResourcePool resourcePool = ResourcePoolManager.getInstance().getResourcePoolByID(hostName,
                    resourcePoolID);
            System.out.println("- ResourcePool :" + resourcePool.getName());
        }

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();
        listOfMors.add(template.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfMors);

        // =========================================================================================
        // Initialize the Sysprep
        // =========================================================================================
        System.out.println("\n*****  Clone Template to VM *****");
        //String vmName=null;
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        vmConfiguration.setUserName("actidev1");
        //vmConfiguration.setUserName("siveo_test");   
        vmConfiguration.setSocietyName("Navaho");
        vmConfiguration.setName("VMNetUdate");

        // ---------------------------------------------------------------
        // Initialize the GuiUnattended Section
        // ---------------------------------------------------------------
        GuiUnattended guiUnattended = new GuiUnattended();
        guiUnattended.setAdminPassword("Clmdp@09");
        guiUnattended.setEncryptedAdminPassword(false);
        guiUnattended.setAutoLogon(true);
        guiUnattended.setAutoLogonCount(3);
        guiUnattended.setTimeZone(105);

        // ---------------------------------------------------------------
        // Initialize the LicenseFilePrintData Section
        // ---------------------------------------------------------------
        LicenseFilePrintData licenseData = new LicenseFilePrintData();
        licenseData.setAutoMode("PerServer");
        licenseData.setAutoUsers(5);

        // ---------------------------------------------------------------
        // Initialize the UserData Section
        // ---------------------------------------------------------------
        UserData userData = new UserData();
        userData.setComputerName(vmConfiguration.getName());
        userData.setFullName("WinVMUser");
        userData.setOrgName("NAVAHO");
        //userData.setProductId("MBKJF-QXT8P-RXWBG-FG687-C79GP");
        // Windows 2003
        userData.setProductId("Q66VX-8TBQ3-2JC46-MDQFC-94CMB");

        //

        // ---------------------------------------------------------------
        // Initialize the Identification Section
        // ---------------------------------------------------------------
        Identification identification = new Identification();

        //Activation du mode WORKGROUP
        identification.setDomainAdmin("SIVEO\\Administrateur");
        identification.setDomainAdminPassword("Clmdp@09");
        identification.setJoinDomain(null);
        identification.setJoinWorkgroup("WORKGROUP");

        //Activation du mode Domain
        //identification.setDomainAdmin("SIVEO\\Administrateur");
        //identification.setDomainAdminPassword("Clmdp@09");
        //identification.setJoinDomain("SIVEO");
        ////identification.setJoinWorkgroup("WORKGROUP");

        // ---------------------------------------------------------------
        // Initialize the GuiRunOnce Section
        // ---------------------------------------------------------------
        GuiRunOnce guiRunOnce = new GuiRunOnce();
        String command = "\"net localgroup Administrateurs " + identification.getJoinDomain() + "\\"
                + vmConfiguration.getUserName() + " /add\"";
        System.out.println("command: " + command);
        guiRunOnce.setCommandList(new String[] { command });

        //test hudson
        // ---------------------------------------------------------------
        // Initialize the Sysprep for Windows
        // ---------------------------------------------------------------
        SysprepWindows winSysPrep = new SysprepWindows();
        //winSysPrep.setGuiRunOnce(null);
        winSysPrep.setGuiUnattended(guiUnattended);
        winSysPrep.setIdentification(identification);
        winSysPrep.setLicenseFilePrintData(licenseData);
        winSysPrep.setUserData(userData);

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        vmConfiguration.setSysprepWindows(winSysPrep);
        //vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------

        NetworkAdapter networkAdapter = new NetworkAdapter();
        //networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});

        //networkAdapter.setDnsServerList(new String[]{"10.251.5.30"});
        networkAdapter.setDnsServerList(new String[] {});
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.62.16.95");
        networkAdapter.setSubnetMask("255.255.252.0");
        networkAdapter.setGateway(new String[] { "10.62.16.2" });
        ////networkAdapter.setMacAddress(null);
        vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"10.251.5.30"});
        vmConfiguration.setDnsServerList(new String[] {});
        //vmConfiguration.setDnsSuffixList(new String[]{});
        vmConfiguration.setDnsSuffixList(new String[] {});

        // ---------------------------------------------------------------
        // Set the CPU configuration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(1024);
        virtualCPU.setReservation(1024);
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setNbCPU(2);
        //vmConfiguration.setVirtualCPU(virtualCPU);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMem = new VirtualMemory();
        virtualMem.setLimit(4096);
        virtualMem.setReservation(2048);
        virtualMem.setMemory(2048);
        virtualMem.setExpandableReservation(false);
        //vmConfiguration.setVirtualMemory(virtualMem);

        // ---------------------------------------------------------------
        // Add a new card
        // ---------------------------------------------------------------
        VirtualNetwork virtualNetwork = null;

        //Select a VMware Network
        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = null;

        // Remove
        network = networkManager.getNetworkByID("network-547", hostName);
        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.remove);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        network = networkManager.getNetworkByID("network-561", hostName);
        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.add);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        // ---------------------------------------------------------------
        // Extend the first Disk and add a new disk 
        // ---------------------------------------------------------------
        net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk = new VirtualDisk();

        // Extend the First Disk
        vDisk = template.getVirtualDeviceManager().getVirtualDisks().get(0);
        vDisk.setAction(VirtualDeviceOperation.edit);
        vDisk.setDiskSize(20 * 1024);
        //vmConfiguration.getListOfVirtualDisk().add(vDisk);

        // Add a new DISK
        vDisk = new VirtualDisk();
        vDisk.setAction(VirtualDeviceOperation.add);
        vDisk.setDiskSize(1024 * 3);
        //vDisk.setLabel("Hard disk 2");
        //vmConfiguration.getListOfVirtualDisk().add(vDisk);

        // ---------------------------------------------------------------
        // Set the additional fields 
        // ---------------------------------------------------------------
        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        // Clone Template to VM with reconfiguration and sysprep 
        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        vmManager.cloneTemplateToVMEx(vmID, hostName, vmConfiguration, hostID, dataStoreID, resourcePoolID,
                vmFolderID);

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void deployInstantVMOnProd() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.246.5.10";
        VMware.create(hostName, 443, "instantvm\\siveo-admin", "Sive0@dmin", false, -1L);

        // =========================================================================================
        // Deploy a VM from a Template and add a new Virtual Network Card
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        // Creation Cross DC
        String hostID = "host-28"; // th3-instantvm-esx01.instantvm.navaho.local
        String dataStoreID = "datastore-61"; // ds-EMC_TH3_CX4-InstantVM-Bronze-cli-01
        String vmID = "vm-581"; //template testdga
        String vmFolderID = "group-v466"; // dossier Contrat_1
        String resourcePoolID = "resgroup-429"; //Contrat_1

        Host host = HostManager.getInstance().getHostByID(hostID, hostName);
        Datastore datastore = DataStoreManager.getInstance().getDatastoreByID(dataStoreID, hostName);
        VirtualMachine template = vmManager.getVmByID(hostName, vmID);

        System.out.println("Infos de Clonage:");
        System.out.println("- Host :" + host.getName());
        System.out.println("- Datastore :" + datastore.getName());
        System.out.println("- Template :" + template.getName());

        if (vmFolderID != null) {
            Folder folder = FolderManager.getInstance().getFolderByID(vmFolderID, hostName);
            System.out.println("- Folder :" + folder.getName());
        }

        if (resourcePoolID != null) {
            ResourcePool resourcePool = ResourcePoolManager.getInstance().getResourcePoolByID(hostName,
                    resourcePoolID);
            System.out.println("- ResourcePool :" + resourcePool.getName());
        }

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();
        listOfMors.add(template.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfMors);

        // =========================================================================================
        // Initialize the Sysprep Linux
        // =========================================================================================
        System.out.println("\n*****  Clone Template to VM *****");
        String vmName = "instantvmjpa";
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        //vmConfiguration.setUserName("instantvmcdo");   
        //vmConfiguration.setUserName("siveo_test");   
        //vmConfiguration.setSocietyName("Navaho");   
        vmConfiguration.setName(vmName);

        // ---------------------------------------------------------------
        // Initialize the Linux Sysprep 
        // ---------------------------------------------------------------
        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("INSTANTVM");
        sysprepLinux.setHostname(vmName);

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        //vmConfiguration.setSysprepWindows(winSysPrep);
        vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------

        NetworkAdapter networkAdapter = new NetworkAdapter();
        //networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});
        //networkAdapter.setDnsServerList(new String[]{"194.133.14.66"});
        networkAdapter.setDnsServerList(new String[] {});
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("81.93.16.200");
        networkAdapter.setSubnetMask("255.255.255.192");
        networkAdapter.setGateway(new String[] { "81.93.16.254" });
        ////networkAdapter.setMacAddress(null);
        vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"194.133.14.66"});
        vmConfiguration.setDnsServerList(new String[] {});
        //vmConfiguration.setDnsSuffixList(new String[]{});
        vmConfiguration.setDnsSuffixList(new String[] {});

        // set the second Network
        //networkAdapter=new NetworkAdapter();
        ////networkAdapter.setDnsDomain("siveo.net");
        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp(null);
        //networkAdapter.setSubnetMask("255.255.255.0");
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        //vmConfiguration.setNetworkAdpater(networkAdapter);

        // !!!
        ////vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        ////vmConfiguration.setDnsSuffixList(new String[]{});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // ---------------------------------------------------------------
        // Set the CPU configuration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(1024);
        virtualCPU.setReservation(1024);
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setNbCPU(2);
        //vmConfiguration.setVirtualCPU(virtualCPU);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMem = new VirtualMemory();
        virtualMem.setLimit(4096);
        virtualMem.setReservation(2048);
        virtualMem.setMemory(2048);
        virtualMem.setExpandableReservation(false);
        //vmConfiguration.setVirtualMemory(virtualMem);

        // ---------------------------------------------------------------
        // Add a new card
        // ---------------------------------------------------------------
        VirtualNetwork virtualNetwork = null;

        //Select a VMware Network
        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = networkManager.getNetworkByID("network-210", hostName);

        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.add);
        //vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        // ---------------------------------------------------------------
        // Add a new card DVSwitch
        // ---------------------------------------------------------------
        DVSwitch dvSwitch = null;
        DVPortGroup dvPortGroup = null;

        DVSwitchManager dvSwitchManager = DVSwitchManager.getInstance();
        dvSwitch = dvSwitchManager.getDVSwitchByUUID("53 50 08 50 ed f4 88 7b-96 ef dd 74 61 59 d8 85", hostName);
        dvPortGroup = dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-520");

        VirtualDVSwitch virtualDVSwitch = new VirtualDVSwitch();
        virtualDVSwitch.setDvSwitch(dvSwitch);
        virtualDVSwitch.setDvPortGroup(dvPortGroup);
        virtualDVSwitch.setAction(VirtualDeviceOperation.add);
        vmConfiguration.getListOfVirtualDVSwitchs().add(virtualDVSwitch);

        /*
        ArrayList<VirtualDVSwitch> listOfVirtualDVSwitch =new ArrayList<VirtualDVSwitch>();   
            
            
        DVSwitchManager dvSwitchManager=DVSwitchManager.getInstance();
        DVSwitch dvSwitch=null;
        DVPortGroup dvPortGroup=null;
            
            
            
            
        //virtualDVSwitch=vm.getVMNetwork().getVirtualDVSwitchByUUIDByDvPortGroupKeyByPortKey("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", "dvportgroup-257", "2273");
            
        virtualDVSwitch=vm.getVMNetwork().getVirtualDVSwitchByUuidByDVPortGroupKey("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", "dvportgroup-202");
            
        //virtualDVSwitch=new VirtualDVSwitch();
        //virtualDVSwitch.setSwitchUuid("67 69 2d 50 b8 e5 40 4b-1c f0 c4 ac 38 54 ac 3d");
        //virtualDVSwitch.setPortGroupKey("dvportgroup-6421");
        virtualDVSwitch.setAction(VirtualDeviceOperation.remove);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
            
        //DVSwitchManager dvSwitchManager=DVSwitchManager.getInstance();
        dvSwitch=dvSwitchManager.getDVSwitchByUUID("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", hostName);
        dvPortGroup=dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-257");
            
        virtualDVSwitch=new VirtualDVSwitch();
        virtualDVSwitch.setDvSwitch(dvSwitch);
        virtualDVSwitch.setDvPortGroup(dvPortGroup);
        virtualDVSwitch.setAction(VirtualDeviceOperation.add);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
            
            
        // Edit a DVSwitch
        virtualDVSwitch=vm.getVMNetwork().getVirtualDVSwitchByUUID("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac");
            
        dvSwitch=dvSwitchManager.getDVSwitchByUUID("a9 9d 2d 50 f1 ad 37 75-61 18 fc 7d 7a 56 52 ac", hostName);
        //dvPortGroup=dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-202");
        dvPortGroup=dvSwitch.getMapOfDVPortGroupByKey().get("dvportgroup-257");
        System.out.println("dvPortGroup: "+dvPortGroup.getName());
            
        virtualDVSwitch.setDvPortGroup(dvPortGroup);
        virtualDVSwitch.setAction(VirtualDeviceOperation.edit);
        //listOfVirtualDVSwitch.add(virtualDVSwitch);
        */

        // ---------------------------------------------------------------
        // Extend the first Disk and add a new disk 
        // ---------------------------------------------------------------
        net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk = new VirtualDisk();

        // Extend the First Disk
        vDisk = template.getVirtualDeviceManager().getVirtualDisks().get(0);
        vDisk.setAction(VirtualDeviceOperation.edit);
        vDisk.setDiskSize(20 * 1024);
        //vmConfiguration.getListOfVirtualDisk().add(vDisk);

        // Add a new DISK
        vDisk = new VirtualDisk();
        vDisk.setAction(VirtualDeviceOperation.add);
        vDisk.setDiskSize(1024 * 3);
        //vDisk.setLabel("Hard disk 2");
        //vmConfiguration.getListOfVirtualDisk().add(vDisk);

        // ---------------------------------------------------------------
        // Set the additional fields 
        // ---------------------------------------------------------------
        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        // Clone Template to VM with reconfiguration and sysprep 
        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        vmManager.cloneTemplateToVMEx(vmID, hostName, vmConfiguration, hostID, dataStoreID, resourcePoolID,
                vmFolderID);

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Connect the card
        // =========================================================================================

        //Refresh the VM
        VMware.refresh(hostName);
        listOfMors.clear();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);
        listOfMors.add(vm.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfMors);

        vm.connectVirtualNetworkOnStart(vm.getVMNetwork().getListOfVirtualNetwork(), "ABCD");

        /*
        ArrayList<VirtualNetwork> listOfVirtualNetworks=vm.getVMNetwork().getListOfVirtualNetwork();
            
        for (VirtualNetwork virtualNetwork2:listOfVirtualNetworks)
        {
           System.out.println("VirtualNetwork: "+virtualNetwork2.getVirtualDevice().getDeviceInfo().getLabel());
               
               
           VirtualDeviceConnectInfo virtualDeviceConnectInfo=virtualNetwork2.getVirtualDevice().getConnectable();
           if (virtualDeviceConnectInfo!=null)
           {
        System.out.println("Connectable");
        System.out.println("AllowGuestControl: "+virtualDeviceConnectInfo.isAllowGuestControl());
        System.out.println("Connected: "+virtualDeviceConnectInfo.isConnected());
        System.out.println("Start Connected "+virtualDeviceConnectInfo.isStartConnected());
           }
        }
        */

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void maintenance() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        ArrayList<VirtualMachine> listOfVirtualMachines = vmManager.getAllVM(hostName);

        if (listOfVirtualMachines != null && !listOfVirtualMachines.isEmpty()) {
            // Mise  jour des VMs
            InventoryManager inventoryManager = InventoryManager.getInstance();
            Inventory inventory = inventoryManager.getInventoryByVC(hostName);
            ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();

            for (VirtualMachine vm : listOfVirtualMachines) {
                listOfMors.add(vm.getMor());
            }
            inventory.getVirtualMachinePropertiesEx(listOfMors);

            // Arrt des machines propres
            for (VirtualMachine vm : listOfVirtualMachines) {
                if (!vm.getPowerState().equals("poweredOff")) {
                    vm.shutdownGuest();
                }
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void templateListNetworks() throws Exception {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        String vmID = "vm-923"; //template SmallVM
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine template = vmManager.getVmByID(hostName, vmID);

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();
        listOfMors.add(template.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfMors);

        ArrayList<Network> listOfNetworks = template.getListOfNetworks();

        for (Network network : listOfNetworks) {
            System.out.println("Network: " + network.getName() + " / ID: " + network.getMor().get_value());
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void updateNetwork() throws Exception {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        //String hostName="10.246.5.10";
        //VMware.create(hostName,443,"instantvm\\siveo-admin","Sive0@dmin",false,-1L,1000);

        // =========================================================================================
        // Suppress the Network Cards from the templates and create a new one 
        // =========================================================================================
        // =========================================================================================
        // Deploy a VM from a Template and add a new Virtual Network Card
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        // Creation Cross DC
        String hostID = "host-532"; // siveo-esx2.siveo.net
        String dataStoreID = "datastore-535"; // VMFSDEMO
        //String vmID="vm-923"; //template SmallVM
        String vmID = "vm-1113"; //template SmallVM
        String vmFolderID = null; // dossier SCVMM
        String resourcePoolID = null; //TestCDO -> "resgroup-1004"

        Host host = HostManager.getInstance().getHostByID(hostID, hostName);
        Datastore datastore = DataStoreManager.getInstance().getDatastoreByID(dataStoreID, hostName);
        VirtualMachine template = vmManager.getVmByID(hostName, vmID);

        System.out.println("Infos de Clonage:");
        System.out.println("- Host :" + host.getName());
        System.out.println("- Datastore :" + datastore.getName());
        System.out.println("- Template :" + template.getName());

        if (vmFolderID != null) {
            Folder folder = FolderManager.getInstance().getFolderByID(vmFolderID, hostName);
            System.out.println("- Folder :" + folder.getName());
        }

        if (resourcePoolID != null) {
            ResourcePool resourcePool = ResourcePoolManager.getInstance().getResourcePoolByID(hostName,
                    resourcePoolID);
            System.out.println("- ResourcePool :" + resourcePool.getName());
        }

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();
        listOfMors.add(template.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfMors);

        // =========================================================================================
        // Initialize the Sysprep Linux
        // =========================================================================================
        System.out.println("\n*****  Clone Template to VM *****");
        String vmName = "instantvmcdo";
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        //vmConfiguration.setUserName("instantvmcdo");   
        //vmConfiguration.setUserName("siveo_test");   
        //vmConfiguration.setSocietyName("Navaho");   
        vmConfiguration.setName(vmName);

        // ---------------------------------------------------------------
        // Initialize the Linux Sysprep 
        // ---------------------------------------------------------------
        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("siveo.net");
        sysprepLinux.setHostname(vmName);

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        //vmConfiguration.setSysprepWindows(winSysPrep);
        vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------

        NetworkAdapter networkAdapter = new NetworkAdapter();
        //networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});
        networkAdapter.setDnsServerList(new String[] { "194.133.14.66" });
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.62.16.75");
        networkAdapter.setSubnetMask("255.255.252.0");
        networkAdapter.setGateway(new String[] { "10.62.16.2" });
        ////networkAdapter.setMacAddress(null);
        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        vmConfiguration.setDnsServerList(new String[] { "194.133.14.66" });
        //vmConfiguration.setDnsSuffixList(new String[]{});
        vmConfiguration.setDnsSuffixList(new String[] {});

        // set the second Network
        //networkAdapter=new NetworkAdapter();
        ////networkAdapter.setDnsDomain("siveo.net");
        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp(null);
        //networkAdapter.setSubnetMask("255.255.255.0");
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        //vmConfiguration.setNetworkAdpater(networkAdapter);

        // !!!
        ////vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        ////vmConfiguration.setDnsSuffixList(new String[]{});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // ---------------------------------------------------------------
        // Set the CPU configuration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(1024);
        virtualCPU.setReservation(1024);
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setNbCPU(2);
        //vmConfiguration.setVirtualCPU(virtualCPU);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMem = new VirtualMemory();
        virtualMem.setLimit(4096);
        virtualMem.setReservation(2048);
        virtualMem.setMemory(2048);
        virtualMem.setExpandableReservation(false);
        //vmConfiguration.setVirtualMemory(virtualMem);

        // ---------------------------------------------------------------
        // Add a new card
        // ---------------------------------------------------------------
        VirtualNetwork virtualNetwork = null;

        //Select a VMware Network
        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = null;

        // Add a new network Card
        network = networkManager.getNetworkByID("network-210", hostName);
        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.add);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        // Delete the Network presents in the Template

        //Delete the Airial Network
        network = networkManager.getNetworkByID("network-193", hostName);
        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.remove);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        //Delete the VM Network Network
        network = networkManager.getNetworkByID("network-547", hostName);
        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.remove);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        network = networkManager.getNetworkByID("network-561", hostName);
        virtualNetwork = new VirtualNetwork();
        virtualNetwork.setNetwork(network);
        virtualNetwork.setAction(VirtualDeviceOperation.remove);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        // ---------------------------------------------------------------
        // Extend the first Disk and add a new disk 
        // ---------------------------------------------------------------
        net.siveo.virtualization.vmware.virtualdevice.VirtualDisk vDisk = new VirtualDisk();

        // Extend the First Disk
        vDisk = template.getVirtualDeviceManager().getVirtualDisks().get(0);
        vDisk.setAction(VirtualDeviceOperation.edit);
        vDisk.setDiskSize(20 * 1024);
        //vmConfiguration.getListOfVirtualDisk().add(vDisk);

        // Add a new DISK
        vDisk = new VirtualDisk();
        vDisk.setAction(VirtualDeviceOperation.add);
        vDisk.setDiskSize(1024 * 3);
        //vDisk.setLabel("Hard disk 2");
        //vmConfiguration.getListOfVirtualDisk().add(vDisk);

        // ---------------------------------------------------------------
        // Set the additional fields 
        // ---------------------------------------------------------------
        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        // Clone Template to VM with reconfiguration and sysprep 
        // ---------------------------------------------------------------
        // ---------------------------------------------------------------
        vmManager.cloneTemplateToVMEx(vmID, hostName, vmConfiguration, hostID, dataStoreID, resourcePoolID,
                vmFolderID);

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Connect the card
        // =========================================================================================
        /*
        //Refresh the VM
        VMware.refresh(hostName);
        listOfMors.clear();
        VirtualMachine vm=vmManager.getVmByName(hostName, vmName);
        listOfMors.add(vm.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfMors);
            
        vm.connectVirtualNetworkOnStart(vm.getVMNetwork().getListOfVirtualNetwork(), "ABCD");
        /*
            
        /*
        ArrayList<VirtualNetwork> listOfVirtualNetworks=vm.getVMNetwork().getListOfVirtualNetwork();
            
        for (VirtualNetwork virtualNetwork2:listOfVirtualNetworks)
        {
           System.out.println("VirtualNetwork: "+virtualNetwork2.getVirtualDevice().getDeviceInfo().getLabel());
               
               
           VirtualDeviceConnectInfo virtualDeviceConnectInfo=virtualNetwork2.getVirtualDevice().getConnectable();
           if (virtualDeviceConnectInfo!=null)
           {
        System.out.println("Connectable");
        System.out.println("AllowGuestControl: "+virtualDeviceConnectInfo.isAllowGuestControl());
        System.out.println("Connected: "+virtualDeviceConnectInfo.isConnected());
        System.out.println("Start Connected "+virtualDeviceConnectInfo.isStartConnected());
           }
        }
        */

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void startInstantVM() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.246.5.10";
        VMware.create(hostName, 443, "instantvm\\siveo-admin", "Sive0@dmin", false, -1L, 1000);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "instantvmjpa");

        //vm.powerOn("1234");
        vm.rebootGuest();
        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void connectDeviceOnStart() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.246.5.10";
        VMware.create(hostName, 443, "instantvm\\siveo-admin", "Sive0@dmin", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "instantvmjpa");

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfMors = new ArrayList<ManagedObjectReference>();
        listOfMors.add(vm.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfMors);

        //ArrayList<VirtualNetwork> listOfVirtualNetwork=vm.getVMNetwork().getListOfVirtualNetwork();
        ArrayList<VirtualDVSwitch> listOfVirtualNetwork = vm.getVMNetwork().getListOfVirtualDVSwitch();

        //vm.connectVirtualNetworkOnStart(listOfVirtualNetwork, "1234");
        vm.connectVirtualDVSwitchOnStart(listOfVirtualNetwork, "1234");

        System.out.println("Press a key to continue");
        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVMHost() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByID(hostName, "vm-1024");

        Host host = vm.getHost();
        System.out.println("host: " + host);
        System.out.println("host: " + host.getName());

        System.out.println("Host copnnection state: " + host.getConnectionState());

        // =========================================================================================
        // 
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getResourcePool() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Get ResourcePool
        // =========================================================================================
        /*
        ResourceManager resourceManager=ResourceManager.getInstance();
        ArrayList<ResourcePool> listOfPool=resourceManager.getAllResourcePool(hostName);
            
        if (listOfPool!=null && !listOfPool.isEmpty())
        {
           for(ResourcePool pool:listOfPool)
           {
        System.out.println("Pool - ID: "+pool.getMor().get_value()+" / Name: "+pool.getName()+" / Parent: "+pool.getParent().getClass());
           }
        }
        */

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        TreeNode rootNode = inventory.getRootNode();
        System.out.println("");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testFastInventory() throws Exception {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.1.109.236";
        VMware.create(hostName, 443, "Administrator", "8x63-K/!/", false, -1L);

        // =========================================================================================
        // Inventory
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        TreeNode rootNode = inventory.getRootNode();
        System.out.println("RootNode: " + rootNode);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "vcs01vbl");

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("10.1.109.242", hostName);

        System.out.println("VirtualMachine Configuration: " + vm.getVmConfiguration());
        System.out.println("VirtualMachine Power State: " + vm.retrievePowerState());
        System.out.println("Host Connection State: " + host.getConnectionState());
        System.out.println("Host Power State: " + host.getPowerState());

        System.out.println("Appuyer sur une touche....");
        System.in.read();

        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();
        listOfManagedObjectReferences.add(vm.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);

        listOfManagedObjectReferences.clear();
        listOfManagedObjectReferences.add(host.getMor());
        inventory.getHostPropertiesEx(listOfManagedObjectReferences);

        //System.out.println("Host CPU Hz: "+host.getCPU().getHz());
        //System.out.println("Host Num CPU Cores: "+host.getCPU().getNumCpuCores());
        //System.out.println("Host Memory size: "+host.getMemory().getMemorySize());

        System.out.println("Host Connection State: " + host.getConnectionState());
        System.out.println("Host Power State: " + host.getPowerState());

        System.out.println("VirtualMachine Configuration: " + vm.getVmConfiguration());
        System.out.println("VirtualMachine Nb cpu: " + vm.getVmConfiguration().getVirtualCPU().getNbCPU());
        System.out.println("VirtualMachine Mghz: " + vm.getVmConfiguration().getVirtualCPU().getMghz());
        System.out.println("VirtualMachine Memory: " + vm.getVmConfiguration().getVirtualMemory().getMemory());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testRecupProperties() throws Exception {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        //String hostName="10.1.109.236";
        //VMware.create(hostName,443,"Administrator","8x63-K/!/",false,-1L);

        // =========================================================================================
        // Inventory
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        TreeNode rootNode = inventory.getRootNode();
        System.out.println("RootNode: " + rootNode);

        VMManager vmManager = VMManager.getInstance();

        // Get All VMs
        ArrayList<VirtualMachine> listOfVms = vmManager.getAllVM(hostName);
        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();

        for (VirtualMachine vm : listOfVms) {
            listOfManagedObjectReferences.add(vm.getMor());
        }

        Date dt01 = new Date();
        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);
        Date dt02 = new Date();

        // Get VM by VM
        listOfManagedObjectReferences.clear();

        Date dt03 = new Date();
        for (VirtualMachine vm : listOfVms) {
            listOfManagedObjectReferences.clear();
            listOfManagedObjectReferences.add(vm.getMor());
            inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);
        }
        Date dt04 = new Date();

        System.out.println("Recup all: " + (dt02.getTime() - dt01.getTime()));
        System.out.println("Recup One by One: " + (dt04.getTime() - dt03.getTime()));

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getAllPrivileges() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        //String hostName="10.1.109.236";
        //VMware.create(hostName,443,"Administrator","8x63-K/!/",false,-1L);

        // =========================================================================================
        // Get all Privileges
        // =========================================================================================
        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        System.out.println("##################### All Privileges #####################");
        authorizationManager.getAllPrivileges(hostName);
        System.out.println("");
        System.out.println("##################### system Privileges #####################");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testRecupNetworkProperties() throws Exception {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        //String hostName="10.1.109.236";
        //VMware.create(hostName,443,"Administrator","8x63-K/!/",false,-1L);

        // =========================================================================================
        // Inventory
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        TreeNode rootNode = inventory.getRootNode();
        System.out.println("RootNode: " + rootNode);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "templ_rhel5");

        // Get All VMs
        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();
        listOfManagedObjectReferences.add(vm.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);

        System.out.println("Premier Appel");
        this.displayNet(vm);

        System.out.println("Deuxime Appel");
        listOfManagedObjectReferences.clear();
        listOfManagedObjectReferences.add(vm.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);
        this.displayNet(vm);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void displayNet(VirtualMachine vm) {
        VMNetwork vmNetwork = vm.getVMNetwork();
        ArrayList<VirtualNetwork> listOfVirtualNetworks = null;
        ArrayList<VirtualDVSwitch> listOfVirtualDVSwitchs = null;

        if (vmNetwork != null) {

            listOfVirtualNetworks = vmNetwork.getListOfVirtualNetwork();
            if (listOfVirtualNetworks != null && !listOfVirtualNetworks.isEmpty()) {
                for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {
                    System.out.println("    - Label: " + virtualNetwork.getLabel());
                    System.out.println("    - Name: " + virtualNetwork.getNetwork().getName());
                    System.out.println("    - Vlan ID: " + virtualNetwork.getNetwork().getVlanId());
                    System.out.println("    - Mac Address: " + virtualNetwork.getMacAddress());
                    System.out.println("");
                }
            }

            listOfVirtualDVSwitchs = vmNetwork.getListOfVirtualDVSwitch();
            if (listOfVirtualDVSwitchs != null && !listOfVirtualDVSwitchs.isEmpty()) {
                for (VirtualDVSwitch virtualDVSwitch : listOfVirtualDVSwitchs) {
                    System.out.println("    - Label: " + virtualDVSwitch.getLabel());
                    System.out.println("    - Name: " + virtualDVSwitch.getDvSwitch().getName());
                    System.out.println("    - DVPortgroup: " + virtualDVSwitch.getDvPortGroup().getName());
                    System.out.println("    - Port: " + virtualDVSwitch.getPortKey());
                    System.out.println("    - Mac Address: " + virtualDVSwitch.getMacAddress());
                    //System.out.println("    - Primary Ip Address: "+virtualDVSwitch.getPrimaryIpAddress());

                    if (virtualDVSwitch.getGuestNic() != null && virtualDVSwitch.getGuestNic().getIpConfig() != null
                            && virtualDVSwitch.getGuestNic().getIpConfig().getListOfAssignedIpAddress() != null
                            && !virtualDVSwitch.getGuestNic().getIpConfig().getListOfAssignedIpAddress()
                                    .isEmpty()) {
                        System.out.println("    - Assigned Ip Address: ");

                        for (IpConfigInfoIpAddress ipConfigInfoIpAddress : virtualDVSwitch.getGuestNic()
                                .getIpConfig().getListOfAssignedIpAddress()) {
                            System.out.println("    - Assigned Ip Address: ");
                            System.out.println("      - " + ipConfigInfoIpAddress.getIpAddress());

                        }
                    }

                    System.out.println("");
                }
            }

        } // fin if network==null;

    }

    public void displayVMDevices(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        VirtualDevice[] arrayOfVirtualDevices = vm.getVirtualDeviceManager().getListOfVirtualDevices();

        if (arrayOfVirtualDevices != null && arrayOfVirtualDevices.length > 0) {
            for (VirtualDevice virtualDevice : arrayOfVirtualDevices) {
                System.out.println("-Key: " + virtualDevice.getKey());
                System.out.println("-Class: " + virtualDevice.getClass());
                System.out.println("-controllerKey: " + virtualDevice.getControllerKey());
                System.out.println("-Label: " + virtualDevice.getDeviceInfo().getLabel());
                System.out.println("-summary: " + virtualDevice.getDeviceInfo().getSummary());

                System.out.println("");
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testEx() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        TreeNode rootNode = InventoryManager.getInstance().getInventoryByVC(hostName).getRootNode();

        System.out.println("Treenode: " + rootNode);
        // =========================================================================================
        // Browse Datastore
        // =========================================================================================
        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        ArrayList<Datastore> listOfDatastores = null;

        listOfDatastores = dataStoreManager.getAllDatastore(hostName);

        if (listOfDatastores != null && listOfDatastores.size() > 0) {
            System.out.println("******* Affichage des Datastores *******");
            for (Datastore datastore : listOfDatastores) {
                System.out.println("-Name:" + datastore.getName());
                System.out.println("-Mor:" + datastore.getMor().get_value() + " / " + datastore.getMor().getType());
                System.out.println("-Capacity:" + datastore.getCapacity());
                System.out.println("-Free Space:" + datastore.getFreeSpace());
                System.out.println("-NbHost:" + datastore.getNbHosts());
                System.out.println("");
            }
        }

        // =========================================================================================
        // Browse Hosts
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        ArrayList<Host> listOfHosts = null;

        listOfHosts = hostManager.getAllHosts(hostName);
        //System.out.println("Nb Hosts: "+listOfHosts.size());

        if (listOfHosts != null && listOfHosts.size() > 0) {
            System.out.println("******* Affichage des Hosts *******");
            for (Host host : listOfHosts) {
                System.out.println("-Name:" + host.getName());
                System.out.println("-Mor:" + host.getMor().get_value() + " / " + host.getMor().getType());
                System.out.println("-CPU:");
                System.out.println(" -Hz:" + host.getCPU().getHz());
                System.out.println(" -Num Cpu Cores:" + host.getCPU().getNumCpuCores());
                System.out.println(" -Num Cpu Packages:" + host.getCPU().getNumCpuPackages());
                System.out.println(" -Num Cpu Threads:" + host.getCPU().getNumCpuThreads());
                System.out.println(" -TotalHz:" + host.getCPU().getTotalHz());
                System.out.println("-Memory:");
                System.out.println(" -Size: " + host.getMemory().getMemorySize());
                if (!host.getNetworks().isEmpty()) {
                    System.out.println("-Network:");

                    for (Network network : host.getNetworks()) {
                        System.out.println(" -Name: " + network.getName());
                        System.out.println(
                                " -Mor: " + network.getMor().get_value() + " / " + network.getMor().getType());
                        System.out.println(" -Vlan Id: " + network.getVlanId());
                    }
                }

                if (!host.getDVSwitch().isEmpty()) {
                    System.out.println("-Ditributed Virtual Switch:");

                    for (DVSwitch dvSwitch : host.getDVSwitch()) {
                        System.out.println(" -Name: " + dvSwitch.getName());
                        System.out.println(
                                " -Mor: " + dvSwitch.getMor().get_value() + " / " + dvSwitch.getMor().getType());
                        System.out.println(" -UUID: " + dvSwitch.getUuid());
                    }
                }

                System.out.println("-CPU Capacity:" + host.getCPUCapacity());
                System.out.println("-Memory Capacity:" + host.getMemoryCapacity());
                System.out.println("-Available Disk Free Space:" + host.getAvailableDiskFreeSpace());
                System.out.println("-Computeresource Available CPU:" + host.getComputeResource().getAvailableCPU());
                System.out.println(
                        "-Computeresource Available Memory:" + host.getComputeResource().getAvailableMemory());
                System.out.println("");
            }
        }

        // =========================================================================================
        // Get VirtualMachine Disks
        // =========================================================================================
        /*
        VMManager vmManager=VMManager.getInstance();
        VirtualMachine vm=vmManager.getVmByName(hostName, "dev.siveo.net");
            
        ArrayList<VirtualDisk> listOfDisks=vm.getDisk();
            
        System.out.println("Nb Disk: "+listOfDisks);
            
        if (!listOfDatastores.isEmpty())
        {
           System.out.println("******* Affichage des Disques *******");
           for (VirtualDisk virtualDisk:listOfDisks)
           {
        System.out.println("-Label: "+virtualDisk.getLabel());
        System.out.println("-Key: "+virtualDisk.getKey());
        System.out.println("-Size: "+virtualDisk.getDiskSize());
           }
        }
            
        VMNetwork vmNetwork=vm.getVMNetwork();
            
        if (vmNetwork!=null)
        {
           System.out.println("******* Affichage des Rseaux *******");
           if (vmNetwork.getListOfVirtualNetwork()!=null && !vmNetwork.getListOfVirtualNetwork().isEmpty())
           {
        System.out.println("Network");
        for (VirtualNetwork virtualNetwork:vmNetwork.getListOfVirtualNetwork())
        {
           System.out.println("-Name: "+virtualNetwork.getNetwork().getName());
           System.out.println("-ID: "+virtualNetwork.getNetwork().getMor().get_value());
        }
           }
        }
        */

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void computeResourceAllocation() throws VMwareException {
        // =========================================================================================
        // Connexion au VC
        // =========================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // VM
        // =========================================================================================
        //String vmName="ovmmnager";
        //VMManager vmManager=VMManager.getInstance();
        //VirtualMachine vm=vmManager.getVmByName(hostName, vmName);

        //System.out.println("Virtual Machine: "+vmName);
        //System.out.println("-CPU Reservation: "+vm.getVmConfiguration().getVirtualCPU().getReservation());
        //System.out.println("-CPU Limit: "+vm.getVmConfiguration().getVirtualCPU().getLimit());

        HostManager hostManager = HostManager.getInstance();

        ArrayList<Host> listOfHosts = hostManager.getAllHosts(hostName);

        for (Host host : listOfHosts) {
            System.out.println("######## " + host.getName() + " System Resources ########");
            HostSystemResourceInfo hostSystemResourceInfo = host.getSystemResources();

            //System.out.println("Entity: "+hostSystemResourceInfo.getConfig().getEntity().get_value()+" / "+hostSystemResourceInfo.getConfig().getEntity().getType());
            System.out.println("Key: " + hostSystemResourceInfo.getKey());
            System.out.println(
                    "CPU Reservation: " + hostSystemResourceInfo.getConfig().getCpuAllocation().getReservation());
            System.out.println("CPU Limit: " + hostSystemResourceInfo.getConfig().getCpuAllocation().getLimit());
            System.out.println("ExpandableReservation: "
                    + hostSystemResourceInfo.getConfig().getCpuAllocation().getExpandableReservation());
            System.out.println("");
            System.out.println("Memory Reservation: "
                    + hostSystemResourceInfo.getConfig().getMemoryAllocation().getReservation());
            System.out.println(
                    "Memory Limit: " + hostSystemResourceInfo.getConfig().getMemoryAllocation().getLimit());
            System.out.println("ExpandableReservation: "
                    + hostSystemResourceInfo.getConfig().getMemoryAllocation().getExpandableReservation());
            System.out.println("");
            System.out.println("Total CPU Used: " + host.getTotalCpuUsed());
            System.out.println("Total Memory Used: " + host.getTotalMemUsed());
            System.out.println("CPU Available: " + host.getAvailableCPU());
            System.out.println("Memory Available: " + host.getAvailableMemory());
            System.out.println("Nb childs: " + hostSystemResourceInfo.getChild().length);
            System.out.println("");

        }

        //Host host=hostManager.getHostByName("vblockbrm2001.vblock.local", hostName);
        Host host = hostManager.getHostByName("siveo-esx4.siveo.net", hostName);

        System.out.println("");
        System.out.println("");

        System.out.println("Total VM CPU Used: " + host.getTotalVMUsedCpu());
        System.out.println("Total VM Memory Used: " + host.getTotalVmMemory());

        System.out.println("");
        System.out.println("***************** HOST " + host.getName() + " *****************");
        System.out.println("");
        System.out.println("Configuration: ");
        System.out.println("-CPU: ");
        System.out.println(" -Hz: " + host.getCPU().getHz());
        System.out.println(" -Nb CPU Packages: " + host.getCPU().getNumCpuPackages());
        System.out.println(" -Nb CPU Cores: " + host.getCPU().getNumCpuCores());
        System.out.println(" -Nb CPU Threads: " + host.getCPU().getNumCpuThreads());
        System.out.println(" -Total Hz: " + host.getCPU().getTotalHz());

        System.out.println("-Memory: ");
        System.out.println(" -Total: " + host.getMemory().getMemorySize());
        if (host.getMemory().getConsoleReservationInfo() != null)
            System.out.println(
                    " -Console: " + host.getMemory().getConsoleReservationInfo().getServiceConsoleReserved());
        if (host.getMemory().getVirtualMachineReservationInfo() != null)
            System.out.println(
                    " -VM: " + host.getMemory().getVirtualMachineReservationInfo().getVirtualMachineReserved());

        System.out.println("Capacity: ");
        System.out.println("-CPU:");
        System.out.println(" -Capcity: " + host.getCPUCapacity());
        System.out.println(" -Max Usage: " + host.getResourcePool().getRunTimeCpuUsage().getMaxUsage());
        System.out.println(" -Overal Usage: " + host.getResourcePool().getRunTimeCpuUsage().getOverallUsage());
        System.out
                .println(" -Reservation Used: " + host.getResourcePool().getRunTimeCpuUsage().getReservationUsed());
        System.out.println(" -Reservation Used For Vm: "
                + host.getResourcePool().getRunTimeCpuUsage().getReservationUsedForVm());
        System.out.println(
                " -Unreserved For Pool: " + host.getResourcePool().getRunTimeCpuUsage().getUnreservedForPool());
        System.out.println(
                " -Unreserved For VM: " + host.getResourcePool().getRunTimeCpuUsage().getUnreservedForVm());

        System.out.println("-Memory:");
        System.out.println(" -Capcity: " + host.getMemoryCapacity());
        System.out.println(" -Max Usage: " + host.getResourcePool().getRunTimeMemoryUsage().getMaxUsage());
        System.out.println(" -Overal Usage: " + host.getResourcePool().getRunTimeMemoryUsage().getOverallUsage());
        System.out.println(
                " -Reservation Used: " + host.getResourcePool().getRunTimeMemoryUsage().getReservationUsed());
        System.out.println(" -Reservation Used For Vm: "
                + host.getResourcePool().getRunTimeMemoryUsage().getReservationUsedForVm());
        System.out.println(
                " -Unreserved For Pool: " + host.getResourcePool().getRunTimeMemoryUsage().getUnreservedForPool());
        System.out.println(
                " -Unreserved For VM: " + host.getResourcePool().getRunTimeMemoryUsage().getUnreservedForVm());

        System.out.println("");
        System.out.println("***************** COMPUTE RESOURCE *****************");

        System.out.println("Compute Resource Effective CPU: " + host.getComputeResource().getEffectiveCpu());
        System.out.println("Compute Resource Effective Memory: " + host.getComputeResource().getEffectiveMemory());
        System.out.println("Compute Resource Total CPU: " + host.getComputeResource().getTotalCpu());
        System.out.println("Compute Resource Total Memory: " + host.getComputeResource().getTotalMemory());

        System.out.println("");

        System.out.println("***************** RESOURCE POOL *****************");
        String resourcePoolName = "NewResourcePool1";
        ResourcePoolManager resourcePoolManager = ResourcePoolManager.getInstance();

        ResourcePool resourcePool = resourcePoolManager.getResourcePoolByName(hostName, resourcePoolName);
        System.out.println(resourcePoolName + ": ");
        System.out.println("-Cpu Reservation: " + resourcePool.getCpuAllocation().getReservation());
        System.out.println("-Cpu Limit: " + resourcePool.getCpuAllocation().getLimit());
        System.out.println("-Cpu Mghz: " + resourcePool.getCpuAllocation().getMghz());
        System.out.println("-Memory Reservation: " + resourcePool.getMemoryAllocation().getReservation());
        System.out.println("-Memory Limit: " + resourcePool.getMemoryAllocation().getLimit());
        System.out.println("-Memory Mghz: " + resourcePool.getMemoryAllocation().getMb());

        System.out.println("-Total Childs ResourcePool Used Cpu: " + resourcePool.getTotalResourcePoolUsedCpu());
        System.out.println("-Total Childs ResourcePool Used Memory: " + resourcePool.getTotalResourceUsedMemory());
        System.out.println("-Total Childs VM CPU Used: " + resourcePool.getTotalVMUsedCpu());
        System.out.println("-Total Childs VM Memory Used: " + resourcePool.getTotalVMUsedMemory());
        System.out.println("-Available Cpu: " + resourcePool.getAvailableCPU());
        System.out.println("-Available Memory: " + resourcePool.getAvailableMemory());
        //System.out.println("-Total ResourcePool Used Memory: "+resourcePool.getTotalResourceUsedMemory());

        resourcePoolName = "NewResourcePool2";
        resourcePool = resourcePoolManager.getResourcePoolByName(hostName, resourcePoolName);
        System.out.println(resourcePoolName + ": ");
        System.out.println("-Cpu Reservation: " + resourcePool.getCpuAllocation().getReservation());
        System.out.println("-Cpu Limit: " + resourcePool.getCpuAllocation().getLimit());
        System.out.println("-Cpu Mghz: " + resourcePool.getCpuAllocation().getMghz());
        System.out.println("-Memory Reservation: " + resourcePool.getMemoryAllocation().getReservation());
        System.out.println("-Memory Limit: " + resourcePool.getMemoryAllocation().getLimit());
        System.out.println("-Memory Mghz: " + resourcePool.getMemoryAllocation().getMb());
        System.out.println("-Total Childs ResourcePool CPU Used: " + resourcePool.getTotalResourcePoolUsedCpu());
        System.out.println("-Total Childs ResourcePool Memory Used: " + resourcePool.getTotalResourceUsedMemory());
        System.out.println("-Total Childs VM CPU Used: " + resourcePool.getTotalVMUsedCpu());
        System.out.println("-Total Childs VM Memory Used: " + resourcePool.getTotalVMUsedMemory());
        System.out.println("-Available Cpu: " + resourcePool.getAvailableCPU());
        System.out.println("-Available Memory: " + resourcePool.getAvailableMemory());
        //System.out.println("-Total ResourcePool Used Memory: "+resourcePool.getTotalResourceUsedMemory());

        System.out.println("");
        System.out.println("***************** ROOT RESOURCE POOL *****************");
        System.out.println("CPU Reservation: " + host.getResourcePool().getCpuAllocation().getReservation());
        System.out.println("CPU Limit: " + host.getResourcePool().getCpuAllocation().getLimit());
        System.out.println("Memory Reservation: " + host.getResourcePool().getMemoryAllocation().getReservation());
        System.out.println("Memory Limit: " + host.getResourcePool().getMemoryAllocation().getLimit());
        System.out.println("-Total ResourcePool CPU Used: " + resourcePool.getTotalResourcePoolUsedCpu());
        System.out.println("-Total ResourcePool Memory Used: " + resourcePool.getTotalResourceUsedMemory());
        System.out.println("-Total VM CPU Used: " + resourcePool.getTotalVMUsedCpu());
        System.out.println("-Total VM Memory Used: " + resourcePool.getTotalVMUsedMemory());

        System.out.println("Available Cpu: " + host.getResourcePool().getAvailableCPU());
        System.out.println("Available Memory:: " + host.getResourcePool().getAvailableMemory());

        host = hostManager.getHostByName("siveo-esx1.siveo.net", hostName);

        System.out.println("compute Resource Class: " + host.getComputeResource().getClass());

        System.out.println("");
        System.out.println("");

        System.out.println("Total VM CPU Used: " + host.getTotalVMUsedCpu());
        System.out.println("Total VM Memory Used: " + host.getTotalVmMemory());

        System.out.println("");
        System.out.println("***************** HOST " + host.getName() + " ****************");
        System.out.println("");
        System.out.println("Configuration: ");
        System.out.println("-CPU: ");
        System.out.println(" -Hz: " + host.getCPU().getHz());
        System.out.println(" -Nb CPU Packages: " + host.getCPU().getNumCpuPackages());
        System.out.println(" -Nb CPU Cores: " + host.getCPU().getNumCpuCores());
        System.out.println(" -Nb CPU Threads: " + host.getCPU().getNumCpuThreads());
        System.out.println(" -Total Hz: " + host.getCPU().getTotalHz());

        System.out.println("-Memory: ");
        System.out.println(" -Total: " + host.getMemory().getMemorySize());
        if (host.getMemory().getConsoleReservationInfo() != null)
            System.out.println(
                    " -Console: " + host.getMemory().getConsoleReservationInfo().getServiceConsoleReserved());
        if (host.getMemory().getVirtualMachineReservationInfo() != null)
            System.out.println(
                    " -VM: " + host.getMemory().getVirtualMachineReservationInfo().getVirtualMachineReserved());

        System.out.println("Capacity: ");
        System.out.println("-CPU:");
        System.out.println(" -Capcity: " + host.getCPUCapacity());
        System.out.println(" -Max Usage: " + host.getResourcePool().getRunTimeCpuUsage().getMaxUsage());
        System.out.println(" -Overal Usage: " + host.getResourcePool().getRunTimeCpuUsage().getOverallUsage());
        System.out
                .println(" -Reservation Used: " + host.getResourcePool().getRunTimeCpuUsage().getReservationUsed());
        System.out.println(" -Reservation Used For Vm: "
                + host.getResourcePool().getRunTimeCpuUsage().getReservationUsedForVm());
        System.out.println(
                " -Unreserved For Pool: " + host.getResourcePool().getRunTimeCpuUsage().getUnreservedForPool());
        System.out.println(
                " -Unreserved For VM: " + host.getResourcePool().getRunTimeCpuUsage().getUnreservedForVm());

        System.out.println("-Memory:");
        System.out.println(" -Capcity: " + host.getMemoryCapacity());
        System.out.println(" -Max Usage: " + host.getResourcePool().getRunTimeMemoryUsage().getMaxUsage());
        System.out.println(" -Overal Usage: " + host.getResourcePool().getRunTimeMemoryUsage().getOverallUsage());
        System.out.println(
                " -Reservation Used: " + host.getResourcePool().getRunTimeMemoryUsage().getReservationUsed());
        System.out.println(" -Reservation Used For Vm: "
                + host.getResourcePool().getRunTimeMemoryUsage().getReservationUsedForVm());
        System.out.println(
                " -Unreserved For Pool: " + host.getResourcePool().getRunTimeMemoryUsage().getUnreservedForPool());
        System.out.println(
                " -Unreserved For VM: " + host.getResourcePool().getRunTimeMemoryUsage().getUnreservedForVm());

        System.out.println("");
        System.out.println("***************** COMPUTE RESOURCE *****************");

        System.out.println("Compute Resource Effective CPU: " + host.getComputeResource().getEffectiveCpu());
        System.out.println("Compute Resource Effective Memory: " + host.getComputeResource().getEffectiveMemory());
        System.out.println("Compute Resource Total CPU: " + host.getComputeResource().getTotalCpu());
        System.out.println("Compute Resource Total Memory: " + host.getComputeResource().getTotalMemory());

        System.out.println("");

        System.out.println("");
        System.out.println("***************** ROOT RESOURCE POOL *****************");
        System.out.println("CPU Reservation: " + host.getResourcePool().getCpuAllocation().getReservation());
        System.out.println("CPU Limit: " + host.getResourcePool().getCpuAllocation().getLimit());
        System.out.println("Memory Reservation: " + host.getResourcePool().getMemoryAllocation().getReservation());
        System.out.println("Memory Limit: " + host.getResourcePool().getMemoryAllocation().getLimit());
        System.out.println("-Total ResourcePool CPU Used: " + resourcePool.getTotalResourcePoolUsedCpu());
        System.out.println("-Total ResourcePool Memory Used: " + resourcePool.getTotalResourceUsedMemory());
        System.out.println("-Total VM CPU Used: " + resourcePool.getTotalVMUsedCpu());
        System.out.println("-Total VM Memory Used: " + resourcePool.getTotalVMUsedMemory());

        System.out.println("Available Cpu: " + host.getResourcePool().getAvailableCPU());
        System.out.println("Available Memory:: " + host.getResourcePool().getAvailableMemory());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void createNodePermission() throws VMwareException {
        // =========================================================================================
        // Connexion au VC
        // =========================================================================================
        String hostName = "10.62.16.35";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        InventoryManager inventoryManager = InventoryManager.getInstance();
        TreeNode treeNode = inventoryManager.getTreeNodeByID("ha-host", hostName);

        System.out.println("Type de node: " + treeNode.getClass());
        Role role = authorizationManager.getRoleByName("ESXRole", hostName);

        authorizationManager.addTreeNodePermission("ha-host", hostName, role.getID(), "SIVEO\\siveo-jth", false,
                false);

        System.out.println();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getResourcesAllocation() throws VMwareException {
        // =========================================================================================
        // Connexion au VC
        // =========================================================================================
        String hostName = "10.62.16.35";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@2013$",false,-1L);

        // =========================================================================================
        // Compute Resource
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx4.siveo.net", hostName);

        ResourceManager resourceManager = ResourceManager.getInstance();
        ComputeResource computeResource = resourceManager.getComputeResourceByID("ha-compute-res", hostName);

        System.out.println("##################### Compute Resource #####################");
        System.out.println(
                "- Compute Resource: " + computeResource.getName() + " / " + computeResource.getMor().get_value());
        System.out.println(" - Resource Pool: " + computeResource.getRootResourcePool().getName() + " / "
                + computeResource.getRootResourcePool().getMor().get_value());
        System.out.println(" - Effective Cpu: " + computeResource.getEffectiveCpu());
        System.out.println(" - Effective Memory: " + computeResource.getEffectiveMemory());
        System.out.println(" - Num Cpu Cores: " + computeResource.getNumCpuCores());
        System.out.println(" - Num Cpu Threads: " + computeResource.getNumCpuThreads());
        System.out.println(" - Num Effective Hosts: " + computeResource.getNumEffectiveHosts());
        System.out.println(" - Num Hosts: " + computeResource.getNumHosts());
        System.out.println(" - Total Cpu: " + computeResource.getTotalCpu());
        System.out.println(" - Total Memory: " + computeResource.getTotalMemory());

        ;

        System.out.println("\n##################### Compute Resource Root Resource Pool #####################");
        ResourcePool resourcePool = host.getResourcePool();
        this.printResourcePool(resourcePool);

        System.out.println("\n##################### Resource Pools #####################");
        List<ResourcePool> listOfResourcePools = host.getComputeResource().getResourcePools();

        if (listOfResourcePools != null && !listOfResourcePools.isEmpty()) {
            for (ResourcePool resourcePool2 : listOfResourcePools) {
                this.printResourcePool(resourcePool2);
            }
        }

        System.out.println("\n###############################################################################");
        System.out.println("\n##################### Compute Resource  #####################");

        System.out.println("CPU:");
        System.out.println("- Capacit Totale: " + host.getComputeResource().getCPUTotalCapacity());
        System.out.println("- Capacit rserve: " + host.getComputeResource().getCPUCapacityReserved());
        System.out.println("- Capacit disponible: " + host.getComputeResource().getCPUCapacityAvailable());

        System.out.println("Mmoire:");
        System.out.println("- Capacit Totale: " + host.getComputeResource().getMemTotalCapacity());
        System.out.println("- Capacit rserve: " + host.getComputeResource().getMemCapacityReserved());
        System.out.println("- Capacit disponible: " + host.getComputeResource().getMemCapacityAvailable());

        System.out.println("\n##################### Resource Pool  #####################");
        ResourcePoolManager resourcePoolManager = ResourcePoolManager.getInstance();

        listOfResourcePools = host.getComputeResource().getResourcePools();
        if (listOfResourcePools != null && !listOfResourcePools.isEmpty()) {
            for (ResourcePool rscPool : listOfResourcePools) {
                System.out.println("Resource Pool: " + rscPool.getName() + " / " + rscPool.getMor().get_value());

                System.out.println("=====================");
                System.out.println("Allocation Resources:");
                System.out.println("=====================");
                System.out.println("CPU:");
                System.out.println("- Capacit Totale: " + rscPool.getCPUTotalCapacity());
                System.out.println("- Capacit rserve: " + rscPool.getCPUCapacityReserved());
                System.out.println("- Capacit disponible: " + rscPool.getCPUCapacityAvailable());

                System.out.println("Mmoire:");
                System.out.println("- Capacit Totale: " + rscPool.getMemTotalCapacity());
                System.out.println("- Capacit rserve: " + rscPool.getMemCapacityReserved());
                System.out.println("- Capacit disponible: " + rscPool.getMemCapacityAvailable());

                System.out.println("===========================");
                System.out.println("Paramtres du ResourcePool:");
                System.out.println("===========================");
                System.out.println("Available CPU: " + rscPool.getAvailableCPU());
                System.out.println("Available Memory: " + rscPool.getAvailableMemory());

                System.out.println("CPU:");
                System.out.println("- Rservation: " + rscPool.getCPUReservation());
                System.out.println("- Rservation Max: " + rscPool.getCPUMaxReservation());
                System.out.println("- Limite: " + rscPool.getCPULimit());
                System.out.println("- Limite Max: " + rscPool.getCPUMaxLimit());

                System.out.println("Memory:");
                System.out.println("- Rservation: " + rscPool.getMemReservation());
                System.out.println("- Rservation Max: " + rscPool.getMemMaxReservation());
                System.out.println("- Limite: " + rscPool.getMemLimit());
                System.out.println("- Limite Max: " + rscPool.getMemMaxLimit());

            }
        }

        //

        //parentName=(String)MorManager.getMorProperty(ws.getVIMService(),parent, new String[] {"name"});

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void printResourcePool(ResourcePool resourcePool) {
        System.out.println("============================================");
        System.out
                .println("- Resource Pool: " + resourcePool.getName() + " / " + resourcePool.getMor().get_value());
        System.out.println("============================================");
        System.out.println("- Parent: " + resourcePool.getParent().getName() + " / "
                + resourcePool.getParent().getMor().getType() + " / "
                + resourcePool.getParent().getMor().get_value());
        System.out.println("\n- CPU Allocation:");
        System.out.println(
                "   - Expandable Reservation: " + resourcePool.getCpuAllocation().getExpandableReservation());
        System.out.println("   - Limit(MHz): " + resourcePool.getCpuAllocation().getLimit());
        System.out.println("   - Reservation(MHz): " + resourcePool.getCpuAllocation().getReservation());
        System.out.println("   - Mghz: " + resourcePool.getCpuAllocation().getMghz());

        System.out.println("\n- Memory Allocation:");
        System.out.println(
                "   - Expandable Reservation: " + resourcePool.getMemoryAllocation().getExpandableReservation());
        System.out.println("   - Limit(MHz): " + resourcePool.getMemoryAllocation().getLimit());
        System.out.println("   - Reservation(MHz): " + resourcePool.getMemoryAllocation().getReservation());
        System.out.println("   - MB: " + resourcePool.getMemoryAllocation().getMb());

        System.out.println("\n- Runtime resource usage for CPU:");
        System.out.println("   - Max Usage: " + resourcePool.getRunTimeCpuUsage().getMaxUsage());
        System.out.println("   - Overall Usage: " + resourcePool.getRunTimeCpuUsage().getOverallUsage());
        System.out.println("   - Reservation Used: " + resourcePool.getRunTimeCpuUsage().getReservationUsed());
        System.out.println(
                "   - Reservation Used for VM: " + resourcePool.getRunTimeCpuUsage().getReservationUsedForVm());
        System.out.println("   - Unreserved For Pool: " + resourcePool.getRunTimeCpuUsage().getUnreservedForPool());
        System.out.println("   - Unreserved For Vm: " + resourcePool.getRunTimeCpuUsage().getUnreservedForVm());

        System.out.println("\n- Runtime resource usage for Memory:");
        System.out.println("   - Max Usage: " + resourcePool.getRunTimeMemoryUsage().getMaxUsage());
        System.out.println("   - Overall Usage: " + resourcePool.getRunTimeMemoryUsage().getOverallUsage());
        System.out.println("   - Reservation Used: " + resourcePool.getRunTimeMemoryUsage().getReservationUsed());
        System.out.println(
                "   - Reservation Used for VM: " + resourcePool.getRunTimeMemoryUsage().getReservationUsedForVm());
        System.out.println(
                "   - Unreserved For Pool: " + resourcePool.getRunTimeMemoryUsage().getUnreservedForPool());
        System.out.println("   - Unreserved For Vm: " + resourcePool.getRunTimeMemoryUsage().getUnreservedForVm());

    }

    public void getHostResourcesAllocation() throws VMwareException {
        // =========================================================================================
        // Connexion au VC
        // =========================================================================================
        //String hostName="10.62.16.35";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        // =========================================================================================
        // Display Host resource 
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        ArrayList<Host> listOfHosts = hostManager.getAllHosts(hostName);
        //Host host=hostManager.getHostByName("siveo-esx4.siveo.net", hostName);

        if (listOfHosts != null) {
            for (Host host : listOfHosts) {
                System.out.println("compute Resource Class: " + host.getComputeResource().getClass());

                System.out.println("");
                System.out.println("");

                System.out.println("Total VM CPU Used: " + host.getTotalVMUsedCpu());
                System.out.println("Total VM Memory Used: " + host.getTotalVmMemory());

                System.out.println("");
                System.out.println("***************** HOST " + host.getName() + " ****************");
                System.out.println("");
                System.out.println("Configuration: ");
                System.out.println("-CPU: ");
                System.out.println(" -Hz: " + host.getCPU().getHz());
                System.out.println(" -Nb CPU Packages: " + host.getCPU().getNumCpuPackages());
                System.out.println(" -Nb CPU Cores: " + host.getCPU().getNumCpuCores());
                System.out.println(" -Nb CPU Threads: " + host.getCPU().getNumCpuThreads());
                System.out.println(" -Total Hz: " + host.getCPU().getTotalHz());

                System.out.println("-Memory: ");
                System.out.println(" -Total: " + host.getMemory().getMemorySize());
                if (host.getMemory().getConsoleReservationInfo() != null)
                    System.out.println(" -Console: "
                            + host.getMemory().getConsoleReservationInfo().getServiceConsoleReserved());
                if (host.getMemory().getVirtualMachineReservationInfo() != null)
                    System.out.println(" -VM: "
                            + host.getMemory().getVirtualMachineReservationInfo().getVirtualMachineReserved());

                System.out.println("Capacity: ");
                System.out.println("-CPU:");
                System.out.println(" -Capcity: " + host.getCPUCapacity());
                System.out.println(" -Max Usage: " + host.getResourcePool().getRunTimeCpuUsage().getMaxUsage());
                System.out.println(
                        " -Overal Usage: " + host.getResourcePool().getRunTimeCpuUsage().getOverallUsage());
                System.out.println(
                        " -Reservation Used: " + host.getResourcePool().getRunTimeCpuUsage().getReservationUsed());
                System.out.println(" -Reservation Used For Vm: "
                        + host.getResourcePool().getRunTimeCpuUsage().getReservationUsedForVm());
                System.out.println(" -Unreserved For Pool: "
                        + host.getResourcePool().getRunTimeCpuUsage().getUnreservedForPool());
                System.out.println(
                        " -Unreserved For VM: " + host.getResourcePool().getRunTimeCpuUsage().getUnreservedForVm());

                System.out.println("-Memory:");
                System.out.println(" -Capcity: " + host.getMemoryCapacity());
                System.out.println(" -Max Usage: " + host.getResourcePool().getRunTimeMemoryUsage().getMaxUsage());
                System.out.println(
                        " -Overal Usage: " + host.getResourcePool().getRunTimeMemoryUsage().getOverallUsage());
                System.out.println(" -Reservation Used: "
                        + host.getResourcePool().getRunTimeMemoryUsage().getReservationUsed());
                System.out.println(" -Reservation Used For Vm: "
                        + host.getResourcePool().getRunTimeMemoryUsage().getReservationUsedForVm());
                System.out.println(" -Unreserved For Pool: "
                        + host.getResourcePool().getRunTimeMemoryUsage().getUnreservedForPool());
                System.out.println(" -Unreserved For VM: "
                        + host.getResourcePool().getRunTimeMemoryUsage().getUnreservedForVm());

                System.out.println("");
                System.out.println("***************** COMPUTE RESOURCE *****************");

                System.out
                        .println("Compute Resource Effective CPU: " + host.getComputeResource().getEffectiveCpu());
                System.out.println(
                        "Compute Resource Effective Memory: " + host.getComputeResource().getEffectiveMemory());
                System.out
                        .println("Compute Resource Available CPU: " + host.getComputeResource().getAvailableCPU());
                System.out.println(
                        "Compute Resource Available Memory: " + host.getComputeResource().getAvailableMemory());
                System.out.println("Compute Resource Total CPU: " + host.getComputeResource().getTotalCpu());
                System.out.println("Compute Resource Total Memory: " + host.getComputeResource().getTotalMemory());

                System.out.println("");

                System.out.println("");
                System.out.println("***************** ROOT RESOURCE POOL *****************");
                System.out.println("Name: " + host.getResourcePool().getName());
                System.out
                        .println("CPU Reservation: " + host.getResourcePool().getCpuAllocation().getReservation());
                System.out.println("CPU Limit: " + host.getResourcePool().getCpuAllocation().getLimit());
                System.out.println(
                        "Memory Reservation: " + host.getResourcePool().getMemoryAllocation().getReservation());
                System.out.println("Memory Limit: " + host.getResourcePool().getMemoryAllocation().getLimit());

                System.out.println(
                        "-Total ResourcePool CPU Used: " + host.getResourcePool().getTotalResourcePoolUsedCpu());
                System.out.println(
                        "-Total ResourcePool Memory Used: " + host.getResourcePool().getTotalResourceUsedMemory());
                System.out.println("-Total VM CPU Used: " + host.getResourcePool().getTotalVMUsedCpu());
                System.out.println("-Total VM Memory Used: " + host.getResourcePool().getTotalVMUsedMemory());

                //System.out.println("-Total ResourcePool CPU Used: "+resourcePool.getTotalResourcePoolUsedCpu());
                //System.out.println("-Total ResourcePool Memory Used: "+resourcePool.getTotalResourceUsedMemory());
                //System.out.println("-Total VM CPU Used: "+resourcePool.getTotalVMUsedCpu());
                //System.out.println("-Total VM Memory Used: "+resourcePool.getTotalVMUsedMemory());

                System.out.println("Available Cpu: " + host.getResourcePool().getAvailableCPU());
                System.out.println("Available Memory:: " + host.getResourcePool().getAvailableMemory());
                System.out.println(
                        "Available ComputeResourceMemory: " + host.getComputeResource().getAvailableMemory());

                System.out.println("");

                //            System.out.println("");
                //            System.out.println("***************** RESOURCE POOL *****************");
                //            ResourcePoolManager resourcePoolManager=ResourcePoolManager.getInstance();
                //            ResourcePool resourcePool=resourcePoolManager.getResourcePoolByName(hostName, "Project_B");
                //            
                //            System.out.println("Available CPU: "+resourcePool.getAvailableCPU());
                //            System.out.println("CPU Allocation Mghz: "+resourcePool.getCpuAllocation().getMghz());
                //            System.out.println("Available Memory: "+resourcePool.getAvailableMemory());

                System.out.println("");

            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void retrieveAllInventoryElementsPropertiesEx() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = null;

        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="10.62.16.34";
        //ws=wsManager.createVIM(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "192.168.101.58";
        ws = wsManager.createVIM(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        System.out.println("VMware API Version: " + ws.getAPIVersion());

        // =========================================================================================
        // ON ESX
        // =========================================================================================
        // Host
        // VM
        // ResourcePool

        // =========================================================================================
        // Retrieve the properties
        // =========================================================================================

        ArrayList<Mor> listOfMors = new ArrayList<Mor>();
        Mor morEx = null;
        ArrayList<String> listOfProperties = null;
        TreeNode node = null;
        Date dtCrea1 = null;
        Date dtCrea2 = null;

        ArrayList<String> commonProperties = new ArrayList<String>(Arrays.asList("permission", "name"));
        ArrayList<String> folderProperties = new ArrayList<String>(Arrays.asList("childEntity", "parent"));
        ArrayList<String> hostProperties = new ArrayList<String>(Arrays.asList("vm", "datastore", "network"));
        ArrayList<String> resourcePoolProperties = new ArrayList<String>(Arrays.asList("resourcePool", "vm"));

        // ----------------------------------------------------------
        // Stored Typed list for each Objects   
        // ----------------------------------------------------------
        ArrayList<ManagedObjectReference> listOfFolders = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfDatacenters = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfClusterComputeResources = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfComputeResources = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfResourcePools = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfHostSystems = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfDatastores = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfVirtualMachines = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfDistributedVirtualSwitches = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfDistributedVirtualPortgroups = new ArrayList<ManagedObjectReference>();
        ArrayList<ManagedObjectReference> listOfNetworks = new ArrayList<ManagedObjectReference>();

        ArrayList<ManagedObjectReference> listOfVirtualApps = new ArrayList<ManagedObjectReference>();

        List<ObjectContent> listOfObjectContents = null;

        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = null;
        ViewManager viewManager = null;

        viewManager = ViewManager.getInstance();
        Date dt01 = new Date();
        listOfManagedObjectReferences = viewManager.getContainerView(ws.getHostName());
        Date dt02 = new Date();

        System.out.println("View Manager: getContainerView: " + (dt02.getTime() - dt01.getTime()));

        if (listOfManagedObjectReferences != null && !listOfManagedObjectReferences.isEmpty()) {
            dtCrea1 = new Date();

            for (ManagedObjectReference mor : listOfManagedObjectReferences) {
                listOfProperties = new ArrayList<String>(commonProperties);
                //listOfProperties=new ArrayList<String>();

                if (mor.getType().equals("Folder")) {
                    node = new Folder(ws, mor);
                    listOfFolders.add(mor);
                    listOfProperties.addAll(folderProperties);
                } else if (mor.getType().equals("Datacenter")) {
                    node = new Datacenter(ws, mor);
                    listOfDatacenters.add(mor);
                    //listOfProperties.addAll(this.dataCenterProperties);

                } else if (mor.getType().equals("ClusterComputeResource")) {
                    node = new ClusterComputeResource(ws, mor);
                    listOfClusterComputeResources.add(mor);
                } else if (mor.getType().equals("ComputeResource")) {
                    node = new ComputeResource(ws, mor);
                    listOfComputeResources.add(mor);
                } else if (mor.getType().equals("ResourcePool")) {
                    node = new ResourcePool(ws, mor);
                    listOfResourcePools.add(mor);
                    listOfProperties.addAll(resourcePoolProperties);
                } else if (mor.getType().equals("HostSystem")) {
                    node = new Host(ws, mor);
                    listOfHostSystems.add(mor);
                    listOfProperties.addAll(hostProperties);

                } else if (mor.getType().equals("Datastore")) {
                    node = new Datastore(ws, mor);
                    listOfDatastores.add(mor);
                } else if (mor.getType().equals("Network")) {
                    node = new Network(ws, mor);
                    listOfNetworks.add(mor);

                } else if (mor.getType().equals("VirtualMachine")) {
                    node = new VirtualMachine(ws, mor);
                    listOfVirtualMachines.add(mor);
                } else if (mor.getType().equals("VirtualApp")) {
                    node = new VirtualApp(ws, mor);
                    listOfVirtualApps.add(mor);
                    //this.virtualApps.add((VirtualApp)node);
                } else if (mor.getType().equals("DistributedVirtualSwitch")) {
                    node = new DVSwitch(ws, mor);
                    listOfDistributedVirtualSwitches.add(mor);
                } else if (mor.getType().equals("VmwareDistributedVirtualSwitch")) {
                    node = new DVSwitch(ws, mor);
                    listOfDistributedVirtualSwitches.add(mor);
                } else if (mor.getType().equals("DistributedVirtualPortgroup")) {
                    node = new DVPortGroup(ws, mor);
                    listOfDistributedVirtualPortgroups.add(mor);
                }

                //
                morEx = new Mor();
                morEx.setManagedObjectReference(node.getMor());

                morEx.setProperties(listOfProperties.toArray(new String[listOfProperties.size()]));
                listOfMors.add(morEx);

            }

            //
            dtCrea2 = new Date();

        }

        //**************
        //      morEx=new Mor();
        //      morEx.setManagedObjectReference(this.getRootNode().getMor());
        //      morEx.setProperties(new String[] {"permission","name"});
        //      listOfMors.add(morEx);

        Date dtMorsAllProp1 = new Date();
        listOfObjectContents = MorManager.getPropertiesInHashEx1(ws, listOfMors);
        Date dtMorsAllProp2 = new Date();

        System.out.println("Temps Creation all Objects: " + (dtCrea2.getTime() - dtCrea1.getTime()));
        System.out.println(
                "Temps Recup Objects Properties: " + (dtMorsAllProp2.getTime() - dtMorsAllProp1.getTime()));
        System.out.println("Nb ObjectContents: " + listOfObjectContents.size());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        //      ws.getVIMService().logout();
        //      wsManager.deleteWS(ws);

        VMware.delete(hostName);

    }

    public void loadInventoryEx() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Get the Inventory Root Node
        // =========================================================================================

        //System.out.println("Build Inventory in: "+(dt2.getTime()-dt1.getTime()));

        Inventory inventory = new Inventory(hostName);
        inventory.browseEx();
        TreeNode rootNode = inventory.getRootNode();

        System.out.println("RootNode: " + rootNode);
        System.out.println("");

        // =========================================================================================
        // 
        // =========================================================================================
        //FolderManagerEx folderManagerEx=FolderManagerEx.getInstance();
        //FolderEx folder= folderManagerEx.getFolderByID("group-v166", hostName);

        //System.out.println("folder: "+folder);

        //folderManagerEx.createFolder(folder, "chris");

        //rootNode=inventoryEx.getRootNode();
        //System.out.println("RootNode: "+rootNode);

        // =========================================================================================
        // 
        // =========================================================================================
        ManagedObjectReference managedObjectReference = new ManagedObjectReference();
        //managedObjectReference.set_value("group-d21");
        managedObjectReference.set_value("group-h81");
        managedObjectReference.setType("Folder");

        /*
            
        DynamicProperty[] arrayOfDynamicProperties=MorManager.getProperties(ws, managedObjectReference, new String[] {"childEntity","childType"});
            
            
        if (arrayOfDynamicProperties!=null && arrayOfDynamicProperties.length>0)
        {
           for (DynamicProperty property:arrayOfDynamicProperties)
           {
        System.out.println("- Name: "+property.getName());
        if (property.getName().equals("childEntity"))
        {
           ArrayOfManagedObjectReference arrayOfChildType=(ArrayOfManagedObjectReference)property.getVal();
               
           if (arrayOfChildType!=null && arrayOfChildType.getManagedObjectReference().length>0)
           {
              System.out.println("- Value: ");
              String name=null;
                  
              for (ManagedObjectReference morChild:arrayOfChildType.getManagedObjectReference())
              {
                 name=((String)MorManager.getMorProperty(ws, morChild,new String[]{"name"}));
                 System.out.println("  - Name: "+name);
                 System.out.println("  - Type: "+morChild.getType());
                 System.out.println("  - Value: "+morChild.get_value());
              }
                  
                  
           }
        }
            
            
            
        if (property.getName().equals("childType"))
        {
           ArrayOfString arrayOfChildType=(ArrayOfString)property.getVal();
           if (arrayOfChildType!=null && arrayOfChildType.getString().length>0)
           {
              System.out.println("- Value: ");
            
              for (String childType:arrayOfChildType.getString())
              {
                 System.out.println("  - "+childType);
              }
                  
                  
           }
        }
           }
        }
            
        */

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        //      ws.getVIMService().logout();
        //      wsManager.deleteWS(ws);

        VMware.delete(hostName);

    }

    /*   
       public void getESXfromVM(String vmName) throws VMwareException 
       {
     VMware vmware=new VMware();
     WSManager wsManager=WSManager.getInstance();
         
     VMManager vmManager=VMManager.getInstance();
     VirtualMachine vm=vmManager.getVmByName(vmName);
     System.out.println("VM: "+vmName);
     System.out.println(" - Host: "+vm.getHost_().getName());
     wsManager.deleteVIM();
       }
        
           
       public void testUser() throws VMwareException
       {
     WSManager wsManager=WSManager.getInstance();
     WS ws=null;
     try
     {
        //ws = wsManager.createVIM("vpshere-4-1", 443, "Administrateur", "Gd@jJ2009$", null, false, 480000);
        //ws = wsManager.createVIM("vpshere-4-1", 443, "christophe", "christophe", null, false, 480000);
        ws = wsManager.createVIM("vsphere-4-0-1", 443, "actidev1", "P@ssw0rd", null, false, 480000);
     }
     catch (VMwareException e)
     {
        // TODO Auto-generated catch block
        e.printStackTrace();
     }
        
     ManagedObjectReference mor=MorManager.getMorRef(ws, null, "VirtualMachine", "ActiBox05");
     ManagedObject managedObject=new ManagedObject(ws, mor);
     VMManager vmManager=VMManager.getInstance();
     vmManager.addVM(ws, mor);
     VirtualMachine vm=vmManager.getVmByMor(mor);
     vm.powerOn();
         
         
       }
    */

    /*
       public void test() throws VMwareException
       {
     WSManager wsManager=WSManager.getInstance();
     WS ws=null;
     try
     {
        ws = wsManager.createVIM("vpshere-4-1", 443, "Administrateur", "Gd@jJ2009$", null, false, 480000);
     }
     catch (VMwareException e)
     {
        // TODO Auto-generated catch block
        e.printStackTrace();
     }
        
     System.out.println("ws: "+ws);
     System.out.println("ws: "+ws.getHostName());
         
        
         
     ArrayList<Host> hostList=null;
     Host host=null;
     InventoryManager inventoryManager=InventoryManager.getInstance();
         
     hostList=inventoryManager.getHost(ws.getHostName());
     HostManager hostManager=HostManager.getInstance();
        
     System.out.println("hostList: "+hostList);
         
     for (int nbHost=0;nbHost<hostList.size();nbHost++)
     {
        host=hostList.get(nbHost);
        System.out.println("\nHost n"+nbHost);
        System.out.println("name:"+host.getName());
        System.out.println("type"+host.getType());
        //System.out.println("\nHost n"+nbHost);
        //System.out.println("name:"+mngObj.getName());
        //System.out.println("type"+mngObj.getType());
        //System.out.println("value"+mngObj.getValue());
        //MorManager.addHost(ws, mngObj);
        hostManager.putHost(host);
     }
        
     host=hostManager.getHost("esx01.siveo.net");
     System.out.println("host: "+host.getMorRef());
        
     wsManager.deleteWS(ws);
         
       }
    */

    public void getHostResourceAllocation() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        // =========================================================================================
        // Get Host Resource
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        ArrayList<Host> listOfHosts = hostManager.getAllHosts(hostName);

        if (listOfHosts != null) {
            for (Host host : listOfHosts) {
                System.out.println("- Host:");
                System.out.println("  - Name: " + host.getName());
                System.out.println("  - ID: " + host.getMor().get_value());
                System.out.println("  - Memory Available: " + host.getResourcePool().getMemCapacityAvailable());
                System.out.println("");
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================

        VMware.delete(hostName);

    }

    public void moveVMIntoFolder() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Movin
        // =========================================================================================
        ArrayList<VirtualMachine> listOfVM = new ArrayList<VirtualMachine>();

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "dev.siveo.net");
        listOfVM.add(vm);

        FolderManager folderManager = FolderManager.getInstance();
        Folder folder = folderManager.getFolderByID("group-v329", hostName);

        vmManager.moveIntoFolder(folder, listOfVM, "1234");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void multiTask() throws VMwareException {
        // =========================================================================================
        // Creation du folder
        // =========================================================================================
        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L, 1 * 10000);

        // --------------------------------------------------------------
        // Creation du folder
        // --------------------------------------------------------------
        // F1 dans essai
        FolderManager folderManager = FolderManager.getInstance();
        Folder folder = folderManager.getFolderByID("group-v5830", hostName);

        Folder newFolder = folderManager.createFolder(folder, "D11");

        try {
            Thread.sleep(4 * 1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // --------------------------------------------------------------
        // Dplacement du folder
        // --------------------------------------------------------------
        folder = folderManager.getFolderByID("group-v2921", hostName);
        folderManager.moveFolder(newFolder, folder, "1234");

        try {
            Thread.sleep(4 * 1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // --------------------------------------------------------------
        // Renommage du folder
        // --------------------------------------------------------------
        folderManager.renameFolder(newFolder, "D12", "1234");

        try {
            Thread.sleep(60 * 1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // --------------------------------------------------------------
        // Destruction du folder
        // --------------------------------------------------------------
        folderManager.deleteFolder(newFolder, "1234");

        try {
            Thread.sleep(4 * 1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("Waiting....");
        try {
            System.in.read();
        } catch (IOException e)

        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // move dans Test-Siveo
        //  Renome
        // kill

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void createFolder() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@0",false,-1L);

        String hostName = "10.62.16.35";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Create
        // =========================================================================================
        DatacenterManager datacenterManager = DatacenterManager.getInstance();
        Datacenter datacenter = datacenterManager.getDatacenterByName("ha-datacenter", hostName);

        //datacenter.getv

        FolderManager folderManager = FolderManager.getInstance();
        Folder folder = folderManager.getFolderByName("VM Folder 1", hostName);

        folderManager.createFolder(datacenter.getVmFolder(), "VM Folder Test");

        System.out.println("Press a key to continue");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void deleteFolder() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Delete
        // =========================================================================================
        FolderManager folderManager = FolderManager.getInstance();
        Folder folder = folderManager.getFolderByName("tutu", hostName);

        folderManager.deleteFolder(folder);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void moveFolder() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Move
        // =========================================================================================
        FolderManager folderManager = FolderManager.getInstance();
        Folder sourceFolder = folderManager.getFolderByID("group-v329", hostName);

        Folder destinationFolder = folderManager.getFolderByID("group-v333", hostName);

        folderManager.moveFolder(sourceFolder, destinationFolder);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void renameFolder() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // Rename
        // =========================================================================================
        FolderManager folderManager = FolderManager.getInstance();
        Folder folder = folderManager.getFolderByID("group-v5915", hostName);

        folderManager.renameFolder(folder, "toto");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void testVMwareTools() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VJTH-TEST-11");

        String toolsStatus = (String) MorManager.getMorProperty(vm.getWS(), vm.getMor(),
                new String[] { "guest.toolsRunningStatus" });

        System.out.println("toolstatus: " + toolsStatus);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVMGuestInfo(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = null;
        vm = vmManager.getVmByName(hostName, vmName);

        System.out.println("************** " + vmName + " Detailled Configuration **************");
        System.out.println("- Template: " + vm.isTemplate());
        System.out.println("- Guest Information");
        System.out.println("  - Host Name: " + vm.getGuest().getHostName());
        System.out.println("  - IP       : " + vm.getGuest().getIpAddress());
        System.out.println("  - OS");
        System.out.println("    - Family   : " + vm.getGuest().getOSFamily());
        System.out.println("    - Full Name: " + vm.getGuest().getOSFullName());
        System.out.println("    - ID       : " + vm.getGuest().getOSId());
        System.out.println("    - State    : " + vm.getGuest().getGuestState());
        System.out.println("");
        System.out.println("  - VMware Tools");
        System.out.println("    - Status        : " + vm.getGuest().getToolsStatus());
        System.out.println("    - Running Status: " + vm.getGuest().getToolsRunningStatus());
        System.out.println("    - Version       : " + vm.getGuest().getToolsVersion());
        System.out.println("    - Version Status: " + vm.getGuest().getToolsVersionStatus());
        System.out.println("\n  - Disk");
        if (!vm.getGuest().getDisk().isEmpty()) {
            int nbGuestDisk = 1;
            for (GuestDisk guestDisk : vm.getGuest().getDisk()) {
                System.out.println("    - Disk n" + nbGuestDisk++);
                System.out.println("      - Capacit    : " + guestDisk.getCapacity());
                System.out.println("      - Taille libre: " + guestDisk.getFreeSpace());
                System.out.println("      - Label       : " + guestDisk.getDiskPath());
            }
        }
        System.out.println("\n  - Network Adapter Info");
        if (!vm.getGuest().getListOfNetworkAdapter().isEmpty()) {
            //GuestInfo guestInfo_=vmConfiguration.getGuestInfo().getGuestInfoo();
            //System.out.println("IPSTACK: "+guestInfo_);
            //System.out.println("IPSTACK: "+guestInfo_.getIpStack());

            int nbGuestnicInfo = 1;
            for (GuestNic guestNic : vm.getGuest().getListOfNetworkAdapter()) {
                System.out.println("    - Network Adapter n" + nbGuestnicInfo++);
                System.out.println("      - Connected: " + guestNic.isConnected());
                System.out.println("      - DeviceConfig Id: " + guestNic.getDeviceConfigId());
                System.out.println("      - Network: " + guestNic.getNetwork());
                System.out.println("      - Network ID: " + guestNic.getNetworkID());
                if (!guestNic.getListOfIPAddress().isEmpty()) {
                    System.out.println("      - IP Address:");

                    for (String ip : guestNic.getListOfIPAddress()) {
                        System.out.println("        - " + ip);
                    }

                }
                System.out.println("      - Mac Address: " + guestNic.getMacAddress());
                if (guestNic.getDnsConfig() != null) {
                    System.out.println("      - DNS Config:");
                    System.out.println("        - Dhcp: " + guestNic.getDnsConfig().isDhcp());
                    System.out.println("        - Domain Name: " + guestNic.getDnsConfig().getDomainName());
                    System.out.println("        - Host Name: " + guestNic.getDnsConfig().getHostName());
                    System.out.println("        - Ip Address:");
                    if (!guestNic.getDnsConfig().getIpAddress().isEmpty()) {
                        for (String ipAddress : guestNic.getDnsConfig().getIpAddress()) {
                            System.out.println("          - " + ipAddress);
                        }
                    }
                    System.out.println("        - Search Domain:");
                    if (!guestNic.getDnsConfig().getSearchDomain().isEmpty()) {
                        for (String searchDomain : guestNic.getDnsConfig().getSearchDomain()) {
                            System.out.println("          - " + searchDomain);
                        }
                    }

                    System.out.println("");

                }

                if (guestNic.getIpConfig() != null) {
                    System.out.println("      - IP Config:");
                    System.out.println("        - autoConfigurationEnabled: "
                            + guestNic.getIpConfig().isAutoConfigurationEnabled());
                }

            }
        }

        System.out.println("");
        System.out.println("");

        if (vm.getGuest().getGuestInfo().getIpStack() != null
                && vm.getGuest().getGuestInfo().getIpStack().length > 0) {
            System.out.println("IP Stack");

        }

        if (vm.getGuest().getGuestInfo().getNet() != null && vm.getGuest().getGuestInfo().getNet().length > 0) {
            System.out.println("Netbios: " + vm.getGuest().getGuestInfo().getNet()[0].getNetBIOSConfig());
            //vm.getGuest().getGuestInfo().getNet()[0].getNetBIOSConfig()
            //System.out.println("IP Stack");

        }

        System.out.println("");
        System.out.println("");
        System.out.println("");

        //VirtualDevice[] listOfVirtualDevice=vm.getVirtualDeviceManager().getAllVirtualDevices();
        VirtualDevice[] listOfVirtualDevice = vm.getVirtualDeviceManager().getListOfVirtualDevices();
        int nbDevice = 1;
        VirtualEthernetCard virtualEthernetCard = null;
        VirtualController virtualController = null;

        for (VirtualDevice device : listOfVirtualDevice) {
            System.out.println("Device n" + nbDevice++);
            System.out.println("- Device: " + device);
            System.out.println("- Device Class: " + device.getClass());
            System.out.println("- Device Super Class: " + device.getClass().getSuperclass());
            System.out.println("- Key    : " + device.getKey());
            System.out.println("- ControllerKey: " + device.getControllerKey());
            System.out.println("- Label  : " + device.getDeviceInfo().getLabel());
            System.out.println("- Summary: " + device.getDeviceInfo().getSummary());
            System.out.println("- Unit Number: " + device.getUnitNumber());

            if (device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualEthernetCard.class)
                    || device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualVmxnet.class)) {
                virtualEthernetCard = (VirtualEthernetCard) device;
                System.out.println("- virtualEthernetCard Class: " + virtualEthernetCard.getClass());
                System.out.println("  - AddressType: " + virtualEthernetCard.getAddressType());
                System.out.println("  - MacAddress: " + virtualEthernetCard.getMacAddress());
                System.out.println("  - WakeOnLanEnabled: " + virtualEthernetCard.getWakeOnLanEnabled());
                System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());

                if (virtualEthernetCard
                        .getBacking() instanceof com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo) {
                    VirtualEthernetCardNetworkBackingInfo virtualEthernetCardNetworkBackingInfo = (VirtualEthernetCardNetworkBackingInfo) virtualEthernetCard
                            .getBacking();
                    System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());
                    System.out
                            .println("    - Device Name: " + virtualEthernetCardNetworkBackingInfo.getDeviceName());
                    System.out.println(
                            "    - Use AutoDetect: " + virtualEthernetCardNetworkBackingInfo.getUseAutoDetect());
                    System.out.println(
                            "    - inPassthroughMode: " + virtualEthernetCardNetworkBackingInfo.inPassthroughMode);
                    System.out.println(
                            "    - Network: " + virtualEthernetCardNetworkBackingInfo.getNetwork().get_value());

                }

                if (virtualEthernetCard.getBacking().getClass()
                        .equals(com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo.class)) {
                    VirtualEthernetCardDistributedVirtualPortBackingInfo backing = (VirtualEthernetCardDistributedVirtualPortBackingInfo) virtualEthernetCard
                            .getBacking();
                    System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());
                    System.out.println("    - PortgroupKey: " + backing.getPort().getPortgroupKey());
                    System.out.println("    - PortKey: " + backing.getPort().getPortKey());
                    System.out.println("    - SwitchUuid: " + backing.getPort().getSwitchUuid());
                }
                //

            }

            if (device.getConnectable() != null) {
                System.out.println("- allowGuestControl: " + device.getConnectable().isAllowGuestControl());
                System.out.println("- connected: " + device.getConnectable().isConnected());
                System.out.println("- startConnected: " + device.getConnectable().isStartConnected());
                if (device.getConnectable().getStatus() != null)
                    System.out.println("- status: " + device.getConnectable().getStatus());

            }

            if (device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualController.class)) {
                virtualController = (VirtualController) device;
                if (virtualController.getDevice() != null && virtualController.getDevice().length > 0) {
                    String devicesControlled = "- Devices Controlled: ";
                    String keys = "";
                    for (int deviceKey : virtualController.getDevice()) {
                        keys = deviceKey + "," + keys;
                    }

                    keys = keys.substring(0, keys.length() - 1);
                    System.out.println(devicesControlled + keys);
                }
            }

        }

        //System.out.println("Taille disk: "+vm.getHardware().getTotalDiskSpace());

        /*
        WS ws=wsManager.getWS(vmWareHostName);
        ManagedObjectReference mor=null;
        mor=MorManager.getMorRef(ws, ws.getVIMService().getRootFolder(), "VirtualMachine", "ActiBox05");
            
        System.out.println("mor: "+mor.get_value());
            
        ArrayList<VirtualMachine> listOfVM=inventoryMng.getAllVM(vmWareHostName);
        for (VirtualMachine vm_:listOfVM)
        {
           System.out.println("vm: "+vm_.getName()+" / "+vm_.getMor().get_value());
        }
        */

        /*
        vm=vmManager.getVmByName(vmWareHostName, "ActiBox05");
        System.out.println("VirtualMachine: "+vm.getName());
        System.out.println("-CPU Reservation: "+vm.getConfiguration().getVirtualCPU().getReservation());
        System.out.println("-CPU Limit: "+vm.getConfiguration().getVirtualCPU().getLimit());
        System.out.println("-CPU: "+vm.getConfiguration().getVirtualCPU().getMghz());
            
        System.out.println("-Memory Reservation: "+vm.getConfiguration().getVirtualMemory().getReservation());
        System.out.println("-Memory Limit: "+vm.getConfiguration().getVirtualMemory().getLimit());
        System.out.println("-Memory: "+vm.getConfiguration().getVirtualMemory().getMemorySize());
        */

        //Host host=vm.getHost();
        //System.out.println("Host Name: "+host.getName());
        //vm.getHardware().getAlldevices();

        //vmManager.configureVMMemory("ActiBox05", 256L);

        //vm.replaceNetwork("network-14");
        //vm.addNetwork("network-14");
        //vm.removeNetwork("network-14");
        //vmManager.updateNetwork("ActiBox05", "networkID");

        //vm.setNetwork();

        /*
        ArrayList<Network> listOfNetwork=host.getNetworks();
            
        for (Network network:listOfNetwork)
        {
           System.out.println("Network Name: "+network.getName());
           System.out.println("Network ID: "+network.getMor().get_value());
        }
        */

        //HardwareDevice hardware=vm.getHardware();
        //ArrayList<VirtualNetwork> listOfVirtualNetwork=hardware.getNetworks();
        //VirtualNetwork virtualNetwork=listOfVirtualNetwork.get(0);
        //virtualNetwork.getvDevice().getBacking().

        /*
        ArrayList<Network> listOfNet=vm.getAvailableNetwork();
            
        for (Network network:listOfNet)
        {
           System.out.println("Network: "+network.getName());
        }
        */

        /*
        try
        {
           System.in.read();
        }
        catch (IOException e)
            
        {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }
         */

        //AuthorizationManager authorManager=AuthorizationManager.getInstance();
        //authorManager.addPermission("SIVEO\\TestGP", true,"test2", "VMSuperPowerUser","vcenter.siveo.net");

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void checkVMRunning(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        System.out.println("");
        System.out.println("Virtual Machine: " + vm.getName());

        String guestRunState = (String) MorManager.getMorProperty(vm.getWS(), vm.getMor(),
                new String[] { "guest.guestState" });
        String toolsStatus = (String) MorManager.getMorProperty(vm.getWS(), vm.getMor(),
                new String[] { "guest.toolsRunningStatus" });

        System.out.println("Guest Running State: " + guestRunState);
        System.out.println("Guest Tools Running State: " + toolsStatus);

        //vm.retrievePowerState();

        ////vmManager.waitForVMRunning("vm-12335", hostName, 2*60*1000,1000,"1234");
        vmManager.waitForVMRunning(vm.getMor().get_value(), hostName, 300000, 1000);

        //VirtualMachine vm=null;
        //vm=vmManager.getVmByName(hostName,vmName);
        //VMMonitor vmMonitor=new VMMonitor(vm);
        //vmMonitor.start();

        System.out.println("Appuyer sur une touche pour sortir...");

        try {
            System.in.read();
        } catch (IOException e)

        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        //vmMonitor.interrupt();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        //      ws.getVIMService().logout();
        //      wsManager.deleteWS(ws);

        VMware.delete(hostName);

    }

    public void checkInventory() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.loadInventory(hostName);
        TreeNode rootNode = inventory.getRootNode();

        System.out.println("Rootnode");

        System.out.println("Appuyer sur une touche pour sortir...");

        try {
            System.in.read();
        } catch (IOException e)

        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // 
        // =========================================================================================
        VMware.refresh(hostName);
        inventory = inventoryManager.getInventoryByVC(hostName);
        rootNode = inventory.getRootNode();

        System.out.println("Rootnode");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        //      ws.getVIMService().logout();
        //      wsManager.deleteWS(ws);

        VMware.delete(hostName);

    }

    public void getUserOrGroups() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Rcupration des utilisateurs locaux
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        ManagedObjectReference userDirectory = null;

        userDirectory = ws.getVIMService().getServiceContent().getUserDirectory();
        ArrayOfString arrayOfString = null;
        String[] domainList = null;

        arrayOfString = (ArrayOfString) MorManager.getMorProperty(ws, userDirectory, new String[] { "domainList" });

        if (arrayOfString != null && arrayOfString.getString() != null && arrayOfString.getString().length > 0) {
            System.out.println("Domain list:");

            for (String domain : arrayOfString.getString()) {
                System.out.println("" + domain);
            }
        }

        String domain = null;
        String searchStr = "";
        String belongsToGroup = null;
        String belongsToUser = null;
        boolean exactMatch = false;
        boolean findUsers = true;
        boolean findGroups = true;

        UserSearchResult[] arrayOfuserSearchResult = null;

        try {
            arrayOfuserSearchResult = ws.getVIMService().getService().retrieveUserGroups(userDirectory, domain,
                    searchStr, belongsToGroup, belongsToUser, exactMatch, findUsers, findGroups);

            if (arrayOfuserSearchResult != null && arrayOfuserSearchResult.length > 0) {
                System.out.println("");
                System.out.println("");

                for (UserSearchResult userSearchResult : arrayOfuserSearchResult) {
                    System.out.println("-Principal: " + userSearchResult.getPrincipal());
                    System.out.println("-Group: " + userSearchResult.isGroup());
                    System.out.println("-FullName: " + userSearchResult.getFullName());
                    System.out.println("");
                }
            }

        } catch (NotFound e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // List Users and Groups Locals
        // =========================================================================================

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        //      ws.getVIMService().logout();
        //      wsManager.deleteWS(ws);

        VMware.delete(hostName);

    }

    public void getDVSwitchInfo() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        DVSwitchManager dvSwitchManager = DVSwitchManager.getInstance();
        DVSwitch dvSwitch = dvSwitchManager.getDVSwitchByID("dvs-183", hostName);

        DistributedVirtualSwitchPortCriteria criteria = new DistributedVirtualSwitchPortCriteria();
        criteria.setConnected(true);
        //criteria.setActive(true);
        criteria.setUplinkPort(false);

        //ArrayOfDistributedVirtualPort  arrayOfDistributedVirtualPort=null;
        DistributedVirtualPort[] arrayOfDistributedVirtualPort = null;

        try {
            arrayOfDistributedVirtualPort = dvSwitch.getWS().getVIMService().getService()
                    .fetchDVPorts(dvSwitch.getMor(), criteria);
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        if (arrayOfDistributedVirtualPort != null)
            System.out.println("Nb Ports Connected: " + arrayOfDistributedVirtualPort.length);

        //dvSwitchManager.getDVSwitchByName(null, hostName).getListOfDVPortGroup().get(0).get

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getRootresourcePoolResources() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        ResourceManager resourceManager = ResourceManager.getInstance();
        ClusterComputeResource clusterComputeResource = resourceManager.getClusterComputeResourceByName("SIVEO",
                hostName);

        ResourcePool resourcePool = clusterComputeResource.getRootResourcePool();

        System.out.println("CPU Reservation: " + resourcePool.getConfig().getCpuAllocation().getReservation());
        System.out.println("CPU Limit: " + resourcePool.getConfig().getCpuAllocation().getLimit());
        System.out.println("MEM Reservation: " + resourcePool.getConfig().getMemoryAllocation().getReservation());
        System.out.println("MEM Limit: " + resourcePool.getConfig().getMemoryAllocation().getLimit());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getDRS() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        ResourceManager resourceManager = ResourceManager.getInstance();
        ClusterComputeResource clusterComputeResource = resourceManager.getClusterComputeResourceByName("AMP",
                hostName);

        WS ws = clusterComputeResource.getWS();
        boolean drs = false;
        String automatisation = null;

        ClusterConfigInfoEx clusterConfigInfoEx = null;

        clusterConfigInfoEx = (ClusterConfigInfoEx) MorManager.getMorProperty(ws, clusterComputeResource.getMor(),
                new String[] { "configurationEx" });

        if (clusterConfigInfoEx != null) {
            drs = clusterConfigInfoEx.getDrsConfig().getEnabled();
            automatisation = clusterConfigInfoEx.getDrsConfig().getDefaultVmBehavior().name();
        }

        System.out.println("DRS enabled: " + drs);
        System.out.println("DRS Automatisation: " + automatisation);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getPerfProvider() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);
        PerfProviderSummary perfProviderSummary = null;

        HostManager hostManager = HostManager.getInstance();
        ArrayList<Host> listOfHosts = null;

        listOfHosts = hostManager.getAllHosts(hostName);

        if (listOfHosts != null && !listOfHosts.isEmpty()) {
            for (Host host : listOfHosts) {
                perfProviderSummary = performanceManager.getPerformanceProvider(host);

                if (perfProviderSummary != null) {
                    System.out.println("Host: " + host.getName() + " / " + host.getMor().get_value());
                    this.printPerfProviderSummary(perfProviderSummary);
                    System.out.println("");
                }

            }
        }

        // VirtualMachines
        ArrayList<VirtualMachine> listOfVirtualMachines = null;
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = null;

        listOfVirtualMachines = vmManager.getAllVM(hostName);

        if (listOfVirtualMachines != null && !listOfVirtualMachines.isEmpty()) {
            vm = listOfVirtualMachines.get(0);
            perfProviderSummary = performanceManager.getPerformanceProvider(vm);

            if (perfProviderSummary != null) {
                System.out.println("VirtualMachine: " + vm.getName() + " / " + vm.getMor().get_value());
                this.printPerfProviderSummary(perfProviderSummary);
                System.out.println("");
            }

        }

        // Datastore
        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        Datastore datastore = null;
        ArrayList<Datastore> listOfDatastores = dataStoreManager.getAllDatastore(hostName);

        if (listOfDatastores != null && !listOfDatastores.isEmpty()) {
            datastore = listOfDatastores.get(0);
            perfProviderSummary = performanceManager.getPerformanceProvider(datastore);

            if (perfProviderSummary != null) {
                System.out.println("Datastore: " + datastore.getName() + " / " + datastore.getMor().get_value());
                this.printPerfProviderSummary(perfProviderSummary);
                System.out.println("");
            }

        }

        // Datacenter
        DatacenterManager datacenterManager = DatacenterManager.getInstance();
        Datacenter datacenter = null;
        ArrayList<Datacenter> listOfDatacenters = datacenterManager.getAllDatacenter(hostName);

        if (listOfDatacenters != null && !listOfDatacenters.isEmpty()) {
            datacenter = listOfDatacenters.get(0);

            perfProviderSummary = performanceManager.getPerformanceProvider(datacenter);

            if (perfProviderSummary != null) {
                System.out.println("Datacenter: " + datacenter.getName() + " / " + datacenter.getMor().get_value());
                this.printPerfProviderSummary(perfProviderSummary);
                System.out.println("");
            }

        }

        // ClusterComputeResource
        ResourceManager resourceManager = ResourceManager.getInstance();
        ClusterComputeResource clusterComputeResource = null;
        ArrayList<ClusterComputeResource> listOfClusterComputeResources = resourceManager
                .getAllClusterComputeResources(hostName);

        if (listOfClusterComputeResources != null && !listOfClusterComputeResources.isEmpty()) {
            clusterComputeResource = listOfClusterComputeResources.get(0);

            perfProviderSummary = performanceManager.getPerformanceProvider(clusterComputeResource);

            if (perfProviderSummary != null) {
                System.out.println("ClusterComputeResource: " + clusterComputeResource.getName() + " / "
                        + clusterComputeResource.getMor().get_value());
                this.printPerfProviderSummary(perfProviderSummary);
                System.out.println("");
            }

        }

        // ResourcePool
        ResourcePoolManager resourcePoolManager = ResourcePoolManager.getInstance();
        ResourcePool resourcePool = resourcePoolManager.getResourcePoolByName(hostName, "ResourcePool1_1");

        if (resourcePool != null) {

            perfProviderSummary = performanceManager.getPerformanceProvider(resourcePool);

            if (perfProviderSummary != null) {
                System.out.println(
                        "ResourcePool: " + resourcePool.getName() + " / " + resourcePool.getMor().get_value());
                this.printPerfProviderSummary(perfProviderSummary);
                System.out.println("");
            }

        }

        // Network
        NetworkManager networkManager = NetworkManager.getInstance();
        Network network = null;
        ArrayList<Network> listOfNetworks = networkManager.getAllNetworks(hostName);

        if (listOfNetworks != null && !listOfNetworks.isEmpty()) {
            network = listOfNetworks.get(0);

            perfProviderSummary = performanceManager.getPerformanceProvider(network);

            if (perfProviderSummary != null) {
                System.out.println("Network: " + network.getName() + " / " + network.getMor().get_value());
                this.printPerfProviderSummary(perfProviderSummary);
                System.out.println("");
            }

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void printPerfProviderSummary(PerfProviderSummary perfProviderSummary) {
        if (perfProviderSummary != null) {
            System.out.println("-currentSupported: " + perfProviderSummary.isCurrentSupported());
            System.out.println("-summarySupported: " + perfProviderSummary.isSummarySupported());
            System.out.println("-refreshRate: " + perfProviderSummary.getRefreshRate());
        }

    }

    public void getHostPerf() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Get Host Performance
        // =========================================================================================
        // Initialize the Performance Engine
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);

        // Get the Performance Counters
        PerfMetricId[] arrayOfPerfMetricIds = null;
        PerfQuerySpec[] arrayOfPerfQuerySpecs = null;

        HostManager hostManager = HostManager.getInstance();

        HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager
                .getMapOfPerfCounterInfoByIdByVC().get(hostName);

        for (String counterName : this.getHostAllPerformanceCountersName()) {
            System.out.println("Counter: " + counterName);
        }

        //arrayOfPerfMetricIds=performanceManager.getPerfMetricFromCounters(this.getHostPerformanceCounters(this.getHostCounters()), hostName);
        arrayOfPerfMetricIds = performanceManager
                .getPerfMetricFromCounterNames(this.getHostAllPerformanceCountersName(), false, hostName);

        System.out.println("Nb Metrics: " + arrayOfPerfMetricIds.length);
        PerfCounterInfo perfCounterInfo = null;

        for (PerfMetricId perfMetricId : arrayOfPerfMetricIds) {
            if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId())) {
                perfCounterInfo = mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId());
                System.out.println("Metric: " + perfMetricId.getCounterId() + "/"
                        + perfCounterInfo.getGroupInfo().getKey() + "." + perfCounterInfo.getNameInfo().getKey()
                        + "." + perfCounterInfo.getRollupType().name());
            }
        }

        //arrayOfPerfQuerySpecs=performanceManager.getHostQueryPerfSpec(hostManager.getAllHosts(hostName), arrayOfPerfMetricIds);
        arrayOfPerfQuerySpecs = performanceManager.getHostQueryPerfSpec(hostManager.getAllHosts(hostName),
                arrayOfPerfMetricIds);

        performanceManager.getPerf1(hostName, arrayOfPerfQuerySpecs);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public ArrayList<String> getHostAllPerformanceCountersName() {
        ArrayList<String> listOfCountersName = new ArrayList<String>();

        listOfCountersName.add("clusterServices.cpufairness.latest");
        listOfCountersName.add("clusterServices.memfairness.latest");

        listOfCountersName.add("cpu.coreUtilization.average"); //
        listOfCountersName.add("cpu.idle.summation"); //
        listOfCountersName.add("cpu.totalCapacity.average"); //
        listOfCountersName.add("cpu.used.summation"); //
        listOfCountersName.add("cpu.utilization.average"); //
        listOfCountersName.add("cpu.reservedCapacity.average");
        listOfCountersName.add("cpu.usage.average");
        listOfCountersName.add("cpu.usage.maximum");
        listOfCountersName.add("cpu.usage.minimum");
        listOfCountersName.add("cpu.usage.none");
        listOfCountersName.add("cpu.usagemhz.average");
        listOfCountersName.add("cpu.usagemhz.maximum");
        listOfCountersName.add("cpu.usagemhz.minimum");
        listOfCountersName.add("cpu.usagemhz.none");
        listOfCountersName.add("datastore.datastoreIops.average");
        listOfCountersName.add("datastore.numberReadAveraged.average");
        listOfCountersName.add("datastore.numberWriteAveraged.average");
        listOfCountersName.add("datastore.read.average");
        listOfCountersName.add("datastore.sizeNormalizedDatastoreLatency.average");
        listOfCountersName.add("datastore.totalReadLatency.average");
        listOfCountersName.add("datastore.totalWriteLatency.average");
        listOfCountersName.add("datastore.write.average");
        listOfCountersName.add("disk.busResets.summation");
        listOfCountersName.add("disk.capacity.latest");
        listOfCountersName.add("disk.commands.summation");
        listOfCountersName.add("disk.commandsAborted.summation");
        listOfCountersName.add("disk.commandsAveraged.average");
        listOfCountersName.add("disk.deltaused.latest");
        listOfCountersName.add("disk.deviceLatency.average");
        listOfCountersName.add("disk.deviceReadLatency.average");
        listOfCountersName.add("disk.deviceWriteLatency.average");
        listOfCountersName.add("disk.kernelLatency.average");
        listOfCountersName.add("disk.kernelReadLatency.average");
        listOfCountersName.add("disk.kernelWriteLatency.average");
        listOfCountersName.add("disk.maxQueueDepth.average");
        listOfCountersName.add("disk.maxTotalLatency.latest");
        listOfCountersName.add("disk.numberRead.summation");
        listOfCountersName.add("disk.numberReadAveraged.average");
        listOfCountersName.add("disk.numberWrite.summation");
        listOfCountersName.add("disk.numberWriteAveraged.average");
        listOfCountersName.add("disk.provisioned.latest");
        listOfCountersName.add("disk.queueLatency.average");
        listOfCountersName.add("disk.queueReadLatency.average");
        listOfCountersName.add("disk.queueWriteLatency.average");
        listOfCountersName.add("disk.read.average");
        listOfCountersName.add("disk.totalLatency.average");
        listOfCountersName.add("disk.totalReadLatency.average");
        listOfCountersName.add("disk.totalWriteLatency.average");
        listOfCountersName.add("disk.unshared.latest");
        listOfCountersName.add("disk.usage.average");
        listOfCountersName.add("disk.usage.maximum");
        listOfCountersName.add("disk.usage.minimum");
        listOfCountersName.add("disk.usage.none");
        listOfCountersName.add("disk.used.latest");
        listOfCountersName.add("disk.write.average");
        listOfCountersName.add("managementAgent.memUsed.average");
        listOfCountersName.add("managementAgent.swapIn.average");
        listOfCountersName.add("managementAgent.swapOut.average");
        listOfCountersName.add("managementAgent.swapUsed.average");
        listOfCountersName.add("mem.active.average");
        listOfCountersName.add("mem.active.maximum");
        listOfCountersName.add("mem.active.minimum");
        listOfCountersName.add("mem.active.none");
        listOfCountersName.add("mem.consumed.average");
        listOfCountersName.add("mem.consumed.maximum");
        listOfCountersName.add("mem.consumed.minimum");
        listOfCountersName.add("mem.consumed.none");
        listOfCountersName.add("mem.granted.average");
        listOfCountersName.add("mem.granted.maximum");
        listOfCountersName.add("mem.granted.minimum");
        listOfCountersName.add("mem.granted.none");
        listOfCountersName.add("mem.heap.average");
        listOfCountersName.add("mem.heap.maximum");
        listOfCountersName.add("mem.heap.minimum");
        listOfCountersName.add("mem.heap.none");
        listOfCountersName.add("mem.mementitlement.latest");
        listOfCountersName.add("mem.overhead.average");
        listOfCountersName.add("mem.overhead.maximum");
        listOfCountersName.add("mem.overhead.minimum");
        listOfCountersName.add("mem.overhead.none");
        listOfCountersName.add("mem.reservedCapacity.average");
        listOfCountersName.add("mem.shared.average");
        listOfCountersName.add("mem.shared.maximum");
        listOfCountersName.add("mem.shared.minimum");
        listOfCountersName.add("mem.shared.none");
        listOfCountersName.add("mem.sharedcommon.average");
        listOfCountersName.add("mem.sharedcommon.maximum");
        listOfCountersName.add("mem.sharedcommon.minimum");
        listOfCountersName.add("mem.sharedcommon.none");
        listOfCountersName.add("mem.state.latest");
        listOfCountersName.add("mem.swapin.average");
        listOfCountersName.add("mem.swapin.maximum");
        listOfCountersName.add("mem.swapin.minimum");
        listOfCountersName.add("mem.swapin.none");
        listOfCountersName.add("mem.swapinRate.average");
        listOfCountersName.add("mem.swapout.average");
        listOfCountersName.add("mem.swapout.maximum");
        listOfCountersName.add("mem.swapout.minimum");
        listOfCountersName.add("mem.swapout.none");
        listOfCountersName.add("mem.swapoutRate.average");
        listOfCountersName.add("mem.swapunreserved.average");
        listOfCountersName.add("mem.swapunreserved.maximum");
        listOfCountersName.add("mem.swapunreserved.minimum");
        listOfCountersName.add("mem.swapunreserved.none");
        listOfCountersName.add("mem.swapused.average");
        listOfCountersName.add("mem.swapused.maximum");
        listOfCountersName.add("mem.swapused.minimum");
        listOfCountersName.add("mem.swapused.none");
        listOfCountersName.add("mem.sysUsage.average");
        listOfCountersName.add("mem.sysUsage.maximum");
        listOfCountersName.add("mem.sysUsage.minimum");
        listOfCountersName.add("mem.sysUsage.none");
        listOfCountersName.add("mem.totalCapacity.average"); //
        listOfCountersName.add("mem.unreserved.average");
        listOfCountersName.add("mem.unreserved.maximum");
        listOfCountersName.add("mem.unreserved.minimum");
        listOfCountersName.add("mem.unreserved.none");
        listOfCountersName.add("mem.usage.average");
        listOfCountersName.add("mem.usage.maximum");
        listOfCountersName.add("mem.usage.minimum");
        listOfCountersName.add("mem.usage.none");
        listOfCountersName.add("mem.vmmemctl.average");
        listOfCountersName.add("mem.vmmemctl.maximum");
        listOfCountersName.add("mem.vmmemctl.minimum");
        listOfCountersName.add("mem.vmmemctl.none");
        listOfCountersName.add("mem.zero.average");
        listOfCountersName.add("mem.zero.maximum");
        listOfCountersName.add("mem.zero.minimum");
        listOfCountersName.add("mem.zero.none");
        listOfCountersName.add("net.droppedRx.summation");
        listOfCountersName.add("net.droppedTx.summation");
        listOfCountersName.add("net.packetsRx.summation");
        listOfCountersName.add("net.packetsTx.summation");
        listOfCountersName.add("net.received.average");
        listOfCountersName.add("net.transmitted.average");
        listOfCountersName.add("net.usage.average");
        listOfCountersName.add("net.usage.maximum");
        listOfCountersName.add("net.usage.minimum");
        listOfCountersName.add("net.usage.none");
        listOfCountersName.add("power.energy.summation");
        //listOfCountersName.add("power.power.average");
        listOfCountersName.add("power.power.average");
        listOfCountersName.add("power.powerCap.average");
        listOfCountersName.add("rescpu.actav1.latest");
        listOfCountersName.add("rescpu.actav15.latest");
        listOfCountersName.add("rescpu.actav5.latest");
        listOfCountersName.add("rescpu.actpk1.latest");
        listOfCountersName.add("rescpu.actpk15.latest");
        listOfCountersName.add("rescpu.actpk5.latest");
        listOfCountersName.add("rescpu.maxLimited1.latest");
        listOfCountersName.add("rescpu.maxLimited15.latest");
        listOfCountersName.add("rescpu.maxLimited5.latest");
        listOfCountersName.add("rescpu.runav1.latest");
        listOfCountersName.add("rescpu.runav15.latest");
        listOfCountersName.add("rescpu.runav5.latest");
        listOfCountersName.add("rescpu.runpk1.latest");
        listOfCountersName.add("rescpu.runpk15.latest");
        listOfCountersName.add("rescpu.runpk5.latest");
        listOfCountersName.add("rescpu.sampleCount.latest");
        listOfCountersName.add("rescpu.samplePeriod.latest");
        listOfCountersName.add("storageAdapter.commandsAveraged.average");
        listOfCountersName.add("storageAdapter.numberReadAveraged.average");
        listOfCountersName.add("storageAdapter.numberWriteAveraged.average");
        listOfCountersName.add("storageAdapter.read.average");
        listOfCountersName.add("storageAdapter.totalReadLatency.average");
        listOfCountersName.add("storageAdapter.totalWriteLatency.average");
        listOfCountersName.add("storageAdapter.write.average");
        listOfCountersName.add("storagePath.commandsAveraged.average");
        listOfCountersName.add("storagePath.numberReadAveraged.average");
        listOfCountersName.add("storagePath.numberWriteAveraged.average");
        listOfCountersName.add("storagePath.read.average");
        listOfCountersName.add("storagePath.totalReadLatency.average");
        listOfCountersName.add("storagePath.totalWriteLatency.average");
        listOfCountersName.add("storagePath.write.average");
        listOfCountersName.add("sys.diskUsage.latest");
        listOfCountersName.add("sys.heartbeat.summation");
        listOfCountersName.add("sys.resourceCpuUsage.average");
        listOfCountersName.add("sys.resourceCpuUsage.maximum");
        listOfCountersName.add("sys.resourceCpuUsage.minimum");
        listOfCountersName.add("sys.resourceCpuUsage.none");
        listOfCountersName.add("sys.uptime.latest");

        return listOfCountersName;
    }

    public ArrayList<String> getHostPerformanceCountersName() {
        ArrayList<String> listOfCountersName = new ArrayList<String>();

        listOfCountersName.add("cpu.coreUtilization.average");
        listOfCountersName.add("cpu.coreUtilization.maximum");
        listOfCountersName.add("cpu.coreUtilization.minimum");
        //listOfCountersName.add("cpu.coreUtilization.none"); 
        //listOfCountersName.add("cpu.cpuentitlement.latest"); 
        listOfCountersName.add("cpu.idle.summation"); //all
        //listOfCountersName.add("cpu.ready.summation"); 
        listOfCountersName.add("cpu.reservedCapacity.average");
        //listOfCountersName.add("cpu.swapwait.summation"); 
        //listOfCountersName.add("cpu.system.summation"); 
        listOfCountersName.add("cpu.totalCapacity.average");
        //listOfCountersName.add("cpu.totalmhz.average"); //all ?
        listOfCountersName.add("cpu.usage.average");
        listOfCountersName.add("cpu.usage.maximum");
        listOfCountersName.add("cpu.usage.minimum");
        //listOfCountersName.add("cpu.usage.none"); 
        listOfCountersName.add("cpu.usagemhz.average");
        listOfCountersName.add("cpu.usagemhz.maximum");
        listOfCountersName.add("cpu.usagemhz.minimum");
        //listOfCountersName.add("cpu.usagemhz.none"); 
        listOfCountersName.add("cpu.used.summation"); //all
        listOfCountersName.add("cpu.utilization.average");
        listOfCountersName.add("cpu.utilization.maximum");
        listOfCountersName.add("cpu.utilization.minimum");
        //listOfCountersName.add("cpu.utilization.none"); 
        //listOfCountersName.add("cpu.wait.summation");  //all jamais rcup ?

        listOfCountersName.add("datastore.read.average"); //all
        listOfCountersName.add("datastore.datastoreIops.average"); //all
        listOfCountersName.add("datastore.numberReadAveraged.average"); //all
        listOfCountersName.add("datastore.numberWriteAveraged.average"); //all
        listOfCountersName.add("datastore.sizeNormalizedDatastoreLatency.average"); //all
        listOfCountersName.add("datastore.totalReadLatency.average"); //all
        listOfCountersName.add("datastore.totalWriteLatency.average"); //all
        listOfCountersName.add("datastore.write.average"); //all

        //listOfCountersName.add("disk.busResets.summation");
        //listOfCountersName.add("disk.capacity.latest"); //all / jamais rcup ?
        //listOfCountersName.add("disk.commands.summation");
        //listOfCountersName.add("disk.commandsAborted.summation");
        //listOfCountersName.add("disk.commandsAveraged.average");
        //listOfCountersName.add("disk.deltaused.latest");
        //listOfCountersName.add("disk.deviceLatency.average");
        //listOfCountersName.add("disk.deviceReadLatency.average");
        //listOfCountersName.add("disk.deviceWriteLatency.average");
        //listOfCountersName.add("disk.kernelLatency.average");
        //listOfCountersName.add("disk.kernelReadLatency.average");
        //listOfCountersName.add("disk.kernelWriteLatency.average");
        //listOfCountersName.add("disk.maxQueueDepth.average");
        //listOfCountersName.add("disk.maxTotalLatency.latest");
        listOfCountersName.add("disk.numberRead.summation"); //all
        listOfCountersName.add("disk.numberReadAveraged.average"); //all
        listOfCountersName.add("disk.numberWrite.summation"); //all
        listOfCountersName.add("disk.numberWriteAveraged.average"); //all
        //listOfCountersName.add("disk.provisioned.latest");
        //listOfCountersName.add("disk.queueLatency.average");
        //listOfCountersName.add("disk.queueReadLatency.average");
        //listOfCountersName.add("disk.queueWriteLatency.average");
        listOfCountersName.add("disk.read.average");
        //listOfCountersName.add("disk.totalLatency.average");
        //listOfCountersName.add("disk.totalReadLatency.average");
        //listOfCountersName.add("disk.totalWriteLatency.average");
        //listOfCountersName.add("disk.unshared.latest"); //all / jamais rcup ?
        listOfCountersName.add("disk.usage.average");
        listOfCountersName.add("disk.usage.maximum");
        listOfCountersName.add("disk.usage.minimum");
        //listOfCountersName.add("disk.usage.none");
        //listOfCountersName.add("disk.used.latest"); //all / jamais rcup ?
        listOfCountersName.add("disk.write.average");

        //listOfCountersName.add("virtualDisk.read.average");
        //listOfCountersName.add("virtualDisk.write.average");
        //listOfCountersName.add("virtualDisk.totalReadLatency.average");
        //listOfCountersName.add("virtualDisk.totalWriteLatency.average");

        //      listOfCountersName.add("managementAgent.swapOut.average"); //all
        //      listOfCountersName.add("managementAgent.swapIn.average");   //all
        //      listOfCountersName.add("managementAgent.memUsed.average"); //all
        //      listOfCountersName.add("managementAgent.swapUsed.average"); //all

        listOfCountersName.add("mem.active.average");
        listOfCountersName.add("mem.active.maximum");
        listOfCountersName.add("mem.active.minimum");
        //listOfCountersName.add("mem.active.none");
        //listOfCountersName.add("mem.activewrite.average");
        //listOfCountersName.add("mem.compressed.average");
        //listOfCountersName.add("mem.compressionRate.average");
        listOfCountersName.add("mem.consumed.average"); // //
        listOfCountersName.add("mem.consumed.maximum");
        listOfCountersName.add("mem.consumed.minimum");
        //listOfCountersName.add("mem.consumed.none");
        //listOfCountersName.add("mem.decompressionRate.average");
        listOfCountersName.add("mem.granted.average"); // //
        listOfCountersName.add("mem.granted.maximum"); // //
        listOfCountersName.add("mem.granted.minimum"); // //
        //listOfCountersName.add("mem.granted.none"); 
        //listOfCountersName.add("mem.heap.average");
        //listOfCountersName.add("mem.heap.maximum");
        //listOfCountersName.add("mem.heap.minimum");
        //listOfCountersName.add("mem.heap.none");
        //listOfCountersName.add("mem.heapfree.average");
        //listOfCountersName.add("mem.heapfree.maximum");
        //listOfCountersName.add("mem.heapfree.minimum");
        //listOfCountersName.add("mem.heapfree.none");
        //listOfCountersName.add("mem.mementitlement.latest"); // jamais rcup
        listOfCountersName.add("mem.overhead.average"); // //
        listOfCountersName.add("mem.overhead.maximum"); // //
        listOfCountersName.add("mem.overhead.minimum"); // //
        //listOfCountersName.add("mem.overhead.none");
        //listOfCountersName.add("mem.overheadMax.average"); //
        listOfCountersName.add("mem.reservedCapacity.average"); // //
        listOfCountersName.add("mem.shared.average"); // //
        listOfCountersName.add("mem.shared.maximum"); // //
        listOfCountersName.add("mem.shared.minimum");// //
        //listOfCountersName.add("mem.shared.none");
        listOfCountersName.add("mem.sharedcommon.average");
        listOfCountersName.add("mem.sharedcommon.maximum");
        listOfCountersName.add("mem.sharedcommon.minimum");
        //listOfCountersName.add("mem.sharedcommon.none");
        listOfCountersName.add("mem.state.latest"); // a rcup ?
        //listOfCountersName.add("mem.swapIn.average");
        listOfCountersName.add("mem.swapin.average");
        //listOfCountersName.add("mem.swapIn.maximum");
        listOfCountersName.add("mem.swapin.maximum");
        //listOfCountersName.add("mem.swapIn.minimum");
        listOfCountersName.add("mem.swapin.minimum");
        //listOfCountersName.add("mem.swapIn.none");
        //listOfCountersName.add("mem.swapin.none");
        listOfCountersName.add("mem.swapinRate.average");
        //listOfCountersName.add("mem.swapOut.average");
        listOfCountersName.add("mem.swapout.average");
        //listOfCountersName.add("mem.swapOut.maximum");
        listOfCountersName.add("mem.swapout.maximum");
        //listOfCountersName.add("mem.swapOut.minimum");
        listOfCountersName.add("mem.swapout.minimum");
        //listOfCountersName.add("mem.swapOut.none");
        //listOfCountersName.add("mem.swapout.none");
        listOfCountersName.add("mem.swapoutRate.average");
        //listOfCountersName.add("mem.swapped.average"); // VM
        //listOfCountersName.add("mem.swapped.maximum"); // VM
        //listOfCountersName.add("mem.swapped.minimum"); // VM
        //listOfCountersName.add("mem.swapped.none"); // VM
        //listOfCountersName.add("mem.swaptarget.average"); // VM
        //listOfCountersName.add("mem.swaptarget.maximum"); // VM
        //listOfCountersName.add("mem.swaptarget.minimum"); // VM
        //listOfCountersName.add("mem.swaptarget.none"); // VM
        //listOfCountersName.add("mem.swapunreserved.average"); // jamais rcup ?
        //listOfCountersName.add("mem.swapunreserved.maximum"); // VM
        //listOfCountersName.add("mem.swapunreserved.minimum"); // VM
        //listOfCountersName.add("mem.swapunreserved.none"); // VM
        listOfCountersName.add("mem.swapused.average");
        listOfCountersName.add("mem.swapused.maximum");
        listOfCountersName.add("mem.swapused.minimum");
        //listOfCountersName.add("mem.swapused.none");
        listOfCountersName.add("mem.sysUsage.average");
        listOfCountersName.add("mem.sysUsage.maximum");
        listOfCountersName.add("mem.sysUsage.minimum");
        //listOfCountersName.add("mem.sysUsage.none");
        listOfCountersName.add("mem.totalCapacity.average");
        //listOfCountersName.add("mem.totalmb.average");
        listOfCountersName.add("mem.unreserved.average"); // //
        listOfCountersName.add("mem.unreserved.maximum"); // //
        listOfCountersName.add("mem.unreserved.minimum"); // //
        //listOfCountersName.add("mem.unreserved.none");
        listOfCountersName.add("mem.usage.average");
        listOfCountersName.add("mem.usage.maximum");
        listOfCountersName.add("mem.usage.minimum");
        //listOfCountersName.add("mem.usage.none");
        listOfCountersName.add("mem.vmmemctl.average");
        listOfCountersName.add("mem.vmmemctl.maximum");
        listOfCountersName.add("mem.vmmemctl.minimum");
        //listOfCountersName.add("mem.vmmemctl.none");
        //listOfCountersName.add("mem.vmmemctltarget.average");
        //listOfCountersName.add("mem.vmmemctltarget.maximum");
        //listOfCountersName.add("mem.vmmemctltarget.minimum");
        //listOfCountersName.add("mem.vmmemctltarget.none");
        //listOfCountersName.add("mem.zero.average");
        //listOfCountersName.add("mem.zero.maximum");
        //listOfCountersName.add("mem.zero.minimum");
        //listOfCountersName.add("mem.zero.none");
        //listOfCountersName.add("mem.zipped.latest");
        //listOfCountersName.add("mem.zipSaved.latest");

        listOfCountersName.add("net.droppedRx.summation"); //all
        listOfCountersName.add("net.droppedTx.summation"); //all
        listOfCountersName.add("net.packetsRx.summation"); //all
        listOfCountersName.add("net.packetsTx.summation"); //all
        listOfCountersName.add("net.received.average");
        listOfCountersName.add("net.transmitted.average");
        listOfCountersName.add("net.usage.average");
        listOfCountersName.add("net.usage.maximum");
        listOfCountersName.add("net.usage.minimum");
        //listOfCountersName.add("net.usage.none");

        listOfCountersName.add("power.energy.summation");
        listOfCountersName.add("power.power.average");
        //listOfCountersName.add("power.power.average"); //counter id=327
        listOfCountersName.add("power.powerCap.average");

        //      listOfCountersName.add("rescpu.actav1.latest");
        //      listOfCountersName.add("rescpu.actpk1.latest");
        //      listOfCountersName.add("rescpu.runav1.latest");
        //      listOfCountersName.add("rescpu.actav5.latest");
        //      listOfCountersName.add("rescpu.actpk5.latest");
        //      listOfCountersName.add("rescpu.runav5.latest");
        //      listOfCountersName.add("rescpu.actav15.latest");
        //      listOfCountersName.add("rescpu.actpk15.latest");
        //      listOfCountersName.add("rescpu.runav15.latest");
        listOfCountersName.add("rescpu.runpk1.latest");
        //      listOfCountersName.add("rescpu.maxLimited1.latest");
        listOfCountersName.add("rescpu.runpk5.latest");
        //      listOfCountersName.add("rescpu.maxLimited5.latest");
        listOfCountersName.add("rescpu.runpk15.latest");
        //      listOfCountersName.add("rescpu.maxLimited15.latest");
        //      listOfCountersName.add("rescpu.sampleCount.latest");
        //      listOfCountersName.add("rescpu.samplePeriod.latest");
        //
        //      listOfCountersName.add("storageAdapter.commandsAveraged.average");
        //      listOfCountersName.add("storageAdapter.numberReadAveraged.average");
        //      listOfCountersName.add("storageAdapter.numberWriteAveraged.average");
        //      listOfCountersName.add("storageAdapter.read.average");
        //      listOfCountersName.add("storageAdapter.write.average");
        //      listOfCountersName.add("storageAdapter.totalReadLatency.average");
        //      listOfCountersName.add("storageAdapter.totalWriteLatency.average");

        //      listOfCountersName.add("storagePath.commandsAveraged.average");
        //      listOfCountersName.add("storagePath.numberReadAveraged.average");
        //      listOfCountersName.add("storagePath.numberWriteAveraged.average");

        listOfCountersName.add("storagePath.read.average");
        listOfCountersName.add("storagePath.write.average");
        listOfCountersName.add("storagePath.totalReadLatency.average");
        listOfCountersName.add("storagePath.totalWriteLatency.average");

        //      listOfCountersName.add("sys.uptime.latest");
        //      listOfCountersName.add("sys.diskUsage.latest");
        //      listOfCountersName.add("sys.resourceCpuUsage.average");
        //      listOfCountersName.add("sys.resourceMemTouched.latest");
        //      listOfCountersName.add("sys.resourceMemMapped.latest");
        //      listOfCountersName.add("sys.resourceMemShared.latest");
        //      listOfCountersName.add("sys.resourceMemSwapped.latest");
        //      listOfCountersName.add("sys.resourceMemOverhead.latest");
        //      listOfCountersName.add("sys.resourceMemCow.latest");
        //      listOfCountersName.add("sys.resourceMemZero.latest");
        //      listOfCountersName.add("sys.resourceCpuRun1.latest");
        //      listOfCountersName.add("sys.resourceCpuAct1.latest");
        //      listOfCountersName.add("sys.resourceCpuMaxLimited1.latest");
        //      listOfCountersName.add("sys.resourceCpuRun5.latest");
        //      listOfCountersName.add("sys.resourceCpuAct5.latest");
        //      listOfCountersName.add("sys.resourceCpuMaxLimited5.latest");
        //      listOfCountersName.add("sys.resourceCpuAllocMin.latest");
        //      listOfCountersName.add("sys.resourceCpuAllocMax.latest");
        //      listOfCountersName.add("sys.resourceCpuAllocShares.latest");
        //      listOfCountersName.add("sys.resourceMemAllocMin.latest");
        //      listOfCountersName.add("sys.resourceMemAllocMax.latest");
        //      listOfCountersName.add("sys.resourceMemAllocShares.latest");

        return listOfCountersName;

    }

    public HashMap<String, String> getHostCounters() {
        HashMap<String, String> mapOfCounter = new HashMap<String, String>();

        mapOfCounter.put("cpu.coreUtilization.average", "");
        mapOfCounter.put("cpu.idle.summation", "*");
        mapOfCounter.put("cpu.reservedCapacity.average", "");
        mapOfCounter.put("cpu.used.summation", "*");
        mapOfCounter.put("cpu.usage.average", "");
        mapOfCounter.put("cpu.usagemhz.average", "");

        return mapOfCounter;

    }

    public ArrayList<Counter> getHostPerformanceCounters(HashMap<String, String> mapOfCounter) {

        ArrayList<Counter> listOfCounters = new ArrayList<Counter>();
        Counter counter = null;

        //**************************************
        //**************************************
        if (mapOfCounter != null && !mapOfCounter.isEmpty()) {
            for (Map.Entry<String, String> counterMap : mapOfCounter.entrySet()) {
                counter = new Counter();
                counter.setFullName(counterMap.getKey());
                counter.setInstance(counterMap.getValue());

                listOfCounters.add(counter);
            }
        }

        return listOfCounters;

    }

    public void getVirtualMachinePerf() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Get Host Performance
        // =========================================================================================
        // Initialize the Performance Engine
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);

        // Get the Performance Counters
        ArrayList<Integer> listOfCountersID = null;
        PerfMetricId[] arrayOfPerfMetricIds = null;
        PerfQuerySpec[] arrayOfPerfQuerySpecs = null;

        VMManager vmManager = VMManager.getInstance();

        HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager
                .getMapOfPerfCounterInfoByIdByVC().get(hostName);

        for (String counterName : this.getVMAllPerformanceCountersName()) {
            System.out.println("Counter: " + counterName);
        }

        //arrayOfPerfMetricIds=performanceManager.getPerfMetricFromCounterNames(this.getHostPerformanceCountersName(),false, hostName);
        //arrayOfPerfMetricIds=performanceManager.getPerfMetricFromCounters(this.getHostPerformanceCounters(this.getHostCounters()), hostName);
        arrayOfPerfMetricIds = performanceManager
                .getPerfMetricFromCounterNames(this.getVMAllPerformanceCountersName(), false, hostName);

        System.out.println("Nb Metrics: " + arrayOfPerfMetricIds.length);
        PerfCounterInfo perfCounterInfo = null;

        for (PerfMetricId perfMetricId : arrayOfPerfMetricIds) {
            if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId())) {
                perfCounterInfo = mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId());
                System.out.println("Metric: " + perfMetricId.getCounterId() + "/"
                        + perfCounterInfo.getGroupInfo().getKey() + "." + perfCounterInfo.getNameInfo().getKey()
                        + "." + perfCounterInfo.getRollupType().name());
            }
        }

        //arrayOfPerfQuerySpecs=performanceManager.getHostQueryPerfSpec(hostManager.getAllHosts(hostName), arrayOfPerfMetricIds);
        arrayOfPerfQuerySpecs = performanceManager.getVMQueryPerfSpec(vmManager.getAllVM(hostName),
                arrayOfPerfMetricIds);

        performanceManager.getPerf1(hostName, arrayOfPerfQuerySpecs);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public ArrayList<String> getVMAllPerformanceCountersName() {
        ArrayList<String> listOfCountersName = new ArrayList<String>();

        //listOfCountersName.add("cpu.cpuentitlement.latest");
        listOfCountersName.add("cpu.idle.summation");
        listOfCountersName.add("cpu.ready.summation");
        listOfCountersName.add("cpu.system.summation");
        listOfCountersName.add("cpu.usage.average");
        listOfCountersName.add("cpu.usage.maximum");
        listOfCountersName.add("cpu.usage.minimum");
        listOfCountersName.add("cpu.usage.none");
        listOfCountersName.add("cpu.usagemhz.average");
        listOfCountersName.add("cpu.usagemhz.maximum");
        listOfCountersName.add("cpu.usagemhz.minimum");
        listOfCountersName.add("cpu.usagemhz.none");
        listOfCountersName.add("cpu.used.summation");
        listOfCountersName.add("cpu.wait.summation");
        listOfCountersName.add("datastore.datastoreIops.average");
        listOfCountersName.add("datastore.numberReadAveraged.average");
        listOfCountersName.add("datastore.numberWriteAveraged.average");
        listOfCountersName.add("datastore.read.average");
        listOfCountersName.add("datastore.sizeNormalizedDatastoreLatency.average");
        listOfCountersName.add("datastore.totalReadLatency.average");
        listOfCountersName.add("datastore.totalWriteLatency.average");
        listOfCountersName.add("datastore.write.average");
        listOfCountersName.add("disk.busResets.summation");
        listOfCountersName.add("disk.commands.summation");
        listOfCountersName.add("disk.commandsAborted.summation");
        listOfCountersName.add("disk.numberRead.summation");
        listOfCountersName.add("disk.numberWrite.summation");
        listOfCountersName.add("disk.read.average");
        listOfCountersName.add("disk.usage.average");
        listOfCountersName.add("disk.usage.maximum");
        listOfCountersName.add("disk.usage.minimum");
        listOfCountersName.add("disk.usage.none");
        listOfCountersName.add("disk.write.average");
        listOfCountersName.add("mem.active.average");
        listOfCountersName.add("mem.active.maximum");
        listOfCountersName.add("mem.active.minimum");
        listOfCountersName.add("mem.active.none");
        listOfCountersName.add("mem.consumed.average");
        listOfCountersName.add("mem.consumed.maximum");
        listOfCountersName.add("mem.consumed.minimum");
        listOfCountersName.add("mem.consumed.none");
        listOfCountersName.add("mem.granted.average");
        listOfCountersName.add("mem.granted.maximum");
        listOfCountersName.add("mem.granted.minimum");
        listOfCountersName.add("mem.granted.none");
        listOfCountersName.add("mem.heapfree.average");
        listOfCountersName.add("mem.heapfree.maximum");
        listOfCountersName.add("mem.heapfree.minimum");
        listOfCountersName.add("mem.heapfree.none");
        listOfCountersName.add("mem.overhead.average");
        listOfCountersName.add("mem.overhead.maximum");
        listOfCountersName.add("mem.overhead.minimum");
        listOfCountersName.add("mem.overhead.none");
        listOfCountersName.add("mem.shared.average");
        listOfCountersName.add("mem.shared.maximum");
        listOfCountersName.add("mem.shared.minimum");
        listOfCountersName.add("mem.shared.none");
        listOfCountersName.add("mem.sharedcommon.average");
        listOfCountersName.add("mem.sharedcommon.maximum");
        listOfCountersName.add("mem.sharedcommon.minimum");
        listOfCountersName.add("mem.sharedcommon.none");
        listOfCountersName.add("mem.state.latest");
        listOfCountersName.add("mem.swapin.average");
        listOfCountersName.add("mem.swapin.maximum");
        listOfCountersName.add("mem.swapin.minimum");
        listOfCountersName.add("mem.swapin.none");
        listOfCountersName.add("mem.swapinRate.average");
        listOfCountersName.add("mem.swapout.average");
        listOfCountersName.add("mem.swapout.maximum");
        listOfCountersName.add("mem.swapout.minimum");
        listOfCountersName.add("mem.swapout.none");
        listOfCountersName.add("mem.swapoutRate.average");
        listOfCountersName.add("mem.swapped.average");
        listOfCountersName.add("mem.swapped.maximum");
        listOfCountersName.add("mem.swapped.minimum");
        listOfCountersName.add("mem.swapped.none");
        listOfCountersName.add("mem.swaptarget.average");
        listOfCountersName.add("mem.swaptarget.maximum");
        listOfCountersName.add("mem.swaptarget.minimum");
        listOfCountersName.add("mem.swaptarget.none");
        listOfCountersName.add("mem.usage.average");
        listOfCountersName.add("mem.usage.maximum");
        listOfCountersName.add("mem.usage.minimum");
        listOfCountersName.add("mem.usage.none");
        listOfCountersName.add("mem.vmmemctl.average");
        listOfCountersName.add("mem.vmmemctl.maximum");
        listOfCountersName.add("mem.vmmemctl.minimum");
        listOfCountersName.add("mem.vmmemctl.none");
        listOfCountersName.add("mem.vmmemctltarget.average");
        listOfCountersName.add("mem.vmmemctltarget.maximum");
        listOfCountersName.add("mem.vmmemctltarget.minimum");
        listOfCountersName.add("mem.vmmemctltarget.none");
        listOfCountersName.add("mem.zero.average");
        listOfCountersName.add("mem.zero.maximum");
        listOfCountersName.add("mem.zero.minimum");
        listOfCountersName.add("mem.zero.none");
        listOfCountersName.add("net.droppedRx.summation");
        listOfCountersName.add("net.droppedTx.summation");
        listOfCountersName.add("net.packetsRx.summation");
        listOfCountersName.add("net.packetsTx.summation");
        listOfCountersName.add("net.received.average");
        listOfCountersName.add("net.transmitted.average");
        listOfCountersName.add("net.usage.average");
        listOfCountersName.add("net.usage.maximum");
        listOfCountersName.add("net.usage.minimum");
        listOfCountersName.add("net.usage.none");
        listOfCountersName.add("power.energy.summation");
        listOfCountersName.add("power.power.average");
        listOfCountersName.add("rescpu.actav1.latest");
        listOfCountersName.add("rescpu.actav15.latest");
        listOfCountersName.add("rescpu.actav5.latest");
        listOfCountersName.add("rescpu.actpk1.latest");
        listOfCountersName.add("rescpu.actpk15.latest");
        listOfCountersName.add("rescpu.actpk5.latest");
        listOfCountersName.add("rescpu.maxLimited1.latest");
        listOfCountersName.add("rescpu.maxLimited15.latest");
        listOfCountersName.add("rescpu.maxLimited5.latest");
        listOfCountersName.add("rescpu.runav1.latest");
        listOfCountersName.add("rescpu.runav15.latest");
        listOfCountersName.add("rescpu.runav5.latest");
        listOfCountersName.add("rescpu.runpk1.latest");
        listOfCountersName.add("rescpu.runpk15.latest");
        listOfCountersName.add("rescpu.runpk5.latest");
        listOfCountersName.add("rescpu.sampleCount.latest");
        listOfCountersName.add("rescpu.samplePeriod.latest");
        listOfCountersName.add("sys.heartbeat.summation");
        listOfCountersName.add("sys.resourceCpuUsage.average");
        listOfCountersName.add("sys.resourceCpuUsage.maximum");
        listOfCountersName.add("sys.resourceCpuUsage.minimum");
        listOfCountersName.add("sys.resourceCpuUsage.none");
        listOfCountersName.add("sys.uptime.latest");
        listOfCountersName.add("virtualDisk.numberReadAveraged.average");
        listOfCountersName.add("virtualDisk.numberWriteAveraged.average");
        listOfCountersName.add("virtualDisk.read.average");
        listOfCountersName.add("virtualDisk.totalReadLatency.average");
        listOfCountersName.add("virtualDisk.totalWriteLatency.average");
        listOfCountersName.add("virtualDisk.write.average");

        return listOfCountersName;
    }

    public ArrayList<String> getVMPerformanceCountersName() {
        ArrayList<String> listOfCountersName = new ArrayList<String>();

        //listOfCountersName.add("cpu.coreUtilization.average"); 
        //listOfCountersName.add("cpu.coreUtilization.maximum"); 
        //listOfCountersName.add("cpu.coreUtilization.minimum"); 
        //listOfCountersName.add("cpu.coreUtilization.none"); 
        //listOfCountersName.add("cpu.cpuentitlement.latest"); 
        //listOfCountersName.add("cpu.idle.summation");   //all
        listOfCountersName.add("cpu.ready.summation");
        //listOfCountersName.add("cpu.reservedCapacity.average"); 
        //listOfCountersName.add("cpu.swapwait.summation"); 
        listOfCountersName.add("cpu.system.summation");
        //listOfCountersName.add("cpu.totalCapacity.average"); 
        //listOfCountersName.add("cpu.totalmhz.average"); //all ?
        listOfCountersName.add("cpu.usage.average");
        //listOfCountersName.add("cpu.usage.maximum"); 
        //listOfCountersName.add("cpu.usage.minimum"); 
        //listOfCountersName.add("cpu.usage.none"); 
        listOfCountersName.add("cpu.usagemhz.average");
        //listOfCountersName.add("cpu.usagemhz.maximum"); 
        //listOfCountersName.add("cpu.usagemhz.minimum"); 
        //listOfCountersName.add("cpu.usagemhz.none"); 
        listOfCountersName.add("cpu.used.summation"); //all
        //listOfCountersName.add("cpu.utilization.average"); 
        //listOfCountersName.add("cpu.utilization.maximum"); 
        //listOfCountersName.add("cpu.utilization.minimum"); 
        //listOfCountersName.add("cpu.utilization.none"); 
        //listOfCountersName.add("cpu.wait.summation");  //all jamais rcup ?

        //listOfCountersName.add("disk.busResets.summation");
        //listOfCountersName.add("disk.capacity.latest"); //all / jamais rcup ?
        //listOfCountersName.add("disk.commands.summation");
        //listOfCountersName.add("disk.commandsAborted.summation");
        //listOfCountersName.add("disk.commandsAveraged.average");
        //listOfCountersName.add("disk.deltaused.latest");
        //listOfCountersName.add("disk.deviceLatency.average");
        //listOfCountersName.add("disk.deviceReadLatency.average");
        //listOfCountersName.add("disk.deviceWriteLatency.average");
        //listOfCountersName.add("disk.kernelLatency.average");
        //listOfCountersName.add("disk.kernelReadLatency.average");
        //listOfCountersName.add("disk.kernelWriteLatency.average");
        //listOfCountersName.add("disk.maxQueueDepth.average");
        //listOfCountersName.add("disk.maxTotalLatency.latest");
        //listOfCountersName.add("disk.numberRead.summation"); //all
        //listOfCountersName.add("disk.numberReadAveraged.average"); //all
        //listOfCountersName.add("disk.numberWrite.summation"); //all
        //listOfCountersName.add("disk.numberWriteAveraged.average"); //all
        //listOfCountersName.add("disk.provisioned.latest");
        //listOfCountersName.add("disk.queueLatency.average");
        //listOfCountersName.add("disk.queueReadLatency.average");
        //listOfCountersName.add("disk.queueWriteLatency.average");
        listOfCountersName.add("disk.read.average");
        //listOfCountersName.add("disk.totalLatency.average");
        //listOfCountersName.add("disk.totalReadLatency.average");
        //listOfCountersName.add("disk.totalWriteLatency.average");
        //listOfCountersName.add("disk.unshared.latest"); //all / jamais rcup ?
        listOfCountersName.add("disk.usage.average");
        //listOfCountersName.add("disk.usage.maximum");
        //listOfCountersName.add("disk.usage.minimum");
        //listOfCountersName.add("disk.usage.none");
        //listOfCountersName.add("disk.used.latest"); //all / jamais rcup ?
        listOfCountersName.add("disk.write.average");

        //listOfCountersName.add("disk.busResets.summation");
        //listOfCountersName.add("disk.commands.summation");
        //listOfCountersName.add("disk.commandsAborted.summation");
        //listOfCountersName.add("disk.numberRead.summation"); //all
        //listOfCountersName.add("disk.numberWrite.summation"); //all

        listOfCountersName.add("mem.active.average");
        //listOfCountersName.add("mem.active.maximum");
        //listOfCountersName.add("mem.active.minimum");
        //listOfCountersName.add("mem.active.none");
        listOfCountersName.add("mem.activewrite.average");
        ///listOfCountersName.add("mem.compressed.average");
        ///listOfCountersName.add("mem.compressionRate.average");
        listOfCountersName.add("mem.consumed.average"); // //
        //listOfCountersName.add("mem.consumed.maximum");
        //listOfCountersName.add("mem.consumed.minimum");
        //listOfCountersName.add("mem.consumed.none");
        //listOfCountersName.add("mem.decompressionRate.average");
        listOfCountersName.add("mem.granted.average"); // //
        //listOfCountersName.add("mem.granted.maximum"); // //
        //listOfCountersName.add("mem.granted.minimum"); // //
        //listOfCountersName.add("mem.granted.none"); 
        //listOfCountersName.add("mem.heap.average");
        //listOfCountersName.add("mem.heap.maximum");
        //listOfCountersName.add("mem.heap.minimum");
        //listOfCountersName.add("mem.heap.none");
        //listOfCountersName.add("mem.heapfree.average");
        //listOfCountersName.add("mem.heapfree.maximum");
        //listOfCountersName.add("mem.heapfree.minimum");
        //listOfCountersName.add("mem.heapfree.none");
        //listOfCountersName.add("mem.mementitlement.latest"); // jamais rcup
        listOfCountersName.add("mem.overhead.average"); // //
        //listOfCountersName.add("mem.overhead.maximum"); // //
        //listOfCountersName.add("mem.overhead.minimum"); // //
        //listOfCountersName.add("mem.overhead.none");
        listOfCountersName.add("mem.overheadMax.average"); //
        //listOfCountersName.add("mem.reservedCapacity.average"); // //
        listOfCountersName.add("mem.shared.average"); // //
        //listOfCountersName.add("mem.shared.maximum"); // //
        //listOfCountersName.add("mem.shared.minimum");// //
        //listOfCountersName.add("mem.shared.none");
        //listOfCountersName.add("mem.sharedcommon.average");
        //listOfCountersName.add("mem.sharedcommon.maximum");
        //listOfCountersName.add("mem.sharedcommon.minimum");
        //listOfCountersName.add("mem.sharedcommon.none");
        //listOfCountersName.add("mem.state.latest"); // a rcup ?
        listOfCountersName.add("mem.swapin.average");
        //listOfCountersName.add("mem.swapin.maximum");
        //listOfCountersName.add("mem.swapin.minimum");
        //listOfCountersName.add("mem.swapin.none");
        listOfCountersName.add("mem.swapinRate.average");
        listOfCountersName.add("mem.swapout.average");
        //listOfCountersName.add("mem.swapout.maximum");
        //listOfCountersName.add("mem.swapout.minimum");
        //listOfCountersName.add("mem.swapout.none");
        listOfCountersName.add("mem.swapoutRate.average");
        listOfCountersName.add("mem.swapped.average"); // VM
        //listOfCountersName.add("mem.swapped.maximum"); // VM
        //listOfCountersName.add("mem.swapped.minimum"); // VM
        //listOfCountersName.add("mem.swapped.none"); // VM
        listOfCountersName.add("mem.swaptarget.average"); // VM
        //listOfCountersName.add("mem.swaptarget.maximum"); // VM
        //listOfCountersName.add("mem.swaptarget.minimum"); // VM
        //listOfCountersName.add("mem.swaptarget.none"); // VM
        //listOfCountersName.add("mem.swapunreserved.average"); // jamais rcup ?
        //listOfCountersName.add("mem.swapunreserved.maximum"); // VM
        //listOfCountersName.add("mem.swapunreserved.minimum"); // VM
        //listOfCountersName.add("mem.swapunreserved.none"); // VM
        //listOfCountersName.add("mem.swapused.average");
        //listOfCountersName.add("mem.swapused.maximum");
        //listOfCountersName.add("mem.swapused.minimum");
        //listOfCountersName.add("mem.swapused.none");
        //listOfCountersName.add("mem.sysUsage.average");
        //listOfCountersName.add("mem.sysUsage.maximum");
        //listOfCountersName.add("mem.sysUsage.minimum");
        //listOfCountersName.add("mem.sysUsage.none");
        //listOfCountersName.add("mem.totalCapacity.average");
        //listOfCountersName.add("mem.totalmb.average");
        //listOfCountersName.add("mem.unreserved.average"); // //
        //listOfCountersName.add("mem.unreserved.maximum"); // //
        //listOfCountersName.add("mem.unreserved.minimum"); // //
        //listOfCountersName.add("mem.unreserved.none");
        listOfCountersName.add("mem.usage.average");
        //listOfCountersName.add("mem.usage.maximum");
        //listOfCountersName.add("mem.usage.minimum");
        //listOfCountersName.add("mem.usage.none");
        listOfCountersName.add("mem.vmmemctl.average");
        //listOfCountersName.add("mem.vmmemctl.maximum");
        //listOfCountersName.add("mem.vmmemctl.minimum");
        //listOfCountersName.add("mem.vmmemctl.none");
        listOfCountersName.add("mem.vmmemctltarget.average");
        //listOfCountersName.add("mem.vmmemctltarget.maximum");
        //listOfCountersName.add("mem.vmmemctltarget.minimum");
        //listOfCountersName.add("mem.vmmemctltarget.none");
        //listOfCountersName.add("mem.zero.average");
        //listOfCountersName.add("mem.zero.maximum");
        //listOfCountersName.add("mem.zero.minimum");
        //listOfCountersName.add("mem.zero.none");
        //listOfCountersName.add("mem.zipped.latest");
        //listOfCountersName.add("mem.zipSaved.latest");

        listOfCountersName.add("net.droppedRx.summation"); //all
        listOfCountersName.add("net.droppedTx.summation"); //all
        listOfCountersName.add("net.packetsRx.summation"); //all
        listOfCountersName.add("net.packetsTx.summation"); //all
        listOfCountersName.add("net.received.average");
        listOfCountersName.add("net.transmitted.average");
        listOfCountersName.add("net.usage.average");
        //listOfCountersName.add("net.usage.maximum");
        //listOfCountersName.add("net.usage.minimum");
        //listOfCountersName.add("net.usage.none");

        listOfCountersName.add("virtualDisk.read.average");
        listOfCountersName.add("virtualDisk.write.average");
        listOfCountersName.add("virtualDisk.totalReadLatency.average");
        listOfCountersName.add("virtualDisk.totalWriteLatency.average");

        listOfCountersName.add("virtualDisk.numberReadAveraged.average");
        listOfCountersName.add("virtualDisk.numberWriteAveraged.average");

        //listOfCountersName.add("vcDebugInfo.morefregstats.summation");

        /*      
                  
            
                  
            
                  
              listOfCountersName.add("datastore.read.average"); //all
              listOfCountersName.add("datastore.datastoreIops.average"); //all
              listOfCountersName.add("datastore.numberReadAveraged.average"); //all
              listOfCountersName.add("datastore.numberWriteAveraged.average"); //all
              listOfCountersName.add("datastore.sizeNormalizedDatastoreLatency.average"); //all
              listOfCountersName.add("datastore.totalReadLatency.average"); //all
              listOfCountersName.add("datastore.totalWriteLatency.average"); //all
              listOfCountersName.add("datastore.write.average"); //all
                  
              //listOfCountersName.add("disk.busResets.summation");
              //listOfCountersName.add("disk.capacity.latest"); //all / jamais rcup ?
              //listOfCountersName.add("disk.commands.summation");
              //listOfCountersName.add("disk.commandsAborted.summation");
              //listOfCountersName.add("disk.commandsAveraged.average");
              //listOfCountersName.add("disk.deltaused.latest");
              //listOfCountersName.add("disk.deviceLatency.average");
              //listOfCountersName.add("disk.deviceReadLatency.average");
              //listOfCountersName.add("disk.deviceWriteLatency.average");
              //listOfCountersName.add("disk.kernelLatency.average");
              //listOfCountersName.add("disk.kernelReadLatency.average");
              //listOfCountersName.add("disk.kernelWriteLatency.average");
              //listOfCountersName.add("disk.maxQueueDepth.average");
              //listOfCountersName.add("disk.maxTotalLatency.latest");
              listOfCountersName.add("disk.numberRead.summation"); //all
              listOfCountersName.add("disk.numberReadAveraged.average"); //all
              listOfCountersName.add("disk.numberWrite.summation"); //all
              listOfCountersName.add("disk.numberWriteAveraged.average"); //all
              //listOfCountersName.add("disk.provisioned.latest");
              //listOfCountersName.add("disk.queueLatency.average");
              //listOfCountersName.add("disk.queueReadLatency.average");
              //listOfCountersName.add("disk.queueWriteLatency.average");
              listOfCountersName.add("disk.read.average");
              //listOfCountersName.add("disk.totalLatency.average");
              //listOfCountersName.add("disk.totalReadLatency.average");
              //listOfCountersName.add("disk.totalWriteLatency.average");
              //listOfCountersName.add("disk.unshared.latest"); //all / jamais rcup ?
              listOfCountersName.add("disk.usage.average");
              listOfCountersName.add("disk.usage.maximum");
              listOfCountersName.add("disk.usage.minimum");
              //listOfCountersName.add("disk.usage.none");
              //listOfCountersName.add("disk.used.latest"); //all / jamais rcup ?
              listOfCountersName.add("disk.write.average");
            
              //listOfCountersName.add("virtualDisk.read.average");
              //listOfCountersName.add("virtualDisk.write.average");
              //listOfCountersName.add("virtualDisk.totalReadLatency.average");
              //listOfCountersName.add("virtualDisk.totalWriteLatency.average");
                  
        //      listOfCountersName.add("managementAgent.swapOut.average"); //all
        //      listOfCountersName.add("managementAgent.swapIn.average");   //all
        //      listOfCountersName.add("managementAgent.memUsed.average"); //all
        //      listOfCountersName.add("managementAgent.swapUsed.average"); //all
            
              listOfCountersName.add("mem.active.average");
              listOfCountersName.add("mem.active.maximum");
              listOfCountersName.add("mem.active.minimum");
              //listOfCountersName.add("mem.active.none");
              //listOfCountersName.add("mem.activewrite.average");
              //listOfCountersName.add("mem.compressed.average");
              //listOfCountersName.add("mem.compressionRate.average");
              listOfCountersName.add("mem.consumed.average"); // //
              listOfCountersName.add("mem.consumed.maximum");
              listOfCountersName.add("mem.consumed.minimum");
              //listOfCountersName.add("mem.consumed.none");
              //listOfCountersName.add("mem.decompressionRate.average");
              listOfCountersName.add("mem.granted.average"); // //
              listOfCountersName.add("mem.granted.maximum"); // //
              listOfCountersName.add("mem.granted.minimum"); // //
              //listOfCountersName.add("mem.granted.none"); 
              //listOfCountersName.add("mem.heap.average");
              //listOfCountersName.add("mem.heap.maximum");
              //listOfCountersName.add("mem.heap.minimum");
              //listOfCountersName.add("mem.heap.none");
              //listOfCountersName.add("mem.heapfree.average");
              //listOfCountersName.add("mem.heapfree.maximum");
              //listOfCountersName.add("mem.heapfree.minimum");
              //listOfCountersName.add("mem.heapfree.none");
              //listOfCountersName.add("mem.mementitlement.latest"); // jamais rcup
              listOfCountersName.add("mem.overhead.average"); // //
              listOfCountersName.add("mem.overhead.maximum"); // //
              listOfCountersName.add("mem.overhead.minimum"); // //
              //listOfCountersName.add("mem.overhead.none");
              //listOfCountersName.add("mem.overheadMax.average"); //
              listOfCountersName.add("mem.reservedCapacity.average"); // //
              listOfCountersName.add("mem.shared.average"); // //
              listOfCountersName.add("mem.shared.maximum"); // //
              listOfCountersName.add("mem.shared.minimum");// //
              //listOfCountersName.add("mem.shared.none");
              listOfCountersName.add("mem.sharedcommon.average");
              listOfCountersName.add("mem.sharedcommon.maximum");
              listOfCountersName.add("mem.sharedcommon.minimum");
              //listOfCountersName.add("mem.sharedcommon.none");
              listOfCountersName.add("mem.state.latest"); // a rcup ?
              //listOfCountersName.add("mem.swapin.average");
              //listOfCountersName.add("mem.swapin.maximum");
              //listOfCountersName.add("mem.swapin.minimum");
              //listOfCountersName.add("mem.swapin.none");
              //listOfCountersName.add("mem.swapinRate.average");
              //listOfCountersName.add("mem.swapout.average");
              //listOfCountersName.add("mem.swapout.maximum");
              //listOfCountersName.add("mem.swapout.minimum");
              //listOfCountersName.add("mem.swapout.none");
              //listOfCountersName.add("mem.swapoutRate.average");
              //listOfCountersName.add("mem.swapped.average"); // VM
              //listOfCountersName.add("mem.swapped.maximum"); // VM
              //listOfCountersName.add("mem.swapped.minimum"); // VM
              //listOfCountersName.add("mem.swapped.none"); // VM
              //listOfCountersName.add("mem.swaptarget.average"); // VM
              //listOfCountersName.add("mem.swaptarget.maximum"); // VM
              //listOfCountersName.add("mem.swaptarget.minimum"); // VM
              //listOfCountersName.add("mem.swaptarget.none"); // VM
              //listOfCountersName.add("mem.swapunreserved.average"); // jamais rcup ?
              //listOfCountersName.add("mem.swapunreserved.maximum"); // VM
              //listOfCountersName.add("mem.swapunreserved.minimum"); // VM
              //listOfCountersName.add("mem.swapunreserved.none"); // VM
              listOfCountersName.add("mem.swapused.average");
              listOfCountersName.add("mem.swapused.maximum");
              listOfCountersName.add("mem.swapused.minimum");
              //listOfCountersName.add("mem.swapused.none");
              listOfCountersName.add("mem.sysUsage.average");
              listOfCountersName.add("mem.sysUsage.maximum");
              listOfCountersName.add("mem.sysUsage.minimum");
              //listOfCountersName.add("mem.sysUsage.none");
              listOfCountersName.add("mem.totalCapacity.average");
              //listOfCountersName.add("mem.totalmb.average");
              listOfCountersName.add("mem.unreserved.average"); // //
              listOfCountersName.add("mem.unreserved.maximum"); // //
              listOfCountersName.add("mem.unreserved.minimum"); // //
              //listOfCountersName.add("mem.unreserved.none");
              listOfCountersName.add("mem.usage.average");
              listOfCountersName.add("mem.usage.maximum");
              listOfCountersName.add("mem.usage.minimum");
              //listOfCountersName.add("mem.usage.none");
              listOfCountersName.add("mem.vmmemctl.average");
              listOfCountersName.add("mem.vmmemctl.maximum");
              listOfCountersName.add("mem.vmmemctl.minimum");
              //listOfCountersName.add("mem.vmmemctl.none");
              //listOfCountersName.add("mem.vmmemctltarget.average");
              //listOfCountersName.add("mem.vmmemctltarget.maximum");
              //listOfCountersName.add("mem.vmmemctltarget.minimum");
              //listOfCountersName.add("mem.vmmemctltarget.none");
              //listOfCountersName.add("mem.zero.average");
              //listOfCountersName.add("mem.zero.maximum");
              //listOfCountersName.add("mem.zero.minimum");
              //listOfCountersName.add("mem.zero.none");
              //listOfCountersName.add("mem.zipped.latest");
              //listOfCountersName.add("mem.zipSaved.latest");
                  
              listOfCountersName.add("net.droppedRx.summation"); //all
              listOfCountersName.add("net.droppedTx.summation"); //all
              listOfCountersName.add("net.packetsRx.summation"); //all
              listOfCountersName.add("net.packetsTx.summation"); //all
              listOfCountersName.add("net.received.average");
              listOfCountersName.add("net.transmitted.average");
              listOfCountersName.add("net.usage.average");
              listOfCountersName.add("net.usage.maximum");
              listOfCountersName.add("net.usage.minimum");
              //listOfCountersName.add("net.usage.none");
            
              listOfCountersName.add("virtualDisk.numberReadAveraged.average");
              listOfCountersName.add("virtualDisk.numberWriteAveraged.average");
              listOfCountersName.add("virtualDisk.read.average");
              listOfCountersName.add("virtualDisk.totalReadLatency.average");
              listOfCountersName.add("virtualDisk.totalWriteLatency.average");
              listOfCountersName.add("virtualDisk.write.average");
            
                  
                  
        //      listOfCountersName.add("power.energy.summation");
        //      listOfCountersName.add("power.power.average");
        //      //listOfCountersName.add("power.power.average"); //counter id=327
        //      listOfCountersName.add("power.powerCap.average");
            
        //      listOfCountersName.add("rescpu.actav1.latest");
        //      listOfCountersName.add("rescpu.actpk1.latest");
        //      listOfCountersName.add("rescpu.runav1.latest");
        //      listOfCountersName.add("rescpu.actav5.latest");
        //      listOfCountersName.add("rescpu.actpk5.latest");
        //      listOfCountersName.add("rescpu.runav5.latest");
        //      listOfCountersName.add("rescpu.actav15.latest");
        //      listOfCountersName.add("rescpu.actpk15.latest");
        //      listOfCountersName.add("rescpu.runav15.latest");
        //      listOfCountersName.add("rescpu.runpk1.latest");
        //      listOfCountersName.add("rescpu.maxLimited1.latest");
        //      listOfCountersName.add("rescpu.runpk5.latest");
        //      listOfCountersName.add("rescpu.maxLimited5.latest");
        //      listOfCountersName.add("rescpu.runpk15.latest");
        //      listOfCountersName.add("rescpu.maxLimited15.latest");
        //      listOfCountersName.add("rescpu.sampleCount.latest");
        //      listOfCountersName.add("rescpu.samplePeriod.latest");
        //
        //      listOfCountersName.add("storageAdapter.commandsAveraged.average");
        //      listOfCountersName.add("storageAdapter.numberReadAveraged.average");
        //      listOfCountersName.add("storageAdapter.numberWriteAveraged.average");
        //      listOfCountersName.add("storageAdapter.read.average");
        //      listOfCountersName.add("storageAdapter.write.average");
        //      listOfCountersName.add("storageAdapter.totalReadLatency.average");
        //      listOfCountersName.add("storageAdapter.totalWriteLatency.average");
               
        //      listOfCountersName.add("storagePath.commandsAveraged.average");
        //      listOfCountersName.add("storagePath.numberReadAveraged.average");
        //      listOfCountersName.add("storagePath.numberWriteAveraged.average");
            
        //      listOfCountersName.add("storagePath.read.average");
        //      listOfCountersName.add("storagePath.write.average");
        //      listOfCountersName.add("storagePath.totalReadLatency.average");
        //      listOfCountersName.add("storagePath.totalWriteLatency.average");
            
        //      listOfCountersName.add("sys.uptime.latest");
        //      listOfCountersName.add("sys.diskUsage.latest");
        //      listOfCountersName.add("sys.resourceCpuUsage.average");
        //      listOfCountersName.add("sys.resourceMemTouched.latest");
        //      listOfCountersName.add("sys.resourceMemMapped.latest");
        //      listOfCountersName.add("sys.resourceMemShared.latest");
        //      listOfCountersName.add("sys.resourceMemSwapped.latest");
        //      listOfCountersName.add("sys.resourceMemOverhead.latest");
        //      listOfCountersName.add("sys.resourceMemCow.latest");
        //      listOfCountersName.add("sys.resourceMemZero.latest");
        //      listOfCountersName.add("sys.resourceCpuRun1.latest");
        //      listOfCountersName.add("sys.resourceCpuAct1.latest");
        //      listOfCountersName.add("sys.resourceCpuMaxLimited1.latest");
        //      listOfCountersName.add("sys.resourceCpuRun5.latest");
        //      listOfCountersName.add("sys.resourceCpuAct5.latest");
        //      listOfCountersName.add("sys.resourceCpuMaxLimited5.latest");
        //      listOfCountersName.add("sys.resourceCpuAllocMin.latest");
        //      listOfCountersName.add("sys.resourceCpuAllocMax.latest");
        //      listOfCountersName.add("sys.resourceCpuAllocShares.latest");
        //      listOfCountersName.add("sys.resourceMemAllocMin.latest");
        //      listOfCountersName.add("sys.resourceMemAllocMax.latest");
        //      listOfCountersName.add("sys.resourceMemAllocShares.latest");
             
        */

        return listOfCountersName;

    }

    public void getResourcePoolPerf() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // 
        // =========================================================================================
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS");
        Calendar curTime = null;

        try {
            curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance());
        } catch (RuntimeFault e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        //System.out.println("curTime: "+curTime);
        //System.out.println("curTime: "+curTime.getTime());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName());
        //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID());
        //System.out.println("curTime lenient: "+curTime.isLenient());

        Calendar startTime = (Calendar) curTime.clone();
        //startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1);

        startTime.set(Calendar.HOUR_OF_DAY, 23);
        startTime.set(Calendar.MINUTE, 30);
        startTime.set(Calendar.SECOND, 00);
        startTime.set(Calendar.MILLISECOND, 00);
        startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1);

        Calendar endTime = (Calendar) curTime.clone();
        endTime.set(Calendar.HOUR_OF_DAY, 23);
        endTime.set(Calendar.MINUTE, 59);
        endTime.set(Calendar.SECOND, 59);
        endTime.set(Calendar.MILLISECOND, 00);
        endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1);

        startTime.roll(Calendar.DATE, -2);
        endTime.roll(Calendar.DATE, -1);

        System.out.println("StartTime: " + dateFormat.format(startTime.getTime()));
        System.out.println("EndTime: " + dateFormat.format(endTime.getTime()));

        // =========================================================================================
        // 
        // =========================================================================================
        ArrayList<TreeNode> listOfTreeNodes = new ArrayList<TreeNode>();
        ArrayList<ResourcePool> listOfResourcePools = new ArrayList<ResourcePool>();

        ResourcePoolManager resourcePoolManager = ResourcePoolManager.getInstance();
        ResourcePool resourcePool = resourcePoolManager.getResourcePoolByName(hostName, "ResourcePool1_1");
        //listOfResourcePools.add(resourcePool);
        listOfTreeNodes.add(resourcePool);

        System.out.println("ResourcePool: " + resourcePool.getMor().get_value());

        // Initialize the Performance Engine
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);

        // =========================================================================================
        // 
        // =========================================================================================
        PerfMetricId[] arrOfPerfMetricIds = null;
        arrOfPerfMetricIds = performanceManager.getAvailablePerfCounter(resourcePool, null, null, 300);

        // Get the Performance Counters
        PerfMetricId[] arrayOfPerfMetricIds = null;
        PerfQuerySpec[] arrayOfPerfQuerySpecs = null;

        HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager
                .getMapOfPerfCounterInfoByIdByVC().get(hostName);

        arrayOfPerfMetricIds = performanceManager
                .getPerfMetricFromCounterNames(this.getResourcePoolPerformanceCounters(), false, hostName);
        ////arrayOfPerfQuerySpecs=performanceManager.getResourcePoolQueryPerfSpec(listOfResourcePools,arrayOfPerfMetricIds,startTime,endTime);
        //arrayOfPerfQuerySpecs=performanceManager.getQueryPerfSpec(listOfTreeNodes,arrayOfPerfMetricIds,startTime,endTime,1800);
        arrayOfPerfQuerySpecs = performanceManager.getQueryPerfSpec(listOfTreeNodes, arrayOfPerfMetricIds, null,
                null, 1800);

        PerfCounterInfo perfCounterInfo = null;

        for (PerfMetricId perfMetricId : arrayOfPerfMetricIds) {
            if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId())) {
                perfCounterInfo = mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId());
                System.out.println("Metric: " + perfMetricId.getCounterId() + "/"
                        + perfCounterInfo.getGroupInfo().getKey() + "." + perfCounterInfo.getNameInfo().getKey()
                        + "." + perfCounterInfo.getRollupType().name());
            }
        }

        performanceManager.getPerf(hostName, arrayOfPerfQuerySpecs);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public ArrayList<String> getResourcePoolPerformanceCounters() {
        ArrayList<String> listOfCountersName = new ArrayList<String>();

        listOfCountersName.add("cpu.cpuentitlement.latest");
        listOfCountersName.add("cpu.usagemhz.average");
        listOfCountersName.add("mem.consumed.average");
        listOfCountersName.add("mem.mementitlement.latest");
        listOfCountersName.add("mem.overhead.average");
        listOfCountersName.add("mem.vmmemctl.average");

        return listOfCountersName;

    }

    public void getDatacenterPerf_() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Construction des dates de Dpart de Fin pour la collecte des statistiques
        // =========================================================================================
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS");
        Calendar curTime = null;

        try {
            curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance());
        } catch (RuntimeFault e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        //System.out.println("curTime: "+curTime);
        //System.out.println("curTime: "+curTime.getTime());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName());
        //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID());
        //System.out.println("curTime lenient: "+curTime.isLenient());

        Calendar startTime = (Calendar) curTime.clone();
        //startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1);

        startTime.set(Calendar.HOUR_OF_DAY, 23);
        startTime.set(Calendar.MINUTE, 30);
        startTime.set(Calendar.SECOND, 00);
        startTime.set(Calendar.MILLISECOND, 00);
        startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1);

        Calendar endTime = (Calendar) curTime.clone();
        endTime.set(Calendar.HOUR_OF_DAY, 23);
        endTime.set(Calendar.MINUTE, 59);
        endTime.set(Calendar.SECOND, 59);
        endTime.set(Calendar.MILLISECOND, 00);
        endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1);

        startTime.roll(Calendar.DATE, -2);
        endTime.roll(Calendar.DATE, -1);

        System.out.println("StartTime: " + dateFormat.format(startTime.getTime()));
        System.out.println("EndTime: " + dateFormat.format(endTime.getTime()));

        // =========================================================================================
        // 
        // =========================================================================================
        ArrayList<TreeNode> listOfTreeNodes = new ArrayList<TreeNode>();

        DatacenterManager datacenterManager = DatacenterManager.getInstance();
        Datacenter datacenter = datacenterManager.getDatacenterByName("RISC_POC", hostName);
        listOfTreeNodes.add(datacenter);

        System.out.println("Datacenter: " + datacenter.getMor().get_value());

        // Initialize the Performance Engine
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);

        // =========================================================================================
        // 
        // =========================================================================================
        //PerfMetricId[] arrOfPerfMetricIds=null;
        //arrOfPerfMetricIds=performanceManager.getAvailablePerfCounter(datacenter, null, null, 300);

        // Get the Performance Counters
        PerfMetricId[] arrayOfPerfMetricIds = null;
        PerfQuerySpec[] arrayOfPerfQuerySpecs = null;

        HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager
                .getMapOfPerfCounterInfoByIdByVC().get(hostName);

        arrayOfPerfMetricIds = performanceManager
                .getPerfMetricFromCounterNames(this.getDatacenterPerformanceCounters(), false, hostName);
        arrayOfPerfQuerySpecs = performanceManager.getQueryPerfSpec(listOfTreeNodes, arrayOfPerfMetricIds,
                startTime, endTime, 300);

        /*
        PerfCounterInfo perfCounterInfo=null;
        for (PerfMetricId perfMetricId:arrayOfPerfMetricIds)
        {
           if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId()))
           {
        perfCounterInfo=mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId());
        System.out.println("Metric: "+perfMetricId.getCounterId()+"/"+perfCounterInfo.getGroupInfo().getKey()+"."+perfCounterInfo.getNameInfo().getKey()+"."+perfCounterInfo.getRollupType().name());
           }
        }
        */

        performanceManager.getPerf(hostName, arrayOfPerfQuerySpecs);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public ArrayList<String> getDatacenterPerformanceCounters() {
        ArrayList<String> listOfCountersName = new ArrayList<String>();

        listOfCountersName.add("vmop.numPoweron.latest");
        listOfCountersName.add("vmop.numPoweroff.latest");

        listOfCountersName.add("vmop.numSuspend.latest");
        listOfCountersName.add("vmop.numReset.latest");
        listOfCountersName.add("vmop.numRebootGuest.latest");
        listOfCountersName.add("vmop.numStandbyGuest.latest");
        listOfCountersName.add("vmop.numShutdownGuest.latest");
        listOfCountersName.add("vmop.numCreate.latest");
        listOfCountersName.add("vmop.numDestroy.latest");
        listOfCountersName.add("vmop.numRegister.latest");
        listOfCountersName.add("vmop.numUnregister.latest");
        listOfCountersName.add("vmop.numReconfigure.latest");
        listOfCountersName.add("vmop.numClone.latest");
        listOfCountersName.add("vmop.numDeploy.latest");
        listOfCountersName.add("vmop.numChangeHost.latest");
        listOfCountersName.add("vmop.numChangeDS.latest");
        listOfCountersName.add("vmop.numChangeHostDS.latest");
        listOfCountersName.add("vmop.numVMotion.latest");
        listOfCountersName.add("vmop.numSVMotion.latest");

        return listOfCountersName;

    }

    public void getClusterPerf() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Construction des dates de Dpart de Fin pour la collecte des statistiques
        // =========================================================================================
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS");
        Calendar curTime = null;

        try {
            curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance());
        } catch (RuntimeFault e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        //System.out.println("curTime: "+curTime);
        //System.out.println("curTime: "+curTime.getTime());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName());
        //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID());
        //System.out.println("curTime lenient: "+curTime.isLenient());

        Calendar startTime = (Calendar) curTime.clone();
        //startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1);

        startTime.set(Calendar.HOUR_OF_DAY, 23);
        startTime.set(Calendar.MINUTE, 30);
        startTime.set(Calendar.SECOND, 00);
        startTime.set(Calendar.MILLISECOND, 00);
        startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1);

        Calendar endTime = (Calendar) curTime.clone();
        endTime.set(Calendar.HOUR_OF_DAY, 23);
        endTime.set(Calendar.MINUTE, 59);
        endTime.set(Calendar.SECOND, 59);
        endTime.set(Calendar.MILLISECOND, 00);
        endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1);

        startTime.roll(Calendar.DATE, -2);
        endTime.roll(Calendar.DATE, -1);

        System.out.println("StartTime: " + dateFormat.format(startTime.getTime()));
        System.out.println("EndTime: " + dateFormat.format(endTime.getTime()));

        // =========================================================================================
        // 
        // =========================================================================================
        ArrayList<TreeNode> listOfTreeNodes = new ArrayList<TreeNode>();

        ResourceManager resourceManager = ResourceManager.getInstance();
        ClusterComputeResource cluster = resourceManager.getClusterComputeResourceByName("SIVEO", hostName);
        listOfTreeNodes.add(cluster);

        System.out.println("Cluster: " + cluster.getMor().get_value());

        // Initialize the Performance Engine
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);

        // =========================================================================================
        // 
        // =========================================================================================
        //PerfMetricId[] arrOfPerfMetricIds=null;
        //arrOfPerfMetricIds=performanceManager.getAvailablePerfCounter(datacenter, null, null, 300);
        performanceManager.getAvailablePerfCounter(cluster, null, null, 300);

        // Get the Performance Counters
        PerfMetricId[] arrayOfPerfMetricIds = null;
        PerfQuerySpec[] arrayOfPerfQuerySpecs = null;

        HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager
                .getMapOfPerfCounterInfoByIdByVC().get(hostName);

        arrayOfPerfMetricIds = performanceManager
                .getPerfMetricFromCounterNames(this.getClusterPerformanceCounters(), true, hostName);
        arrayOfPerfQuerySpecs = performanceManager.getQueryPerfSpec(listOfTreeNodes, arrayOfPerfMetricIds,
                startTime, endTime, 300);

        /*
        PerfCounterInfo perfCounterInfo=null;
        for (PerfMetricId perfMetricId:arrayOfPerfMetricIds)
        {
           if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId()))
           {
        perfCounterInfo=mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId());
        System.out.println("Metric: "+perfMetricId.getCounterId()+"/"+perfCounterInfo.getGroupInfo().getKey()+"."+perfCounterInfo.getNameInfo().getKey()+"."+perfCounterInfo.getRollupType().name());
           }
        }
        */

        performanceManager.getPerf(hostName, arrayOfPerfQuerySpecs);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public ArrayList<String> getClusterPerformanceCounters() {
        ArrayList<String> listOfCountersName = new ArrayList<String>();

        listOfCountersName.add("cpu.usage.average");
        listOfCountersName.add("cpu.usagemhz.average");
        listOfCountersName.add("mem.consumed.average");
        listOfCountersName.add("mem.overhead.average");
        listOfCountersName.add("mem.usage.average");
        listOfCountersName.add("mem.vmmemctl.average");

        listOfCountersName.add("vmop.numPoweron.latest");
        listOfCountersName.add("vmop.numPoweroff.latest");
        listOfCountersName.add("vmop.numSuspend.latest");
        listOfCountersName.add("vmop.numReset.latest");
        listOfCountersName.add("vmop.numRebootGuest.latest");
        listOfCountersName.add("vmop.numStandbyGuest.latest");
        listOfCountersName.add("vmop.numShutdownGuest.latest");
        listOfCountersName.add("vmop.numCreate.latest");
        listOfCountersName.add("vmop.numDestroy.latest");
        listOfCountersName.add("vmop.numRegister.latest");
        listOfCountersName.add("vmop.numUnregister.latest");
        listOfCountersName.add("vmop.numReconfigure.latest");
        listOfCountersName.add("vmop.numClone.latest");
        listOfCountersName.add("vmop.numDeploy.latest");
        listOfCountersName.add("vmop.numChangeHost.latest");
        listOfCountersName.add("vmop.numChangeDS.latest");
        listOfCountersName.add("vmop.numChangeHostDS.latest");
        listOfCountersName.add("vmop.numVMotion.latest");
        listOfCountersName.add("vmop.numSVMotion.latest");

        /*      
              listOfCountersName.add("clusterServices.cpufairness.latest");
              listOfCountersName.add("clusterServices.effectivecpu.average");
              listOfCountersName.add("clusterServices.effectivemem.average");
              listOfCountersName.add("clusterServices.failover.latest");
              listOfCountersName.add("clusterServices.memfairness.latest");
              listOfCountersName.add("cpu.reservedCapacity.average");
              listOfCountersName.add("cpu.totalmhz.average");
              listOfCountersName.add("cpu.usage.average");
              listOfCountersName.add("cpu.usage.maximum");
              listOfCountersName.add("cpu.usage.minimum");
              listOfCountersName.add("cpu.usage.none");
              listOfCountersName.add("cpu.usagemhz.average");
              listOfCountersName.add("cpu.usagemhz.maximum");
              listOfCountersName.add("cpu.usagemhz.minimum");
              listOfCountersName.add("cpu.usagemhz.none");
              listOfCountersName.add("mem.active.average");
              listOfCountersName.add("mem.active.maximum");
              listOfCountersName.add("mem.active.minimum");
              listOfCountersName.add("mem.active.none");
              listOfCountersName.add("mem.consumed.average");
              listOfCountersName.add("mem.consumed.maximum");
              listOfCountersName.add("mem.consumed.minimum");
              listOfCountersName.add("mem.consumed.none");
              listOfCountersName.add("mem.granted.average");
              listOfCountersName.add("mem.granted.maximum");
              listOfCountersName.add("mem.granted.minimum");
              listOfCountersName.add("mem.granted.none");
              listOfCountersName.add("mem.reservedCapacity.average");
              listOfCountersName.add("mem.swapunreserved.average");
              listOfCountersName.add("mem.swapunreserved.maximum");
              listOfCountersName.add("mem.swapunreserved.minimum");
              listOfCountersName.add("mem.swapunreserved.none");
              listOfCountersName.add("mem.swapused.average");
              listOfCountersName.add("mem.swapused.maximum");
              listOfCountersName.add("mem.swapused.minimum");
              listOfCountersName.add("mem.swapused.none");
              listOfCountersName.add("mem.totalmb.average");
              listOfCountersName.add("mem.vmmemctl.average");
              listOfCountersName.add("mem.vmmemctl.maximum");
              listOfCountersName.add("mem.vmmemctl.minimum");
              listOfCountersName.add("mem.vmmemctl.none");
        */

        return listOfCountersName;

    }

    public void getDatastorePerf() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Initialize Variables
        // =========================================================================================
        // Initialize the Performance Engine
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);

        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        //Datastore datastore=dataStoreManager.getDatastoreByName("VCE-AMP-2", hostName);
        Datastore datastore = dataStoreManager.getDatastoreByName("SIVEO_ADMIN", hostName);
        System.out.println("DataStore: " + datastore.getMor().get_value());

        // Get the Performance Counters
        PerfMetricId[] arrayOfPerfMetricIds = null;
        PerfQuerySpec[] arrayOfPerfQuerySpecs = null;
        DataStoreManager dsManager = DataStoreManager.getInstance();

        HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = performanceManager
                .getMapOfPerfCounterInfoByIdByVC().get(hostName);

        // =========================================================================================
        // Get Datastore Performance Counters
        // =========================================================================================
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS");
        Calendar curTime = null;

        try {
            curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance());
        } catch (RuntimeFault e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        //System.out.println("curTime: "+curTime);
        //System.out.println("curTime: "+curTime.getTime());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone());
        //System.out.println("curTime timeZone: "+curTime.getTimeZone().getDisplayName());
        //System.out.println("curTime timeZone id: "+curTime.getTimeZone().getID());
        //System.out.println("curTime lenient: "+curTime.isLenient());

        Calendar startTime = (Calendar) curTime.clone();
        //startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY)-1);

        startTime.set(Calendar.HOUR_OF_DAY, 23);
        startTime.set(Calendar.MINUTE, 30);
        startTime.set(Calendar.SECOND, 00);
        startTime.set(Calendar.MILLISECOND, 00);
        startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1);

        Calendar endTime = (Calendar) curTime.clone();
        endTime.set(Calendar.HOUR_OF_DAY, 23);
        endTime.set(Calendar.MINUTE, 59);
        endTime.set(Calendar.SECOND, 59);
        endTime.set(Calendar.MILLISECOND, 00);
        endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1);

        startTime.roll(Calendar.DATE, -2);
        endTime.roll(Calendar.DATE, -1);

        //System.out.println("Ecart entre dbut et fin: "+(endTime.getTime().getTime()-startTime.getTime().getTime()));

        for (String counterName : this.getDatastorePerformanceCountersName()) {
            System.out.println("Counter: " + counterName);
        }

        arrayOfPerfMetricIds = performanceManager
                .getPerfMetricFromCounterNames(this.getDatastorePerformanceCountersName(), false, hostName);
        arrayOfPerfQuerySpecs = performanceManager.getDSQueryPerfSpec(dsManager.getAllDatastore(hostName),
                arrayOfPerfMetricIds, startTime, endTime);

        PerfCounterInfo perfCounterInfo = null;

        for (PerfMetricId perfMetricId : arrayOfPerfMetricIds) {
            if (mapOfPerfCounterInfoByID.containsKey(perfMetricId.getCounterId())) {
                perfCounterInfo = mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId());
                System.out.println("Metric: " + perfMetricId.getCounterId() + "/"
                        + perfCounterInfo.getGroupInfo().getKey() + "." + perfCounterInfo.getNameInfo().getKey()
                        + "." + perfCounterInfo.getRollupType().name());
            }
        }

        System.out.println("StartTime: " + dateFormat.format(startTime.getTime()));
        System.out.println("EndTime: " + dateFormat.format(endTime.getTime()));

        performanceManager.getPerfDS(hostName, arrayOfPerfQuerySpecs);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public ArrayList<String> getDatastorePerformanceCountersName() {
        ArrayList<String> listOfCountersName = new ArrayList<String>();

        listOfCountersName.add("disk.capacity.latest");
        listOfCountersName.add("disk.provisioned.latest");
        listOfCountersName.add("disk.unshared.latest");
        listOfCountersName.add("disk.used.latest");

        return listOfCountersName;

    }

    public void getDatacenterPerf() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        Calendar curTime = null;
        try {
            curTime = ws.getVIMService().getService().currentTime(ws.getVIMService().getServiceInstance());
        } catch (RuntimeFault e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (RemoteException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        DatacenterManager datacenterManager = DatacenterManager.getInstance();
        ArrayList<Datacenter> listOfDatacenter = datacenterManager.getAllDatacenter(hostName);
        ArrayList<TreeNode> listOfTreeNodes = new ArrayList<TreeNode>();

        if (listOfDatacenter != null && !listOfDatacenter.isEmpty()) {
            for (Datacenter datacenter : listOfDatacenter) {
                listOfTreeNodes.add((TreeNode) datacenter);
            }
        }

        Calendar startTime = (Calendar) curTime.clone();
        //startTime.roll(Calendar.DATE, -1);

        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);

        performanceManager.getPerfDC(listOfTreeNodes, startTime, null, 300);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public ArrayList<String> getAllPerformanceCounters() {
        ArrayList<String> listOfCountersName = new ArrayList<String>();

        listOfCountersName.add("clusterServices.cpufairness.latest");
        listOfCountersName.add("clusterServices.effectivecpu.average");
        listOfCountersName.add("clusterServices.effectivemem.average");
        listOfCountersName.add("clusterServices.failover.latest");
        listOfCountersName.add("clusterServices.memfairness.latest");
        listOfCountersName.add("cpu.coreUtilization.average");
        listOfCountersName.add("cpu.coreUtilization.maximum");
        listOfCountersName.add("cpu.coreUtilization.minimum");
        listOfCountersName.add("cpu.coreUtilization.none");
        listOfCountersName.add("cpu.cpuentitlement.latest");
        listOfCountersName.add("cpu.idle.summation");
        listOfCountersName.add("cpu.ready.summation");
        listOfCountersName.add("cpu.reservedCapacity.average");
        listOfCountersName.add("cpu.swapwait.summation");
        listOfCountersName.add("cpu.system.summation");
        listOfCountersName.add("cpu.totalCapacity.average");
        listOfCountersName.add("cpu.totalmhz.average");
        listOfCountersName.add("cpu.usage.average");
        listOfCountersName.add("cpu.usage.maximum");
        listOfCountersName.add("cpu.usage.minimum");
        listOfCountersName.add("cpu.usage.none");
        listOfCountersName.add("cpu.usagemhz.average");
        listOfCountersName.add("cpu.usagemhz.maximum");
        listOfCountersName.add("cpu.usagemhz.minimum");
        listOfCountersName.add("cpu.usagemhz.none");
        listOfCountersName.add("cpu.used.summation");
        listOfCountersName.add("cpu.utilization.average");
        listOfCountersName.add("cpu.utilization.maximum");
        listOfCountersName.add("cpu.utilization.minimum");
        listOfCountersName.add("cpu.utilization.none");
        listOfCountersName.add("cpu.wait.summation");
        listOfCountersName.add("datastore.datastoreIops.average");
        listOfCountersName.add("datastore.numberReadAveraged.average");
        listOfCountersName.add("datastore.numberWriteAveraged.average");
        listOfCountersName.add("datastore.read.average");
        listOfCountersName.add("datastore.sizeNormalizedDatastoreLatency.average");
        listOfCountersName.add("datastore.totalReadLatency.average");
        listOfCountersName.add("datastore.totalWriteLatency.average");
        listOfCountersName.add("datastore.write.average");
        listOfCountersName.add("disk.busResets.summation");
        listOfCountersName.add("disk.capacity.latest");
        listOfCountersName.add("disk.commands.summation");
        listOfCountersName.add("disk.commandsAborted.summation");
        listOfCountersName.add("disk.commandsAveraged.average");
        listOfCountersName.add("disk.deltaused.latest");
        listOfCountersName.add("disk.deviceLatency.average");
        listOfCountersName.add("disk.deviceReadLatency.average");
        listOfCountersName.add("disk.deviceWriteLatency.average");
        listOfCountersName.add("disk.kernelLatency.average");
        listOfCountersName.add("disk.kernelReadLatency.average");
        listOfCountersName.add("disk.kernelWriteLatency.average");
        listOfCountersName.add("disk.maxQueueDepth.average");
        listOfCountersName.add("disk.maxTotalLatency.latest");
        listOfCountersName.add("disk.numberRead.summation");
        listOfCountersName.add("disk.numberReadAveraged.average");
        listOfCountersName.add("disk.numberWrite.summation");
        listOfCountersName.add("disk.numberWriteAveraged.average");
        listOfCountersName.add("disk.provisioned.latest");
        listOfCountersName.add("disk.queueLatency.average");
        listOfCountersName.add("disk.queueReadLatency.average");
        listOfCountersName.add("disk.queueWriteLatency.average");
        listOfCountersName.add("disk.read.average");
        listOfCountersName.add("disk.totalLatency.average");
        listOfCountersName.add("disk.totalReadLatency.average");
        listOfCountersName.add("disk.totalWriteLatency.average");
        listOfCountersName.add("disk.unshared.latest");
        listOfCountersName.add("disk.usage.average");
        listOfCountersName.add("disk.usage.maximum");
        listOfCountersName.add("disk.usage.minimum");
        listOfCountersName.add("disk.usage.none");
        listOfCountersName.add("disk.used.latest");
        listOfCountersName.add("disk.write.average");
        listOfCountersName.add("managementAgent.memUsed.average");
        listOfCountersName.add("managementAgent.swapIn.average");
        listOfCountersName.add("managementAgent.swapOut.average");
        listOfCountersName.add("managementAgent.swapUsed.average");
        listOfCountersName.add("mem.active.average");
        listOfCountersName.add("mem.active.maximum");
        listOfCountersName.add("mem.active.minimum");
        listOfCountersName.add("mem.active.none");
        listOfCountersName.add("mem.activewrite.average");
        listOfCountersName.add("mem.compressed.average");
        listOfCountersName.add("mem.compressionRate.average");
        listOfCountersName.add("mem.consumed.average");
        listOfCountersName.add("mem.consumed.maximum");
        listOfCountersName.add("mem.consumed.minimum");
        listOfCountersName.add("mem.consumed.none");
        listOfCountersName.add("mem.decompressionRate.average");
        listOfCountersName.add("mem.granted.average");
        listOfCountersName.add("mem.granted.maximum");
        listOfCountersName.add("mem.granted.minimum");
        listOfCountersName.add("mem.granted.none");
        listOfCountersName.add("mem.heap.average");
        listOfCountersName.add("mem.heap.maximum");
        listOfCountersName.add("mem.heap.minimum");
        listOfCountersName.add("mem.heap.none");
        listOfCountersName.add("mem.heapfree.average");
        listOfCountersName.add("mem.heapfree.maximum");
        listOfCountersName.add("mem.heapfree.minimum");
        listOfCountersName.add("mem.heapfree.none");
        listOfCountersName.add("mem.mementitlement.latest");
        listOfCountersName.add("mem.overhead.average");
        listOfCountersName.add("mem.overhead.maximum");
        listOfCountersName.add("mem.overhead.minimum");
        listOfCountersName.add("mem.overhead.none");
        listOfCountersName.add("mem.overheadMax.average");
        listOfCountersName.add("mem.reservedCapacity.average");
        listOfCountersName.add("mem.shared.average");
        listOfCountersName.add("mem.shared.maximum");
        listOfCountersName.add("mem.shared.minimum");
        listOfCountersName.add("mem.shared.none");
        listOfCountersName.add("mem.sharedcommon.average");
        listOfCountersName.add("mem.sharedcommon.maximum");
        listOfCountersName.add("mem.sharedcommon.minimum");
        listOfCountersName.add("mem.sharedcommon.none");
        listOfCountersName.add("mem.state.latest");
        listOfCountersName.add("mem.swapIn.average");
        listOfCountersName.add("mem.swapin.average");
        listOfCountersName.add("mem.swapIn.maximum");
        listOfCountersName.add("mem.swapin.maximum");
        listOfCountersName.add("mem.swapIn.minimum");
        listOfCountersName.add("mem.swapin.minimum");
        listOfCountersName.add("mem.swapIn.none");
        listOfCountersName.add("mem.swapin.none");
        listOfCountersName.add("mem.swapinRate.average");
        listOfCountersName.add("mem.swapOut.average");
        listOfCountersName.add("mem.swapout.average");
        listOfCountersName.add("mem.swapOut.maximum");
        listOfCountersName.add("mem.swapout.maximum");
        listOfCountersName.add("mem.swapOut.minimum");
        listOfCountersName.add("mem.swapout.minimum");
        listOfCountersName.add("mem.swapOut.none");
        listOfCountersName.add("mem.swapout.none");
        listOfCountersName.add("mem.swapoutRate.average");
        listOfCountersName.add("mem.swapped.average");
        listOfCountersName.add("mem.swapped.maximum");
        listOfCountersName.add("mem.swapped.minimum");
        listOfCountersName.add("mem.swapped.none");
        listOfCountersName.add("mem.swaptarget.average");
        listOfCountersName.add("mem.swaptarget.maximum");
        listOfCountersName.add("mem.swaptarget.minimum");
        listOfCountersName.add("mem.swaptarget.none");
        listOfCountersName.add("mem.swapunreserved.average");
        listOfCountersName.add("mem.swapunreserved.maximum");
        listOfCountersName.add("mem.swapunreserved.minimum");
        listOfCountersName.add("mem.swapunreserved.none");
        listOfCountersName.add("mem.swapused.average");
        listOfCountersName.add("mem.swapused.maximum");
        listOfCountersName.add("mem.swapused.minimum");
        listOfCountersName.add("mem.swapused.none");
        listOfCountersName.add("mem.sysUsage.average");
        listOfCountersName.add("mem.sysUsage.maximum");
        listOfCountersName.add("mem.sysUsage.minimum");
        listOfCountersName.add("mem.sysUsage.none");
        listOfCountersName.add("mem.totalCapacity.average");
        listOfCountersName.add("mem.totalmb.average");
        listOfCountersName.add("mem.unreserved.average");
        listOfCountersName.add("mem.unreserved.maximum");
        listOfCountersName.add("mem.unreserved.minimum");
        listOfCountersName.add("mem.unreserved.none");
        listOfCountersName.add("mem.usage.average");
        listOfCountersName.add("mem.usage.maximum");
        listOfCountersName.add("mem.usage.minimum");
        listOfCountersName.add("mem.usage.none");
        listOfCountersName.add("mem.vmmemctl.average");
        listOfCountersName.add("mem.vmmemctl.maximum");
        listOfCountersName.add("mem.vmmemctl.minimum");
        listOfCountersName.add("mem.vmmemctl.none");
        listOfCountersName.add("mem.vmmemctltarget.average");
        listOfCountersName.add("mem.vmmemctltarget.maximum");
        listOfCountersName.add("mem.vmmemctltarget.minimum");
        listOfCountersName.add("mem.vmmemctltarget.none");
        listOfCountersName.add("mem.zero.average");
        listOfCountersName.add("mem.zero.maximum");
        listOfCountersName.add("mem.zero.minimum");
        listOfCountersName.add("mem.zero.none");
        listOfCountersName.add("mem.zipped.latest");
        listOfCountersName.add("mem.zipSaved.latest");
        listOfCountersName.add("net.droppedRx.summation");
        listOfCountersName.add("net.droppedTx.summation");
        listOfCountersName.add("net.packetsRx.summation");
        listOfCountersName.add("net.packetsTx.summation");
        listOfCountersName.add("net.received.average");
        listOfCountersName.add("net.transmitted.average");
        listOfCountersName.add("net.usage.average");
        listOfCountersName.add("net.usage.maximum");
        listOfCountersName.add("net.usage.minimum");
        listOfCountersName.add("net.usage.none");
        listOfCountersName.add("power.energy.summation");
        listOfCountersName.add("power.power.average");
        listOfCountersName.add("power.power.average");
        listOfCountersName.add("power.powerCap.average");
        listOfCountersName.add("rescpu.actav1.latest");
        listOfCountersName.add("rescpu.actav15.latest");
        listOfCountersName.add("rescpu.actav5.latest");
        listOfCountersName.add("rescpu.actpk1.latest");
        listOfCountersName.add("rescpu.actpk15.latest");
        listOfCountersName.add("rescpu.actpk5.latest");
        listOfCountersName.add("rescpu.maxLimited1.latest");
        listOfCountersName.add("rescpu.maxLimited15.latest");
        listOfCountersName.add("rescpu.maxLimited5.latest");
        listOfCountersName.add("rescpu.runav1.latest");
        listOfCountersName.add("rescpu.runav15.latest");
        listOfCountersName.add("rescpu.runav5.latest");
        listOfCountersName.add("rescpu.runpk1.latest");
        listOfCountersName.add("rescpu.runpk15.latest");
        listOfCountersName.add("rescpu.runpk5.latest");
        listOfCountersName.add("rescpu.sampleCount.latest");
        listOfCountersName.add("rescpu.samplePeriod.latest");
        listOfCountersName.add("storageAdapter.commandsAveraged.average");
        listOfCountersName.add("storageAdapter.numberReadAveraged.average");
        listOfCountersName.add("storageAdapter.numberWriteAveraged.average");
        listOfCountersName.add("storageAdapter.read.average");
        listOfCountersName.add("storageAdapter.totalReadLatency.average");
        listOfCountersName.add("storageAdapter.totalWriteLatency.average");
        listOfCountersName.add("storageAdapter.write.average");
        listOfCountersName.add("storagePath.commandsAveraged.average");
        listOfCountersName.add("storagePath.numberReadAveraged.average");
        listOfCountersName.add("storagePath.numberWriteAveraged.average");
        listOfCountersName.add("storagePath.read.average");
        listOfCountersName.add("storagePath.totalReadLatency.average");
        listOfCountersName.add("storagePath.totalWriteLatency.average");
        listOfCountersName.add("storagePath.write.average");
        listOfCountersName.add("sys.cosDiskUsage.latest");
        listOfCountersName.add("sys.diskUsage.latest");
        listOfCountersName.add("sys.heartbeat.summation");
        listOfCountersName.add("sys.resourceCpuAct1.latest");
        listOfCountersName.add("sys.resourceCpuAct5.latest");
        listOfCountersName.add("sys.resourceCpuAllocMax.latest");
        listOfCountersName.add("sys.resourceCpuAllocMin.latest");
        listOfCountersName.add("sys.resourceCpuAllocShares.latest");
        listOfCountersName.add("sys.resourceCpuMaxLimited1.latest");
        listOfCountersName.add("sys.resourceCpuMaxLimited5.latest");
        listOfCountersName.add("sys.resourceCpuRun1.latest");
        listOfCountersName.add("sys.resourceCpuRun5.latest");
        listOfCountersName.add("sys.resourceCpuUsage.average");
        listOfCountersName.add("sys.resourceCpuUsage.maximum");
        listOfCountersName.add("sys.resourceCpuUsage.minimum");
        listOfCountersName.add("sys.resourceCpuUsage.none");
        listOfCountersName.add("sys.resourceMemAllocMax.latest");
        listOfCountersName.add("sys.resourceMemAllocMin.latest");
        listOfCountersName.add("sys.resourceMemAllocShares.latest");
        listOfCountersName.add("sys.resourceMemCow.latest");
        listOfCountersName.add("sys.resourceMemMapped.latest");
        listOfCountersName.add("sys.resourceMemOverhead.latest");
        listOfCountersName.add("sys.resourceMemShared.latest");
        listOfCountersName.add("sys.resourceMemSwapped.latest");
        listOfCountersName.add("sys.resourceMemTouched.latest");
        listOfCountersName.add("sys.resourceMemZero.latest");
        listOfCountersName.add("sys.uptime.latest");
        listOfCountersName.add("vcDebugInfo.activationlatencystats.maximum");
        listOfCountersName.add("vcDebugInfo.activationlatencystats.minimum");
        listOfCountersName.add("vcDebugInfo.activationlatencystats.summation");
        listOfCountersName.add("vcDebugInfo.activationstats.maximum");
        listOfCountersName.add("vcDebugInfo.activationstats.minimum");
        listOfCountersName.add("vcDebugInfo.activationstats.summation");
        listOfCountersName.add("vcDebugInfo.hostsynclatencystats.maximum");
        listOfCountersName.add("vcDebugInfo.hostsynclatencystats.minimum");
        listOfCountersName.add("vcDebugInfo.hostsynclatencystats.summation");
        listOfCountersName.add("vcDebugInfo.hostsyncstats.maximum");
        listOfCountersName.add("vcDebugInfo.hostsyncstats.minimum");
        listOfCountersName.add("vcDebugInfo.hostsyncstats.summation");
        listOfCountersName.add("vcDebugInfo.inventorystats.maximum");
        listOfCountersName.add("vcDebugInfo.inventorystats.minimum");
        listOfCountersName.add("vcDebugInfo.inventorystats.summation");
        listOfCountersName.add("vcDebugInfo.lockstats.maximum");
        listOfCountersName.add("vcDebugInfo.lockstats.minimum");
        listOfCountersName.add("vcDebugInfo.lockstats.summation");
        listOfCountersName.add("vcDebugInfo.lrostats.maximum");
        listOfCountersName.add("vcDebugInfo.lrostats.minimum");
        listOfCountersName.add("vcDebugInfo.lrostats.summation");
        listOfCountersName.add("vcDebugInfo.miscstats.maximum");
        listOfCountersName.add("vcDebugInfo.miscstats.minimum");
        listOfCountersName.add("vcDebugInfo.miscstats.summation");
        listOfCountersName.add("vcDebugInfo.morefregstats.maximum");
        listOfCountersName.add("vcDebugInfo.morefregstats.minimum");
        listOfCountersName.add("vcDebugInfo.morefregstats.summation");
        listOfCountersName.add("vcDebugInfo.scoreboard.maximum");
        listOfCountersName.add("vcDebugInfo.scoreboard.minimum");
        listOfCountersName.add("vcDebugInfo.scoreboard.summation");
        listOfCountersName.add("vcDebugInfo.sessionstats.maximum");
        listOfCountersName.add("vcDebugInfo.sessionstats.minimum");
        listOfCountersName.add("vcDebugInfo.sessionstats.summation");
        listOfCountersName.add("vcDebugInfo.systemstats.maximum");
        listOfCountersName.add("vcDebugInfo.systemstats.minimum");
        listOfCountersName.add("vcDebugInfo.systemstats.summation");
        listOfCountersName.add("vcDebugInfo.vcservicestats.maximum");
        listOfCountersName.add("vcDebugInfo.vcservicestats.minimum");
        listOfCountersName.add("vcDebugInfo.vcservicestats.summation");
        listOfCountersName.add("vcResources.cpuqueuelength.average");
        listOfCountersName.add("vcResources.ctxswitchesrate.average");
        listOfCountersName.add("vcResources.diskqueuelength.average");
        listOfCountersName.add("vcResources.diskreadbytesrate.average");
        listOfCountersName.add("vcResources.diskreadsrate.average");
        listOfCountersName.add("vcResources.diskwritebytesrate.average");
        listOfCountersName.add("vcResources.diskwritesrate.average");
        listOfCountersName.add("vcResources.netqueuelength.average");
        listOfCountersName.add("vcResources.packetrate.average");
        listOfCountersName.add("vcResources.packetrecvrate.average");
        listOfCountersName.add("vcResources.packetsentrate.average");
        listOfCountersName.add("vcResources.pagefaultrate.average");
        listOfCountersName.add("vcResources.physicalmemusage.average");
        listOfCountersName.add("vcResources.poolnonpagedbytes.average");
        listOfCountersName.add("vcResources.poolpagedbytes.average");
        listOfCountersName.add("vcResources.priviledgedcpuusage.average");
        listOfCountersName.add("vcResources.processcpuusage.average");
        listOfCountersName.add("vcResources.processhandles.average");
        listOfCountersName.add("vcResources.processthreads.average");
        listOfCountersName.add("vcResources.syscallsrate.average");
        listOfCountersName.add("vcResources.systemcpuusage.average");
        listOfCountersName.add("vcResources.systemnetusage.average");
        listOfCountersName.add("vcResources.systemthreads.average");
        listOfCountersName.add("vcResources.usercpuusage.average");
        listOfCountersName.add("vcResources.virtualmemusage.average");
        listOfCountersName.add("virtualDisk.numberReadAveraged.average");
        listOfCountersName.add("virtualDisk.numberWriteAveraged.average");
        listOfCountersName.add("virtualDisk.read.average");
        listOfCountersName.add("virtualDisk.totalReadLatency.average");
        listOfCountersName.add("virtualDisk.totalWriteLatency.average");
        listOfCountersName.add("virtualDisk.write.average");
        listOfCountersName.add("vmop.numChangeDS.latest");
        listOfCountersName.add("vmop.numChangeHost.latest");
        listOfCountersName.add("vmop.numChangeHostDS.latest");
        listOfCountersName.add("vmop.numClone.latest");
        listOfCountersName.add("vmop.numCreate.latest");
        listOfCountersName.add("vmop.numDeploy.latest");
        listOfCountersName.add("vmop.numDestroy.latest");
        listOfCountersName.add("vmop.numPoweroff.latest");
        listOfCountersName.add("vmop.numPoweron.latest");
        listOfCountersName.add("vmop.numRebootGuest.latest");
        listOfCountersName.add("vmop.numReconfigure.latest");
        listOfCountersName.add("vmop.numRegister.latest");
        listOfCountersName.add("vmop.numReset.latest");
        listOfCountersName.add("vmop.numShutdownGuest.latest");
        listOfCountersName.add("vmop.numStandbyGuest.latest");
        listOfCountersName.add("vmop.numSuspend.latest");
        listOfCountersName.add("vmop.numSVMotion.latest");
        listOfCountersName.add("vmop.numUnregister.latest");
        listOfCountersName.add("vmop.numVMotion.latest");

        return listOfCountersName;

    }

    public void getPerfCounters() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        PerformanceManager performanceManager = PerformanceManager.getInstance();

        ArrayList<Counter> listOfCounters = performanceManager.getAllCounters(hostName);

        if (listOfCounters != null && !listOfCounters.isEmpty()) {

            for (Counter counter : listOfCounters) {
                /*
                System.out.println(counter.getGroupKey()+";"+counter.getFullName()+";"+counter.getDescription()+";"+counter.getRollupType()+";"+counter.getStatisticsType()+";"+counter.getUnitKey());
                    
                    
                System.out.println("INSERT INTO counter (id,nom,categorie,stat_type,unite,vi_type) VALUES (nextval('counter_id'),'"+
                       counter.getFullName()+"','"+counter.getGroupKey()+"','"+counter.getStatisticsType()+"','"+counter.getUnitKey()+"','vmware');"
                      );
                */

                System.out.println("Counter: " + counter.getId() + " / " + counter.getFullName());
                System.out.println("- Group Key: " + counter.getGroupKey());
                System.out.println("- Group Name: " + counter.getGroupName());
                System.out.println("- Level: " + counter.getLevel());
                System.out.println("- Name Key: " + counter.getNameKey());
                System.out.println("- Name: " + counter.getName());
                System.out.println("- Description: " + counter.getDescription());
                System.out.println("- Rollup Type: " + counter.getRollupType());
                System.out.println("- Statistics Type: " + counter.getStatisticsType());
                System.out.println("- Unit Key: " + counter.getUnitKey());
                System.out.println("- Unit: " + counter.getUnit());
                System.out.println("- Unit Description: " + counter.getUnitDescription());

                System.out.println("");

            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getPerfCounterByEntity() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx4.siveo.net", hostName);
        String counterFullName = null;

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "siveoapp.siveo.net");

        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);
        HashMap<Integer, PerfCounterInfo> mapOfPerfCounterInfoByID = null;

        PerfCounterInfo perfCounterInfo = null;

        mapOfPerfCounterInfoByID = performanceManager.getMapOfPerfCounterInfoByIdByVC().get(hostName);

        PerfMetricId[] arrayOfPerfMetricIds = performanceManager.getAvailablePerfCounter(vm, null, null, 20);

        if (arrayOfPerfMetricIds != null && arrayOfPerfMetricIds.length > 0) {

            System.out.println("Counters:");

            for (PerfMetricId perfMetricId : arrayOfPerfMetricIds) {
                perfCounterInfo = mapOfPerfCounterInfoByID.get(perfMetricId.getCounterId());
                counterFullName = perfCounterInfo.getGroupInfo().getKey() + "."
                        + perfCounterInfo.getNameInfo().getKey() + "." + perfCounterInfo.getRollupType().name();

                //System.out.println("-Counter: "+counterFullName+" / ID: "+perfMetricId.getCounterId()+" / Instance: "+perfMetricId.getInstance());
                System.out.println(counterFullName + ";" + perfMetricId.getCounterId());

            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void loadInventoryView() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = null;

        //String hostName="vsphere-4-1";
        //ws=wsManager.createVIM(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "192.168.101.79";
        ws = wsManager.createVIM(hostName, 443, "svc-siveo", "S1v30d6m3", false, -1L);

        ManagedObjectReference inventoryView = null;

        try {
            inventoryView = ws.getVIMService().getService()
                    .createInventoryView(ws.getVIMService().getServiceContent().getViewManager());
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("Inventory View: " + inventoryView);

        ManagedObjectReference dcMor = new ManagedObjectReference();
        //dcMor.set_value("datacenter-21");
        //dcMor.setType("Datacenter");
        dcMor.set_value("group-d1");
        dcMor.setType("Folder");

        ArrayOfManagedObjectReference arrayOfManagedObjectReference = null;
        ManagedObjectReference[] arrOfManagedObjectReferences = null;

        try {
            arrOfManagedObjectReferences = ws.getVIMService().getService().openInventoryViewFolder(inventoryView,
                    new ManagedObjectReference[] { dcMor });

            System.out.println("arrOfManagedObjectReferences: " + arrOfManagedObjectReferences);

            if (arrOfManagedObjectReferences != null && arrOfManagedObjectReferences.length > 0) {
                for (ManagedObjectReference mor : arrOfManagedObjectReferences) {
                    System.out.println("Mor: " + mor.getType() + " / " + mor.get_value());
                }
            }

        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        ws.getVIMService().logout();
        wsManager.deleteWS(ws);

    }

    public void cloneVMToVM() throws VMwareException {
        //String hostName="10.0.12.6";
        //VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,480000L,1000L);

        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,480000L,1000L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        //VMware vmware=new VMware(hostName,443,"siveo_admin","s1v3oP0C",false,480000L,1000L);
        //VMware vmware=new VMware("vpshere-4-1",443,"Administrateur","Gd@jJ2009$",false,480000L,1000L);

        //WSManager wsManager=WSManager.getInstance();
        VMManager vmManager = VMManager.getInstance();

        // =========================================================================================
        // Initialize the Sysprep
        // =========================================================================================
        System.out.println("\n*****  Clone VM to VM *****");
        //String vmName=null;
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        //vmConfiguration.setUserName("actidev1");   
        vmConfiguration.setUserName("actidev1");
        vmConfiguration.setSocietyName("NAVAHO");
        vmConfiguration.setName("CloneVMTestInt");

        /*
              // ---------------------------------------------------------------
              // Initialize the GuiUnattended Section
              // ---------------------------------------------------------------
              GuiUnattended guiUnattended=new GuiUnattended();
              guiUnattended.setAdminPassword("Clmdp@09");
              guiUnattended.setEncryptedAdminPassword(false);
              guiUnattended.setAutoLogon(true);
              guiUnattended.setAutoLogonCount(3);
              guiUnattended.setTimeZone(105);
                  
              // ---------------------------------------------------------------
              // Initialize the LicenseFilePrintData Section
              // ---------------------------------------------------------------
              LicenseFilePrintData licenseData=new LicenseFilePrintData();
              licenseData.setAutoMode("PerServer");
              licenseData.setAutoUsers(5);
            
              // ---------------------------------------------------------------
              // Initialize the UserData Section
              // ---------------------------------------------------------------
              UserData userData=new UserData();
              userData.setComputerName(vmConfiguration.getName());
              userData.setFullName("WinVMUser");
              userData.setOrgName("SIVEO");
              userData.setProductId("MBKJF-QXT8P-RXWBG-FG687-C79GP");
            
              //
                  
              // ---------------------------------------------------------------
              // Initialize the Identification Section
              // ---------------------------------------------------------------
              // SIVEO - Join Workgroup
              Identification identification =new Identification();
              //identification.setDomainAdmin("SIVEO\\Administrateur");
              //identification.setDomainAdminPassword("Clmdp@09");
              //identification.setJoinDomain(null);
              identification.setJoinWorkgroup("WORKGROUP");
            
              //identification.setDomainAdmin("SIVEO\\Administrateur");
              //identification.setDomainAdminPassword("Clmdp@09");
              //identification.setJoinDomain("SIVEO");
              ////identification.setJoinWorkgroup("WORKGROUP");
            
              //Vblock (join domain)
              //identification.setDomainAdmin("VBLOCK\\svc-siveodev");
              //identification.setDomainAdminPassword("KzT$g#h4");
              //identification.setJoinDomain("VBLOCK");
                  
                  
              // ---------------------------------------------------------------
              // Initialize the GuiRunOnce Section
              // ---------------------------------------------------------------
              GuiRunOnce guiRunOnce = new GuiRunOnce();
              String command="\"net localgroup Administrateurs "+identification.getJoinDomain()+"\\"+vmConfiguration.getUserName()+" /add\"";
              System.out.println("command: "+command);
              guiRunOnce.setCommandList(new String[]{command});
                  
              //test hudson
              // ---------------------------------------------------------------
              // Initialize the Sysprep for Windows
              // ---------------------------------------------------------------
              SysprepWindows winSysPrep=new SysprepWindows();
              //winSysPrep.setGuiRunOnce(guiRunOnce);
              winSysPrep.setGuiUnattended(guiUnattended);
              winSysPrep.setIdentification(identification);
              winSysPrep.setLicenseFilePrintData(licenseData);
              winSysPrep.setUserData(userData);
        */

        // ---------------------------------------------------------------
        // Initialize the Linux Sysprep 
        // ---------------------------------------------------------------
        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("siveo.net");
        sysprepLinux.setHostname("TestRHEL");

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        //vmConfiguration.setSysprepWindows(winSysPrep);
        vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set Boot Options
        //
        // If not set the default values are:
        //
        // EnterBIOSSetup -> false
        // BootDelay      -> 0L
        // ---------------------------------------------------------------
        //BootOptions vmBootOpt=new BootOptions();
        //vmBootOpt.setEnterBIOSSetup(false);
        //vmBootOpt.setBootDelay(0L);

        vmConfiguration.setBootOptions(null);

        // ---------------------------------------------------------------
        // Set Console Preferences
        //
        // If not set the default values are:
        //
        // CloseOnPowerOffOrSuspend -> false
        // EnterFullScreenOnPowerOn -> false
        // powerOnWhenOpened        -> false
        // ---------------------------------------------------------------
        //ConsolePreferences vmConsolePref=new ConsolePreferences();
        //vmConsolePref.setCloseOnPowerOffOrSuspend(true);
        //vmConsolePref.setEnterFullScreenOnPowerOn(true);
        //vmConsolePref.setPowerOnWhenOpened(true);

        vmConfiguration.setConsolePreference(null);

        // ---------------------------------------------------------------
        // Set the defaults for the power operations on a virtual machine
        //
        // If not set the default values are:
        //
        // defaultPowerOffType -> "soft" 
        // defaultResetType    -> "soft" 
        // defaultSuspendType  -> "soft"  
        // powerOffType        -> "soft" 
        // resetType           -> "soft"
        // standbyAction       -> null
        // suspendType         -> "soft"
        // ---------------------------------------------------------------
        //PowerOptions vmPowerOpt=new PowerOptions();
        //vmPowerOpt.setPowerOffType("soft");
        //vmPowerOpt.setResetType("soft");
        //vmPowerOpt.setSuspendType("soft");

        vmConfiguration.setPowerOptions(null);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------

        NetworkAdapter networkAdapter = new NetworkAdapter();
        //networkAdapter.setDnsDomain("siveo.net");
        ////networkAdapter.setDnsServerList(new String[]{"192.168.0.50","212.27.40.240","212.27.40.241"});
        ////networkAdapter.setDnsServerList(new String[]{"192.168.1.13","192.168.1.1"});
        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.62.16.33");
        networkAdapter.setSubnetMask("255.255.255.0");
        ////networkAdapter.setGateway(new String[]{"192.168.0.254"});
        networkAdapter.setGateway(new String[] { "10.62.16.254" });
        ////networkAdapter.setMacAddress(null);

        //vmConfiguration.setNetworkAdpater(networkAdapter);

        // !!!
        //vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //vmConfiguration.setDnsSuffixList(new String[]{});
        vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // set the second Network
        //networkAdapter=new NetworkAdapter();
        ////networkAdapter.setDnsDomain("siveo.net");
        //networkAdapter.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        //networkAdapter.setPrimaryWINS(null);
        //networkAdapter.setSecondaryWINS(null);
        //networkAdapter.setNetBIOS(null);
        //networkAdapter.setIp(null);
        //networkAdapter.setSubnetMask("255.255.255.0");
        //networkAdapter.setGateway(new String[]{"10.0.12.1"});
        //vmConfiguration.setNetworkAdpater(networkAdapter);

        // !!!
        ////vmConfiguration.setDnsServerList(new String[]{"192.168.1.1","192.168.1.50"});
        //vmConfiguration.setDnsServerList(new String[]{"192.168.165.1","194.133.125.66"});
        ////vmConfiguration.setDnsSuffixList(new String[]{});
        //vmConfiguration.setDnsSuffixList(new String[]{});

        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // ---------------------------------------------------------------
        // Set the Network Traffic configuration
        // ---------------------------------------------------------------

        //NetworkTraffic netTraffic= new NetworkTraffic();
        //netTraffic.setAverageBps(0);
        //netTraffic.setBurstSize(0);
        //netTraffic.setPeakBps(0);
        //netTraffic.setShaper(false);

        vmConfiguration.setNetworkTraffic(null);

        // ---------------------------------------------------------------
        // Set the CPU configuration
        // ---------------------------------------------------------------
        VirtualCPU virtualCPU = new VirtualCPU();
        virtualCPU.setLimit(1024);
        virtualCPU.setReservation(1024);
        //virtualCPU.setShareLevel(null);
        virtualCPU.setExpandableReservation(false);
        virtualCPU.setNbCPU(1);
        //vmConfiguration.setVirtualCPU(virtualCPU);

        // ---------------------------------------------------------------
        // Set the Memory confguration
        // ---------------------------------------------------------------
        VirtualMemory virtualMem = new VirtualMemory();
        virtualMem.setLimit(4096);
        virtualMem.setReservation(4096);
        virtualMem.setExpandableReservation(false);
        // !!!
        //virtualMem.setMemorySize(256);

        //vmConfiguration.setVirtualMemory(virtualMem);

        vmConfiguration.setPowerOn(true);
        vmConfiguration.setCorrelID("1234ABC");

        // VirtualCenter VBLOCK
        //String dataStore="datastore-2919"; //VCE-AMP-1
        //String host="host-123"; //vblockbrm2001.vblock.local
        //String vm="vm-33747"; //TestIntel
        //String vmFolder="group-v2921"; //Test-Siveo

        // VirtualCenter PROD Siveo
        String dataStore = "datastore-535"; //VMFSDEMO
        String host = "host-71"; //siveo-esx2.siveo.net
        String vm = "vm-751"; //TESTJTH003
        String vmFolder = "group-v459"; //STS

        //String dataStore="datastore-247";
        //String host="host-246";
        //String vm="vm-341";
        //String vmFolder="group-v344";

        // -----------------------------------------------------------
        // Get the VM numbre od Cards
        // -----------------------------------------------------------   
        //VirtualMachine vm1=vmManager.getVmByID(hostName, vm);
        //VMNetwork vmNetwork=vm1.getVMNetwork();
        //System.out.println("Nombre de network: "+vmNetwork.getListOfVirtualNetwork().size());
        //System.out.println("Nombre de VirtualSwitch: "+vmNetwork.getListOfVirtualDVSwitch().size());

        //System.out.println("Nombre de cartes rseaux: "+(vmNetwork.getListOfVirtualDVSwitch().size()+vmNetwork.getListOfVirtualNetwork().size()));

        vmManager.cloneVMToVM(vm, hostName, vmConfiguration, host, dataStore, null, vmFolder);

        VMware.delete(hostName);

    }

    public void computeTime() throws VMwareException {

        // =========================================================================================
        // Connexion au VirtualCenter
        // =========================================================================================
        String hostName = "192.168.101.79";
        VMware.create(hostName, 443, "svc-siveo", "S1v30d6m3", false, -1L);

        VMware.delete(hostName);

    }

    public void getDatastoreInfo() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Get Datastore Full Information
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx2.siveo.net", hostName);

        HostConfigInfo hostCfgInfo = (HostConfigInfo) MorManager.getMorProperty(ws, host.getMor(),
                new String[] { "config" });

        HostHostBusAdapter[] arrayOfHostHostBusAdapters = null;

        System.out.println("Host Storage system information");
        System.out.println("");

        if (hostCfgInfo != null) {
            HostStorageDeviceInfo hostStorageInfo = hostCfgInfo.getStorageDevice();

            if (hostStorageInfo != null) {

                arrayOfHostHostBusAdapters = hostStorageInfo.getHostBusAdapter();
                if (arrayOfHostHostBusAdapters != null && arrayOfHostHostBusAdapters.length > 0) {
                    System.out.println("Host bus adapters:");
                    for (HostHostBusAdapter hostHostBusAdapter : arrayOfHostHostBusAdapters) {
                        System.out.println("- Bus: " + hostHostBusAdapter.getBus());
                        System.out.println("- Device: " + hostHostBusAdapter.getDevice());
                        System.out.println("- Driver: " + hostHostBusAdapter.getDriver());
                        System.out.println("- Key: " + hostHostBusAdapter.getKey());
                        System.out.println("- Model: " + hostHostBusAdapter.getModel());
                        System.out.println("- PCI: " + hostHostBusAdapter.getPci());
                        System.out.println("- Status: " + hostHostBusAdapter.getStatus());
                        System.out.println("");
                    }
                }

                HostMultipathInfo hostMultipathInfo = hostStorageInfo.getMultipathInfo();
                if (hostMultipathInfo != null) {
                    HostMultipathInfoLogicalUnit[] arrayOfMultipathInfoLogicalUnits = hostMultipathInfo.getLun();

                    if (arrayOfMultipathInfoLogicalUnits != null && arrayOfMultipathInfoLogicalUnits.length > 0) {
                        System.out.println("Multipath Configuration");

                        for (HostMultipathInfoLogicalUnit hostMultipathInfoLogicalUnit : arrayOfMultipathInfoLogicalUnits) {
                            System.out.println("- ID: " + hostMultipathInfoLogicalUnit.getId());
                            System.out.println("- Key: " + hostMultipathInfoLogicalUnit.getKey());
                            System.out.println("- Lun: " + hostMultipathInfoLogicalUnit.getLun());

                            HostMultipathInfoPath[] arrayOfHostMultipathInfoPaths = hostMultipathInfoLogicalUnit
                                    .getPath();

                            if (arrayOfHostMultipathInfoPaths != null && arrayOfHostMultipathInfoPaths.length > 0) {
                                System.out.println("- Paths available to access this LogicalUnit");

                                for (HostMultipathInfoPath hostMultipathInfoPath : arrayOfHostMultipathInfoPaths) {
                                    System.out.println("  - Adapter: " + hostMultipathInfoPath.getAdapter());
                                    System.out.println("  - Key: " + hostMultipathInfoPath.getKey());
                                    System.out.println("  - Lun: " + hostMultipathInfoPath.getLun());
                                    System.out.println("  - Name: " + hostMultipathInfoPath.getName());
                                    System.out.println("  - State: " + hostMultipathInfoPath.getState());
                                    System.out.println("");
                                }

                            }

                        }
                    }

                }

                ScsiLun[] arrayOfSCILun = null;
                arrayOfSCILun = hostStorageInfo.getScsiLun();

                if (arrayOfSCILun != null && arrayOfSCILun.length > 0) {
                    System.out.println("");
                    System.out.println("");
                    System.out.println("SCSI Logical Units:");
                    for (ScsiLun scsiLun : arrayOfSCILun) {
                        if (scsiLun instanceof com.vmware.vim25.HostScsiDisk) {
                            HostScsiDisk hostScsiDisk = (HostScsiDisk) scsiLun;
                            System.out.println("- Device Path: " + hostScsiDisk.getDevicePath());
                            System.out.println("- Nb Block: " + hostScsiDisk.getCapacity().getBlock());
                            System.out.println("- Block Size: " + hostScsiDisk.getCapacity().getBlockSize());
                        }

                        System.out.println("- ScsiLun Class: " + scsiLun.getClass());
                        System.out.println("- Display Name: " + scsiLun.getDisplayName());
                        System.out.println("- CanonicalName: " + scsiLun.getCanonicalName());
                        System.out.println("- Key: " + scsiLun.getKey());
                        System.out.println("- Model: " + scsiLun.getModel());
                        System.out.println("- Device Name: " + scsiLun.getDeviceName());
                        System.out.println("- Device Type: " + scsiLun.getDeviceType());
                        System.out.println("- UUID: " + scsiLun.getUuid());
                        System.out.println("");
                    }
                }
            }

        }

        // =========================================================================================
        // Get Datastore Full Information
        // =========================================================================================
        ArrayList<Datastore> listOfDatastores = null;
        DatastoreInfo dsInfo = null;
        VmfsDatastoreInfo vmfsDSInfo = null;
        HostScsiDiskPartition[] arrayOfDiskPartition = null;

        listOfDatastores = host.getListOfDatastores();

        if (listOfDatastores != null && !listOfDatastores.isEmpty()) {
            System.out.println("Datastore Information: ");

            for (Datastore datastore : listOfDatastores) {
                System.out.println("- Name: " + datastore.getName());
                System.out.println("- Capacity: " + datastore.getCapacity());
                System.out.println("- Free Space: " + datastore.getFreeSpace());

                String dsURL = (String) MorManager.getMorProperty(ws, datastore.getMor(),
                        new String[] { "summary.url" });
                System.out.println("- URL: " + dsURL);

                dsInfo = (DatastoreInfo) MorManager.getMorProperty(ws, datastore.getMor(), new String[] { "info" });
                //System.out.println("DSInfo Class: "+dsInfo.getClass());

                if (dsInfo != null && dsInfo instanceof com.vmware.vim25.VmfsDatastoreInfo) {
                    vmfsDSInfo = (VmfsDatastoreInfo) dsInfo;

                    if (vmfsDSInfo.getVmfs() != null) {
                        System.out.println("- UUID: " + vmfsDSInfo.getVmfs().getUuid());
                        arrayOfDiskPartition = vmfsDSInfo.getVmfs().getExtent();

                        if (arrayOfDiskPartition != null && arrayOfDiskPartition.length > 0) {
                            System.out.println("- Disk Partition: ");

                            for (HostScsiDiskPartition hostScsiDiskPartition : arrayOfDiskPartition) {
                                System.out.println("  - DiskName: " + hostScsiDiskPartition.getDiskName());
                                System.out.println("  - Partition N: " + hostScsiDiskPartition.getPartition());
                            }

                        }
                    }

                }

                System.out.println("");

            }

        }

        /*
            
        // =========================================================================================
        // Initialize Variables
        // =========================================================================================
        DataStoreManager datastoreManager=DataStoreManager.getInstance();
            
        //Datastore datastore=datastoreManager.getDatastoreByName("datastore2", hostName);
        Datastore datastore=datastoreManager.getDatastoreByName("SIVEO_ADMIN_TC3", hostName);
            
        String url=(String)MorManager.getMorProperty(ws.getVIMService(),datastore.getMor(), new String[] {"summary.url"});
        System.out.println("URL: "+url);
            
        DatastoreInfo dsInfo=(DatastoreInfo)MorManager.getMorProperty(ws.getVIMService(),datastore.getMor(), new String[] {"info"});
        System.out.println("DS Info: "+dsInfo.getClass());
            
        HostScsiDiskPartition[] arrayOfDiskPartition=null;
            
        if (dsInfo instanceof com.vmware.vim25.VmfsDatastoreInfo)
        {
           VmfsDatastoreInfo vmfsDSInfo=(VmfsDatastoreInfo)dsInfo;
           if (vmfsDSInfo.getVmfs()!=null)
           {
        System.out.println("UUID: "+vmfsDSInfo.getVmfs().getUuid());
        arrayOfDiskPartition=vmfsDSInfo.getVmfs().getExtent();
            
        if (arrayOfDiskPartition!=null && arrayOfDiskPartition.length>0)
        {
           System.out.println("Disk Partition: ");
               
           for (HostScsiDiskPartition hostScsiDiskPartition:arrayOfDiskPartition)
           {
              System.out.println("DiskName: "+hostScsiDiskPartition.getDiskName());
              System.out.println("Partition: "+hostScsiDiskPartition.getPartition());
           }
               
        }
           }
        }
            
            
            
            
            
            
        // =========================================================================================
        // Get the naa.60060160e60e26002c42a955a83ae011
        // =========================================================================================
        HostManager hostManager=HostManager.getInstance();
        //Host host=hostManager.getHostByName("siveo-esx2.siveo.net", hostName);
        Host host=hostManager.getHostByName("siveo-esx4.siveo.net", hostName);
            
            
        HostConfigInfo hostCfgInfo=(HostConfigInfo)MorManager.getMorProperty(ws.getVIMService(),host.getMor(), new String[] {"config"});
            
        if (hostCfgInfo!=null)
        {
           HostStorageDeviceInfo hostStorageInfo=hostCfgInfo.getStorageDevice();
               
           if (hostStorageInfo!=null)
           {
        ScsiLun[] arrayOfSCILun=null;
        arrayOfSCILun=hostStorageInfo.getScsiLun();
            
        if (arrayOfSCILun!=null && arrayOfSCILun.length>0)
        {
           for (ScsiLun scsiLun:arrayOfSCILun)
           {
              System.out.println("-Display Name: "+scsiLun.getDisplayName());
              System.out.println("-canonicalName: "+scsiLun.getCanonicalName());
              System.out.println("  - Device Name: "+scsiLun.getDeviceName());
              System.out.println("  - UUID: "+scsiLun.getUuid());
              System.out.println("");
           }
        }
           }
               
        }
            
        */

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getHostStatisticInfo() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Initialize Variables
        // =========================================================================================

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - cpu.idle.summation
        // - cpu.used.summation
        // ------------------------------------------------------------
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx2.siveo.net", hostName);

        CPU hostCPU = host.getCPU();

        System.out.println("CPU Info:");
        System.out.println("- Vitesse du processeur: " + hostCPU.getHz());
        System.out.println("- Sockets du processeur: " + hostCPU.getNumCpuPackages());
        System.out.println("- Coeurs de processeur par socket: " + hostCPU.getNumCpuCores());
        System.out.println("- Processeurs logiques: " + hostCPU.getNumCpuThreads());

        HostHardwareInfo hostHardwareInfo = (HostHardwareInfo) MorManager.getMorProperty(ws, host.getMor(),
                new String[] { "hardware" });

        if (hostHardwareInfo != null) {
            for (HostCpuPackage hostCpuPackage : hostHardwareInfo.getCpuPkg()) {
                System.out.println("- Index: " + hostCpuPackage.getIndex());
                System.out.println("- Bus speed in HZ: " + hostCpuPackage.getBusHz());
                System.out.println("- description: " + hostCpuPackage.getDescription());
                System.out.println("- CPU speed in HZ: " + hostCpuPackage.getHz());
                if (hostCpuPackage.getThreadId() != null && hostCpuPackage.getThreadId().length > 0) {
                    System.out.println("- Tread ID: ");

                    for (Short threadID : hostCpuPackage.getThreadId()) {
                        System.out.println("  - " + threadID);
                    }
                }

                System.out.println("- Vendor: " + hostCpuPackage.getVendor());
            }
        }

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - datastore.read.average
        // - datastore.datastoreIops.average
        // - datastore.numberReadAveraged.average
        // - datastore.numberWriteAveraged.average
        // - datastore.sizeNormalizedDatastoreLatency.average
        // - datastore.totalReadLatency.average
        // - datastore.totalWriteLatency.average
        // - datastore.write.average
        // ------------------------------------------------------------
        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        Datastore datastore = dataStoreManager.getDatastoreByUUID("4d121f47-efbe7d6f-0b87-e41f13606ec0", hostName);
        System.out.println("Datastore: " + datastore.getName());

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - disk.numberRead.summation
        // - disk.numberReadAveraged.average
        // - disk.numberWrite.summation
        // - disk.numberWriteAveraged.average
        // ------------------------------------------------------------
        //host=hostManager.getHostByName("siveo-esx2.siveo.net", hostName);

        HostDisk hostDisk = null;
        hostDisk = host.getMapOfHostDiskByCanonicalName().get("naa.500000e114990fb0");
        //scsiLogicalUnit=host.getMapOfSCSILunByCanonicalName().get("naa.60060160e60e26007a03f43ca83ae011");
        //naa.60060160e60e26007a03f43ca83ae011

        System.out.println("Host Disk Name: " + hostDisk.getDisplayName());

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - net.droppedRx.summation
        // - net.droppedTx.summation
        // - net.packetsRx.summation
        // - net.packetsTx.summation
        // ------------------------------------------------------------
        Host host1 = hostManager.getHostByName("siveo-esx1.siveo.net", hostName);
        String pnicName = "vmnic0";

        PNic pnic = host1.getPnic(pnicName);

        ArrayList<Network> listOfNetworks = pnic.getListOfNetworks();

        if (!listOfNetworks.isEmpty()) {
            System.out.println("Liste des network associ au PNIC: " + pnicName);
            for (Network network : listOfNetworks) {
                System.out.println("Name: " + network.getName() + " / Vlan ID: " + network.getVlanId());
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getHostStatisticEntityInfo() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Initialize Variables
        // =========================================================================================

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - datastore.read.average
        // ------------------------------------------------------------
        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        Datastore datastore = dataStoreManager.getDatastoreByUUID("4d121f47-efbe7d6f-0b87-e41f13606ec0", hostName);
        System.out.println("Datastore: " + datastore.getName());

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("siveo-esx2.siveo.net", hostName);

        HostConfigManager hostConfigManager = (HostConfigManager) MorManager.getMorProperty(ws, host.getMor(),
                new String[] { "configManager" });
        ManagedObjectReference hostStorageSystem = null;
        ManagedObjectReference hostDatastoreSystem = null;
        HostScsiDisk[] arrayOfHostScsiDisks = null;

        String[] arrayOfDevicePaths = null;
        ArrayList<String> listOfPaths = new ArrayList<String>();

        if (hostConfigManager != null) {
            hostDatastoreSystem = hostConfigManager.getDatastoreSystem();
            if (hostDatastoreSystem != null) {
                try {
                    arrayOfHostScsiDisks = ws.getVIMService().getService()
                            .queryAvailableDisksForVmfs(hostDatastoreSystem, datastore.getMor());
                    if (arrayOfHostScsiDisks != null && arrayOfHostScsiDisks.length > 0) {
                        System.out.println("Host Scsi Disks");

                        for (HostScsiDisk hostScsiDisk : arrayOfHostScsiDisks) {
                            System.out.println("- Canonical Name: " + hostScsiDisk.getCanonicalName());
                            System.out.println("- UUID: " + hostScsiDisk.getUuid());
                            System.out.println("- Key: " + hostScsiDisk.getKey());
                            System.out.println("- Serial Number: " + hostScsiDisk.getSerialNumber());
                            System.out.println("- Device Path: " + hostScsiDisk.getDevicePath());
                            System.out.println("- Device Name: " + hostScsiDisk.getDeviceName());
                            System.out.println("- Display Name: " + hostScsiDisk.getDisplayName());
                            System.out.println("- Durable Name: " + hostScsiDisk.getDurableName());
                            listOfPaths.add(hostScsiDisk.getDevicePath());
                        }

                        //         vmConfigSpec.setDeviceChange(listOfVirtualDeviceConfigSpec.toArray(new VirtualDeviceConfigSpec[listOfVirtualDeviceConfigSpec.size()]));   
                        arrayOfDevicePaths = (listOfPaths.toArray(new String[listOfPaths.size()]));

                    }
                } catch (NotFound e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (HostConfigFault e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (RuntimeFault e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (RemoteException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

            System.out.println("");
            System.out.println("");

            hostStorageSystem = hostConfigManager.getStorageSystem();

            HostFileSystemVolumeInfo hostFileSystemVolumeInfo = (HostFileSystemVolumeInfo) MorManager
                    .getMorProperty(ws, hostStorageSystem, new String[] { "fileSystemVolumeInfo" });

            if (hostFileSystemVolumeInfo != null) {
                HostFileSystemMountInfo[] hostFileSystemMountInfos = hostFileSystemVolumeInfo.getMountInfo();

                if (hostFileSystemMountInfos != null && hostFileSystemMountInfos.length > 0) {
                    System.out.println("Host File System Mount Point");
                    for (HostFileSystemMountInfo hostFileSystemMountInfo : hostFileSystemMountInfos) {
                        System.out.println("-Name: " + hostFileSystemMountInfo.getVolume().getName());
                        System.out.println("-Type: " + hostFileSystemMountInfo.getVolume().getType());
                        System.out.println("-Capcity: " + hostFileSystemMountInfo.getVolume().getCapacity());
                        System.out.println("-Path: " + hostFileSystemMountInfo.getMountInfo().getPath());
                        System.out
                                .println("-Acces Mode: " + hostFileSystemMountInfo.getMountInfo().getAccessMode());
                        System.out.println("");
                    }
                }

            }

        }

        HostDiskPartitionInfo[] arrayOfHostDiskPartitionInfos = null;

        try {
            arrayOfHostDiskPartitionInfos = ws.getVIMService().getService()
                    .retrieveDiskPartitionInfo(hostStorageSystem, arrayOfDevicePaths);
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("");
        System.out.println("");

        if (arrayOfHostDiskPartitionInfos != null && arrayOfHostDiskPartitionInfos.length > 0) {
            for (HostDiskPartitionInfo hostDiskPartitionInfo : arrayOfHostDiskPartitionInfos) {
                System.out.println("Device Name: " + hostDiskPartitionInfo.getDeviceName());

                if (hostDiskPartitionInfo.getSpec() != null) {
                    HostDiskPartitionSpec hostDiskPartitionSpec = hostDiskPartitionInfo.getSpec();

                    if (hostDiskPartitionSpec != null) {
                        if (hostDiskPartitionSpec.getPartition() != null
                                && hostDiskPartitionSpec.getPartition().length > 0) {
                            for (HostDiskPartitionAttributes hostDiskPartitionAttributes : hostDiskPartitionSpec
                                    .getPartition()) {
                                System.out.println("-Partition: " + hostDiskPartitionAttributes.getPartition());
                                System.out.println("-Attributes: " + hostDiskPartitionAttributes.getAttributes());
                                System.out
                                        .println("-Start Sector: " + hostDiskPartitionAttributes.getStartSector());
                                System.out.println("-End Sector: " + hostDiskPartitionAttributes.getEndSector());

                            }

                        }

                    }

                }

                System.out.println("Layout: " + hostDiskPartitionInfo.getDeviceName());
                System.out.println("Spec: " + hostDiskPartitionInfo.getDeviceName());
            }
        }

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - disk.numberRead.summation
        // - disk.numberReadAveraged.average
        // ------------------------------------------------------------

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVMStatisticInfo() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Initialize Variables
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        //VirtualMachine vm=vmManager.getVmByID(hostName, "vm-207");
        VirtualMachine vm = vmManager.getVmByName(hostName, "SCVMM");

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - cpu.system.summation
        // - cpu.used.summation
        //
        // Rcupration du nombre de Virtual CPU
        // ------------------------------------------------------------
        VirtualCPU virtualCPU = vm.getConfiguration().getVirtualCPU();
        System.out.println("Nb vCPU: " + virtualCPU.getNbCPU());
        //System.out.println("Nb vCPU: "+virtualCPU.getReservation());
        //System.out.println("Nb vCPU: "+virtualCPU.getLimit());

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - disk.read.average
        // - disk.write.average
        //
        // Rcupration du nombre de Virtual CPU
        // ------------------------------------------------------------
        HostDisk hostDisk = null;
        hostDisk = vm.getHost().getMapOfHostDiskByCanonicalName().get("naa.6006016071602100ceb19ca4de5ee111");

        System.out.println("Disk Display name: " + hostDisk.getDisplayName());

        //vm.getDatastores()

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - net.packetsRx.summation
        // - net.packetsTx.summation
        // ------------------------------------------------------------
        VirtualNetwork virtualNetwork = null;
        VirtualDVSwitch virtualDVSwitch = null;
        Object virtualNet = null;

        int key = 4000;

        virtualNet = vm.getVirtualDeviceManager().getVirtualNetworkByKey(key);

        if (virtualNet != null) {

            if (virtualNet instanceof VirtualNetwork) {
                virtualNetwork = (VirtualNetwork) virtualNet;
                System.out.println("Virtual Network:");
                System.out.println("- Label: " + virtualNetwork.getLabel());
                System.out.println("- Etiquette Rseau: " + virtualNetwork.getNetwork().getName());
            } else if (virtualNet instanceof VirtualDVSwitch) {
                virtualDVSwitch = (VirtualDVSwitch) virtualNet;
                System.out.println("DVSwitch");
                System.out.println("- Label: " + virtualDVSwitch.getLabel());
                System.out.println("- Etiquette Rseau: " + virtualDVSwitch.getDvSwitch().getName());
            }

        }

        System.out.println("");

        // ------------------------------------------------------------
        // Traitement des compteurs:
        // - virtualDisk.numberReadAveraged.average
        // - virtualDisk.numberWriteAveraged.average
        // - virtualDisk.read.average
        // - virtualDisk.totalReadLatency.average
        // - virtualDisk.totalWriteLatency.average
        // - virtualDisk.write.average
        // ------------------------------------------------------------
        net.siveo.virtualization.vmware.virtualdevice.VirtualDisk virtualDisk = null;
        virtualDisk = vm.getVirtualDeviceManager().getVirtualDiskByNode("scsi0:0");
        System.out.println("Virtual Disk:");
        System.out.println("- Label: " + virtualDisk.getLabel());
        System.out.println("- Size: " + virtualDisk.getDiskSize());
        System.out.println("");

        virtualDisk = vm.getVirtualDeviceManager().getVirtualDiskByNode("scsi1:9");

        System.out.println("- Label: " + virtualDisk.getLabel());
        System.out.println("- Size: " + virtualDisk.getDiskSize());
        System.out.println("");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getHostNetworkconfiguration(String esxName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Initialize Variables
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName(esxName, hostName);

        HostNetworkConfiguration hostNetworkConfiguration = host.getHostNetworkConfiguration();

        if (hostNetworkConfiguration != null) {
            // =========================================================================================
            // Capability vector indicating the available product features. 
            // =========================================================================================
            NetCapabilities netCapabilities = hostNetworkConfiguration.getCapabilities();

            System.out.println("******** Host Networking Information ********\n");

            System.out.println("----------------------");
            System.out.println("---- Capabilities ----");
            System.out.println("----------------------");

            if (netCapabilities != null) {
                System.out.println("----------------------");
                System.out.println("---- Capabilities ----");
                System.out.println("----------------------");
                System.out
                        .println("- canSetPhysicalNicLinkSpeed: " + netCapabilities.isCanSetPhysicalNicLinkSpeed());
                System.out.println("- dhcpOnVnicSupported       : " + netCapabilities.isDhcpOnVnicSupported());
                System.out.println("- dnsConfigSupported        : " + netCapabilities.isDnsConfigSupported());
                System.out.println("- ipRouteConfigSupported    : " + netCapabilities.isIpRouteConfigSupported());

                if (host.getWS().getAPIVersion().equals("4.0") || host.getWS().getAPIVersion().equals("4.1"))
                    System.out.println("- ipV6Supported             : " + netCapabilities.isIpV6Supported());

                System.out.println("- maxPortGroupsPerVswitch   : " + netCapabilities.getMaxPortGroupsPerVswitch());

                if (netCapabilities.getNicTeamingPolicy() != null
                        && netCapabilities.getNicTeamingPolicy().length > 0) {
                    for (int nbPolicy = 0; nbPolicy < netCapabilities.getNicTeamingPolicy().length; nbPolicy++) {
                        System.out.println("- nicTeamingPolicy n" + nbPolicy + "      : "
                                + netCapabilities.getNicTeamingPolicy()[nbPolicy]);
                    }
                }

                System.out.println("- ipRouteConfigSupported    : " + netCapabilities.isIpRouteConfigSupported());
                System.out.println("- supportsNetworkHints      : " + netCapabilities.isSupportsNetworkHints());
                System.out.println("- supportsNicTeaming        : " + netCapabilities.isSupportsNicTeaming());
                System.out.println("- supportsVlan              : " + netCapabilities.isSupportsVlan());
                System.out.println("- usesServiceConsoleNic     : " + netCapabilities.isUsesServiceConsoleNic());
                System.out.println("- vnicConfigSupported       : " + netCapabilities.isVnicConfigSupported());
                System.out.println("- vswitchConfigSupported    : " + netCapabilities.isVswitchConfigSupported());

            }

            //
            ArrayList<PNic> listOfPnics = hostNetworkConfiguration.getListofPNics();

            if (!listOfPnics.isEmpty()) {
                System.out.println("------------------------------------");
                System.out.println("---- Physiscal Network Adapters ----");
                System.out.println("------------------------------------");

                int nbPnic = 1;
                int nbVswitch = 1;
                int nbPortgroup = 1;

                for (PNic pNic : listOfPnics) {
                    System.out.println("Physiscal Network Adapter n" + nbPnic++);
                    System.out.println("- Device: " + pNic.getDevice());
                    System.out.println("- Driver: " + pNic.getDriver());
                    System.out.println("- Key: " + pNic.getKey());
                    if (pNic.getLinkSpeed() != null) {
                        System.out.println("- Dupleix: " + pNic.getLinkSpeed().isDuplex());
                        System.out.println("- Speed Mb: " + pNic.getLinkSpeed().getSpeedMb());
                    }

                    System.out.println("- Mac Address: " + pNic.getMac());
                    System.out.println("- PCI: " + pNic.getPci());
                    System.out.println("- Wake On Lan Supported: " + pNic.isWakeOnLanSupported());

                    if (!pNic.getListOfVirtualSwitchs().isEmpty()) {
                        System.out.println("  ------------------------");
                        System.out.println("  ---- Virtual Switch ----");
                        System.out.println("  ------------------------");

                        for (VirtualSwitch virtualSwitch : pNic.getListOfVirtualSwitchs()) {
                            System.out.println("  Virtual Switch n" + nbVswitch++);
                            System.out.println("  - Name: " + virtualSwitch.getName());
                            System.out.println("  - key: " + virtualSwitch.getKey());
                            System.out.println("  - mtu: " + virtualSwitch.getMtu());
                            System.out.println("  - Num Ports: " + virtualSwitch.getNumPorts());
                            System.out.println("  - Num Ports Available: " + virtualSwitch.getNumPortsAvailable());

                            if (!virtualSwitch.getListfOfPNics().isEmpty()) {
                                for (PNic vsPnic : virtualSwitch.getListfOfPNics()) {
                                    System.out.println("  - Pnic: " + vsPnic.getDevice());
                                }
                            }

                            if (!virtualSwitch.getListOfPortGroups().isEmpty()) {
                                System.out.println("    --------------------");
                                System.out.println("    ---- Port Group ----");
                                System.out.println("    --------------------");

                                for (PortGroup portGroup : virtualSwitch.getListOfPortGroups()) {
                                    System.out.println("    Port Group n" + nbPortgroup++);
                                    System.out.println("    - Name: " + portGroup.getName());
                                    System.out.println("    - VlanID: " + portGroup.getVlanId());
                                    System.out.println("");

                                }

                            }

                            System.out.println("");
                        }

                    }

                    System.out.println("");
                    System.out.println("");
                }

            }

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVMDevices(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Rcupration de la VM associe au Nom
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        VirtualDevice[] listOfVirtualDevice = vm.getVirtualDeviceManager().getListOfVirtualDevices();
        int nbDevice = 1;
        VirtualEthernetCard virtualEthernetCard = null;
        VirtualController virtualController = null;

        for (VirtualDevice device : listOfVirtualDevice) {
            System.out.println("Device n" + nbDevice++);
            System.out.println("- Device: " + device);
            System.out.println("- Device Class: " + device.getClass());
            System.out.println("- Device Super Class: " + device.getClass().getSuperclass());
            System.out.println("- Key    : " + device.getKey());
            System.out.println("- ControllerKey: " + device.getControllerKey());
            System.out.println("- Label  : " + device.getDeviceInfo().getLabel());
            System.out.println("- Summary: " + device.getDeviceInfo().getSummary());
            System.out.println("- Unit Number: " + device.getUnitNumber());

            if (device instanceof com.vmware.vim25.VirtualLsiLogicSASController) {
                VirtualLsiLogicSASController virtualLsiLogicSASController = (VirtualLsiLogicSASController) device;
                System.out.println(
                        "- Scsi Ctlr Unit Number: " + virtualLsiLogicSASController.getScsiCtlrUnitNumber());
                System.out.println("- Bus Number: " + virtualLsiLogicSASController.getBusNumber());
            }

            if (device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualEthernetCard.class)
                    || device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualVmxnet.class)) {
                virtualEthernetCard = (VirtualEthernetCard) device;
                System.out.println("- virtualEthernetCard Class: " + virtualEthernetCard.getClass());
                System.out.println("  - AddressType: " + virtualEthernetCard.getAddressType());
                System.out.println("  - MacAddress: " + virtualEthernetCard.getMacAddress());
                System.out.println("  - WakeOnLanEnabled: " + virtualEthernetCard.getWakeOnLanEnabled());
                System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());

                if (virtualEthernetCard
                        .getBacking() instanceof com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo) {
                    VirtualEthernetCardNetworkBackingInfo virtualEthernetCardNetworkBackingInfo = (VirtualEthernetCardNetworkBackingInfo) virtualEthernetCard
                            .getBacking();
                    System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());
                    System.out
                            .println("    - Device Name: " + virtualEthernetCardNetworkBackingInfo.getDeviceName());
                    System.out.println(
                            "    - Use AutoDetect: " + virtualEthernetCardNetworkBackingInfo.getUseAutoDetect());
                    System.out.println(
                            "    - inPassthroughMode: " + virtualEthernetCardNetworkBackingInfo.inPassthroughMode);
                    System.out.println(
                            "    - Network: " + virtualEthernetCardNetworkBackingInfo.getNetwork().get_value());

                }

                if (virtualEthernetCard.getBacking().getClass()
                        .equals(com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo.class)) {
                    VirtualEthernetCardDistributedVirtualPortBackingInfo backing = (VirtualEthernetCardDistributedVirtualPortBackingInfo) virtualEthernetCard
                            .getBacking();
                    System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());
                    System.out.println("    - PortgroupKey: " + backing.getPort().getPortgroupKey());
                    System.out.println("    - PortKey: " + backing.getPort().getPortKey());
                    System.out.println("    - SwitchUuid: " + backing.getPort().getSwitchUuid());
                }
                //

            }

            if (device.getConnectable() != null) {
                System.out.println("- allowGuestControl: " + device.getConnectable().isAllowGuestControl());
                System.out.println("- connected: " + device.getConnectable().isConnected());
                System.out.println("- startConnected: " + device.getConnectable().isStartConnected());
                if (device.getConnectable().getStatus() != null)
                    System.out.println("- status: " + device.getConnectable().getStatus());

            }

            if (device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualController.class)) {
                virtualController = (VirtualController) device;
                if (virtualController.getDevice() != null && virtualController.getDevice().length > 0) {
                    String devicesControlled = "- Devices Controlled: ";
                    String keys = "";
                    for (int deviceKey : virtualController.getDevice()) {
                        keys = deviceKey + "," + keys;
                    }

                    keys = keys.substring(0, keys.length() - 1);
                    System.out.println(devicesControlled + keys);
                }
            }

        }

        VMware.delete(hostName);

    }

    public void convertVMToTemplate() throws VMwareException {

        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //      String hostName="192.168.101.179";
        //      VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        String folderID = "group-v575";

        VMManager vmManager = VMManager.getInstance();
        vmManager.convertVMToTemplate("vm-2229", hostName, "TPL_MovetoFolder", folderID, "1234");

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);

    }

    /*   
       public void setVirtualMachineIP() throws VMwareException
       {
          // =========================================================================================
          // Cration de la connexion au VirtualCenter
          // =========================================================================================
          //String hostName="192.168.101.79";
          //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);
        
          //String hostName="vsphere-4-1";
          //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);
        
          String hostName="10.251.5.14";
          VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);
              
          //String hostName="192.168.101.179";
          //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);
              
          // =========================================================================================
          // Mis  jour IP
          // =========================================================================================
          GuestCustUtil guestCustUtil=new GuestCustUtil();
              
          guestCustUtil.setCustUtilExe("D:\\VMware\\Guest Tools\\guestcustutil.exe");
          guestCustUtil.setPsExec("D:\\VMware\\Guest Tools\\PsExec.exe");
              
          //guestCustUtil.setTimeOut(40);
          guestCustUtil.setIpAddress("10.62.16.66");
          guestCustUtil.setSubnetMask("255.255.252.0");
          guestCustUtil.setGateway("10.62.16.3");
          guestCustUtil.getListOfDNS().add("10.251.5.50");
          guestCustUtil.getListOfDNS().add("194.133.14.66");
          guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
          guestCustUtil.getListOfDnsSuffixes().add("siveo");
              
              
              
          //PsExec psExec=new PsExec();
          PsExec psExec=new PsExec("10.62.16.69", "Administrator", "Passw0rd$", "00:50:56:a6:00:0e", guestCustUtil);
              
          System.out.println("Command: "+psExec.buildCommand());
              
          VMManager vmManager=VMManager.getInstance();
          vmManager.configureIP("10.62.16.69", "Administrator", "Passw0rd$", "00:50:56:a6:00:0e", guestCustUtil);
              
          // =========================================================================================
          // Destruction du WebService
          // =========================================================================================
          VMware.delete(hostName);
       }
    */

    /*   
       public void setVirtualMachineIPOnLinux() throws VMwareException
       {
          // =========================================================================================
          // Cration de la connexion au VirtualCenter
          // =========================================================================================
          //String hostName="192.168.101.79";
          //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);
        
          //String hostName="vsphere-4-1";
          //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);
        
          String hostName="10.251.5.14";
          VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);
              
          //String hostName="192.168.101.179";
          //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);
              
          // =========================================================================================
          // Mis  jour IP
          // =========================================================================================
          GuestCustUtil guestCustUtil=new GuestCustUtil();
              
          //guestCustUtil.setCustUtilExe("D:\\VMware\\Guest Tools\\guestcustutil.exe");
          //guestCustUtil.setPsExec("D:\\VMware\\Guest Tools\\winexe");
        
          guestCustUtil.setCustUtilExe("C:\\Windows\\guestcustutil.exe");
          guestCustUtil.setPsExec("winexe");
          guestCustUtil.setPathToScript("/disk2/appeva/jboss-5.1.0.GA/server/siveo-jbpm/GuestTools");
              
          //guestCustUtil.setTimeOut(40);
          guestCustUtil.setIpAddress("10.62.16.106");
          guestCustUtil.setSubnetMask("255.255.252.0");
          guestCustUtil.setGateway("10.62.16.2");
          guestCustUtil.getListOfDNS().add("10.251.5.50");
          guestCustUtil.getListOfDNS().add("194.133.14.66");
          guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
          guestCustUtil.getListOfDnsSuffixes().add("siveo");
              
          VMManager vmManager=VMManager.getInstance();
          vmManager.configureIpWithWinExec("10.62.16.100", "SIVEO\\Administrateur", "Clmdp@09", "00:50:56:A6:00:15", guestCustUtil);
              
          // =========================================================================================
          // Destruction du WebService
          // =========================================================================================
          VMware.delete(hostName);
       }
    */

    public void testJsch() throws VMwareException {
        GuestCustUtil guestCustUtil = new GuestCustUtil();

        guestCustUtil.setCustUtilExe("D:\\VMware\\Guest Tools\\manu\\final\\reconfigurationVM.pl");

        /*
        //- Modif config IP
        guestCustUtil.setIpAddress("10.62.16.100");
        guestCustUtil.setSubnetMask("255.255.252.0");
        guestCustUtil.setGateway("10.62.16.2");
        guestCustUtil.getListOfDNS().add("10.251.5.50");
        guestCustUtil.getListOfDNS().add("194.133.14.66");
        guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.setAdmin(false);    
        guestCustUtil.setClient(false);
        */

        /*
        //- Modif config IP + Admin
        guestCustUtil.setIpAddress("10.62.16.100");
        guestCustUtil.setSubnetMask("255.255.252.0");
        guestCustUtil.setGateway("10.62.16.2");
        guestCustUtil.getListOfDNS().add("10.251.5.50");
        guestCustUtil.getListOfDNS().add("194.133.14.66");
        guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.setAdmin(true);    
        guestCustUtil.setClient(false);
        guestCustUtil.setIpJboss("10.251.5.50/24");
        */

        /*
        //- Modif config IP + client
        guestCustUtil.setIpAddress("10.62.16.100");
        guestCustUtil.setSubnetMask("255.255.252.0");
        guestCustUtil.setGateway("10.62.16.2");
        guestCustUtil.getListOfDNS().add("10.251.5.50");
        guestCustUtil.getListOfDNS().add("194.133.14.66");
        guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.setAdmin(false);    
        guestCustUtil.setClient(true);
        guestCustUtil.setIpJboss("10.0.0.0");  
        */

        //- Maj Admin
        /*
        guestCustUtil.setIpAddress(null);
        guestCustUtil.setSubnetMask(null);
        guestCustUtil.setGateway("10.62.16.2");
        //guestCustUtil.getListOfDNS().add("10.251.5.50");
        //guestCustUtil.getListOfDNS().add("194.133.14.66");
        //guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.setAdmin(true);    
        guestCustUtil.setClient(false);
        guestCustUtil.setIpJboss("10.251.5.50/24");    
        */

        guestCustUtil.setIpAddress(null);
        guestCustUtil.setSubnetMask(null);
        guestCustUtil.setGateway("10.62.16.2");
        //guestCustUtil.getListOfDNS().add("10.251.5.50");
        //guestCustUtil.getListOfDNS().add("194.133.14.66");
        //guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.setAdmin(false);
        guestCustUtil.setClient(true);
        guestCustUtil.setIpJboss("10.251.5.50/24");

        int guestOSID = 2;

        //Jsch jsch=new Jsch("10.62.16.82", "root", "Passw0rd$", "00:50:56:A6:00:15", guestOSID, guestCustUtil);
        //jsch.setScriptname("reconfigurationVM.pl");

        //System.out.println("Command: "+jsch.buildCommandLine());

    }

    public void getIPInfo(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        GuestCustUtil guestCustUtil = new GuestCustUtil();
        guestCustUtil.setCustUtilExe("D:\\VMware\\Guest Tools\\manu\\final\\ok\\recupinfo.pl");
        //vm.getIPInfo("10.62.16.85", "root", "cahh4gee$", guestCustUtil);

        //ArrayList<String> listOfMacAddresses=new ArrayList<String>();
        //listOfMacAddresses.add("00:50:56:A6:00:14");
        //listOfMacAddresses.add("00:50:56:a6:00:1c");
        //vm.getIPInfo("10.62.16.85", "root", "cahh4gee$", listOfMacAddresses,guestCustUtil);

        // =========================================================================================
        // Affichage des Networks avec leur configuration IP
        // =========================================================================================
        VMNetwork vmNetwork = vm.getVMNetwork();

        ArrayList<VirtualNetwork> listOfVirtualNetworks = null;
        ArrayList<VirtualDVSwitch> listOfVirtualDVSwitchs = null;

        listOfVirtualNetworks = vmNetwork.getListOfVirtualNetwork();
        listOfVirtualDVSwitchs = vmNetwork.getListOfVirtualDVSwitch();

        if (listOfVirtualNetworks != null && !listOfVirtualNetworks.isEmpty()) {
            System.out.println("############ Virtual Network ############");

            for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {
                System.out.println("-Name: " + virtualNetwork.getNetwork().getName());
                System.out.println("-Mac Address: " + virtualNetwork.getMacAddress());
                System.out.println("-IP: " + virtualNetwork.getIp());
                System.out.println("-BroadCast: " + virtualNetwork.getBroadCast());
                System.out.println("-Gateway: " + virtualNetwork.getGateway());
                System.out.println("-Netmask: " + virtualNetwork.getNetmask());
                System.out.println("-Carte Admin: " + virtualNetwork.isAdmin());
                System.out.println("-Carte Client: " + virtualNetwork.isClient());

                if (virtualNetwork.getListOfDns() != null && !virtualNetwork.getListOfDns().isEmpty()) {
                    System.out.println("-Dns:");

                    for (String dns : virtualNetwork.getListOfDns()) {
                        System.out.println(" - " + dns);
                    }
                }

                System.out.println("");

            }
        }

        if (listOfVirtualDVSwitchs != null && !listOfVirtualDVSwitchs.isEmpty()) {
            System.out.println("############ Virtual Network ############");

            for (VirtualDVSwitch virtualDVSwitch : listOfVirtualDVSwitchs) {
                System.out.println("-Name: " + virtualDVSwitch.getDvSwitch().getName());
                System.out.println("-Mac Address: " + virtualDVSwitch.getMacAddress());
                System.out.println("-IP: " + virtualDVSwitch.getIp());
                System.out.println("-BroadCast: " + virtualDVSwitch.getBroadCast());
                System.out.println("-Gateway: " + virtualDVSwitch.getGateway());
                System.out.println("-Netmask: " + virtualDVSwitch.getNetmask());
                System.out.println("-Carte Admin: " + virtualDVSwitch.isAdmin());
                System.out.println("-Carte Client: " + virtualDVSwitch.isClient());

                if (virtualDVSwitch.getListOfDns() != null && !virtualDVSwitch.getListOfDns().isEmpty()) {
                    System.out.println("-Dns:");

                    for (String dns : virtualDVSwitch.getListOfDns()) {
                        System.out.println(" - " + dns);
                    }
                }

                System.out.println("");

            }
        }

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getWindowsIPInfoFromWindows(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);
        /*
              String toto="\n<?xml version=\"1.0\" standalone=\"yes\"?><AdapterInfo><Adapter><Name>{85FDBA24-FE54-474E-8584-43789FF4830A}</Name><Description>Intel(R) PRO/1000 MT Network Connection #2</Description><MacAddress>00:50:56:A6:00:0E</MacAddress><IP>10.62.16.66</IP><Subnet>255.255.252.0</Subnet><Gateway>10.62.16.2</Gateway><Dns>10.251.5.50,194.133.14.66</Dns></Adapter><Adapter><Name>{39257C80-3915-4D13-B35F-8923D196114F}</Name><Description>Intel(R) PRO/1000 MT Network Connection</Description><MacAddress>00:50:56:A6:00:08</MacAddress><IP>10.62.16.118</IP><Subnet>255.255.252.0</Subnet><Gateway>10.62.16.2</Gateway><Dns>10.251.5.50,194.133.14.67</Dns></Adapter></AdapterInfo>";
              String titi=toto.substring(toto.indexOf("<?xml"), toto.length()); 
                  
              InputStream inputStream =null;
              AdapterInfo adapterInfo=null;
              List<Adapter> adapters=null;
            
              inputStream = new ByteArrayInputStream(titi.getBytes());
              adapterInfo=AdapterInfoManager.loadXMLFile(AdapterInfo.class, inputStream);
            
              System.out.println("Adpater Info: "+adapterInfo);
                  
              adapters=adapterInfo.getAdapter();
                  
              if (adapters!=null && !adapters.isEmpty())
              {
                 for (Adapter adapter:adapters)
                 {
        System.out.println("########## Adapter ##########");
        System.out.println("- Name: "+adapter.getName());
        System.out.println("- Description: "+adapter.getDescription());
        System.out.println("- Mac Address: "+adapter.getMacAddress());
        System.out.println("- IP: "+adapter.getIP());
        if (adapter.getIP6()!=null)
        {
           System.out.println("- IP6: "+adapter.getIP6());
        }
            
        System.out.println("- Subnet: "+adapter.getSubnet());
        System.out.println("- Gateway: "+adapter.getGateway());
        if (adapter.getDns()!=null && !adapter.getDns().isEmpty())
           System.out.println("- DNS: "+adapter.getDns());
            
        if (adapter.getRoute()!=null)
        {
           System.out.println("- Admin: "+new Boolean(adapter.getRoute().getAdmin()));
           System.out.println("- Client: "+new Boolean(adapter.getRoute().getClient()));
        }
            
        System.out.println("");
                 }
            
              }
        */

        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        GuestCustUtil guestCustUtil = new GuestCustUtil();
        guestCustUtil.setCustUtilExe("D:\\VMware\\Guest Tools\\GetAdpaterInfo.exe");
        guestCustUtil.setPsExec("D:\\VMware\\Guest Tools\\PsExec.exe");

        //vm.getWindowsIPInfoFromWindows("10.62.16.66", "Administrator", "Passw0rd$", guestCustUtil);

        // =========================================================================================
        // Affichage des Networks avec leur configuration IP
        // =========================================================================================
        VMNetwork vmNetwork = vm.getVMNetwork();

        ArrayList<VirtualNetwork> listOfVirtualNetworks = null;
        ArrayList<VirtualDVSwitch> listOfVirtualDVSwitchs = null;

        listOfVirtualNetworks = vmNetwork.getListOfVirtualNetwork();
        listOfVirtualDVSwitchs = vmNetwork.getListOfVirtualDVSwitch();

        if (listOfVirtualNetworks != null && !listOfVirtualNetworks.isEmpty()) {
            System.out.println("############ Virtual Network ############");

            for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {
                System.out.println("-Name: " + virtualNetwork.getNetwork().getName());
                System.out.println("-Mac Address: " + virtualNetwork.getMacAddress());
                System.out.println("-IP: " + virtualNetwork.getIp());
                System.out.println("-BroadCast: " + virtualNetwork.getBroadCast());
                System.out.println("-Gateway: " + virtualNetwork.getGateway());
                System.out.println("-Netmask: " + virtualNetwork.getNetmask());
                System.out.println("-Carte Admin: " + virtualNetwork.isAdmin());
                System.out.println("-Carte Client: " + virtualNetwork.isClient());

                if (virtualNetwork.getListOfDns() != null && !virtualNetwork.getListOfDns().isEmpty()) {
                    System.out.println("-Dns:");

                    for (String dns : virtualNetwork.getListOfDns()) {
                        System.out.println(" - " + dns);
                    }
                }

                System.out.println("");

            }
        }

        if (listOfVirtualDVSwitchs != null && !listOfVirtualDVSwitchs.isEmpty()) {
            System.out.println("############ Virtual Network ############");

            for (VirtualDVSwitch virtualDVSwitch : listOfVirtualDVSwitchs) {
                System.out.println("-Name: " + virtualDVSwitch.getDvSwitch().getName());
                System.out.println("-Mac Address: " + virtualDVSwitch.getMacAddress());
                System.out.println("-IP: " + virtualDVSwitch.getIp());
                System.out.println("-BroadCast: " + virtualDVSwitch.getBroadCast());
                System.out.println("-Gateway: " + virtualDVSwitch.getGateway());
                System.out.println("-Netmask: " + virtualDVSwitch.getNetmask());
                System.out.println("-Carte Admin: " + virtualDVSwitch.isAdmin());
                System.out.println("-Carte Client: " + virtualDVSwitch.isClient());

                if (virtualDVSwitch.getListOfDns() != null && !virtualDVSwitch.getListOfDns().isEmpty()) {
                    System.out.println("-Dns:");

                    for (String dns : virtualDVSwitch.getListOfDns()) {
                        System.out.println(" - " + dns);
                    }
                }

                System.out.println("");

            }
        }

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getWindowsIPInfoFromLinux(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        System.out.println("VM ID: " + vm.getMor().get_value());

        GuestCustUtil guestCustUtil = new GuestCustUtil();
        guestCustUtil.setCustUtilExe("GetAdpaterInfo.exe");
        guestCustUtil.setCustUtilCmd("getWindowsIPinfos.cmd");
        guestCustUtil.setPsExec("winexe");
        guestCustUtil.setPathToScript("/disk2/appeva/jboss-5.1.0.GA/server/siveo-jbpm/GuestTools");

        //vm.getWindowsIPInfoFromLinux("10.62.16.66", "Administrator", "Passw0rd$", guestCustUtil);
        //vm.getWindowsIPInfoFromLinux("10.62.16.100", "SIVEO\\Administrateur", "Clmdp@09", guestCustUtil);

        Collection<String> t = null;

        // =========================================================================================
        // Affichage des Networks avec leur configuration IP
        // =========================================================================================
        VMNetwork vmNetwork = vm.getVMNetwork();

        ArrayList<VirtualNetwork> listOfVirtualNetworks = null;
        ArrayList<VirtualDVSwitch> listOfVirtualDVSwitchs = null;

        listOfVirtualNetworks = vmNetwork.getListOfVirtualNetwork();
        listOfVirtualDVSwitchs = vmNetwork.getListOfVirtualDVSwitch();

        if (listOfVirtualNetworks != null && !listOfVirtualNetworks.isEmpty()) {
            System.out.println("############ Virtual Network ############");

            for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {
                System.out.println("-Name: " + virtualNetwork.getNetwork().getName());
                System.out.println("-Mac Address: " + virtualNetwork.getMacAddress());
                System.out.println("-IP: " + virtualNetwork.getIp());
                System.out.println("-BroadCast: " + virtualNetwork.getBroadCast());
                System.out.println("-Gateway: " + virtualNetwork.getGateway());
                System.out.println("-Netmask: " + virtualNetwork.getNetmask());
                System.out.println("-Carte Admin: " + virtualNetwork.isAdmin());
                System.out.println("-Carte Client: " + virtualNetwork.isClient());

                if (virtualNetwork.getListOfDns() != null && !virtualNetwork.getListOfDns().isEmpty()) {
                    System.out.println("-Dns:");

                    for (String dns : virtualNetwork.getListOfDns()) {
                        System.out.println(" - " + dns);
                    }
                }

                System.out.println("");

            }
        }

        if (listOfVirtualDVSwitchs != null && !listOfVirtualDVSwitchs.isEmpty()) {
            System.out.println("############ Virtual Network ############");

            for (VirtualDVSwitch virtualDVSwitch : listOfVirtualDVSwitchs) {
                System.out.println("-Name: " + virtualDVSwitch.getDvSwitch().getName());
                System.out.println("-Mac Address: " + virtualDVSwitch.getMacAddress());
                System.out.println("-IP: " + virtualDVSwitch.getIp());
                System.out.println("-BroadCast: " + virtualDVSwitch.getBroadCast());
                System.out.println("-Gateway: " + virtualDVSwitch.getGateway());
                System.out.println("-Netmask: " + virtualDVSwitch.getNetmask());
                System.out.println("-Carte Admin: " + virtualDVSwitch.isAdmin());
                System.out.println("-Carte Client: " + virtualDVSwitch.isClient());

                if (virtualDVSwitch.getListOfDns() != null && !virtualDVSwitch.getListOfDns().isEmpty()) {
                    System.out.println("-Dns:");

                    for (String dns : virtualDVSwitch.getListOfDns()) {
                        System.out.println(" - " + dns);
                    }
                }

                System.out.println("");

            }
        }

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void setLinuxVMIP() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Set IP Configuration
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();

        GuestCustUtil guestCustUtil = new GuestCustUtil();

        //guestCustUtil.setCustUtilExe("D:\\VMware\\Guest Tools\\manu\\final\\reconfigurationVM.pl");
        guestCustUtil.setCustUtilExe("D:\\Siveo\\script\\reconfigurationVM.pl");

        // Set IP Configuration
        /*
        guestCustUtil.setIpAddress("10.62.16.102");
        guestCustUtil.setSubnetMask("255.255.252.0");
        guestCustUtil.setGateway("10.62.16.2");
        guestCustUtil.getListOfDNS().add("10.251.5.50");
        guestCustUtil.getListOfDNS().add("194.133.14.66");
        guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.getListOfDnsSuffixes().add("siveo.org");
        guestCustUtil.setIpJboss("10.251.7.0/24");
        */

        // Set IP + Admin
        /*
        guestCustUtil.setIpAddress("10.62.16.101");
        guestCustUtil.setSubnetMask("255.255.252.0");
        guestCustUtil.setGateway("10.62.16.1");
        guestCustUtil.getListOfDNS().add("10.251.5.50");
        guestCustUtil.getListOfDNS().add("194.133.14.66");
        guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.setAdmin(true);    
        guestCustUtil.setClient(false);
        guestCustUtil.setIpJboss("10.251.7.0/24");
        */

        // Set IP + Client
        /*
        guestCustUtil.setIpAddress("10.62.16.100");
        guestCustUtil.setSubnetMask("255.255.252.0");
        guestCustUtil.setGateway("10.62.16.2");
        guestCustUtil.getListOfDNS().add("10.251.5.50");
        guestCustUtil.getListOfDNS().add("194.133.14.66");
        guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.setAdmin(false);    
        guestCustUtil.setClient(true);
        guestCustUtil.setIpJboss(null);  
        */

        // Maj Admin

        guestCustUtil.setIpAddress(null);
        guestCustUtil.setSubnetMask(null);
        guestCustUtil.setGateway("10.37.240.1");
        //guestCustUtil.getListOfDNS().add("10.251.5.50");
        //guestCustUtil.getListOfDNS().add("194.133.14.66");
        //guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.setAdmin(true);
        guestCustUtil.setClient(false);
        guestCustUtil.setIpJboss("10.62.16.101");

        // Maj Client
        /*
        guestCustUtil.setIpAddress(null);
        guestCustUtil.setSubnetMask(null);
        guestCustUtil.setGateway("10.62.16.2");
        //guestCustUtil.getListOfDNS().add("10.251.5.50");
        //guestCustUtil.getListOfDNS().add("194.133.14.66");
        //guestCustUtil.getListOfDnsSuffixes().add("siveo.net");
        guestCustUtil.setAdmin(false);    
        guestCustUtil.setClient(true);
        guestCustUtil.setIpJboss("10.251.7.0/24");      
        */

        //String guestOSID="centos64Guest";
        String guestOSID = "rhel4_64Guest";

        //vmManager.configureLinuxIP("10.62.16.85", "root", "cahh4gee$", "00:50:56:A6:00:1C", guestOSID, guestCustUtil);
        //vmManager.configureLinuxIP("10.62.16.175", "root", "Passw0rd$", "00:50:56:A6:6A:4B", guestOSID, guestCustUtil);

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void moveVM() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getDatastores() throws VMwareException {
        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        DataStoreManager dataStoreManager = DataStoreManager.getInstance();

        ArrayList<Datastore> listOfDS = dataStoreManager.getAllDatastore(hostName);
        System.out.println("Nb DS: " + listOfDS);
        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getDataStoreInfo() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // Set IP Configuration
        // =========================================================================================
        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        Datastore datastore = dataStoreManager.getDatastoreByName("VCE-AMP-2", hostName);

        System.out.println("Datastore");
        System.out.println("-Name: " + datastore.getName());
        System.out.println("-Capacity: " + datastore.getCapacity());
        System.out.println("-FreeSpace: " + datastore.getFreeSpace());

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getFirstVMNetwork() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        //VirtualMachine vm=vmManager.getVmByName(hostName, "SCVMM");

        VirtualMachine vm = vmManager.getVmByName(hostName, "TestCDORHEL");

        Object networkCard = null;

        networkCard = vm.getVMNetwork().getPrimaryNetwork();

        System.out.println("networkCard: " + networkCard);

        if (networkCard instanceof VirtualNetwork) {
            VirtualNetwork virtualNetwork = (VirtualNetwork) networkCard;
            System.out.println("-Name: " + virtualNetwork.getNetwork().getName());
            System.out.println("-Label: " + virtualNetwork.getVirtualDevice().getDeviceInfo().getLabel());
            System.out.println("-Mac Address: " + virtualNetwork.getMacAddress());
        } else if (networkCard instanceof VirtualDVSwitch) {
            VirtualDVSwitch virtualDVSwitch = (VirtualDVSwitch) networkCard;
            System.out.println("-Name: " + virtualDVSwitch.getDvSwitch().getName());
            System.out.println("-PortGroup: " + virtualDVSwitch.getDvPortGroup().getName());
            System.out.println("-Label: " + virtualDVSwitch.getVirtualDevice().getDeviceInfo().getLabel());
            System.out.println("-Mac Address: " + virtualDVSwitch.getMacAddress());
        }

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getSortedVMNetwork() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "SCVMM");

        //VirtualMachine vm=vmManager.getVmByName(hostName, "TestCDORHEL");

        ArrayList<Object> listOfObjects = vm.getVMNetwork().getSortedListOfNetworks();

        if (listOfObjects != null && !listOfObjects.isEmpty()) {
            for (Object object : listOfObjects) {
                if (object instanceof VirtualNetwork) {
                    VirtualNetwork virtualNetwork = (VirtualNetwork) object;
                    System.out.println("-Name: " + virtualNetwork.getNetwork().getName());
                    System.out.println("-Label: " + virtualNetwork.getVirtualDevice().getDeviceInfo().getLabel());
                    System.out.println("-Mac Address: " + virtualNetwork.getMacAddress());
                    System.out.println("");
                } else if (object instanceof VirtualDVSwitch) {
                    VirtualDVSwitch virtualDVSwitch = (VirtualDVSwitch) object;
                    System.out.println("-Name: " + virtualDVSwitch.getDvSwitch().getName());
                    System.out.println("-PortGroup: " + virtualDVSwitch.getDvPortGroup().getName());
                    System.out.println("-Port: " + virtualDVSwitch.getPortKey());
                    System.out.println("-Label: " + virtualDVSwitch.getVirtualDevice().getDeviceInfo().getLabel());
                    System.out.println("-Mac Address: " + virtualDVSwitch.getMacAddress());
                    System.out.println("");
                }

            }
        }

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void cloneTemplateToVmAndSetIP() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Initialize the Sysprep
        // =========================================================================================
        System.out.println("\n*****  Clone Template to VM *****");
        //String vmName=null;
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        //vmConfiguration.setUserName("actidev1");   
        vmConfiguration.setUserName("siveo_test");
        vmConfiguration.setSocietyName("siveo");
        vmConfiguration.setName("SCVMM_Clone");

        // ---------------------------------------------------------------
        // Initialize the GuiUnattended Section
        // ---------------------------------------------------------------
        GuiUnattended guiUnattended = new GuiUnattended();
        guiUnattended.setAdminPassword("Passw0rd$");
        guiUnattended.setEncryptedAdminPassword(false);
        guiUnattended.setAutoLogon(true);
        guiUnattended.setAutoLogonCount(3);
        guiUnattended.setTimeZone(105);

        // ---------------------------------------------------------------
        // Initialize the LicenseFilePrintData Section
        // ---------------------------------------------------------------
        LicenseFilePrintData licenseData = new LicenseFilePrintData();
        licenseData.setAutoMode("PerServer");
        licenseData.setAutoUsers(5);

        // ---------------------------------------------------------------
        // Initialize the UserData Section
        // ---------------------------------------------------------------
        UserData userData = new UserData();
        userData.setComputerName(vmConfiguration.getName());
        userData.setFullName("WinVMUser");
        userData.setOrgName("SIVEO");
        userData.setProductId("MBKJF-QXT8P-RXWBG-FG687-C79GP");

        //

        // ---------------------------------------------------------------
        // Initialize the Identification Section
        // ---------------------------------------------------------------
        Identification identification = new Identification();
        identification.setDomainAdmin("SIVEO\\Administrateur");
        identification.setDomainAdminPassword("Clmdp@09");
        identification.setJoinDomain(null);
        identification.setJoinWorkgroup("WORKGROUP");

        //identification.setDomainAdmin("SIVEO\\Administrateur");
        //identification.setDomainAdminPassword("Clmdp@09");
        //identification.setJoinDomain("SIVEO");
        ////identification.setJoinWorkgroup("WORKGROUP");

        // ---------------------------------------------------------------
        // Initialize the GuiRunOnce Section
        // ---------------------------------------------------------------
        GuiRunOnce guiRunOnce = new GuiRunOnce();
        String command = "\"net localgroup Administrateurs " + identification.getJoinDomain() + "\\"
                + vmConfiguration.getUserName() + " /add\"";
        //System.out.println("command: "+command);
        //guiRunOnce.setCommandList(new String[]{command});

        // ---------------------------------------------------------------
        // Initialize the Sysprep for Windows
        // ---------------------------------------------------------------
        SysprepWindows winSysPrep = new SysprepWindows();
        //winSysPrep.setGuiRunOnce(guiRunOnce);
        winSysPrep.setGuiUnattended(guiUnattended);
        winSysPrep.setIdentification(identification);
        winSysPrep.setLicenseFilePrintData(licenseData);
        winSysPrep.setUserData(userData);

        // ---------------------------------------------------------------
        // Initialize the Linux Sysprep 
        // ---------------------------------------------------------------
        //SysprepLinux sysprepLinux=new SysprepLinux();
        //sysprepLinux.setDomain("siveo.net");
        //sysprepLinux.setHostname("TestRHEL");

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================

        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        vmConfiguration.setSysprepWindows(winSysPrep);
        //vmConfiguration.setSysprepLinux(sysprepLinux);

        // =========================================================================================
        // Initialize Global Configuration
        // =========================================================================================
        // VirtualCenter PROD Siveo
        String dataStoreID = "datastore-247";
        String hostID = "host-246";
        String resourcePoolID = null;
        String vmID = "vm-492";
        //String vmFolder="group-v471";
        String vmFolderID = null;

        // ---------------------------------------------------------------
        // Get the Template Virtual Network Configuration
        // ---------------------------------------------------------------
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByID(hostName, vmID);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------
        VirtualNetwork virtualNetwork = null;

        // Set the First Network Card IP Configuration 
        GuestIPConfig guestIPConfig = new GuestIPConfig();
        guestIPConfig.setDnsServerList(new String[] { "10.251.5.50", "194.133.14.66" });
        guestIPConfig.setPrimaryWINS(null);
        guestIPConfig.setSecondaryWINS(null);
        guestIPConfig.setNetBIOS(null);
        guestIPConfig.setIp("10.62.16.85");
        guestIPConfig.setSubnetMask("255.255.252.0");
        guestIPConfig.setGateway(new String[] { "10.62.16.2" });
        virtualNetwork = vm.getVMNetwork().getVirtualNetworkByName("VM NetTest");
        virtualNetwork.setGuestIPConfig(guestIPConfig);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        // Set the Second Network Card IP Configuration 
        guestIPConfig.setDnsServerList(new String[] { "10.251.5.50", "194.133.14.66" });
        guestIPConfig.setPrimaryWINS(null);
        guestIPConfig.setSecondaryWINS(null);
        guestIPConfig.setNetBIOS(null);
        guestIPConfig.setIp("10.62.16.87");
        guestIPConfig.setSubnetMask("255.255.252.0");
        guestIPConfig.setGateway(new String[] { "10.62.16.2" });
        virtualNetwork = vm.getVMNetwork().getVirtualNetworkByName("VM Admin");
        virtualNetwork.setGuestIPConfig(guestIPConfig);
        vmConfiguration.getListOfVirtualNetworks().add(virtualNetwork);

        vmConfiguration.setDnsServerList(new String[] { "10.251.5.50", "194.133.14.66" });
        //vmConfiguration.setDnsSuffixList(new String[]{});
        vmConfiguration.setDnsSuffixList(new String[] { "siveo.net", "siveo" });

        vmConfiguration.setPowerOn(false);
        vmConfiguration.setCorrelID("1234ABC");

        // VirtualCenter VBLOCK
        //String dataStore="datastore-2919";
        //String host="host-123";
        //String vm="vm-3344";

        //FolderManager folderManager=FolderManager.getInstance();
        //Folder folder=folderManager.getFolderByID("group-v344", hostName);

        vmManager.cloneTemplateToVM1(vmID, hostName, vmConfiguration, hostID, dataStoreID, resourcePoolID,
                vmFolderID);

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getVMNetwork() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // Get Network
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "Win2003-STD");

        VMNetwork vmNetwork = vm.getVMNetwork();

        ArrayList<VirtualNetwork> listOfVirtualNetworks = vmNetwork.getListOfVirtualNetwork();

        if (listOfVirtualNetworks != null && !listOfVirtualNetworks.isEmpty()) {
            System.out.println("Virtual Networks:");

            for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {

                System.out.println("Virtual Networks:");
                System.out.println("- Name: " + virtualNetwork.getNetwork().getName());

            }
        }

        ArrayList<VirtualDVSwitch> listOfDvSwitchs = vmNetwork.getListOfVirtualDVSwitch();

        if (listOfDvSwitchs != null && !listOfDvSwitchs.isEmpty()) {
            for (VirtualDVSwitch virtualDVSwitch : listOfDvSwitchs) {
                System.out.println("-VirtualDVSwitch: " + virtualDVSwitch.getDvSwitch().getName());
                System.out.println("-Portgroup: " + virtualDVSwitch.getDvPortGroup().getName() + " / "
                        + virtualDVSwitch.getDvPortGroup().getKey());
                System.out.println("-Portkey: " + virtualDVSwitch.getPortKey());
                System.out.println("");
            }
        }

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void configureVMIP() throws VMwareException {

        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Initialize the Sysprep
        // =========================================================================================
        System.out.println("\n*****  Configure VM IP Settings*****");
        //String vmName=null;
        VMConfiguration vmConfiguration = new VMConfiguration();

        // ---------------------------------------------------------------
        // Set the Society Name
        // ---------------------------------------------------------------
        //vmConfiguration.setUserName("actidev1");   
        vmConfiguration.setUserName("siveo_test");
        vmConfiguration.setSocietyName("siveo");
        vmConfiguration.setName("CDO");

        // ---------------------------------------------------------------
        // Initialize the GuiUnattended Section
        // ---------------------------------------------------------------
        GuiUnattended guiUnattended = new GuiUnattended();
        guiUnattended.setAdminPassword("Clmdp2012");
        guiUnattended.setEncryptedAdminPassword(false);
        guiUnattended.setAutoLogon(true);
        guiUnattended.setAutoLogonCount(3);
        guiUnattended.setTimeZone(105);

        // ---------------------------------------------------------------
        // Initialize the LicenseFilePrintData Section
        // ---------------------------------------------------------------
        LicenseFilePrintData licenseData = new LicenseFilePrintData();
        licenseData.setAutoMode("PerServer");
        licenseData.setAutoUsers(5);

        // ---------------------------------------------------------------
        // Initialize the UserData Section
        // ---------------------------------------------------------------
        UserData userData = new UserData();
        userData.setComputerName(vmConfiguration.getName());
        userData.setFullName("WinVMUser");
        userData.setOrgName("SIVEO");
        userData.setProductId("MBKJF-QXT8P-RXWBG-FG687-C79GP");

        //

        // ---------------------------------------------------------------
        // Initialize the Identification Section
        // ---------------------------------------------------------------
        Identification identification = new Identification();
        identification.setDomainAdmin("SIVEO\\Administrateur");
        identification.setDomainAdminPassword("Clmdp@09");
        identification.setJoinDomain(null);
        identification.setJoinWorkgroup("WORKGROUP");

        //identification.setDomainAdmin("SIVEO\\Administrateur");
        //identification.setDomainAdminPassword("Clmdp@09");
        //identification.setJoinDomain("SIVEO");
        ////identification.setJoinWorkgroup("WORKGROUP");

        // ---------------------------------------------------------------
        // Initialize the GuiRunOnce Section
        // ---------------------------------------------------------------
        GuiRunOnce guiRunOnce = new GuiRunOnce();
        String command = "\"net localgroup Administrateurs " + identification.getJoinDomain() + "\\"
                + vmConfiguration.getUserName() + " /add\"";
        //System.out.println("command: "+command);
        guiRunOnce.setCommandList(new String[] { command });

        //test hudson
        // ---------------------------------------------------------------
        // Initialize the Sysprep for Windows
        // ---------------------------------------------------------------
        SysprepWindows winSysPrep = new SysprepWindows();
        //winSysPrep.setGuiRunOnce(guiRunOnce);
        winSysPrep.setGuiUnattended(guiUnattended);
        winSysPrep.setIdentification(identification);
        winSysPrep.setLicenseFilePrintData(licenseData);
        winSysPrep.setUserData(userData);

        // ---------------------------------------------------------------
        // Initialize the Sysprep
        // ---------------------------------------------------------------
        //SysprepLinux sysprepLinux=new SysprepLinux();
        //sysprepLinux.setDomain("siveo.net");
        //sysprepLinux.setHostname(vmConfiguration.getName());

        SysprepLinux sysprepLinux = new SysprepLinux();
        sysprepLinux.setDomain("siveo.net");
        sysprepLinux.setHostname("msppoc1");

        // =========================================================================================
        // Initialize the VM Configuration
        // =========================================================================================
        // ---------------------------------------------------------------
        // Set the Sysprep
        // ---------------------------------------------------------------
        vmConfiguration.setSysprepWindows(winSysPrep);
        //vmConfiguration.setSysprepLinux(sysprepLinux);

        // ---------------------------------------------------------------
        // Set the Network configuration
        //
        // If not set the default values are:
        //
        // DHCP
        // ---------------------------------------------------------------
        // Set IP for the first Network Adapter

        NetworkAdapter networkAdapter = new NetworkAdapter();
        /*
        networkAdapter.setDnsServerList(new String[]{"10.251.5.50","194.133.14.66"});
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.251.7.23");
        networkAdapter.setSubnetMask("255.255.255.240");
        networkAdapter.setGateway(new String[]{"10.251.5.17"});
        networkAdapter.setMacAddress("00:50:56:a6:6a:4b");
        //vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);
        */

        // Set IP for the second Network Adapter
        networkAdapter = new NetworkAdapter();
        networkAdapter.setDnsServerList(new String[] { "10.251.5.50", "194.133.14.66" });
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.62.16.68");
        networkAdapter.setSubnetMask("255.255.252.0");
        networkAdapter.setGateway(new String[] { "10.62.16.2" });
        networkAdapter.setMacAddress("00:50:56:a6:00:08");
        vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        // !!!
        vmConfiguration.setDnsServerList(new String[] { "10.251.5.50", "194.133.14.66" });
        vmConfiguration.setDnsSuffixList(new String[] {});

        //vmConfiguration.setPowerOn(true);
        vmConfiguration.setCorrelID("1234ABC");

        VMManager vmManager = VMManager.getInstance();
        //VirtualMachine vm=vmManager.getVmByName(hostName, "msppoc1");
        VirtualMachine vm = vmManager.getVmByName(hostName, "SCVMM");
        vmManager.configureIP(vm.getMor().get_value(), hostName, vmConfiguration);

        VMware.delete(hostName);

    }

    public void getVM_VMXFile(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Get the location path
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        VirtualMachineFileInfo d = vm.getConfigInfo().getFiles();
        System.out.println("Path name to the configuration file: " + d.getVmPathName());

        /*
        VirtualMachineConfigInfoDatastoreUrlPair[] arrayOfvirtualMachineConfigInfoDatastoreUrlPairs=vm.getConfig().getDatastoreUrl();
            
        if (arrayOfvirtualMachineConfigInfoDatastoreUrlPairs!=null && arrayOfvirtualMachineConfigInfoDatastoreUrlPairs.length>0)
        {
           for (VirtualMachineConfigInfoDatastoreUrlPair virtualMachineConfigInfoDatastoreUrlPair:arrayOfvirtualMachineConfigInfoDatastoreUrlPairs)
           {
        System.out.println("-Name: "+virtualMachineConfigInfoDatastoreUrlPair.getName()+"/ url: "+virtualMachineConfigInfoDatastoreUrlPair.getUrl());
           }
        }
        */

        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getVNCInfo(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        // ESX 6
        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<String> listOfMorIDs = new ArrayList<String>();

        listOfMorIDs.add(vm.getMor().get_value());
        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        Vnc vnc = vm.getVnc();
        if (vnc != null) {
            System.out.println("VNC Information");
            System.out.println("- Enabled: " + vnc.isEnabled());
            System.out.println("- Port: " + vnc.getPort());
            System.out.println("- Password: " + vnc.getPassword());
            System.out.println("- KeyMap: " + vnc.getKeyMap());
            System.out.println("- Key: " + vnc.getKey());
        } else {
            System.out.println("VNC is not activated");
        }

        //      Vnc vnc=vm.retrieveVNCInfo();
        //      
        //      if (vnc!=null)
        //      {
        //         System.out.println("VNC Information");
        //         System.out.println("- Enabled: "+vnc.isEnabled());
        //         System.out.println("- Port: "+vnc.getPort());
        //         System.out.println("- Password: "+vnc.getPassword());
        //         System.out.println("- KeyMap: "+vnc.getKeyMap());
        //         System.out.println("- Key: "+vnc.getKey());
        //      }
        //      else
        //      {
        //         System.out.println("VNC is not activated");
        //      }

        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void enbaleVNC(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // ESX 6
        //      String hostName="163.172.7.95";
        //      VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L,1000L);

        //      String hostName="10.62.16.33";
        //      VMware.create(hostName,443,"root","cahh4gee$",false,-1L,1000L);

        String hostName = "192.168.101.122";
        VMware.create(hostName, 443, "root", "cahh4gee$", false, -1L);

        // =========================================================================================
        // Reconfig
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        vm.enableVNC(5905, "mandriva", "fr");

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void enbaleVNCOnESXi() throws Exception {
        // =========================================================================================
        // Construction de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="10.62.16.33";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        //String hostName="10.62.16.35";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        //String hostName="163.172.7.95";
        //VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L);

        //String hostName="192.168.101.122";
        //VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        // Keonys ESXi Ingenieur 
        String hostName = "10.10.0.64";
        VMware.create(hostName, 443, "root", "Keonys123", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "LaVMCDO");

        vm.enableVNC(5905, "mandriva", "fr");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void disableVNC(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        // =========================================================================================
        // Reconfig
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        vm.disableVNC("1234");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getHostIP(String esxName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // Retrieve the host IP Address
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        Host host = null;

        if (esxName != null) {
            host = hostManager.getHostByName(esxName, hostName);
            System.out.println("Host: " + host.getName() + " / " + host.getIP());
        } else {
            ArrayList<Host> listOfHosts = hostManager.getAllHosts(hostName);

            if (listOfHosts != null && !listOfHosts.isEmpty()) {
                for (Host host_ : listOfHosts) {
                    System.out.println("Host: " + host_.getName() + " / " + host_.getIP());
                }
            }

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getInventory() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        // =========================================================================================
        // Get Inventory
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        System.out.println("RootNode: " + inventory.getRootNode());
        System.out.println("");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVapp() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "10.251.5.75";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        // =========================================================================================
        // Get Inventory
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        TreeNode rootNode = inventory.getRootNode();

        System.out.println("RootNode: " + rootNode);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getToolsInformation(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        Guest guest = vm.getGuest();

        if (guest != null) {
            System.out.println("- Tools Running Status: " + guest.getToolsRunningStatus().getName() + " / "
                    + guest.getToolsRunningStatus().getDescription());
            System.out.println("- Tools Status: " + guest.getToolsStatus());
            System.out.println("- Tools Version: " + guest.getToolsVersion());
            System.out.println("- Tools Version Status: " + guest.getToolsVersionStatus().getName() + " / "
                    + guest.getToolsVersionStatus().getDescription());
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void installTools(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        vm.mountToolsInstaller();
        //vm.UnmountToolsInstaller();

        System.out.println("Appuyer sur une touche");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void upgradeTools(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L,1000L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L, 1000L);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        if (vm != null) {
            vm.upgradeTools("1234567");
        }

        System.out.println("Appuyer sur une touche");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void manageTpl() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@09", false, -1L);

        VMware.keepAlive(hostName);
        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        // =========================================================================================
        // Get Inventory
        // =========================================================================================
        String vmName = "msppoc1";
        String vmID = "vm-34";
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        System.out.println("VM is template: " + vm.isTemplate());
        System.out.println("VM state: " + vm.getPowerState());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void queryAvailablePerf() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        // =========================================================================================
        // Get the WebService
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        PerfMetricId[] listOfPerfMetric = null;
        PerfMetricId perfMetricId = null;

        ArrayList<PerfMetricId> listOfPerfMetricIds = new ArrayList<PerfMetricId>();

        // =========================================================================================
        // Get the vApp
        // =========================================================================================
        VirtualAppManager virtualAppManager = VirtualAppManager.getInstance();
        VirtualApp virtualApp = virtualAppManager.getVAppByName("vAppVMFolder", hostName);

        // =========================================================================================
        // Get the RefreshRate
        // =========================================================================================
        PerfProviderSummary perfProviderSummary = null;
        try {
            perfProviderSummary = ws.getVIMService().getService()
                    .queryPerfProviderSummary(ws.getPerformanceManager(), virtualApp.getMor());
        } catch (RuntimeFault e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        System.out.println("Real-Time Statistics :" + perfProviderSummary.isCurrentSupported());
        System.out.println("Historical Statistics: " + perfProviderSummary.isSummarySupported());
        System.out.println("Refresh Rate: " + perfProviderSummary.getRefreshRate());

        // =========================================================================================
        // Get the WebService
        // =========================================================================================
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        performanceManager.init(hostName);

        HashMap<Integer, Counter> mapOfCounter = performanceManager.getAllCountersByID(hostName);

        for (Map.Entry<Integer, Counter> entry : mapOfCounter.entrySet()) {
            perfMetricId = new PerfMetricId();
            perfMetricId.setCounterId(entry.getKey());
            perfMetricId.setInstance("*");
            listOfPerfMetricIds.add(perfMetricId);
        }

        // =========================================================================================
        // Get the WebService
        // =========================================================================================
        performanceManager.getAvailablePerfCounter(virtualApp, null, null, 1800);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVAppPerformance() throws VMwareException {
        // ===================================================================================
        // Connection to the  VirtualCenter
        // ===================================================================================
        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        // ===================================================================================
        // Get all ResourcePool from the VC
        // ===================================================================================
        ArrayList<TreeNode> listOfTreenodes = new ArrayList<TreeNode>();

        //InventoryManager inventoryManager=InventoryManager.getInstance();
        //listOfTreenodes=inventoryManager.getTreeNodeByType("ResourcePool", hostName);

        VirtualAppManager virtualAppManager = VirtualAppManager.getInstance();

        listOfTreenodes.addAll(virtualAppManager.getAllVApp(hostName));

        // ===================================================================================
        // Create the "Performance Engine"
        // --------------------------------------------------------------
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        Performance performance = performanceManager.create(hostName);

        // ===================================================================================
        // Build the StartTime and the EndTime
        // ===================================================================================
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss:SSSS");
        Calendar curTime = performance.getCurrentDateTime();

        Calendar startTime = (Calendar) curTime.clone();
        startTime.set(Calendar.HOUR_OF_DAY, 23);
        startTime.set(Calendar.MINUTE, 00);
        startTime.set(Calendar.SECOND, 00);
        startTime.set(Calendar.MILLISECOND, 00);
        startTime.set(Calendar.HOUR_OF_DAY, startTime.get(Calendar.HOUR_OF_DAY) - 1);

        Calendar endTime = (Calendar) curTime.clone();
        endTime.set(Calendar.HOUR_OF_DAY, 22);
        endTime.set(Calendar.MINUTE, 59);
        endTime.set(Calendar.SECOND, 59);
        endTime.set(Calendar.MILLISECOND, 00);
        endTime.set(Calendar.HOUR_OF_DAY, endTime.get(Calendar.HOUR_OF_DAY) - 1);

        startTime.roll(Calendar.DATE, -2);
        endTime.roll(Calendar.DATE, -1);

        System.out.println("StartTime: " + dateFormat.format(startTime.getTime()));
        System.out.println("EndTime: " + dateFormat.format(endTime.getTime()));

        // #########################################################

        // ===================================================================================
        // ResourcePool Performance Counters Collect
        // ===================================================================================

        // --------------------------------------------------------------
        // Build the PerfMetrics from the Host Performance Counters
        // --------------------------------------------------------------
        PerfMetricId[] arrayOfPerfMetricId = null;

        /*
        HashMap<Integer,PerfCounterInfo> mapPerf=performance.getMapOfPerfCounterInfoByIdByVC().get(hostName);
            
        System.out.println("Nb PerfCounterInfo: "+mapPerf.size());
            
        PerfMetricId perfMetricId=null;
            
        ArrayList<PerfMetricId> listOfPerfMetricIds=new ArrayList<PerfMetricId>();
            
        for (Map.Entry<Integer,PerfCounterInfo> entry:mapPerf.entrySet())
        {
           perfMetricId=new PerfMetricId();
           perfMetricId.setCounterId(entry.getKey());
           perfMetricId.setInstance("*");
           listOfPerfMetricIds.add(perfMetricId);
        }
            
        System.out.println("Nb PerfMetric: "+listOfPerfMetricIds.size());
            
            
        if (!listOfPerfMetricIds.isEmpty())
        {
           arrayOfPerfMetricId=(listOfPerfMetricIds.toArray(new PerfMetricId[listOfPerfMetricIds.size()]));   
        }
        */

        // --------------------------------------------------------------
        // Build the PerfMetrics from the Host Performance Counters
        // --------------------------------------------------------------
        HashMap<String, String> mapOfInstanceByCounterName = new HashMap<String, String>();

        mapOfInstanceByCounterName.put("cpu.cpuentitlement.latest", "");
        mapOfInstanceByCounterName.put("cpu.usagemhz.average", "");
        mapOfInstanceByCounterName.put("mem.consumed.average", "");
        mapOfInstanceByCounterName.put("mem.mementitlement.latest", "");
        mapOfInstanceByCounterName.put("mem.overhead.average", "");
        mapOfInstanceByCounterName.put("mem.vmmemctl.average", "");

        //PerfMetricId[] arrayOfPerfMetricId=performance.getPerfMetric(this.getResourcePoolPerformanceCounters());
        arrayOfPerfMetricId = performance.getPerfMetric(mapOfInstanceByCounterName);

        // --------------------------------------------------------------
        // Build the PerfQuerySpecs from the Host PerfMetrics
        // --------------------------------------------------------------
        int refreshRate = 300;
        PerfQuerySpec[] arrayOfPerfQuerySpecs = performance.getQueryPerfSpec(listOfTreenodes, arrayOfPerfMetricId,
                null, null, refreshRate);
        //PerfQuerySpec[]  arrayOfPerfQuerySpecs=performance.getQueryPerfSpec(listOfTreenodes, arrayOfPerfMetricId, startTime, endTime, refreshRate);

        // --------------------------------------------------------------
        // Retrieve the Performance Counter Values
        // --------------------------------------------------------------
        ArrayList<PerfMetric> listOfPerfMetrics = null;
        ArrayList<PerfResult> listOfPerfResults = null;
        listOfPerfResults = performance.getPerf(arrayOfPerfQuerySpecs);
        System.out.println("listOfPerfResults: " + listOfPerfResults.size());

        if (!listOfPerfResults.isEmpty()) {
            System.out.println("\n\n\n########## PerfResult ##########");

            for (PerfResult perfResult : listOfPerfResults) {
                System.out.println("- Sampling Interval: " + perfResult.getSamplingRate());
                System.out.println("- Sampling Period: " + perfResult.getSamplingPeriod());
                System.out.println("- Entity: " + perfResult.getEntity().getName() + " / "
                        + perfResult.getEntity().getMor().get_value() + " / "
                        + perfResult.getEntity().getMor().getType());

                listOfPerfMetrics = perfResult.getListOfPerfMetrics();
                if (!listOfPerfMetrics.isEmpty()) {
                    System.out.println("- Metrics:");

                    for (PerfMetric perfMetric : listOfPerfMetrics) {
                        System.out.println(
                                " - Counter: " + perfMetric.getCounterName() + " / " + perfMetric.getInstance());
                        System.out.println(" - Values: " + perfMetric.getValues());
                    }

                }

                System.out.println("");

            }
        }

        // ===================================================================================
        // Destroy the VC connection
        // ===================================================================================
        VMware.delete(hostName);

    }

    public void getVMGuest() throws VMwareException {
        // ===================================================================================
        // Create the VC Connection
        // ===================================================================================
        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // ===================================================================================
        // Retrieve IP Infos
        // ===================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "JTH-TESTCREIP-01");

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();
        listOfManagedObjectReferences.add(vm.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);

        Guest guest = vm.getGuest();

        // ===================================================================================
        // Destroy the VC connection
        // ===================================================================================
        VMware.delete(hostName);
    }

    public void getVMIPInfos() throws VMwareException {
        // ===================================================================================
        // Create the VC Connection
        // ===================================================================================
        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@2013$", false, -1L);

        // ===================================================================================
        // Retrieve IP Infos
        // ===================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "JTH-TESTCREIP-01");

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();
        listOfManagedObjectReferences.add(vm.getMor());

        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);

        VMNetwork vmNetwork = vm.getVMNetwork();

        ArrayList<VirtualNetwork> listOfNetworks = vmNetwork.getListOfVirtualNetwork();
        ArrayList<String> listOfIPAddresses = null;

        if (listOfNetworks != null && !listOfNetworks.isEmpty()) {
            for (VirtualNetwork virtualNetwork : listOfNetworks) {
                System.out.println("- Network Name: " + virtualNetwork.getNetwork().getName());
                System.out.println("- MAC Address: " + virtualNetwork.getMacAddress());
                listOfIPAddresses = virtualNetwork.getListOfIPAddress();
                if (listOfIPAddresses != null && !listOfIPAddresses.isEmpty()) {
                    for (String ip : listOfIPAddresses) {
                        System.out.println("- IP: " + ip);
                    }
                }

                System.out.println("");

            }
        }

        // ===================================================================================
        // Destroy the VC connection
        // ===================================================================================
        VMware.delete(hostName);
    }

    public void getVirtualMachineInfo() throws VMwareException {
        // ===================================================================================
        // Create the VC Connection
        // ===================================================================================
        String hostName = "10.10.0.64";
        VMware.create(hostName, 443, "root", "Keonys123", false, -1L);

        // ===================================================================================
        // 
        // ===================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        ArrayList<String> listOfMorIDs = new ArrayList<String>();

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByID(hostName, "720");

        listOfMorIDs.add(vm.getMor().get_value());
        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        //VirtualMachineConnectionState virtualMachineConnectionState=null;
        String virtualMachineConnectionState = vm.getConnectionState();
        System.out.println("VM Connection State: " + virtualMachineConnectionState);

        //      VirtualMachineConnectionState virtualMachineConnectionState=null;
        //      virtualMachineConnectionState=(VirtualMachineConnectionState)MorManager.getMorProperty(vm.getWS(),vm.getMor(), new String[] {"runtime.connectionState"});
        //      System.out.println("VM Connection State: "+virtualMachineConnectionState);

        HostManager hostManager = HostManager.getInstance();
        Host host = hostManager.getHostByName("SSCL-VMSERV-01.keonys.local", hostName);

        ArrayOfManagedObjectReference arrayOfManagedObjectReference = null;
        arrayOfManagedObjectReference = (ArrayOfManagedObjectReference) MorManager.getMorProperty(host.getWS(),
                host.getMor(), new String[] { "vm" });

        System.out.println("");

        if (arrayOfManagedObjectReference != null
                && arrayOfManagedObjectReference.getManagedObjectReference() != null
                && arrayOfManagedObjectReference.getManagedObjectReference().length > 0) {
            for (ManagedObjectReference mor : arrayOfManagedObjectReference.getManagedObjectReference()) {
                String name = (String) MorManager.getMorProperty(host.getWS(), mor, new String[] { "name" });
                System.out.println("" + name);
            }
        }

        // ===================================================================================
        // Destroy the VC connection
        // ===================================================================================
        VMware.delete(hostName);

    }

    public void getVirtualMachinesInfo() throws VMwareException {
        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================

        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="10.0.12.6";
        //VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,-1L,1000L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L,1000L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L,1000L);

        //      String hostName="10.62.16.34";
        //      VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        //String hostName="163.172.7.95";
        //VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L);

        //      String hostName="10.62.16.33";
        //      VMware.create(hostName,443,"root","cahh4gee$",false,-1L,1000L);

        //      String hostName="163.172.7.95";
        //      VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L,1000L);

        //      String hostName="192.168.101.122";
        //      VMware.create(hostName,443,"root","cahh4gee$",false,-1L);

        String hostName = "10.10.0.64";
        VMware.create(hostName, 443, "root", "Keonys123", false, -1L);

        // =========================================================================================
        // Get All VirtualMachines and Templates and display their Configuration
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        TreeNode root = inventory.getRootNode();

        System.out.println("RootNode: " + root);

        VMConfiguration vmConfiguration = null;
        String vmName = null;

        VMManager vmManager = VMManager.getInstance();
        ArrayList<VirtualMachine> vms = vmManager.getAllVM(hostName);

        ArrayList<String> listOfMorIDs = new ArrayList<String>();

        //      System.out.println("List of Power State:");
        //      System.out.println("- "+VirtualMachinePowerState.poweredOff.name());
        //      System.out.println("- "+VirtualMachinePowerState.poweredOn.name());
        //      
        //      System.out.println("List of host Power State:");
        //      System.out.println("- "+HostSystemPowerState.poweredOff+" / "+HostSystemPowerState.poweredOff.name()+" / "+HostSystemPowerState.poweredOff.toString());
        //      System.out.println("- "+VirtualMachinePowerState.poweredOn.name());

        VirtualMachineSummary virtualMachineSummary = null;
        String padding = "#####################################################################################";
        //String paddingSpace="                                             ";
        //String decoration=null;

        if (vms != null && !vms.isEmpty()) {
            for (VirtualMachine vm : vms) {
                listOfMorIDs.add(vm.getMor().get_value());
            }

            inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

            for (VirtualMachine vm : vms) {
                vmConfiguration = vm.getConfiguration();
                vmName = vm.getName();

                virtualMachineSummary = vm.getSummary();

                System.out.println("\n#################" + padding.substring(0, vmName.length())
                        + "##########################################");
                System.out.println(" " + vmName);
                System.out.println("#################" + padding.substring(0, vmName.length())
                        + "##########################################");

                if (vm.getHost() != null) {
                    System.out.println("- Host: " + vm.getHost().getName());
                    //vm.getHost()
                }

                System.out.println("- PowerState: " + vm.getPowerState());

                //            if (virtualMachineSummary.getQuickStats()!=null)
                //            {
                //               System.out.println("- QuickStats");
                //               System.out.println(" - CPU Usage: " +virtualMachineSummary.getQuickStats().getOverallCpuUsage());
                //            }

                if (vmConfiguration.getVirtualCPU() != null) {

                    System.out.println("\n=====================");
                    System.out.println("======== CPU ========");
                    System.out.println("=====================");
                    System.out.println("- Nb vCPU: " + vmConfiguration.getVirtualCPU().getNbCPU());
                    System.out.println("- Mghz: " + vmConfiguration.getVirtualCPU().getMghz());
                    System.out.println("- Reservation: " + vmConfiguration.getVirtualCPU().getReservation());
                    System.out.println("- Limit: " + vmConfiguration.getVirtualCPU().getLimit());
                    if (vmConfiguration.getVirtualCPU().getShareLevel() != null)
                        System.out.println("- Share Level: " + vmConfiguration.getVirtualCPU().getShareLevel());

                    System.out.println("- Share Level: " + vmConfiguration.getVirtualCPU().getShares());

                }

                if (vmConfiguration.getVirtualMemory() != null) {
                    System.out.println("\n========================");
                    System.out.println("======== Memory ========");
                    System.out.println("========================");
                    System.out.println("- Memory: " + vmConfiguration.getVirtualMemory().getMemory());
                    System.out.println("- Memory Size: " + vmConfiguration.getVirtualMemory().getMemorySize());
                    System.out.println(
                            "- Memory Reservation: " + vmConfiguration.getVirtualMemory().getReservation());
                    System.out.println("- Memory Limit: " + vmConfiguration.getVirtualMemory().getLimit());
                    if (vmConfiguration.getVirtualMemory().getShareLevel() != null)
                        System.out.println("- Share Level: " + vmConfiguration.getVirtualMemory().getShareLevel());

                    System.out.println("- Share Level: " + vmConfiguration.getVirtualMemory().getShares());

                }

                System.out.println("\n===================================");
                System.out.println("======== Guest Information ========");
                System.out.println("===================================");
                System.out.println("- Host Name: " + vm.getGuest().getHostName());
                System.out.println("- IP Primary Address: " + vm.getGuest().getIpAddress());
                System.out.println("- OS");
                System.out.println("- Family   : " + vm.getGuest().getOSFamily());
                System.out.println("  - Full Name: " + vm.getGuest().getOSFullName());
                System.out.println("  - ID       : " + vm.getGuest().getOSId());
                System.out.println("- VMware Tools");
                //               System.out.println("  - Status        : "+vm.getGuest().getToolsStatus());
                //               System.out.println("  - Running Status: "+vm.getGuest().getToolsRunningStatus().getName());
                //               System.out.println("  - Version       : "+vm.getGuest().getToolsVersion());
                //               System.out.println("  - Version Status: "+vm.getGuest().getToolsVersionStatus().getName());
                if (!vm.getGuest().getDisk().isEmpty()) {
                    int nbGuestDisk = 1;
                    for (GuestDisk guestDisk : vm.getGuest().getDisk()) {
                        System.out.println("- Disk n" + nbGuestDisk++);
                        System.out.println("  - Capacit    : " + guestDisk.getCapacity());
                        System.out.println("  - Taille libre: " + guestDisk.getFreeSpace());
                        System.out.println("  - Label       : " + guestDisk.getDiskPath());
                    }
                }

                System.out.println("\n======================================");
                System.out.println("======== Network Adapter Info ========");
                System.out.println("======================================");

                VMNetwork vmNetwork = vm.getVMNetwork();
                ArrayList<VirtualNetwork> listOfVirtualNetworks = null;
                ArrayList<VirtualDVSwitch> listOfVirtualDVSwitchs = null;

                if (vmNetwork != null) {

                    listOfVirtualNetworks = vmNetwork.getListOfVirtualNetwork();
                    if (listOfVirtualNetworks != null && !listOfVirtualNetworks.isEmpty()) {
                        for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {
                            System.out.println("- Label: " + virtualNetwork.getLabel());
                            System.out.println("- Name: " + virtualNetwork.getNetwork().getName());
                            System.out.println("- Vlan ID: " + virtualNetwork.getNetwork().getVlanId());
                            System.out.println("- Mac Address: " + virtualNetwork.getMacAddress());
                            if (virtualNetwork.getListOfIPAddress() != null) {
                                for (String ip : virtualNetwork.getListOfIPAddress()) {
                                    System.out.println("- IP: " + ip);
                                }
                            }
                            System.out.println("");
                        }
                    }

                    listOfVirtualDVSwitchs = vmNetwork.getListOfVirtualDVSwitch();
                    if (listOfVirtualDVSwitchs != null && !listOfVirtualDVSwitchs.isEmpty()) {
                        for (VirtualDVSwitch virtualDVSwitch : listOfVirtualDVSwitchs) {
                            System.out.println("- Label: " + virtualDVSwitch.getLabel());
                            System.out.println("- Name: " + virtualDVSwitch.getDvSwitch().getName());
                            System.out.println("- DVPortgroup: " + virtualDVSwitch.getDvPortGroup().getName());
                            System.out.println("- Port: " + virtualDVSwitch.getPortKey());
                            System.out.println("- Mac Address: " + virtualDVSwitch.getMacAddress());
                            //System.out.println("    - Primary Ip Address: "+virtualDVSwitch.getPrimaryIpAddress());

                            if (virtualDVSwitch.getGuestNic() != null
                                    && virtualDVSwitch.getGuestNic().getIpConfig() != null
                                    && virtualDVSwitch.getGuestNic().getIpConfig()
                                            .getListOfAssignedIpAddress() != null
                                    && !virtualDVSwitch.getGuestNic().getIpConfig().getListOfAssignedIpAddress()
                                            .isEmpty()) {
                                System.out.println("    - Assigned Ip Address: ");

                                for (IpConfigInfoIpAddress ipConfigInfoIpAddress : virtualDVSwitch.getGuestNic()
                                        .getIpConfig().getListOfAssignedIpAddress()) {
                                    System.out.println("    - Assigned Ip Address: ");
                                    System.out.println("      - " + ipConfigInfoIpAddress.getIpAddress());

                                }
                            }

                            System.out.println("");
                        }
                    }

                }

                System.out.println("\n==============================");
                System.out.println("======== Virtual Disk ========");
                System.out.println("==============================");
                ArrayList<VirtualDisk> listOfVirtualDisks = vm.getDisk();
                int nbDisk = 1;
                if (listOfVirtualDisks != null && !listOfVirtualDisks.isEmpty()) {
                    for (VirtualDisk virtualDisk : listOfVirtualDisks) {
                        System.out.println("- Virtual Disk n" + nbDisk++);
                        System.out.println("  - Label: " + virtualDisk.getLabel());
                        System.out.println("  - Key: " + virtualDisk.getKey());
                        System.out.println("  - Controller Key: " + virtualDisk.getControllerKey());
                        System.out.println("  - UnitNumber: " + virtualDisk.getUnitNumber());
                        System.out.println("  - Size: " + virtualDisk.getDiskSize());
                        System.out.println("  - Backing: " + virtualDisk.getBacking());
                        if (virtualDisk.getBacking() instanceof com.vmware.vim25.VirtualDiskFlatVer2BackingInfo) {
                            com.vmware.vim25.VirtualDiskFlatVer2BackingInfo virtualDiskBacking = (com.vmware.vim25.VirtualDiskFlatVer2BackingInfo) virtualDisk
                                    .getBacking();
                            System.out.println("    - Parent: " + virtualDiskBacking.getParent());
                            System.out.println(
                                    "    - Datastore Value: " + virtualDiskBacking.getDatastore().get_value());
                            System.out
                                    .println("    - Backing Object Id: " + virtualDiskBacking.getBackingObjectId());
                            System.out.println("    - Change Id: " + virtualDiskBacking.getChangeId());
                            System.out.println("    - Content Id: " + virtualDiskBacking.getContentId());
                            System.out
                                    .println("    - Delta Disk Format: " + virtualDiskBacking.getDeltaDiskFormat());
                            System.out.println("    - Disk Mode: " + virtualDiskBacking.getDiskMode());
                            System.out.println("    - FileName: " + virtualDiskBacking.getFileName());
                            System.out.println("    - UUID: " + virtualDiskBacking.getUuid());
                            System.out.println("    - Delta Grain Size: " + virtualDiskBacking.getDeltaGrainSize());
                            System.out.println("    - Digest Enabled: " + virtualDiskBacking.getDigestEnabled());
                            System.out.println("    - Eagerly Scrub: " + virtualDiskBacking.getEagerlyScrub());
                            System.out.println("    - Split: " + virtualDiskBacking.getSplit());
                            System.out
                                    .println("    - Thin Provisioned: " + virtualDiskBacking.getThinProvisioned());
                            System.out.println("    - Write Through: " + virtualDiskBacking.getWriteThrough());

                        }
                        //com.vmware.vim25.VirtualDiskFlatVer2BackingInfo
                        //System.out.println("  - Backing Class: "+virtualDisk.getBacking().getClass());
                    }
                }

                System.out.println("\n===========================");
                System.out.println("======== Datastore ========");
                System.out.println("===========================");
                System.out.println("- Datastore Information");
                if (vm.getDatastores() != null) {
                    for (Datastore ds : vm.getDatastores()) {
                        System.out.println(" - Datastore: " + ds.getName());
                    }
                }

            }

        }

        /*      
              if (vm.getGuestInfo()!=null && vm.getGuestInfo().getIpStack()!=null && vm.getGuestInfo().getIpStack().length>0)
              {
                 GuestStackInfo[] arrayOfGuestStackInfos=null;
                     
                 arrayOfGuestStackInfos=vm.getGuestInfo().getIpStack();
                     
                 for (GuestStackInfo guestStackInfo:arrayOfGuestStackInfos)
                 {
        System.out.println("Internet Protocol stack as configured in the guest operating system");
        System.out.println("");
        System.out.println("");
            
        if (guestStackInfo.getIpRouteConfig()!=null && guestStackInfo.getIpRouteConfig().getIpRoute()!=null && guestStackInfo.getIpRouteConfig().getIpRoute().length>0)
        {
           for (NetIpRouteConfigInfoIpRoute netIpRouteConfigInfoIpRoute:guestStackInfo.getIpRouteConfig().getIpRoute())
           {
              System.out.println("Gateway: "+netIpRouteConfigInfoIpRoute.getGateway().getIpAddress());
           }
        }
            
                 }
                     
              }
        */

        /*
            
        if (!vm.getGuest().getListOfNetworkAdapter().isEmpty())
        {
           //GuestInfo guestInfo_=vmConfiguration.getGuestInfo().getGuestInfoo();
           //System.out.println("IPSTACK: "+guestInfo_);
           //System.out.println("IPSTACK: "+guestInfo_.getIpStack());
               
               
               
           int nbGuestnicInfo=1;
           for (GuestNic guestNic:vm.getGuest().getListOfNetworkAdapter())
           {
        System.out.println("    - Network Adapter n"+nbGuestnicInfo++);
        System.out.println("      - Connected: "+guestNic.isConnected());
        System.out.println("      - DeviceConfig Id: "+guestNic.getDeviceConfigId());
        System.out.println("      - Network: "+guestNic.getNetwork());
        System.out.println("      - Network ID: "+guestNic.getNetworkID());
        if (!guestNic.getListOfIPAddress().isEmpty())
        {
           System.out.println("      - IP Address:");
               
           for (String ip:guestNic.getListOfIPAddress())
           {
              System.out.println("        - "+ip);
           }
               
        }
        System.out.println("      - Mac Address: "+guestNic.getMacAddress());
        if (guestNic.getDnsConfig()!=null)
        {
           System.out.println("      - DNS Config:");
           System.out.println("        - Dhcp: "+guestNic.getDnsConfig().isDhcp());
           System.out.println("        - Domain Name: "+guestNic.getDnsConfig().getDomainName());
           System.out.println("        - Host Name: "+guestNic.getDnsConfig().getHostName());
           System.out.println("        - Ip Address:");
           if (!guestNic.getDnsConfig().getIpAddress().isEmpty())
           {
              for (String ipAddress:guestNic.getDnsConfig().getIpAddress())
              {
                 System.out.println("          - "+ipAddress);
              }
           }
           System.out.println("        - Search Domain:");
           if (!guestNic.getDnsConfig().getSearchDomain().isEmpty())
           {
              for (String searchDomain:guestNic.getDnsConfig().getSearchDomain())
              {
                 System.out.println("          - "+searchDomain);
              }
           }
            
           System.out.println("");
            
        }
            
        if (guestNic.getIpConfig()!=null)
        {
           System.out.println("      - IP Config:");
           System.out.println("        - autoConfigurationEnabled: "+guestNic.getIpConfig().isAutoConfigurationEnabled());
        }
            
            
           }
        }
            
        */

        System.out.println("");
        System.out.println("");

        VirtualMachine vm = vmManager.getVmByName(hostName, "VFOD-TEST-01");
        listOfMorIDs.clear();
        listOfMorIDs.add(vm.getMor().get_value());
        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        //VirtualDevice[] listOfVirtualDevice=vm.getVirtualDeviceManager().getAllVirtualDevices();
        VirtualDevice[] listOfVirtualDevice = vm.getVirtualDeviceManager().getListOfVirtualDevices();
        int nbDevice = 1;
        VirtualEthernetCard virtualEthernetCard = null;
        VirtualController virtualController = null;

        for (VirtualDevice device : listOfVirtualDevice) {
            System.out.println("Device n" + nbDevice++);
            System.out.println("- Device: " + device);
            System.out.println("- Device Class: " + device.getClass());
            if (device.getBacking() != null) {
                System.out.println("- Backing Device Class: " + device.getBacking().getClass());

                if (device.getBacking() instanceof com.vmware.vim25.VirtualDiskFlatVer2BackingInfo) {
                    com.vmware.vim25.VirtualDiskFlatVer2BackingInfo backingInfo = (com.vmware.vim25.VirtualDiskFlatVer2BackingInfo) device
                            .getBacking();
                    System.out.println(" - FileName: " + backingInfo.getFileName());
                }
            }
            System.out.println("- Device Super Class: " + device.getClass().getSuperclass());
            System.out.println("- Key    : " + device.getKey());
            System.out.println("- ControllerKey: " + device.getControllerKey());
            if (device.getSlotInfo() != null
                    && device.getSlotInfo() instanceof com.vmware.vim25.VirtualDevicePciBusSlotInfo) {
                System.out.println("- Slot number: "
                        + ((com.vmware.vim25.VirtualDevicePciBusSlotInfo) device.getSlotInfo()).getPciSlotNumber());
            }
            System.out.println("- Label  : " + device.getDeviceInfo().getLabel());
            System.out.println("- Summary: " + device.getDeviceInfo().getSummary());
            System.out.println("- Unit Number: " + device.getUnitNumber());

            if (device instanceof com.vmware.vim25.VirtualSCSIController) {
                VirtualSCSIController virtualSCSIController = (VirtualSCSIController) device;
                System.out.println("- Scsi Ctlr Unit Number: " + virtualSCSIController.getScsiCtlrUnitNumber());
                System.out.println("- Bus Number: " + virtualSCSIController.getBusNumber());
            }

            if (device instanceof com.vmware.vim25.VirtualLsiLogicSASController) {
                VirtualLsiLogicSASController virtualLsiLogicSASController = (VirtualLsiLogicSASController) device;
                System.out.println(
                        "- Scsi Ctlr Unit Number: " + virtualLsiLogicSASController.getScsiCtlrUnitNumber());
                System.out.println("- Bus Number: " + virtualLsiLogicSASController.getBusNumber());
            }

            if (device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualEthernetCard.class)
                    || device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualVmxnet.class)) {
                virtualEthernetCard = (VirtualEthernetCard) device;
                System.out.println("- Device Class: " + device.getClass());
                System.out.println("- Device Super Class: " + device.getClass().getSuperclass());
                System.out.println("- virtualEthernetCard Class: " + virtualEthernetCard.getClass());
                System.out.println("  - AddressType: " + virtualEthernetCard.getAddressType());
                System.out.println("  - MacAddress: " + virtualEthernetCard.getMacAddress());
                System.out.println("  - WakeOnLanEnabled: " + virtualEthernetCard.getWakeOnLanEnabled());
                System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());

                if (virtualEthernetCard
                        .getBacking() instanceof com.vmware.vim25.VirtualEthernetCardNetworkBackingInfo) {
                    VirtualEthernetCardNetworkBackingInfo virtualEthernetCardNetworkBackingInfo = (VirtualEthernetCardNetworkBackingInfo) virtualEthernetCard
                            .getBacking();
                    System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());
                    System.out
                            .println("    - Device Name: " + virtualEthernetCardNetworkBackingInfo.getDeviceName());
                    System.out.println(
                            "    - Use AutoDetect: " + virtualEthernetCardNetworkBackingInfo.getUseAutoDetect());
                    System.out.println(
                            "    - inPassthroughMode: " + virtualEthernetCardNetworkBackingInfo.inPassthroughMode);
                    System.out.println(
                            "    - Network: " + virtualEthernetCardNetworkBackingInfo.getNetwork().get_value());

                }

                if (virtualEthernetCard.getBacking().getClass()
                        .equals(com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo.class)) {
                    VirtualEthernetCardDistributedVirtualPortBackingInfo backing = (VirtualEthernetCardDistributedVirtualPortBackingInfo) virtualEthernetCard
                            .getBacking();
                    System.out.println("  - Backing Info: " + virtualEthernetCard.getBacking().getClass());
                    System.out.println("    - PortgroupKey: " + backing.getPort().getPortgroupKey());
                    System.out.println("    - PortKey: " + backing.getPort().getPortKey());
                    System.out.println("    - SwitchUuid: " + backing.getPort().getSwitchUuid());
                }
                //

            }

            if (device.getConnectable() != null) {
                System.out.println("- allowGuestControl: " + device.getConnectable().isAllowGuestControl());
                System.out.println("- connected: " + device.getConnectable().isConnected());
                System.out.println("- startConnected: " + device.getConnectable().isStartConnected());
                if (device.getConnectable().getStatus() != null)
                    System.out.println("- status: " + device.getConnectable().getStatus());

            }

            if (device.getClass().getSuperclass().equals(com.vmware.vim25.VirtualController.class)) {
                virtualController = (VirtualController) device;
                if (virtualController.getDevice() != null && virtualController.getDevice().length > 0) {
                    String devicesControlled = "- Devices Controlled: ";
                    String keys = "";
                    for (int deviceKey : virtualController.getDevice()) {
                        keys = deviceKey + "," + keys;
                    }

                    keys = keys.substring(0, keys.length() - 1);
                    System.out.println(devicesControlled + keys);
                }
            }

        } // Fin boucle sur les perihpriques d'une VM

        //System.out.println("Taille disk: "+vm.getHardware().getTotalDiskSpace());

        /*
        WS ws=wsManager.getWS(vmWareHostName);
        ManagedObjectReference mor=null;
        mor=MorManager.getMorRef(ws, ws.getVIMService().getRootFolder(), "VirtualMachine", "ActiBox05");
            
        System.out.println("mor: "+mor.get_value());
            
        ArrayList<VirtualMachine> listOfVM=inventoryMng.getAllVM(vmWareHostName);
        for (VirtualMachine vm_:listOfVM)
        {
           System.out.println("vm: "+vm_.getName()+" / "+vm_.getMor().get_value());
        }
        */

        /*
        vm=vmManager.getVmByName(vmWareHostName, "ActiBox05");
        System.out.println("VirtualMachine: "+vm.getName());
        System.out.println("-CPU Reservation: "+vm.getConfiguration().getVirtualCPU().getReservation());
        System.out.println("-CPU Limit: "+vm.getConfiguration().getVirtualCPU().getLimit());
        System.out.println("-CPU: "+vm.getConfiguration().getVirtualCPU().getMghz());
            
        System.out.println("-Memory Reservation: "+vm.getConfiguration().getVirtualMemory().getReservation());
        System.out.println("-Memory Limit: "+vm.getConfiguration().getVirtualMemory().getLimit());
        System.out.println("-Memory: "+vm.getConfiguration().getVirtualMemory().getMemorySize());
        */

        //Host host=vm.getHost();
        //System.out.println("Host Name: "+host.getName());
        //vm.getHardware().getAlldevices();

        //vmManager.configureVMMemory("ActiBox05", 256L);

        //vm.replaceNetwork("network-14");
        //vm.addNetwork("network-14");
        //vm.removeNetwork("network-14");
        //vmManager.updateNetwork("ActiBox05", "networkID");

        //vm.setNetwork();

        /*
        ArrayList<Network> listOfNetwork=host.getNetworks();
            
        for (Network network:listOfNetwork)
        {
           System.out.println("Network Name: "+network.getName());
           System.out.println("Network ID: "+network.getMor().get_value());
        }
        */

        //HardwareDevice hardware=vm.getHardware();
        //ArrayList<VirtualNetwork> listOfVirtualNetwork=hardware.getNetworks();
        //VirtualNetwork virtualNetwork=listOfVirtualNetwork.get(0);
        //virtualNetwork.getvDevice().getBacking().

        /*
        ArrayList<Network> listOfNet=vm.getAvailableNetwork();
            
        for (Network network:listOfNet)
        {
           System.out.println("Network: "+network.getName());
        }
        */

        /*
        try
        {
           System.in.read();
        }
        catch (IOException e)
            
        {
           // TODO Auto-generated catch block
           e.printStackTrace();
        }
         */

        //AuthorizationManager authorManager=AuthorizationManager.getInstance();
        //authorManager.addPermission("SIVEO\\TestGP", true,"test2", "VMSuperPowerUser","vcenter.siveo.net");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================

        VMware.delete(hostName);
    }
    //fin mthode

    public void getURLConsole(String vmName, boolean limitWorkspaceView, boolean limitSingleVMView)
            throws VMwareException {
        //String hostName="10.0.12.6";
        //VMware.create(hostName,443,"siveo_admin","s1v3oP0C",false,-1L,1000L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.1.109.236";
        //VMware.create(hostName,443,"Administrator","8x63-K/!/",false,-1L);

        String hostName = "192.168.101.110";
        VMware.create(hostName, 443, "root", "mandriva", false, -1L);

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        // Get the VirtualCenter UUID
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        AboutInfo aboutInfo = ws.getVIMService().getServiceContent().getAbout();
        System.out.println("VC UUID: " + aboutInfo.getInstanceUuid());
        System.out.println("VM Id: " + vm.getMor().get_value());

        System.out.println("");

        //https://reflex.primp-industries.com:9443/vsphere-client/vmrc/vmrc.jsp?vm=EE26E7F6-591B-4256-BD7A-402E5AC9E0A8:VirtualMachine:vm-1506

        //System.out.println("URL Console: "+vm.getURLConsole(vmName, limitWorkspaceView, limitSingleVMView));

        System.out.println("URL Console: " + vm.getConsoleURL(false, false, false));
        //System.out.println("URL Console Encoded: "+vmManager.getURLConsoleForVMName(vmName, hostName,true,limitWorkspaceView, limitSingleVMView));

        //System.out.println("URL Console: "+vmManager.getURLConsoleForVMName(vmName,hostName, false,limitWorkspaceView, limitSingleVMView));
        //System.out.println("URL Console Encoded: "+vmManager.getURLConsoleForVMName(vmName,hostName, true,limitWorkspaceView, limitSingleVMView));

        //String encoded="d3NVcmw9aHR0cDovL2xvY2FsaG9zdDo4MC9zZGsmbW89VmlydHVhbE1hY2hpbmV8dm0tNDgzMSZpbnZlbnRvcnk9ZXhwYW5kZWQmdGFicz1zaG93Xw==";
        //String encoded="d3NVcmw9aHR0cDovL2xvY2FsaG9zdDo4MC9zZGsmbW89VmlydHVhbE1hY2hpbmV8dm0tNDgzMSZpbnZlbnRvcnk9ZXhwYW5kZWQmdGFicz1zaG93_";
        //System.out.println("\nDecoded: "+new String(Base64.decode(encoded)));

        VMware.delete(hostName);
    }

    public void getURLConsole() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "10.251.5.75";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        // =========================================================================================
        // Get Inventory
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        AboutInfo aboutInfo = ws.getVIMService().getServiceContent().getAbout();

        System.out.println("VC UUID: " + aboutInfo.getInstanceUuid());

        //8D15F481-21B4-4EF1-86D8-7556ADFAC0BC

        //https://reflex.primp-industries.com:9443/vsphere-client/vmrc/vmrc.jsp?vm=EE26E7F6-591B-4256-BD7A-402E5AC9E0A8:VirtualMachine:vm-1506

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getOSFromVMX(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "10.251.5.75";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        // =========================================================================================
        // Get Inventory
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        OptionValue[] optionValues = vm.getConfigInfo().getExtraConfig();

        if (optionValues != null && optionValues.length > 0) {
            for (OptionValue optionValue : optionValues) {
                System.out.println("Key: " + optionValue.getKey() + " / " + optionValue.getValue());
            }
        }

        VirtualMachineGuestSummary guestSummary = (VirtualMachineGuestSummary) MorManager.getMorProperty(vm.getWS(),
                vm.getMor(), new String[] { "summary.guest" });

        if (guestSummary != null) {
            System.out.println("Guest FullName: " + guestSummary.getGuestFullName());
            System.out.println("guest ID: " + guestSummary.getGuestId());
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void reconfMACAddress() throws Exception {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VJTH-TSTLIN-02");

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();

        VirtualNetwork virtualNetwork1 = null;

        listOfManagedObjectReferences.add(vm.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);

        ArrayList<VirtualNetwork> listOfVirtualNetworks = null;
        ArrayList<VirtualNetwork> listOfVirtualNetworkDevices = new ArrayList<VirtualNetwork>();
        VMNetwork vmNetwork = vm.getVMNetwork();
        listOfVirtualNetworks = vmNetwork.getListOfVirtualNetwork();

        //Remove
        for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {
            virtualNetwork.setAction(VirtualDeviceOperation.remove);
            listOfVirtualNetworkDevices.add(virtualNetwork);
        }

        // Add   
        for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {
            virtualNetwork1 = new VirtualNetwork();
            virtualNetwork1.setNetwork(virtualNetwork.getNetwork());
            virtualNetwork1.setVirtualDevice(virtualNetwork.getVirtualDevice());
            virtualNetwork1.setAction(VirtualDeviceOperation.add);
            listOfVirtualNetworkDevices.add(virtualNetwork1);
        }

        vm.configure(null, null, null, listOfVirtualNetworkDevices, null, "12345");

        System.out.println("Press a key to continue...");
        System.in.read();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void changeMACAddress() throws Exception {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "TPL_windows");

        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        ArrayList<ManagedObjectReference> listOfManagedObjectReferences = new ArrayList<ManagedObjectReference>();

        listOfManagedObjectReferences.add(vm.getMor());
        inventory.getVirtualMachinePropertiesEx(listOfManagedObjectReferences);

        ArrayList<VirtualNetwork> listOfVirtualNetworks = null;
        VMNetwork vmNetwork = vm.getVMNetwork();

        VirtualMachineConfigSpec virtualMachineConfigSpec = new VirtualMachineConfigSpec();
        ArrayList<VirtualDeviceConfigSpec> listOfVirtualDeviceConfigSpec = new ArrayList<VirtualDeviceConfigSpec>();

        listOfVirtualNetworks = vmNetwork.getListOfVirtualNetwork();

        // Boucle sur les cartes rsaux
        for (VirtualNetwork virtualNetwork : listOfVirtualNetworks) {
            Network network = virtualNetwork.getNetwork();
            VirtualEthernetCardNetworkBackingInfo virtualEthernetCardNetworkBackingInfo = new VirtualEthernetCardNetworkBackingInfo();

            virtualEthernetCardNetworkBackingInfo.setDeviceName(network.getName());
            virtualEthernetCardNetworkBackingInfo.setNetwork(network.getMor());

            // =========================================================================================
            // Create a VirtualCard depending of the Virtual Network Device associated to the VM  
            // =========================================================================================
            VirtualDevice virtualCard = null;
            //VirtualEthernetCard virtualEthernetCard=null;   

            if (virtualNetwork.getVirtualDevice().getClass().getName().equals(Constants.NETWORK_ADAPTER_E1000)) {
                virtualCard = new VirtualE1000();
                ((VirtualE1000) virtualCard).setAddressType(Constants.NETWORK_MAC_ADDRESS_TYPE_GENERATED);
            } else if (virtualNetwork.getVirtualDevice().getClass().getName()
                    .equals(Constants.NETWORK_ADAPTER_PCNet32)) {
                virtualCard = new VirtualPCNet32();
                ((VirtualPCNet32) virtualCard).setAddressType(Constants.NETWORK_MAC_ADDRESS_TYPE_GENERATED);
            } else if (virtualNetwork.getVirtualDevice().getClass().getName()
                    .equals(Constants.NETWORK_ADAPTER_VMXNET)) {
                virtualCard = new VirtualVmxnet();
                ((VirtualVmxnet) virtualCard).setAddressType(Constants.NETWORK_MAC_ADDRESS_TYPE_GENERATED);
            } else if (virtualNetwork.getVirtualDevice().getClass().getName()
                    .equals(Constants.NETWORK_ADAPTER_VMXNET2)) {
                virtualCard = new VirtualVmxnet2();
                ((VirtualVmxnet2) virtualCard).setAddressType(Constants.NETWORK_MAC_ADDRESS_TYPE_GENERATED);
            } else if (virtualNetwork.getVirtualDevice().getClass().getName()
                    .equals(Constants.NETWORK_ADAPTER_VMXNET3)) {
                virtualCard = new VirtualVmxnet3();
                ((VirtualVmxnet3) virtualCard).setAddressType(Constants.NETWORK_MAC_ADDRESS_TYPE_GENERATED);
            } else {
                virtualCard = new VirtualVmxnet();
                ((VirtualVmxnet) virtualCard).setAddressType(Constants.NETWORK_MAC_ADDRESS_TYPE_GENERATED);
            }

            // =========================================================================================
            // Set the Virtual Network Card Properties  
            // =========================================================================================
            virtualCard.setBacking(virtualEthernetCardNetworkBackingInfo);
            virtualCard.setKey(virtualNetwork.getVirtualDevice().getKey());

            //virtualNetwork.getVirtualDevice().setBacking(virtualEthernetCardNetworkBackingInfo);

            VirtualDeviceConnectInfo connectable = null;

            if (virtualCard.getConnectable() == null) {
                connectable = new VirtualDeviceConnectInfo();
                connectable.setAllowGuestControl(false);
                connectable.setStartConnected(true);
                virtualCard.setConnectable(connectable);

            } else {
                connectable = virtualCard.getConnectable();
                connectable.setStartConnected(true);
                virtualCard.setConnectable(connectable);
            }

            // =========================================================================================
            // Set the Virtual Device Config Spec  
            // =========================================================================================
            VirtualDeviceConfigSpec vDeviceConfigSpec = new VirtualDeviceConfigSpec();
            vDeviceConfigSpec.setDevice(virtualCard);
            vDeviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.edit);

            listOfVirtualDeviceConfigSpec.add(vDeviceConfigSpec);
        }

        //
        if (!listOfVirtualDeviceConfigSpec.isEmpty()) {
            virtualMachineConfigSpec.setDeviceChange(listOfVirtualDeviceConfigSpec
                    .toArray(new VirtualDeviceConfigSpec[listOfVirtualDeviceConfigSpec.size()]));
        }

        // =========================================================================================
        // Reconfigure the VM  
        // =========================================================================================
        try {
            vm.getWS().getVIMService().getService().reconfigVM_Task(vm.getMor(), virtualMachineConfigSpec);
        } catch (ConcurrentAccess concurrentAccess) {
            throw new VMwareException(
                    "Error: The changeVersion does not match the server's changeVersion for the configuration",
                    ErrorHelper.getStackTraceAsString(concurrentAccess));
        } catch (DuplicateName duplicateName) {
            throw new VMwareException("Error: The specified name already exists in the parent folder",
                    ErrorHelper.getStackTraceAsString(duplicateName));
        } catch (FileFault fileFault) {
            throw new VMwareException(
                    "Error: There is a problem creating or accessing the virtual machine's files for this operation",
                    ErrorHelper.getStackTraceAsString(fileFault));
        } catch (InsufficientResourcesFault insufficientResourcesFault) {
            throw new VMwareException("Error: This operation would violate a resource usage policy",
                    ErrorHelper.getStackTraceAsString(insufficientResourcesFault));
        } catch (InvalidDatastore invalidDatastore) {
            throw new VMwareException("Error: Invalid Datastore",
                    ErrorHelper.getStackTraceAsString(invalidDatastore));
        } catch (InvalidName invalidName) {
            throw new VMwareException("Error: The specified Virtual Machine name is invalid",
                    ErrorHelper.getStackTraceAsString(invalidName));
        } catch (InvalidPowerState invalidPowerState) {
            throw new VMwareException(
                    "Error: The power state is poweredOn and the virtual hardware cannot support the configuration changes",
                    ErrorHelper.getStackTraceAsString(invalidPowerState));
        } catch (InvalidState invalidState) {
            throw new VMwareException(
                    "Error: The operation cannot be performed in the current state of the virtual machine",
                    ErrorHelper.getStackTraceAsString(invalidState));
        } catch (TaskInProgress taskInProgress) {
            throw new VMwareException("Error: The virtual machine is busy",
                    ErrorHelper.getStackTraceAsString(taskInProgress));
        } catch (TooManyDevices tooManyDevices) {
            throw new VMwareException("Error: The device specifications exceed the allowed limits",
                    ErrorHelper.getStackTraceAsString(tooManyDevices));
        } catch (VmWwnConflict vmWwnConflict) {
            throw new VMwareException(
                    "Error: The WWN of the virtual machine has been used by other virtual machines",
                    ErrorHelper.getStackTraceAsString(vmWwnConflict));
        } catch (VmConfigFault vmConfigFault) {
            throw new VMwareException("Error: The spec is invalid. Typically, a more specific subclass is thrown",
                    ErrorHelper.getStackTraceAsString(vmConfigFault));
        } catch (RuntimeFault runtimeFault) {
            throw new VMwareException("Error: Connection was lost", runtimeFault);
        } catch (RemoteException remoteException) {
            throw new VMwareException("Error: Connection was lost", remoteException);
        }

        System.out.println("Press a key to continue");
        System.in.read();

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getOSonESX() throws Exception {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="192.168.101.110";
        //VMware.create(hostName,443,"root","mandriva",false,-1L);

        //String hostName="192.168.101.58";
        //VMware.create(hostName,443,"root","cahh4gee$2012",false,-1L);

        String hostName = "192.168.101.122";
        VMware.create(hostName, 443, "root", "cahh4gee$", false, -1L);

        // =========================================================================================
        // VM
        // =========================================================================================
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);

        ArrayList<ManagedObjectReference> listOfVMMor = new ArrayList<ManagedObjectReference>();
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "TestCDO");

        Guest os = vmManager.getGuestOSOnESXi(vm.getMor().get_value(), hostName);

        System.out.println("OS:");
        System.out.println("- Familly: " + os.getOSFamily());
        System.out.println("- FullName: " + os.getOSFullName());
        System.out.println("- ID: " + os.getOSId());

        //      ArrayList<VirtualMachine> listOfVMs=vmManager.getAllVM(hostName);
        //      
        //      for(VirtualMachine vm:listOfVMs)
        //      {
        //         listOfVMMor.add(vm.getMor());
        //      }
        //      
        //      Guest guest=null;
        //      
        //      inventory.getVirtualMachinePropertiesEx(listOfVMMor);
        //      
        //      for (VirtualMachine vm:listOfVMs)
        //      {
        //         guest=vm.getGuest();
        //         System.out.println("Virtual Machine: "+vm.getName());
        //         if(guest!=null)
        //         {
        //            System.out.println("- Guest:");
        //            System.out.println("  - OS Family: "+guest.getOSFamily());
        //            System.out.println("  - OS Full Name: "+guest.getOSFullName());
        //            System.out.println("  - OS ID: "+guest.getOSId());
        //            
        //         }
        //         else
        //         {
        //            System.out.println("- Guest: NO Guest Found");
        //         }
        //
        //         System.out.println("");
        //         
        //      }

        //      //Methode recup OS
        //      
        //      String rootPath="/vmfs/volumes/";
        //      String vmxFile=null;
        //      
        //      ArrayList<Datastore> listOfDatastores=vm.getDatastores();
        //      Datastore ds=listOfDatastores.get(0);
        //      System.out.println("DS UUID: "+ds.getUuid());
        //      
        //      vmxFile=rootPath+ds.getUuid()+"/"+vm.getName()+"/"+vm.getName()+".vmx";
        //      System.out.println("VM Path: "+vmxFile);
        //      
        //      ///vmfs/volumes/5477c809-c02e5a9b-3dbc-000c29265e45/TPL_debian
        //
        //      int exitCode=-1;
        //      String sortie=null;
        //      
        //      Jsch jsch=new Jsch(hostName, "root", "mandriva");
        //      jsch.connectKerberos();
        //      
        //      String command="cat "+vmxFile+" | grep \"guestOS\"";
        //      exitCode=jsch.executeCmd(command);
        //      
        //      if (exitCode!=0)
        //      {
        //         jsch.disconnect();
        //         throw new Exception("Error: Clone VM to VM on ESXi failed.");
        //      }
        //      
        //      sortie=jsch.getStdOut();
        //      System.out.println("Sortie: "+sortie);
        //
        //      String OS=sortie.substring(sortie.indexOf("\"")+1, sortie.lastIndexOf("\""));
        //      System.out.println("OS: "+OS);
        //      jsch.disconnect();

        //      VirtualMachineConfigInfo configInfo=vm.getConfigInfo();
        //      if(configInfo!=null)
        //      {
        //         OptionValue[] optionValues=configInfo.getExtraConfig();
        //
        //         if (optionValues!=null)
        //         {
        //            for (OptionValue optionValue:optionValues)
        //            {
        //               System.out.println("Key: "+optionValue.getKey());
        //               System.out.println("Value: "+optionValue.getValue());
        //            }
        //         }
        //         
        //      }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void setGuestHostname() throws Exception {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="192.168.101.110";
        //VMware.create(hostName,443,"root","mandriva",false,-1L);

        String hostName = "192.168.101.58";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        // =========================================================================================
        // VM
        // =========================================================================================
        System.out.println("Dbut lancement de la modification du hostname");

        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VJTH-TSTWIN-02");
        //vmManager.customGuestOSOnESXi(vm.getMor().get_value(), hostName,"Administrateur", "Clmdp@2013", "windows7-64", "/opt/jboss-as/eva/GuestTools");
        vmManager.customGuestOSOnESXi(vm.getMor().get_value(), hostName, "192.168.101.143", "Administrateur",
                "Clmdp@2013", "windows7-64", "/opt/jboss-as/eva/GuestTools");

        System.out.println("Fin lancement de la modification du hostname");

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getCurrentTime() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================

        String hostName = "192.168.101.110";
        VMware.create(hostName, 443, "root", "mandriva", false, -1L);

        // =========================================================================================
        // =========================================================================================
        PerformanceManager performanceManager = PerformanceManager.getInstance();
        Performance performance = performanceManager.create(hostName);

        Calendar dt = performance.getCurrentDateTime();
        System.out.println("Dt: " + dt);
        System.out.println("Dt time: " + dt.getTime());

        // =========================================================================================
        // =========================================================================================
        System.out.println("");
        System.out.println("");
        Date dateActu = new Date();
        Calendar dateTest = Calendar.getInstance();

        System.out.println("DataTest: " + dateTest.getTime());
        dateTest.add(Calendar.DAY_OF_YEAR, -7);
        System.out.println("DataTest (-7 jours): " + dateTest.getTime());
        System.out.println("DataActu: " + dateActu);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void disconnectAndReconnect() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "192.168.101.58";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        int nbElements = inventory.getMapOfTreeNodeByID().size();
        System.out.println("Nb Elements: " + nbElements);

        System.out.println("Press a key to disconnect...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        VMware.delete(hostName);

        try {
            Thread.sleep(5L * 1000L);
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        System.out.println("Press a key to reconnect...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);
        inventory = inventoryManager.getInventoryByVC(hostName);
        nbElements = inventory.getMapOfTreeNodeByID().size();
        System.out.println("Nb Elements: " + nbElements);

        System.out.println("Press a key to terminate...");
        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVMNetworkAvailable() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "10.62.16.33";
        VMware.create(hostName, 443, "root", "cahh4gee$2012", false, -1L);

        //String hostName="10.62.16.34";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@2013$",false,-1L);

        // =========================================================================================
        // 
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VJTH-TSTWIN-22");
        //VirtualMachine vm=vmManager.getVmByName(hostName, "evakeonys");

        ArrayList<String> listOfMorIDs = new ArrayList<String>();
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        listOfMorIDs.add(vm.getMor().get_value());
        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        System.out.println("VM Id: " + vm.getMor().get_value());

        ArrayList<Network> listOfAvailableNetworkAdpaters = vm.getAvailableBackingNetworks();

        if (listOfAvailableNetworkAdpaters != null && !listOfAvailableNetworkAdpaters.isEmpty()) {
            for (Network network : listOfAvailableNetworkAdpaters) {
                System.out.println("" + network.getMor().get_value() + " / " + network.getName());
            }
        } else {
            System.out.println("No network available !!");
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getAPIVersion() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.110";
        VMware.create(hostName, 443, "root", "mandriva", false, -1L);

        // =========================================================================================
        // Get VMware WebService API Version
        // =========================================================================================
        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        AboutInfo aboutInfo = ws.getVIMService().getServiceContent().getAbout();

        if (aboutInfo != null) {
            System.out.println("############## Info ##############");
            System.out.println("- API Type: " + aboutInfo.getApiType());
            System.out.println("- API Version: " + aboutInfo.getApiVersion());
            System.out.println("- Build: " + aboutInfo.getBuild());
            System.out.println("- Full Name: " + aboutInfo.getFullName());
            System.out.println("- Instance UUID: " + aboutInfo.getInstanceUuid());
            System.out.println("- Licence Product Name: " + aboutInfo.getLicenseProductName());
            System.out.println("- Licence Product Version: " + aboutInfo.getLicenseProductVersion());
            System.out.println("- Locale Build: " + aboutInfo.getLocaleBuild());
            System.out.println("- Locale Version: " + aboutInfo.getLocaleVersion());
            System.out.println("- Name: " + aboutInfo.getName());
            System.out.println("- OS Type: " + aboutInfo.getOsType());
            System.out.println("- Prodcut Line ID: " + aboutInfo.getProductLineId());
            System.out.println("- Vendor: " + aboutInfo.getVendor());
            System.out.println("- Version: " + aboutInfo.getVersion());
        }

        //System.out.println("Vmware API Version: "+ws.getVIMService().getApi());

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void revertToSnapshot() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.110";
        VMware.create(hostName, 443, "root", "mandriva", false, -1L);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "VTES-TEST-03");

        SnapshotManager snapshotManager = SnapshotManager.getInstance();
        snapshotManager.revertToSnapshotByID(vm, "6-snapshot-1", "123456");

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getSnapshot(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.110";
        VMware.create(hostName, 443, "root", "mandriva", false, -1L);

        // =========================================================================================
        // List the VM Snapshot
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        SnapshotManager snapshotManager = SnapshotManager.getInstance();
        Snapshot rootSnapshot = snapshotManager.getSnapShotTree(vm);
        Snapshot currentSnapshot = snapshotManager.getCurrentSnapShot(vm);

        ArrayList<Snapshot> listOfsnap = snapshotManager.getAllSnapShot(vm);

        int nbSnap = 1;

        for (Snapshot snap : listOfsnap) {
            System.out.println("Snapshot n" + nbSnap++);
            System.out.println("- ID: " + snap.getMor().get_value());
            System.out.println("- Name: " + snap.getName());
            System.out.println("- Description: " + snap.getDescription());
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void revertToSnapshotBySnapshotName(String vmName, String snapName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L,1000L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L, 1000L);

        // =========================================================================================
        // List the VM Snapshot
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        SnapshotManager snapshotManager = SnapshotManager.getInstance();
        if (snapName != null)
            snapshotManager.revertToSnapshot(vm, snapName, "123456789");
        else
            snapshotManager.revertToCurrentSnapshot(vm, "123456789");

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void revertToSnapshotBySnapshotID(String vmName, String snapID) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L, 1000L);

        // =========================================================================================
        // List the VM Snapshot
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        ArrayList<String> listOfMorIDs = new ArrayList<String>();
        listOfMorIDs.add(vm.getMor().get_value());
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        SnapshotManager snapshotManager = SnapshotManager.getInstance();
        if (snapID != null)
            snapshotManager.revertToSnapshotByID(vm, snapID, "123456789");
        else
            snapshotManager.revertToCurrentSnapshot(vm, "123456789");

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void removeSnapshotBySnapshotID(String vmName, String snapID) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L, 1000L);

        // =========================================================================================
        // List the VM Snapshot
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        ArrayList<String> listOfMorIDs = new ArrayList<String>();
        listOfMorIDs.add(vm.getMor().get_value());
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        SnapshotManager snapshotManager = SnapshotManager.getInstance();
        if (snapID != null)
            snapshotManager.removeSnapshotByID(vm, snapID, "123456789");

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void removeAllSnapshot(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        //String hostName="163.172.7.95";
        //VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L,1000L);

        // Keonys ESXi Ingenieur 
        String hostName = "10.10.0.64";
        VMware.create(hostName, 443, "root", "Keonys123", false, -1L);

        // =========================================================================================
        // List the VM Snapshot
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        ArrayList<String> listOfMorIDs = new ArrayList<String>();
        listOfMorIDs.add(vm.getMor().get_value());
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        SnapshotManager snapshotManager = SnapshotManager.getInstance();
        snapshotManager.removeAllSnaphsot(vm, "12345");

        System.out.println("Press a key to continue...");

        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void listSnapshot(String vmName) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        String hostName = "163.172.7.95";
        VMware.create(hostName, 443, "eva", "cahh4gee$2015", false, -1L);

        // =========================================================================================
        // List Snapshot
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);

        ArrayList<String> listOfMorIDs = new ArrayList<String>();
        listOfMorIDs.add(vm.getMor().get_value());
        InventoryManager inventoryManager = InventoryManager.getInstance();
        Inventory inventory = inventoryManager.getInventoryByVC(hostName);
        inventory.getVirtualMachinePropertiesExFromIDs(listOfMorIDs);

        SnapshotManager snapshotManager = SnapshotManager.getInstance();
        ArrayList<Snapshot> listOfSnapshots = snapshotManager.getAllSnapShot(vm);

        if (listOfSnapshots != null && !listOfSnapshots.isEmpty()) {
            for (Snapshot snapshot : listOfSnapshots) {
                System.out.println("Snapshot: " + snapshot.getName() + " / " + snapshot.getMor().get_value() + " / "
                        + snapshot.getMor().getType());
            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void takeSnapshot(String vmName, String snapName, String snapDescription) throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"Administrateur","Clmdp@09",false,-1L);

        //      String hostName="192.168.101.179";
        //      VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L,1000);

        //      String hostName="163.172.7.95";
        //      VMware.create(hostName,443,"eva","cahh4gee$2015",false,-1L,1000);

        String hostName = "10.10.0.64";
        VMware.create(hostName, 443, "root", "Keonys123", false, -1L);

        // =========================================================================================
        // List the VM Snapshot
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, vmName);
        String correlID = "1234567";

        SnapshotManager snapshotManager = SnapshotManager.getInstance();
        snapshotManager.takeSnapshot(vm, snapName, snapDescription, true, false, correlID);

        //      TaskManager taskManager=TaskManager.getInstance();
        //      Boolean running=true;
        //      Integer progressPercent=0;
        //      
        //      while (running)
        //      {
        //         progressPercent=taskManager.getProgress(correlID);
        //         
        //         if (progressPercent!=null && progressPercent==100)
        //         {
        //            running=false;
        //         }
        //         
        //         System.out.println("Progress: "+progressPercent);
        //      }

        // =========================================================================================
        // Wait key pressed
        // =========================================================================================
        System.out.println("Press any key to exit");
        try {
            System.in.read();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);
    }

    public void getAllVNCPorts() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // Get Inventory
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        ArrayList<VirtualMachine> listOfVM = vmManager.getAllVM(hostName);
        Vnc vnc = null;

        if (listOfVM != null && !listOfVM.isEmpty()) {
            for (VirtualMachine vm : listOfVM) {
                System.out.println("VM Name: " + vm.getName());
                vnc = vm.getVnc();
                if (vnc != null) {
                    System.out.println(" - VNC Password: " + vnc.getPassword());
                    System.out.println(" - VNC Port: " + vnc.getPort());
                    System.out.println(" - VNC KeyMap: " + vnc.getKeyMap());
                }

                System.out.println("");

            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void addRole() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.100.2.13";
        VMware.create(hostName, 443, "KEONYS\\JNW", "GG@1dague", false, -1L);

        // =========================================================================================
        // Create the IT Role
        // =========================================================================================
        AuthorizationManager authorizationManager = AuthorizationManager.getInstance();
        //authorizationManager.createRole(hostName, "Siveo_IT", Privileges.roleIT);

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getHostResource() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // Get Inventory
        // =========================================================================================
        HostManager hostManager = HostManager.getInstance();
        ArrayList<Host> listOfHosts = hostManager.getAllHosts(hostName);

        ResourcePool resourcePool = null;
        ResourcePoolResourceUsage resourcePoolResourceUsage = null;

        if (listOfHosts != null && !listOfHosts.isEmpty()) {
            for (Host host : listOfHosts) {
                System.out.println("Host " + host.getName());
                System.out.println("- AvailableCPU: " + host.getAvailableCPU());
                System.out.println("- AvailableDiskFreeSpace: " + host.getAvailableDiskFreeSpace());
                System.out.println("- AvailableMemory: " + host.getAvailableMemory());
                System.out.println("- CPU Capacity: " + host.getCPUCapacity());
                System.out.println("- CPU Max Capacity: " + host.getCPUMaxCapacity());
                System.out.println("- Memory Capacity: " + host.getMemoryCapacity());
                System.out.println("- TotalCpuUsed: " + host.getTotalCpuUsed());
                System.out.println("- TotalMemUsed: " + host.getTotalMemUsed());
                System.out.println("- TotalVmMemory: " + host.getTotalVmMemory());
                System.out.println("- TotalVMUsedCpu: " + host.getTotalVMUsedCpu());

                System.out.println("- RunTime Usage: ");
                resourcePool = host.getResourcePool();
                ResourcePoolRuntimeInfo resourcePoolRuntimeInfo = resourcePool.getRuntimeInfo();

                if (resourcePoolRuntimeInfo != null) {
                    resourcePoolResourceUsage = resourcePoolRuntimeInfo.getCpu();

                    if (resourcePoolResourceUsage != null) {
                        System.out.println("  - CPU Usage:");
                        System.out.println("    - Max Usage: " + resourcePoolResourceUsage.getMaxUsage());
                        System.out.println("    - Overall Usage: " + resourcePoolResourceUsage.getOverallUsage());
                        System.out.println(
                                "    - Reservation Used: " + resourcePoolResourceUsage.getReservationUsed());
                        System.out.println("    - Reservation Used For Vm: "
                                + resourcePoolResourceUsage.getReservationUsedForVm());
                        System.out.println(
                                "    - Unreserved For Pool: " + resourcePoolResourceUsage.getUnreservedForPool());
                        System.out.println(
                                "    - Unreserved For Vm: " + resourcePoolResourceUsage.getUnreservedForVm());
                    }

                    resourcePoolResourceUsage = resourcePoolRuntimeInfo.getMemory();

                    if (resourcePoolResourceUsage != null) {
                        System.out.println("  - Memory Usage:");
                        System.out.println("    - Max Usage: " + resourcePoolResourceUsage.getMaxUsage());
                        System.out.println("    - Overall Usage: " + resourcePoolResourceUsage.getOverallUsage());
                        System.out.println(
                                "    - Reservation Used: " + resourcePoolResourceUsage.getReservationUsed());
                        System.out.println("    - Reservation Used For Vm: "
                                + resourcePoolResourceUsage.getReservationUsedForVm());
                        System.out.println(
                                "    - Unreserved For Pool: " + resourcePoolResourceUsage.getUnreservedForPool());
                        System.out.println(
                                "    - Unreserved For Vm: " + resourcePoolResourceUsage.getUnreservedForVm());
                    }

                    System.out.println("");
                }

                //host.getResourceAllocation()
                //resourcePool.getCpuAllocation();
                //resourcePool.getMemoryAllocation();

            }
        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getVirtualCenterInfos() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        String hostName = "10.62.16.34";
        VMware.create(hostName, 443, "Administrateur", "Clmdp@2013$", false, -1L);

        // =========================================================================================
        // Get VirtualCenter
        // =========================================================================================
        VirtualCenter virtualCenter = VMware.getVirtualCenterInfos(hostName);

        System.out.println("##################### " + hostName + " VirtualCenter Infos #####################");
        System.out.println("- Nombre de VM: " + virtualCenter.getNbVM());
        System.out.println("- Nombre de VM allumes: " + virtualCenter.getNbVMStarted());
        System.out.println("- Nombre de VM arrtes: " + virtualCenter.getNbVMStopped());
        System.out.println("- Total CPU: " + virtualCenter.getCpuTotal());
        System.out.println("- Total Memory: " + virtualCenter.getMemTotal());
        System.out.println("- Total Size Disk: " + virtualCenter.getDsTotalSize());
        System.out.println("- Total Free Size Disk: " + virtualCenter.getDsFreeSize());

        System.out.println("list DS:" + virtualCenter.getListOfDatastore().size());

        // =========================================================================================
        // 
        // =========================================================================================

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void getDatastoreChilds() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        // =========================================================================================
        // Get VirtualCenter
        // =========================================================================================
        DataStoreManager dataStoreManager = DataStoreManager.getInstance();
        ArrayList<Datastore> listOfDatastores = dataStoreManager.getAllDatastore(hostName);
        ArrayList<Host> listOfHosts = null;
        ArrayList<VirtualMachine> listOfVirtualMachines = null;

        if (listOfDatastores != null) {
            for (Datastore ds : listOfDatastores) {
                System.out.println("Datastore:");
                System.out.println("- Name: " + ds.getName());
                System.out.println("- ID: " + ds.getMor().get_value());

                listOfHosts = ds.getListOfHosts();
                if (listOfHosts != null) {
                    System.out.println("- Hosts:");

                    for (Host host : listOfHosts) {
                        System.out.println("  - Name: " + host.getName() + " / " + host.getMor().get_value());
                        System.out.println();
                    }
                }

                listOfVirtualMachines = ds.getListOfVirtualMachines();
                if (listOfVirtualMachines != null) {
                    System.out.println("- VirtualMachines:");

                    for (VirtualMachine vm : listOfVirtualMachines) {
                        System.out.println("  - Name: " + vm.getName() + " / " + vm.getMor().get_value());
                    }
                }

            }
        }

        // =========================================================================================
        // 
        // =========================================================================================

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void listVM_Templates() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        String hostName = "192.100.2.13";
        VMware.create(hostName, 443, "jnw", "GG@1dague", false, -1L);

        // =========================================================================================
        // Get VirtualCenter
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        ArrayList<VirtualMachine> listOfVM = vmManager.getAllVM(hostName);

        ArrayList<VirtualMachine> listOfVirtualMachine = new ArrayList<VirtualMachine>();
        ArrayList<VirtualMachine> listOfTemplates = new ArrayList<VirtualMachine>();

        if (listOfVM != null && !listOfVM.isEmpty()) {
            for (VirtualMachine vm : listOfVM) {
                if (vm.isTemplate()) {
                    listOfTemplates.add(vm);
                } else {
                    listOfVirtualMachine.add(vm);
                }
            }

            System.out.println("Virtual Machines:");
            for (VirtualMachine virtualM : listOfVirtualMachine) {
                System.out.println("-Name: " + virtualM.getName());
            }

            System.out.println("");

            System.out.println("Templates:");
            for (VirtualMachine template : listOfTemplates) {
                System.out.println("-Name: " + template.getName());
            }

        }

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    /*   
       public void userAdd() throws VMwareException
       {
          // =========================================================================================
          // Cration de la connexion au VirtualCenter
          // =========================================================================================
          //String hostName="192.168.101.79";
          //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);
        
          //String hostName="vsphere-4-1";
          //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);
        
          String hostName="10.251.5.14";
          VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);
              
          //String hostName="192.168.101.179";
          //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);
        
          //String hostName="10.251.5.75";
          //VMware.create(hostName,4443,"svc-siveodev","KzT$g#h4",false,-1L);
        
          // =========================================================================================
          // 
          // =========================================================================================
          VMManager vmManager=VMManager.getInstance();
          //VirtualMachine vm=vmManager.getVmByName(hostName, "evakeonys");
          //System.out.println("Adresse IP :"+vm.getGuest().getIpAddress());
              
              
          // =========================================================================================
          // 
          // =========================================================================================
          vmManager.addUserOnVMLinux("10.251.5.33", "root", "cahh4gee$2012", "D:\\Siveo\\dev\\workspace\\Octarine\\Scripts\\create-compte.ksh", "actidev1", "P@ssw0rd$");
              
    //      String user="actidev1";
    //      String password="P@ssw0rd$";
    //      
    //      
    //      String command=null;
    //      String script="D:\\Siveo\\dev\\workspace\\Octarine\\Scripts\\create-compte.ksh";
    //      
    //      File localScript=null;
    //      localScript =new File(script);
    //      String scriptname = localScript.getName();
    //
    //      command="chmod 755 /root/"+scriptname+"; /root/"+scriptname+" "+user+" "+password;
    //      
    //      Jsch jsch=new Jsch("10.251.5.33", "root", "cahh4gee$2012");
    //      jsch.connect();
    //      
    //      jsch.remoteCopy(script);
    //      
    //      int coderetour=jsch.executeCmd(command);
    //      
    //      System.out.println("Retour execution: "+coderetour);
    //      
    //      jsch.disconnect();
              
              
              
          // =========================================================================================
          // Destruction du WebService
          // =========================================================================================
          VMware.delete(hostName);
        
       }
    */

    public void testSysprep() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        //String hostName="10.251.5.14";
        //VMware.create(hostName,443,"SIVEO\\Administrateur","Clmdp@09",false,-1L);

        String hostName = "192.168.101.179";
        VMware.create(hostName, 443, "svc-siveodev", "KzT$g#h4", false, -1L);

        //String hostName="10.251.5.75";
        //VMware.create(hostName,4443,"svc-siveodev","KzT$g#h4",false,-1L);

        // =========================================================================================
        // GuiUnattended
        // =========================================================================================
        GuiUnattended guiUnattended = new GuiUnattended();
        guiUnattended.setAdminPassword("88ca2a479d994521400dfb82cccbf38d1c7863c258f6a79016cafc63f3d102da");
        guiUnattended.setEncryptedAdminPassword(true);
        guiUnattended.setAutoLogon(false);
        guiUnattended.setAutoLogonCount(0);
        guiUnattended.setTimeZone(105);

        // =========================================================================================
        // LicenseFilePrintData
        // =========================================================================================
        LicenseFilePrintData licenseFilePrintData = new LicenseFilePrintData();
        licenseFilePrintData.setAutoMode("PerSeat");
        licenseFilePrintData.setAutoUsers(5);

        // =========================================================================================
        // UserData
        // =========================================================================================
        UserData userData = new UserData();
        userData.setComputerName("Test-Deploy-W2K3");
        userData.setFullName("DGME");
        userData.setOrgName("DGME");
        userData.setProductId("J82BT-QX6DR-XXCRX-3CVKF-C374D");

        // =========================================================================================
        // Identification
        // =========================================================================================
        Identification identification = new Identification();
        identification.setJoinWorkgroup("WORKGROUP");

        // =========================================================================================
        // Networking
        // =========================================================================================

        SysprepWindows sysprepWindows = new SysprepWindows();
        sysprepWindows.setGuiUnattended(guiUnattended);
        sysprepWindows.setLicenseFilePrintData(licenseFilePrintData);
        sysprepWindows.setUserData(userData);
        sysprepWindows.setIdentification(identification);

        // =========================================================================================
        // VMConfiguration
        // =========================================================================================
        VMConfiguration vmConfiguration = new VMConfiguration();
        vmConfiguration.setSysprepWindows(sysprepWindows);

        vmConfiguration.setDnsServerList(new String[] { "10.251.5.50", "194.133.14.66" });
        vmConfiguration.setDnsSuffixList(new String[] {});

        NetworkAdapter networkAdapter = new NetworkAdapter();
        networkAdapter.setDnsServerList(new String[] { "10.251.5.50", "194.133.14.66" });
        networkAdapter.setPrimaryWINS(null);
        networkAdapter.setSecondaryWINS(null);
        networkAdapter.setNetBIOS(null);
        networkAdapter.setIp("10.251.7.23");
        networkAdapter.setSubnetMask("255.255.255.240");
        networkAdapter.setGateway(new String[] { "10.251.5.17" });
        networkAdapter.setMacAddress("00:50:56:a6:6a:4b");
        vmConfiguration.getListOfNetworkAdapters().add(networkAdapter);

        vmConfiguration.setName("CDO");

        // =========================================================================================
        // Appel
        // =========================================================================================
        VMManager vmManager = VMManager.getInstance();
        VirtualMachine vm = vmManager.getVmByName(hostName, "Win2003-STD");

        String vmId = vm.getMor().get_value();

        vmManager.checkSysprep(vmId, hostName, vmConfiguration);

        // =========================================================================================
        // Destruction du WebService
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void parseSamplingDate() throws VMwareException {
        // =========================================================================================
        // Cration de la connexion au VirtualCenter
        // =========================================================================================
        //String hostName="192.168.101.79";
        //VMware.create(hostName,443,"svc-siveo","S1v30d6m3",false,-1L,1000L);

        //String hostName="vsphere-4-1";
        //VMware.create(hostName,443,"Administrateur","Gd@jJ2009$",false,-1L);

        String hostName = "10.251.5.14";
        VMware.create(hostName, 443, "SIVEO\\Administrateur", "Clmdp@09", false, -1L);

        //String hostName="192.168.101.179";
        //VMware.create(hostName,443,"svc-siveodev","KzT$g#h4",false,-1L);

        WSManager wsManager = WSManager.getInstance();
        WS ws = wsManager.getWS(hostName);

        // =========================================================================================
        // Initialize Variables
        // =========================================================================================
        String dt = "20,2012-02-08T15:22:20Z";

        // =========================================================================================
        // Destruction de la connexion au VirtualCenter
        // =========================================================================================
        VMware.delete(hostName);

    }

    public void checkTab(int num) throws VMwareException {
        int tab1 = 1;
        int tab2 = 2;
        int tab3 = 4;
        int tab4 = 8;
        int tab5 = 16;
        int tab6 = 32;
        int tab7 = 64;
        int tab8 = 128;
        int tab9 = 256;
        int tab10 = 512;

        int[] listOfTab = new int[] { tab1, tab2, tab3, tab4, tab5, tab6, tab7, tab8, tab9, tab10 };

        for (int numTabs : listOfTab) {
            if ((num & numTabs) == tab1)
                System.out.println("-Tab 1");

            if ((num & numTabs) == tab2)
                System.out.println("-Tab 2");

            if ((num & numTabs) == tab3)
                System.out.println("-Tab 3");

        }

    }

    public void checkTab1(int tabs) throws VMwareException {
        int tab1 = 1;
        int tab2 = 2;
        int tab3 = 4;
        int tab4 = 8;
        int tab5 = 16;
        int tab6 = 32;
        int tab7 = 64;
        int tab8 = 128;

        int[] listOfTab = new int[] { tab1, tab2, tab3, tab4, tab5, tab6, tab7, tab8 };

        for (int tab : listOfTab) {
            if ((tabs & tab) == tab1)
                System.out.println("-Tab 1");

            if ((tabs & tab) == tab2)
                System.out.println("-Tab 2");

            if ((tabs & tab) == tab3)
                System.out.println("-Tab 3");

            if ((tabs & tab) == tab4)
                System.out.println("-Tab 4");

            if ((tabs & tab) == tab5)
                System.out.println("-Tab 5");

            if ((tabs & tab) == tab6)
                System.out.println("-Tab 6");

            if ((tabs & tab) == tab7)
                System.out.println("-Tab 7");

            if ((tabs & tab) == tab8)
                System.out.println("-Tab 8");
        }
    }

}