Exemplo n.º 1
0
        /// <summary>
        ///     Adds the vCenter to Fabric and discovery its VMs.
        /// </summary>
        /// <param name="fabricName">Fabric ID.</param>
        /// <param name="vCenterName">vCenter Name.</param>
        /// <param name="input">Add vCenter input.</param>
        /// <returns>Job operation response</returns>
        public PSSiteRecoveryLongRunningOperation NewAzureRmSiteRecoveryvCenter(
            string fabricName,
            string vCenterName,
            AddVCenterRequest input)
        {
            var op = this.GetSiteRecoveryClient()
                     .ReplicationvCenters.BeginCreateWithHttpMessagesAsync(
                fabricName,
                vCenterName,
                input,
                this.GetRequestHeaders(true))
                     .GetAwaiter()
                     .GetResult();

            var result = SiteRecoveryAutoMapperProfile.Mapper.Map <PSSiteRecoveryLongRunningOperation>(op);

            return(result);
        }
        /// <summary>
        ///     Discover the vCenter.
        /// </summary>
        private void DiscovervCenter()
        {
            var fabricResponse =
                this.RecoveryServicesClient.GetAzureSiteRecoveryFabric(this.Fabric.Name);

            var vmwareFabricDetails =
                (VMwareDetails)fabricResponse.Properties.CustomDetails;

            var addvCenterRequest = new AddVCenterRequest();

            var addvCenterRequestProperties =
                new AddVCenterRequestProperties();

            addvCenterRequestProperties.FriendlyName = this.Name;
            addvCenterRequestProperties.IpAddress    = this.IpOrHostName;
            addvCenterRequestProperties.Port         = this.Port.ToString();
            string processServerId = vmwareFabricDetails.ProcessServers.First(
                vmd => (
                    vmd.IpAddress.Equals(vmwareFabricDetails.IpAddress) ||
                    string.Compare(
                        vmwareFabricDetails.HostName,
                        vmd.FriendlyName,
                        StringComparison.OrdinalIgnoreCase) == 0)).Id;

            addvCenterRequestProperties.ProcessServerId = processServerId;
            addvCenterRequestProperties.RunAsAccountId  = this.Account.AccountId;

            addvCenterRequest.Properties = addvCenterRequestProperties;

            var response = this.RecoveryServicesClient.NewAzureRmSiteRecoveryvCenter(
                this.Fabric.Name,
                this.Name,
                addvCenterRequest);

            var jobResponse = this.RecoveryServicesClient.GetAzureSiteRecoveryJobDetails(
                PSRecoveryServicesClient.GetJobIdFromReponseLocation(response.Location));

            this.WriteObject(new ASRJob(jobResponse));
        }
 /// <summary>
 /// Add vCenter.
 /// </summary>
 /// <remarks>
 /// The operation to create a vCenter object..
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fabricName'>
 /// Fabric name.
 /// </param>
 /// <param name='vCenterName'>
 /// vCenter name.
 /// </param>
 /// <param name='addVCenterRequest'>
 /// The input to the add vCenter operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <VCenter> BeginCreateAsync(this IReplicationvCentersOperations operations, string fabricName, string vCenterName, AddVCenterRequest addVCenterRequest, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateWithHttpMessagesAsync(fabricName, vCenterName, addVCenterRequest, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Add vCenter.
 /// </summary>
 /// <remarks>
 /// The operation to create a vCenter object..
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='fabricName'>
 /// Fabric name.
 /// </param>
 /// <param name='vCenterName'>
 /// vCenter name.
 /// </param>
 /// <param name='addVCenterRequest'>
 /// The input to the add vCenter operation.
 /// </param>
 public static VCenter BeginCreate(this IReplicationvCentersOperations operations, string fabricName, string vCenterName, AddVCenterRequest addVCenterRequest)
 {
     return(operations.BeginCreateAsync(fabricName, vCenterName, addVCenterRequest).GetAwaiter().GetResult());
 }