Пример #1
0
        /// <summary>
        /// Initiates a rebuild of the server
        /// </summary>
        /// <param name="name">The new name for the server.</param>
        /// <param name="imageId">The ID of the new image for the server.</param>
        /// <param name="flavor">The new flavor for server.</param>
        /// <param name="adminPassword">The new admin password for the server.</param>
        /// <param name="accessIPv4">The new access IP v4 address for the server. </param>
        /// <param name="accessIPv6">The new access IP v6 address for the server. </param>
        /// <param name="metadata">The list of any metadata to associate with the server. </param>
        /// <param name="diskConfig">The disk configuration value. <remarks>Available values are [AUTO, MANUAL]</remarks></param>
        /// <param name="personality">The file path and file contents. </param>
        /// <returns><c>bool</c> indicating if the action was successful</returns>
        public bool Rebuild(string name, string imageId, string flavor, string adminPassword, string accessIPv4 = null, string accessIPv6 = null, Metadata metadata = null, string diskConfig = null, Personality personality = null)
        {
            var details = Provider.RebuildServer(Id, name, imageId, flavor, adminPassword, accessIPv4, accessIPv6, metadata, diskConfig, personality, Region);

            if (details == null)
            {
                return(false);
            }

            UpdateThis(details);

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerRebuildDetails"/> class with the specified details.
        /// </summary>
        /// <param name="name">The new name for the server. If the value is <c>null</c>, the server name is not changed.</param>
        /// <param name="imageName">The image to rebuild the server from. This is specified as an image ID (see <see cref="SimpleServerImage.Id"/>) or a full URL.</param>
        /// <param name="flavor">The new flavor for server. This is obtained from <see cref="net.openstack.Core.Domain.Flavor.Id"/>.</param>
        /// <param name="adminPassword">The new admin password for the server.</param>
        /// <param name="accessIPv4">The new IP v4 address for the server. If the value is <c>null</c>, the server's IP v4 address is not updated.</param>
        /// <param name="accessIPv6">The new IP v6 address for the server. If the value is <c>null</c>, the server's IP v6 address is not updated.</param>
        /// <param name="metadata">The list of metadata to associate with the server. If the value is <c>null</c>, the metadata associated with the server is not changed during the rebuild operation.</param>
        /// <param name="diskConfig">The disk configuration. If the value is <c>null</c>, the default configuration for the specified image is used.</param>
        /// <param name="personality">The path and contents of a file to inject in the target file system during the rebuild operation. If the value is <c>null</c>, no file is injected.</param>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="imageName"/> is <c>null</c>.
        /// <para>-or-</para>
        /// <para>If <paramref name="flavor"/> is <c>null</c>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="adminPassword"/> is <c>null</c>.</para>
        /// </exception>
        /// <exception cref="ArgumentException">
        /// If <paramref name="imageName"/> is empty.
        /// <para>-or-</para>
        /// <para>If <paramref name="flavor"/> is empty.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="adminPassword"/> is empty.</para>
        /// <para>-or-</para>
        /// <para>If the <see cref="AddressFamily"/> of <paramref name="accessIPv4"/> is not <see cref="AddressFamily.InterNetwork"/></para>
        /// <para>-or-</para>
        /// <para>If the <see cref="AddressFamily"/> of <paramref name="accessIPv6"/> is not <see cref="AddressFamily.InterNetworkV6"/></para>
        /// </exception>
        public ServerRebuildDetails(string name, string imageName, string flavor, string adminPassword, IPAddress accessIPv4, IPAddress accessIPv6, Metadata metadata, DiskConfiguration diskConfig, Personality personality)
        {
            if (imageName == null)
                throw new ArgumentNullException("imageName");
            if (flavor == null)
                throw new ArgumentNullException("flavor");
            if (adminPassword == null)
                throw new ArgumentNullException("adminPassword");
            if (string.IsNullOrEmpty(imageName))
                throw new ArgumentException("imageName cannot be empty");
            if (string.IsNullOrEmpty(flavor))
                throw new ArgumentException("flavor cannot be empty");
            if (string.IsNullOrEmpty(adminPassword))
                throw new ArgumentException("adminPassword cannot be empty");
            if (accessIPv4 != null && accessIPv4.AddressFamily != AddressFamily.InterNetwork)
                throw new ArgumentException("The specified value for accessIPv4 is not an IP v4 address.", "accessIPv4");
            if (accessIPv6 != null && accessIPv6.AddressFamily != AddressFamily.InterNetworkV6)
                throw new ArgumentException("The specified value for accessIPv6 is not an IP v6 address.", "accessIPv6");

            Name = name;
            ImageName = imageName;
            Flavor = flavor;
            AdminPassword = adminPassword;
            AccessIPv4 = accessIPv4;
            AccessIPv6 = accessIPv6;
            Metadata = metadata;
            DiskConfig = diskConfig;
            Personality = personality;
        }
Пример #3
0
        /// <summary>
        /// Initiates an asynchronous rebuild of the server.
        /// </summary>
        /// <remarks>
        /// When the method returns, the current instance is updated to reflect the state
        /// of the server at the end of the operation.
        /// </remarks>
        /// <param name="name">The new name for the server. If the value is <see langword="null"/>, the server name is not changed.</param>
        /// <param name="imageId">The image to rebuild the server from. This is specified as an image ID (see <see cref="SimpleServerImage.Id"/>) or a full URL.</param>
        /// <param name="flavor">The new flavor for server. This is obtained from <see cref="Flavor.Id"/>.</param>
        /// <param name="adminPassword">The new admin password for the server.</param>
        /// <param name="accessIPv4">The new IP v4 address for the server, or <see cref="IPAddress.None"/> to remove the configured IP v4 address for the server. If the value is <see langword="null"/>, the server's IP v4 address is not updated.</param>
        /// <param name="accessIPv6">The new IP v6 address for the server, or <see cref="IPAddress.None"/> to remove the configured IP v6 address for the server. If the value is <see langword="null"/>, the server's IP v6 address is not updated.</param>
        /// <param name="metadata">The list of metadata to associate with the server. If the value is <see langword="null"/>, the metadata associated with the server is not changed during the rebuild operation.</param>
        /// <param name="diskConfig">The disk configuration. If the value is <see langword="null"/>, the default configuration for the specified image is used.</param>
        /// <param name="personality">The path and contents of a file to inject in the target file system during the rebuild operation. If the value is <see langword="null"/>, no file is injected.</param>
        /// <returns><see langword="true"/> if the rebuild operation was successfully initiated; otherwise <see langword="false"/>.</returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="imageId"/> is <see langword="null"/>.
        /// <para>-or-</para>
        /// <para>If <paramref name="flavor"/> is <see langword="null"/>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="adminPassword"/> is <see langword="null"/>.</para>
        /// </exception>
        /// <exception cref="ArgumentException">
        /// If <paramref name="name"/> is empty.
        /// <para>-or-</para>
        /// <para>If <paramref name="flavor"/> is empty.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="adminPassword"/> is empty.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="accessIPv4"/> is not <see cref="IPAddress.None"/> and the <see cref="AddressFamily"/> of <paramref name="accessIPv4"/> is not <see cref="AddressFamily.InterNetwork"/>.</para>
        /// <para>-or-</para>
        /// <para>If <paramref name="accessIPv6"/> is not <see cref="IPAddress.None"/> and the <see cref="AddressFamily"/> of <paramref name="accessIPv6"/> is not <see cref="AddressFamily.InterNetworkV6"/>.</para>
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// If the provider does not support the given <paramref name="diskConfig"/>.
        /// </exception>
        /// <exception cref="ResponseException">If the REST API request failed.</exception>
        public bool Rebuild(string name, string imageId, string flavor, string adminPassword, IPAddress accessIPv4 = null, IPAddress accessIPv6 = null, Metadata metadata = null, DiskConfiguration diskConfig = null, Personality personality = null)
        {
            if (imageId == null)
            {
                throw new ArgumentNullException("imageId");
            }
            if (flavor == null)
            {
                throw new ArgumentNullException("flavor");
            }
            if (string.IsNullOrEmpty(imageId))
            {
                throw new ArgumentException("imageId cannot be empty");
            }
            if (string.IsNullOrEmpty(flavor))
            {
                throw new ArgumentException("flavor cannot be empty");
            }
            if (accessIPv4 != null && !IPAddress.None.Equals(accessIPv4) && accessIPv4.AddressFamily != AddressFamily.InterNetwork)
            {
                throw new ArgumentException("The specified value for accessIPv4 is not an IP v4 address.", "accessIPv4");
            }
            if (accessIPv6 != null && !IPAddress.None.Equals(accessIPv6) && accessIPv6.AddressFamily != AddressFamily.InterNetworkV6)
            {
                throw new ArgumentException("The specified value for accessIPv6 is not an IP v6 address.", "accessIPv6");
            }
            if (diskConfig != null && diskConfig != DiskConfiguration.Auto && diskConfig != DiskConfiguration.Manual)
            {
                throw new NotSupportedException("The specified disk configuration is not supported.");
            }

            var details = Provider.RebuildServer(Id, name, imageId, flavor, adminPassword, accessIPv4, accessIPv6, metadata, diskConfig, personality, Region, Identity);

            if (details == null)
            {
                return(false);
            }

            UpdateThis(details);

            return(true);
        }