Пример #1
0
        /// <summary>
        /// Sets the password. This is done by setting the value of the password-secret stored in the credentials.
        /// </summary>
        /// <param name="password">The new password.</param>
        public void SetPassword(string password)
        {
            Util.ThrowIfParameterNull(password, "password");

            var session = _connection.Session;

            if (session != null)
            {
                string secretRef = Secret.get_by_uuid(session, PasswordSecret);
                Secret.set_value(_connection.Session, secretRef, password);
            }
        }
Пример #2
0
 protected string GetSecret(Host host)
 {
     try
     {
         var opaqueRef = Secret.get_by_uuid(host.Connection.Session, host.power_on_config[POWER_ON_PASSWORD_SECRET]);
         return(Secret.get_value(host.Connection.Session, opaqueRef));
     }
     catch
     {
         return(string.Empty);
     }
 }
Пример #3
0
        public void SetStorageLinkCredentials(string host, string username, string password)
        {
            var otherConfig = new Dictionary <string, string>(other_config);

            if (host == null)
            {
                otherConfig.Remove("storagelink_host");
            }
            else
            {
                otherConfig["storagelink_host"] = host;
            }

            if (username == null)
            {
                otherConfig.Remove("storagelink_user");
            }
            else
            {
                otherConfig["storagelink_user"] = username;
            }

            if (password == null)
            {
                otherConfig.Remove("storagelink_password_secret");
            }
            else if (otherConfig.ContainsKey("storagelink_password_secret"))
            {
                try
                {
                    string secretRef = Secret.get_by_uuid(Connection.Session, otherConfig["storagelink_password_secret"]);
                    Secret.set_value(Connection.Session, secretRef, password);
                }
                catch (Failure)
                {
                    otherConfig["storagelink_password_secret"] = Secret.CreateSecret(Connection.Session, password);
                }
                catch (WebException)
                {
                    otherConfig["storagelink_password_secret"] = Secret.CreateSecret(Connection.Session, password);
                }
            }
            else
            {
                otherConfig["storagelink_password_secret"] = Secret.CreateSecret(Connection.Session, password);
            }

            Pool.set_other_config(Connection.Session, opaque_ref, otherConfig);
        }
Пример #4
0
        public string GetSecretyInfo(IXenConnection connection, string secretType)
        {
            string UUID = string.Empty;

            switch (secretType)
            {
            case CallHomeSettings.UPLOAD_CREDENTIAL_USER_SECRET:
                UUID = UserNameSecretUuid;
                break;

            case CallHomeSettings.UPLOAD_CREDENTIAL_PASSWORD_SECRET:
                UUID = PasswordSecretUuid;
                break;

            case CallHomeSettings.UPLOAD_TOKEN_SECRET:
                UUID = UploadTokenSecretUuid;
                break;

            default:
                log.ErrorFormat("Error getting the {0} from the xapi secret", secretType);
                break;
            }

            if (connection == null || string.IsNullOrEmpty(UUID))
            {
                return(null);
            }
            try
            {
                string opaqueref = Secret.get_by_uuid(connection.Session, UUID);
                return(Secret.get_value(connection.Session, opaqueref));
            }
            catch (Exception e)
            {
                log.Error("Exception getting the upload token from the xapi secret", e);
                return(null);
            }
        }