Package com.vmware.vim25

Examples of com.vmware.vim25.OvfCreateImportSpecResult


        importSpecParams.setDiskProvisioning(diskOption); // diskOption: thin, thick, etc
        //importSpecParams.setPropertyMapping(null);

        String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
        VmwareContext context = host.getContext();
        OvfCreateImportSpecResult ovfImportResult =
                context.getService().createImportSpec(context.getServiceContent().getOvfManager(), ovfDescriptor, morRp, dsMo.getMor(), importSpecParams);

        if (ovfImportResult == null) {
            String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: " + vmName + ", diskOption: " + diskOption;
            s_logger.error(msg);
            throw new Exception(msg);
        }

        if(!ovfImportResult.getError().isEmpty()) {
            for (LocalizedMethodFault fault : ovfImportResult.getError()) {
                s_logger.error("createImportSpec error: " + fault.getLocalizedMessage());
            }
            throw new CloudException("Failed to create an import spec from " + ovfFilePath + ". Check log for details.");
        }

        if (!ovfImportResult.getWarning().isEmpty()) {
            for (LocalizedMethodFault fault : ovfImportResult.getError()) {
                s_logger.warn("createImportSpec warning: " + fault.getLocalizedMessage());
            }
        }

        DatacenterMO dcMo = new DatacenterMO(context, host.getHyperHostDatacenter());
        ManagedObjectReference morLease = context.getService().importVApp(morRp, ovfImportResult.getImportSpec(), dcMo.getVmFolder(), morHost);
        if (morLease == null) {
            String msg = "importVApp() failed. ovfFilePath: " + ovfFilePath + ", vmName: " + vmName + ", diskOption: " + diskOption;
            s_logger.error(msg);
            throw new Exception(msg);
        }
        boolean importSuccess = true;
        final HttpNfcLeaseMO leaseMo = new HttpNfcLeaseMO(context, morLease);
        HttpNfcLeaseState state = leaseMo.waitState(new HttpNfcLeaseState[] {HttpNfcLeaseState.READY, HttpNfcLeaseState.ERROR});
        try {
            if (state == HttpNfcLeaseState.READY) {
                final long totalBytes = HttpNfcLeaseMO.calcTotalBytes(ovfImportResult);
                File ovfFile = new File(ovfFilePath);

                HttpNfcLeaseInfo httpNfcLeaseInfo = leaseMo.getLeaseInfo();
                List<HttpNfcLeaseDeviceUrl> deviceUrls = httpNfcLeaseInfo.getDeviceUrl();
                long bytesAlreadyWritten = 0;

                final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter();
                try {
                    for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) {
                        String deviceKey = deviceUrl.getImportKey();
                        for (OvfFileItem ovfFileItem : ovfImportResult.getFileItem()) {
                            if (deviceKey.equals(ovfFileItem.getDeviceId())) {
                                String absoluteFile = ovfFile.getParent() + File.separator + ovfFileItem.getPath();
                                String urlToPost = deviceUrl.getUrl();
                                urlToPost = resolveHostNameInUrl(dcMo, urlToPost);
View Full Code Here


        importSpecParams.setDiskProvisioning(diskOption); // diskOption: thin, thick, etc
        //importSpecParams.setPropertyMapping(null);

        String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
        VmwareContext context = host.getContext();
        OvfCreateImportSpecResult ovfImportResult = context.getService().createImportSpec(
                context.getServiceContent().getOvfManager(), ovfDescriptor, morRp,
                dsMo.getMor(), importSpecParams);

        if(ovfImportResult == null) {
            String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
                    + vmName + ", diskOption: " + diskOption;
            s_logger.error(msg);
            throw new Exception(msg);
        }

        DatacenterMO dcMo = new DatacenterMO(context, host.getHyperHostDatacenter());
        ManagedObjectReference morLease = context.getService().importVApp(morRp,
                ovfImportResult.getImportSpec(), dcMo.getVmFolder(), morHost);
        if(morLease == null) {
            String msg = "importVApp() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
                    + vmName + ", diskOption: " + diskOption;
            s_logger.error(msg);
            throw new Exception(msg);
        }
        boolean importSuccess = true;
        final HttpNfcLeaseMO leaseMo = new HttpNfcLeaseMO(context, morLease);
        HttpNfcLeaseState state = leaseMo.waitState(
                new HttpNfcLeaseState[] { HttpNfcLeaseState.READY, HttpNfcLeaseState.ERROR });
        try {
            if(state == HttpNfcLeaseState.READY) {
                final long totalBytes = HttpNfcLeaseMO.calcTotalBytes(ovfImportResult);
                File ovfFile = new File(ovfFilePath);

                HttpNfcLeaseInfo httpNfcLeaseInfo = leaseMo.getLeaseInfo();
                List<HttpNfcLeaseDeviceUrl> deviceUrls = httpNfcLeaseInfo.getDeviceUrl();
                long bytesAlreadyWritten = 0;

                final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter();
                try {
                    for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) {
                        String deviceKey = deviceUrl.getImportKey();
                        for (OvfFileItem ovfFileItem : ovfImportResult.getFileItem()) {
                            if (deviceKey.equals(ovfFileItem.getDeviceId())) {
                                String absoluteFile = ovfFile.getParent() + File.separator + ovfFileItem.getPath();
                                String urlToPost = deviceUrl.getUrl();
                                urlToPost = resolveHostNameInUrl(dcMo, urlToPost);
View Full Code Here

    importSpecParams.setNetworkMapping(new OvfNetworkMapping[] { networkMapping });
*/   
    importSpecParams.setPropertyMapping(null);
   
    String ovfDescriptor = readOvfContent("C:\\research\\vmware\\winxpsp3-ovf\\winxpsp3-ovf.ovf");
    OvfCreateImportSpecResult ovfImportResult = cb.getServiceConnection3().getService().createImportSpec(
      morOvf, ovfDescriptor, morRp, morDs, importSpecParams);
   
    if(ovfImportResult != null) {
      long totalBytes = addTotalBytes(ovfImportResult);
     
      ManagedObjectReference morLease = cb.getServiceConnection3().getService().importVApp(morRp,
        ovfImportResult.getImportSpec(), morVmFolder, morHost);
     
      HttpNfcLeaseState state;
      for(;;) {
        state = (HttpNfcLeaseState)cb.getServiceUtil3().getDynamicProperty(morLease, "state");
        if(state == HttpNfcLeaseState.ready || state == HttpNfcLeaseState.error)
          break;
      }
     
      if(state == HttpNfcLeaseState.ready) {
        HttpNfcLeaseInfo httpNfcLeaseInfo = (HttpNfcLeaseInfo)cb.getServiceUtil3().getDynamicProperty(morLease, "info");
            HttpNfcLeaseDeviceUrl[] deviceUrls = httpNfcLeaseInfo.getDeviceUrl()
            long bytesAlreadyWritten = 0
            for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) {
             
              String deviceKey = deviceUrl.getImportKey()
              for (OvfFileItem ovfFileItem : ovfImportResult.getFileItem()) { 
                if (deviceKey.equals(ovfFileItem.getDeviceId())) { 
                  System.out.println("Import key==OvfFileItem device id: " + deviceKey);
                  System.out.println("device URL: " + deviceUrl.getUrl());
                 
                  String absoluteFile = "C:\\research\\vmware\\winxpsp3-ovf\\" + ovfFileItem.getPath();
View Full Code Here

        importSpecParams.setDiskProvisioning(diskOption); // diskOption: thin, thick, etc
        //importSpecParams.setPropertyMapping(null);

        String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
        VmwareContext context = host.getContext();
        OvfCreateImportSpecResult ovfImportResult = context.getService().createImportSpec(
                context.getServiceContent().getOvfManager(), ovfDescriptor, morRp,
                dsMo.getMor(), importSpecParams);

        if(ovfImportResult == null) {
            String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
                    + vmName + ", diskOption: " + diskOption;
            s_logger.error(msg);
            throw new Exception(msg);
        }

        if(!ovfImportResult.getError().isEmpty()) {
            for (LocalizedMethodFault fault : ovfImportResult.getError()) {
                s_logger.error("createImportSpec error: " + fault.getLocalizedMessage());
            }
            throw new CloudException("Failed to create an import spec from " + ovfFilePath + ". Check log for details.");
        }

        if (!ovfImportResult.getWarning().isEmpty()) {
            for (LocalizedMethodFault fault : ovfImportResult.getError()) {
                s_logger.warn("createImportSpec warning: " + fault.getLocalizedMessage());
            }
        }

        DatacenterMO dcMo = new DatacenterMO(context, host.getHyperHostDatacenter());
        ManagedObjectReference morLease = context.getService().importVApp(morRp,
                ovfImportResult.getImportSpec(), dcMo.getVmFolder(), morHost);
        if(morLease == null) {
            String msg = "importVApp() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
                    + vmName + ", diskOption: " + diskOption;
            s_logger.error(msg);
            throw new Exception(msg);
        }
        boolean importSuccess = true;
        final HttpNfcLeaseMO leaseMo = new HttpNfcLeaseMO(context, morLease);
        HttpNfcLeaseState state = leaseMo.waitState(
                new HttpNfcLeaseState[] { HttpNfcLeaseState.READY, HttpNfcLeaseState.ERROR });
        try {
            if(state == HttpNfcLeaseState.READY) {
                final long totalBytes = HttpNfcLeaseMO.calcTotalBytes(ovfImportResult);
                File ovfFile = new File(ovfFilePath);

                HttpNfcLeaseInfo httpNfcLeaseInfo = leaseMo.getLeaseInfo();
                List<HttpNfcLeaseDeviceUrl> deviceUrls = httpNfcLeaseInfo.getDeviceUrl();
                long bytesAlreadyWritten = 0;

                final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter();
                try {
                    for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) {
                        String deviceKey = deviceUrl.getImportKey();
                        for (OvfFileItem ovfFileItem : ovfImportResult.getFileItem()) {
                            if (deviceKey.equals(ovfFileItem.getDeviceId())) {
                                String absoluteFile = ovfFile.getParent() + File.separator + ovfFileItem.getPath();
                                String urlToPost = deviceUrl.getUrl();
                                urlToPost = resolveHostNameInUrl(dcMo, urlToPost);
View Full Code Here

    importSpecParams.setDiskProvisioning(diskOption); // diskOption: thin, thick, etc
    importSpecParams.setPropertyMapping(null);
   
    String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
    VmwareContext context = host.getContext();
    OvfCreateImportSpecResult ovfImportResult = context.getService().createImportSpec(
      context.getServiceContent().getOvfManager(), ovfDescriptor, morRp,
      dsMo.getMor(), importSpecParams);
   
    if(ovfImportResult == null) {
      String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
        + vmName + ", diskOption: " + diskOption;
      s_logger.error(msg);
      throw new Exception(msg);
    }
   
    DatacenterMO dcMo = new DatacenterMO(context, host.getHyperHostDatacenter());
    ManagedObjectReference morLease = context.getService().importVApp(morRp,
      ovfImportResult.getImportSpec(), dcMo.getVmFolder(), morHost);
    if(morLease == null) {
      String msg = "importVApp() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
        + vmName + ", diskOption: " + diskOption;
      s_logger.error(msg);
      throw new Exception(msg);
    }
    final HttpNfcLeaseMO leaseMo = new HttpNfcLeaseMO(context, morLease);
    HttpNfcLeaseState state = leaseMo.waitState(
      new HttpNfcLeaseState[] { HttpNfcLeaseState.ready, HttpNfcLeaseState.error });
    try {
      if(state == HttpNfcLeaseState.ready) {
        final long totalBytes = HttpNfcLeaseMO.calcTotalBytes(ovfImportResult);
        File ovfFile = new File(ovfFilePath);
       
        HttpNfcLeaseInfo httpNfcLeaseInfo = leaseMo.getLeaseInfo();
            HttpNfcLeaseDeviceUrl[] deviceUrls = httpNfcLeaseInfo.getDeviceUrl()
            long bytesAlreadyWritten = 0;
           
            final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter();
            try {
              for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) {
                String deviceKey = deviceUrl.getImportKey()
                for (OvfFileItem ovfFileItem : ovfImportResult.getFileItem()) {
                  if (deviceKey.equals(ovfFileItem.getDeviceId())) { 
                    String absoluteFile = ovfFile.getParent() + File.separator + ovfFileItem.getPath();
                    String urlToPost = deviceUrl.getUrl();
                    urlToPost = resolveHostNameInUrl(dcMo, urlToPost);
                   
View Full Code Here

    importSpecParams.setDiskProvisioning(diskOption); // diskOption: thin, thick, etc
    importSpecParams.setPropertyMapping(null);
   
    String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
    VmwareContext context = host.getContext();
    OvfCreateImportSpecResult ovfImportResult = context.getService().createImportSpec(
      context.getServiceContent().getOvfManager(), ovfDescriptor, morRp,
      dsMo.getMor(), importSpecParams);
   
    if(ovfImportResult == null) {
      String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
        + vmName + ", diskOption: " + diskOption;
      s_logger.error(msg);
      throw new Exception(msg);
    }
   
    DatacenterMO dcMo = new DatacenterMO(context, host.getHyperHostDatacenter());
    ManagedObjectReference morLease = context.getService().importVApp(morRp,
      ovfImportResult.getImportSpec(), dcMo.getVmFolder(), morHost);
    if(morLease == null) {
      String msg = "importVApp() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
        + vmName + ", diskOption: " + diskOption;
      s_logger.error(msg);
      throw new Exception(msg);
    }
        boolean importSuccess = true;
    final HttpNfcLeaseMO leaseMo = new HttpNfcLeaseMO(context, morLease);
    HttpNfcLeaseState state = leaseMo.waitState(
      new HttpNfcLeaseState[] { HttpNfcLeaseState.ready, HttpNfcLeaseState.error });
    try {
      if(state == HttpNfcLeaseState.ready) {
        final long totalBytes = HttpNfcLeaseMO.calcTotalBytes(ovfImportResult);
        File ovfFile = new File(ovfFilePath);
       
        HttpNfcLeaseInfo httpNfcLeaseInfo = leaseMo.getLeaseInfo();
            HttpNfcLeaseDeviceUrl[] deviceUrls = httpNfcLeaseInfo.getDeviceUrl()
            long bytesAlreadyWritten = 0;
           
            final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter();
            try {
              for (HttpNfcLeaseDeviceUrl deviceUrl : deviceUrls) {
                String deviceKey = deviceUrl.getImportKey()
                for (OvfFileItem ovfFileItem : ovfImportResult.getFileItem()) {
                  if (deviceKey.equals(ovfFileItem.getDeviceId())) { 
                    String absoluteFile = ovfFile.getParent() + File.separator + ovfFileItem.getPath();
                    String urlToPost = deviceUrl.getUrl();
                    urlToPost = resolveHostNameInUrl(dcMo, urlToPost);
                   
View Full Code Here

        vmFolder = (Folder) host.getVms()[0].getParent();

        importSpecParams.setLocale("US");
        importSpecParams.setEntityName(newVmName);
        importSpecParams.setDeploymentOption("");
        OvfNetworkMapping networkMapping = new OvfNetworkMapping();
        networkMapping.setName("Network 1");
        networkMapping.setNetwork(host.getNetworks()[0].getMOR());
        importSpecParams.setNetworkMapping(new OvfNetworkMapping[] { networkMapping });
        importSpecParams.setPropertyMapping(null);

        /* read ovf from the file. */
        ovfDescriptor = readOvfContent(ovfPath);
View Full Code Here

 
  public ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception {
    if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.get_value() + ", properties: " + new Gson().toJson(propertyPaths));
   
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("VirtualMachine");
    pSpec.setPathSet(propertyPaths);
   
      TraversalSpec host2VmTraversal = new TraversalSpec();
      host2VmTraversal.setType("HostSystem");
      host2VmTraversal.setPath("vm");
      host2VmTraversal.setName("host2VmTraversal");
View Full Code Here

  @Override
  public ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception {
    if(s_logger.isTraceEnabled())
      s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.get_value() + ", properties: " + new Gson().toJson(propertyPaths));

    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("Datastore");
    pSpec.setPathSet(propertyPaths);
   
      TraversalSpec host2DatastoreTraversal = new TraversalSpec();
      host2DatastoreTraversal.setType("HostSystem");
      host2DatastoreTraversal.setPath("datastore");
      host2DatastoreTraversal.setName("host2DatastoreTraversal");
View Full Code Here

  public ManagedObjectReference getNetworkMor(String portGroupName) throws Exception {
    PropertySpec pSpec = new PropertySpec();
    pSpec.setType("Network");
    pSpec.setPathSet(new String[] {"summary.name"});
   
      TraversalSpec host2NetworkTraversal = new TraversalSpec();
      host2NetworkTraversal.setType("HostSystem");
      host2NetworkTraversal.setPath("network");
      host2NetworkTraversal.setName("host2NetworkTraversal");

      ObjectSpec oSpec = new ObjectSpec();
      oSpec.setObj(_mor);
      oSpec.setSkip(Boolean.TRUE);
      oSpec.setSelectSet(new SelectionSpec[] { host2NetworkTraversal });
View Full Code Here

TOP

Related Classes of com.vmware.vim25.OvfCreateImportSpecResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.