Пример #1
0
 /// <summary>
 ///   <para>Creates and instantiates the Service Fabric compose deployment described by the compose deployment description.</para>
 /// </summary>
 /// <param name="composeDeploymentDescription">
 /// <para>The <see cref="ComposeDeploymentDescription"/> that describes the compose deployment to be created.</para>
 /// </param>
 /// <param name="client"><see cref="System.Fabric.FabricClient"/> object.</param>
 /// <param name="timeout">
 /// <para>Defines the maximum amount of time the system will allow this operation to continue before returning <see cref="System.TimeoutException" />.</para>
 /// </param>
 /// <returns>
 ///   <para>A <see cref="System.Threading.Tasks.Task" /> representing the operation.</para>
 /// </returns>
 /// <exception cref="System.Fabric.FabricObjectClosedException">
 ///   <para>The <see cref="System.Fabric.FabricClient" /> object is in a closed state. Dispose of the <see cref="System.Fabric.FabricClient" />
 ///   object you are using and instantiate a new <see cref="System.Fabric.FabricClient" /> object.</para>
 /// </exception>
 /// <exception cref="System.Fabric.FabricException">
 ///   <para>
 ///     <see cref="System.Fabric.FabricErrorCode.ImageBuilderValidationError" />: The create application request is not valid with respect to the provisioned manifests for the requested application type.</para>
 ///   <para>
 ///     <see cref="System.Fabric.FabricErrorCode.InvalidNameUri" />: The application name is not a valid Naming URI.</para>
 ///   <para>
 ///     <see cref="System.Fabric.FabricErrorCode.CorruptedImageStoreObjectFound" />: A corrupted file was encountered on the image store.</para>
 /// </exception>
 /// <exception cref="System.Fabric.FabricElementAlreadyExistsException">
 ///   <para><see cref="System.Fabric.FabricErrorCode.ComposeDeploymentAlreadyExists" />: The compose deployment has already been created.</para>
 ///   <para><see cref="System.Fabric.FabricErrorCode.ApplicationAlreadyExists" />: The application has already been created so that compose deployment can not be created using the same name. </para>
 /// </exception>
 /// <exception cref="System.UnauthorizedAccessException">
 ///   <para>There was an error accessing a file on the Image Store.</para>
 /// </exception>
 /// <exception cref="System.IO.FileNotFoundException">
 ///   <para>A required file was not found on the Image Store.</para>
 /// </exception>
 /// <exception cref="System.IO.DirectoryNotFoundException">
 ///   <para>A required directory was not found on the Image Store.</para>
 /// </exception>
 /// <exception cref="System.IO.PathTooLongException">
 ///   <para>A path to an Image Store file/directory was too long.</para>
 /// </exception>
 /// <exception cref="System.IO.IOException">
 ///   <para>
 ///     <see cref="System.Fabric.FabricErrorCode.ImageStoreIOException" />: There was an IO error communicating with the Image Store.</para>
 /// </exception>
 /// <exception cref="System.TimeoutException">
 ///   <para>The request timed out but may have already been accepted for processing by the system.</para>
 /// </exception>
 /// <exception cref="System.OperationCanceledException">
 ///   <para>The request was canceled before the timeout expired but may have already been accepted for processing by the system.</para>
 /// </exception>
 /// <exception cref="System.ArgumentException">
 ///   <para>
 ///     The parameters specified via the <see cref="ComposeDeploymentDescription"/> are incorrect.
 ///   </para>
 /// </exception>
 public static Task CreateComposeDeploymentAsync(
     this FabricClient.ComposeDeploymentClient client,
     ComposeDeploymentDescription composeDeploymentDescription,
     TimeSpan timeout)
 {
     return(client.CreateComposeDeploymentAsync(composeDeploymentDescription.ToWrapper(), timeout));
 }
Пример #2
0
        protected override void ProcessRecord()
        {
            ComposeDeploymentDescription description =
                new ComposeDeploymentDescription(this.DeploymentName, this.GetAbsolutePath(this.Compose))
            {
                ContainerRegistryUserName   = this.RegistryUserName,
                ContainerRegistryPassword   = this.RegistryPassword,
                IsRegistryPasswordEncrypted = this.PasswordEncrypted
            };

            this.CreateComposeDeployment(description);
        }
        protected void CreateComposeDeployment(ComposeDeploymentDescription description)
        {
            var clusterConnection = this.GetClusterConnection();

            try
            {
                clusterConnection.CreateComposeDeploymentAsync(
                    description,
                    this.GetTimeout(),
                    this.GetCancellationToken()).Wait();
                this.WriteObject(new PSObject(description));
            }
            catch (AggregateException aggregateException)
            {
                aggregateException.Handle((ae) =>
                {
                    this.ThrowTerminatingError(
                        ae,
                        Constants.CreateComposeDeploymentInstanceErrorId,
                        clusterConnection);
                    return(true);
                });
            }
        }