/** * Creates a new virtual computer system definition. * * @param globalSettingDataText the Global setting data text of the virtual system to create * @throws JIException */ public void defineVirtualSystem(final String globalSettingDataText) throws JIException { if (this.defineVirtualSystem == null) { for (final SWbemMethod m : super.getMethods()) { if (m.getName().equals("DefineVirtualSystem")) { this.defineVirtualSystem = m; } } } SWbemObject inParams = this.defineVirtualSystem.getInParameters(); inParams .getObjectDispatcher() .put("SystemSettingData", new JIVariant(new JIString(globalSettingDataText))); Object[] methodParams = new Object[] { new JIString("DefineVirtualSystem"), new JIVariant(inParams.getObjectDispatcher()), new Integer(0), JIVariant.NULL(), }; // Execute the method. JIVariant[] results = super.objectDispatcher.callMethodA("ExecMethod_", methodParams); // Get the out parameters. // JIVariant outParamsVar = results[0]; // IJIComObject co = outParamsVar.getObjectAsComObject(); // IJIDispatch outParamsDisp = (IJIDispatch) JIObjectFactory.narrowObject(co); // Get the out parameter virtualSystemResources and convert it into an // array of JIVariants. // JIVariant definedSystem = outParamsDisp.get("DefinedSystem"); }
/** * Destroys a virtual system in hyper-v * * @param vmDispatch A reference to the virtual computer system instance to be destroyed. */ public void destroyVirtualSystem2(final IJIDispatch vmDispatch) throws Exception { if (this.destroyVirtualSystem == null) { for (final SWbemMethod m : super.getMethods()) { if (m.getName().equals("DestroyVirtualSystem")) { this.destroyVirtualSystem = m; } } } JIVariant tmp = vmDispatch.get("Path_"); IJIDispatch dispatchTemp = (IJIDispatch) JIObjectFactory.narrowObject( tmp.getObjectAsComObject().queryInterface(IJIDispatch.IID)); String virtualSystemPath = dispatchTemp.get("Path").getObjectAsString2(); SWbemObject inParams = this.destroyVirtualSystem.getInParameters(); inParams .getObjectDispatcher() .put("ComputerSystem", new JIVariant(new JIString(virtualSystemPath))); Object[] methodParams = new Object[] { new JIString("DestroyVirtualSystem"), new JIVariant(inParams.getObjectDispatcher()), new Integer(0), JIVariant.NULL(), }; // Execute the method. super.objectDispatcher.callMethodA("ExecMethod_", methodParams); // JIVariant[] tmp = // dispatch.callMethodA("DefineVirtualSystem", new Object[] { // new JIString(globalSettingDataText), JIVariant.OPTIONAL_PARAM(), // JIVariant.OPTIONAL_PARAM(),}); // int defRes = tmp[0].getObjectAsInt(); }
/** * Add resources to an existing virtual computer system * * @param vmDispatch A reference to the computer system instance to which the resource is to be * added. * @param newResourceAllocationDispatch the new resource allocation setting data reference to be * added. * @return the resource allocation setting data path of the added resource * @deprecated * @throws JIException */ @Deprecated public String addVirtualSystemResources2( final IJIDispatch vmDispatch, final IJIDispatch newResourceAllocationDispatch) throws JIException { if (this.addVirtualSystemResources == null) { for (final SWbemMethod m : super.getMethods()) { if (m.getName().equals("AddVirtualSystemResources")) { this.addVirtualSystemResources = m; } } } // Getting the dispatcher of the VM Path IJIDispatch vmPathDispatcher = (IJIDispatch) JIObjectFactory.narrowObject( vmDispatch.get("Path_").getObjectAsComObject().queryInterface(IJIDispatch.IID)); // Getting the virtual machine path String vmPath = vmPathDispatcher.get("Path").getObjectAsString2(); // Getting the dispatcher of the resource path String resourceText = newResourceAllocationDispatch.callMethodA("GetText_", new Object[] {new Integer(1)})[0] .getObjectAsString2(); SWbemObject inParams = this.addVirtualSystemResources.getInParameters(); inParams.getObjectDispatcher().put("TargetSystem", new JIVariant(new JIString(vmPath))); inParams .getObjectDispatcher() .put( "ResourceSettingData", new JIVariant(new JIArray(new JIString[] {new JIString(resourceText)}))); Object[] methodParams = new Object[] { new JIString("AddVirtualSystemResources"), new JIVariant(inParams.getObjectDispatcher()), new Integer(0), JIVariant.NULL(), }; // Execute the method. JIVariant[] results = super.objectDispatcher.callMethodA("ExecMethod_", methodParams); // Get the out parameters. JIVariant outParamsVar = results[0]; IJIComObject co = outParamsVar.getObjectAsComObject(); IJIDispatch outParamsDisp = (IJIDispatch) JIObjectFactory.narrowObject(co); // Get the out parameter virtualSystemResources and convert it into an // array of JIVariants. JIVariant newResourcesVars = outParamsDisp.get("NewResources"); JIArray newResourcesVarsJIArr = newResourcesVars.getObjectAsArray(); JIVariant[] newResourcesVarsJIVarArr = (JIVariant[]) newResourcesVarsJIArr.getArrayInstance(); String newResourceCoString = newResourcesVarsJIVarArr[0].getObjectAsString2(); return newResourceCoString; }