예제 #1
0
        /// <summary>
        /// Initiates an asynchronous resize of the server. A server resize is performed by
        /// specifying a new <see cref="Flavor"/> for the server.
        /// </summary>
        /// <remarks>
        /// Following a resize operation, the original server is not immediately removed. After testing
        /// if the resulting server is operating successfully, a call should be made to <see cref="ConfirmResize"/>
        /// to keep the resized server, or to <see cref="RevertResize"/> to revert to the original server.
        /// If 24 hours pass and neither of these methods is called, the server will be automatically confirmed.
        /// </remarks>
        /// <param name="name">The new name for the resized server.</param>
        /// <param name="flavor">The new flavor. This is obtained from <see cref="Flavor.Id">Flavor.Id</see>.</param>
        /// <param name="diskConfig">The disk configuration. If the value is <see langword="null"/>, the default configuration for the specified image is used.</param>
        /// <returns><see langword="true"/> if the resize operation is successfully started; otherwise, <see langword="false"/>.</returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="name"/> is <see langword="null"/>.
        /// <para>-or-</para>
        /// <para>If <paramref name="flavor"/> 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>
        /// </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 Resize(string name, string flavor, DiskConfiguration diskConfig = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (flavor == null)
            {
                throw new ArgumentNullException("flavor");
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("name cannot be empty");
            }
            if (string.IsNullOrEmpty(flavor))
            {
                throw new ArgumentException("flavor cannot be empty");
            }
            if (diskConfig != null && diskConfig != DiskConfiguration.Auto && diskConfig != DiskConfiguration.Manual)
            {
                throw new NotSupportedException("The specified disk configuration is not supported.");
            }

            return(Provider.ResizeServer(Id, name, flavor, diskConfig, Region, Identity));
        }
예제 #2
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. 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. 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 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>
        /// <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 && 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");
            }
            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);
        }
예제 #3
0
 /// <inheritdoc/>
 protected override DiskConfiguration FromName(string name)
 {
     return(DiskConfiguration.FromName(name));
 }