예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerResizeDetails"/> class with the specified details.
        /// </summary>
        /// <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>
        /// <exception cref="ArgumentNullException">
        /// <para>If <paramref name="flavor"/> is <see langword="null"/>.</para>
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <para>If <paramref name="flavor"/> is empty.</para>
        /// </exception>
        public ServerResizeDetails(string flavor, DiskConfiguration diskConfig)
        {
            if (flavor == null)
            {
                throw new ArgumentNullException("flavor");
            }
            if (string.IsNullOrEmpty(flavor))
            {
                throw new ArgumentException("flavor cannot be empty");
            }

            Flavor     = flavor;
            DiskConfig = diskConfig;
        }
예제 #2
0
            /// <summary>
            /// Initializes a new instance of the <see cref="CreateServerDetails"/> class
            /// with the specified details.
            /// </summary>
            /// <param name="name">Name of the new server.</param>
            /// <param name="imageName">The image to use for the new server instance. This is
            /// specified as an image ID (see <see cref="SimpleServerImage.Id"/>) or a full URL.</param>
            /// <param name="flavorId">The flavor to use for the new server instance. This
            /// is specified as a flavor ID (see <see cref="Flavor.Id"/>) or a full URL.</param>
            /// <param name="adminPass">The root Password </param>
            /// <param name="keyName">the ssh keyname to add to server</param>
            /// <param name="securityGroupNames">A collection of openstack security group name</param>
            /// <param name="attachVolumeIds">A collection of voiume ids which will be attached to the instance.</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="metadata">The metadata to associate with the server.</param>
            /// <param name="personality">A collection of <see cref="Personality"/> objects describing the paths and contents of files to inject in the target file system during the creation process. If the value is <see langword="null"/>, no files are injected.</param>
            /// <param name="accessIPv4">The behavior of this value is unspecified. Do not use.</param>
            /// <param name="accessIPv6">The behavior of this value is unspecified. Do not use.</param>
            /// <param name="networks">A collection of identifiers for networks to initially connect to the server. These are obtained from <see cref="CloudNetwork.Id">CloudNetwork.Id</see></param>
            public CreateServerDetails(string name, string imageName, string flavorId, string adminPass, string keyName, string[] securityGroupNames, string[] attachVolumeIds, DiskConfiguration diskConfig, Dictionary <string, string> metadata, string accessIPv4, string accessIPv6, IEnumerable <string> networks, IEnumerable <Personality> personality)
            {
                Name        = name;
                ImageId     = imageName;
                FlavorId    = flavorId;
                DiskConfig  = diskConfig;
                Metadata    = metadata;
                AccessIPv4  = accessIPv4;
                AccessIPv6  = accessIPv6;
                Networks    = (networks == null ? null : networks.Select(i => new NewServerNetwork(i)).ToArray());
                Personality = personality != null?personality.ToArray() : null;

                KeyName             = keyName;
                SecurityGroupNames  = SecurityGroupName.GetGroupNamesFromStrings(securityGroupNames).ToArray <SecurityGroupName>();
                BlockDeviceMappings = VolumeIds.GetVolumeIdsFromStrings(attachVolumeIds).ToArray <VolumeIds>();
                AdminPass           = adminPass;
            }
예제 #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="net.openstack.Core.Exceptions.Response.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;
         * //}
         */

        /// <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="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 flavor is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// If flavor is empty.
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// If the provider does not support the given <paramref name="diskConfig"/>.
        /// </exception>
        /// <exception cref="net.openstack.Core.Exceptions.Response.ResponseException">If the REST API request failed.</exception>
        public bool Resize(string flavor, DiskConfiguration diskConfig = null)
        {
            if (flavor == null)
            {
                throw new ArgumentNullException("flavor");
            }
            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, flavor, diskConfig, Region, Identity));
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CreateServerRequest"/> class
 /// with the specified details.
 /// </summary>
 /// <param name="name">Name of the new server.</param>
 /// <param name="imageId">The image to use for the new server instance. This is
 /// specified as an image ID (see <see cref="SimpleServerImage.Id"/>) or a full URL.</param>
 /// <param name="flavorId">The flavor to use for the new server instance. This
 /// is specified as a flavor ID (see <see cref="Flavor.Id"/>) or a full URL.</param>
 /// <param name="adminPass">The root Password </param>
 /// <param name="keyName">The ssh key name</param>
 /// <param name="securityGroupNames">A collection of openstack security group name</param>
 /// <param name="attachVolumeIds">A collection of voiume ids which will be attached to the instance.</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="metadata">The metadata to associate with the server.</param>
 /// <param name="personality">A collection of <see cref="Personality"/> objects describing the paths and contents of files to inject in the target file system during the creation process. If the value is <see langword="null"/>, no files are injected.</param>
 /// <param name="accessIPv4">The behavior of this value is unspecified. Do not use.</param>
 /// <param name="accessIPv6">The behavior of this value is unspecified. Do not use.</param>
 ///<param name="networks">A collection of identifiers for networks to initially connect to the server. These are obtained from <see cref="CloudNetwork.Id">CloudNetwork.Id</see></param>
 public CreateServerRequest(string name, string imageId, string flavorId, string adminPass, string keyName, string[] securityGroupNames, string[] attachVolumeIds, DiskConfiguration diskConfig, Dictionary <string, string> metadata, string accessIPv4, string accessIPv6, IEnumerable <string> networks, IEnumerable <Personality> personality)
 {
     Details = new CreateServerDetails(name, imageId, flavorId, adminPass, keyName, securityGroupNames, attachVolumeIds, diskConfig, metadata, accessIPv4, accessIPv6, networks, personality);
 }
예제 #5
0
 /// <inheritdoc/>
 protected override DiskConfiguration FromName(string name)
 {
     return(DiskConfiguration.FromName(name));
 }