private ConverterTargetVmSpecManagedVmLocation BuildTargetVMLocation()
        {
            ConverterTargetVmSpecManagedVmLocation        targetVMLocation = new ConverterTargetVmSpecManagedVmLocation();
            ConverterVimConnectionSpecLoginVimCredentials vimCredentials   = new ConverterVimConnectionSpecLoginVimCredentials();

            vimCredentials.password = _vcPassword;
            vimCredentials.username = _vcUsername;
            ConverterVimConnectionSpec vimConnectionSpec = new ConverterVimConnectionSpec();

            vimConnectionSpec.hostname            = _vcServerName;
            vimConnectionSpec.credentials         = vimCredentials;
            vimConnectionSpec.verifyPeer          = true;
            vimConnectionSpec.verifyPeerSpecified = true;
            vimConnectionSpec.sslThumbprint       = _vcThumbprint;
            targetVMLocation.vimConnect           = vimConnectionSpec;
            return(targetVMLocation);
        }
Ejemplo n.º 2
0
        public ConverterServerConversionConversionJobInfo SubmitJob(ConverterServerConversionConversionJobSpec jobSpec)
        {
            ConverterServerConversionConversionJobInfo result = null;
            bool retry;

            do
            {
                retry = false;

                try {
                    result = _converterService.ConverterServerConversionManagerCreateJob(_converterServerContent.conversionManager, jobSpec, null);
                } catch (SoapException e) {
                    String remoteThumbprint = ExtractCertificateThumbprintFromFaultMessage(e.Detail.InnerText);

                    if (remoteThumbprint != null)
                    {
                        // source machine spec
                        ConverterComputerSpecLiveComputerLocation liveSourceLocation = (ConverterComputerSpecLiveComputerLocation)jobSpec.source.location;

                        // destination connection spec
                        ConverterVimConnectionSpec vimConnectionSpec = ((ConverterTargetVmSpecManagedVmLocation)jobSpec.conversionParams.cloningParams.target.location).vimConnect;

                        if (liveSourceLocation != null && (liveSourceLocation.sslThumbprint == null || liveSourceLocation.sslThumbprint.Length == 0))
                        {
                            if (ReadYesNo("\nSource machine certificate validation failed.\n" +
                                          "Source machine: " + liveSourceLocation.hostname + "\n" +
                                          "Certificate thumprint: " + remoteThumbprint + "\n" +
                                          "Proceed with connecting to the source machine?", false))
                            {
                                liveSourceLocation.sslThumbprint = remoteThumbprint;
                                retry = true;
                            }
                        }
                        else if (vimConnectionSpec != null && (vimConnectionSpec.sslThumbprint == null || vimConnectionSpec.sslThumbprint.Length == 0))
                        {
                            if (ReadYesNo("\nDestination vCenter/ESX server certificate validation failed.\n" +
                                          "Destination vCenter/ESX server: " + vimConnectionSpec.hostname + "\n" +
                                          "Certificate thumprint: " + remoteThumbprint + "\n" +
                                          "Proceed with connecting to the destination server?", false))
                            {
                                vimConnectionSpec.sslThumbprint = remoteThumbprint;
                                retry = true;
                            }
                        }
                    }

                    if (!retry)
                    {
                        Console.WriteLine("Caught SoapException - \n" +
                                          " Actor : " + e.Actor + "\n" +
                                          " Code : " + e.Code + "\n" +
                                          " Detail XML : " + e.Detail.OuterXml);
                    }
                } catch (Exception e) {
                    Console.WriteLine("Caught Exception : \n" +
                                      " Name : " + e.GetType().Name + "\n" +
                                      " Message : " + e.Message + "\n" +
                                      " Trace : " + e.StackTrace);
                }
            } while (retry);

            return(result);
        }