Exemplo n.º 1
0
 internal ManagementException(Exception e, string msg, ManagementBaseObject errObj) : base(msg, e)
 {
     try
     {
         if (e as ManagementException == null)
         {
             if (e as COMException == null)
             {
                 this.errorCode = (ManagementStatus)base.HResult;
             }
             else
             {
                 this.errorCode = (ManagementStatus)((COMException)e).ErrorCode;
             }
         }
         else
         {
             this.errorCode = ((ManagementException)e).ErrorCode;
             if (this.errorObject == null)
             {
                 this.errorObject = null;
             }
             else
             {
                 this.errorObject = (ManagementBaseObject)((ManagementException)e).errorObject.Clone();
             }
         }
     }
     catch
     {
     }
 }
Exemplo n.º 2
0
 public ManagementException(string message, Exception innerException) : this(innerException, message, null)
 {
     if (innerException as ManagementException == null)
     {
         this.errorCode = ManagementStatus.Failed;
     }
 }
Exemplo n.º 3
0
        internal ManagementException(Exception e, string msg, ManagementBaseObject errObj) : base(msg, e)
        {
            try
            {
                if (e is ManagementException)
                {
                    errorCode = ((ManagementException)e).ErrorCode;

                    // May/may not have extended error info.
                    //
                    if (errorObject != null)
                    {
                        errorObject = (ManagementBaseObject)((ManagementException)e).errorObject.Clone();
                    }
                    else
                    {
                        errorObject = null;
                    }
                }
                else if (e is COMException)
                {
                    errorCode = (ManagementStatus)((COMException)e).ErrorCode;
                }
                else
                {
                    errorCode = (ManagementStatus)this.HResult;
                }
            }
            catch {}
        }
Exemplo n.º 4
0
        internal static void ThrowWithExtendedInfo(ManagementStatus errorCode)
        {
            ManagementBaseObject errObj = null;
            string msg = null;

            //Try to get extended error info first, and save in errorObject member
            IWbemClassObjectFreeThreaded obj = WbemErrorInfo.GetErrorInfo();

            if (obj != null)
            {
                errObj = new ManagementBaseObject(obj);
            }

            //If the error code is not a WMI one and there's an extended error object available, stick the message
            //from the extended error object in.
            if (((msg = GetMessage(errorCode)) == null) && (errObj != null))
            {
                try
                {
                    msg = (string)errObj["Description"];
                }
                catch {}
            }

            throw new ManagementException(errorCode, msg, errObj);
        }
Exemplo n.º 5
0
		public ManagementException(string message, Exception innerException) : this(innerException, message, null)
		{
			if (innerException as ManagementException == null)
			{
				this.errorCode = ManagementStatus.Failed;
			}
		}
Exemplo n.º 6
0
		internal ManagementException(Exception e, string msg, ManagementBaseObject errObj) : base(msg, e)
		{
			try
			{
				if (e as ManagementException == null)
				{
					if (e as COMException == null)
					{
						this.errorCode = (ManagementStatus)base.HResult;
					}
					else
					{
						this.errorCode = (ManagementStatus)((COMException)e).ErrorCode;
					}
				}
				else
				{
					this.errorCode = ((ManagementException)e).ErrorCode;
					if (this.errorObject == null)
					{
						this.errorObject = null;
					}
					else
					{
						this.errorObject = (ManagementBaseObject)((ManagementException)e).errorObject.Clone();
					}
				}
			}
			catch
			{
			}
		}
Exemplo n.º 7
0
		/// <summary>IoC constructor.</summary>>
		public CloudProvisioning(ICloudConfigurationSettings settings, ILog log)
		{
			_log = log;
			_retryPolicy = AzureManagementPolicies.TransientServerErrorBackOff;

			// try get settings and certificate
			_deploymentId = CloudEnvironment.AzureDeploymentId;
			_subscriptionId = settings.SelfManagementSubscriptionId ?? Maybe.String;
			var certificateThumbprint = settings.SelfManagementCertificateThumbprint ?? Maybe.String;
			if (certificateThumbprint.HasValue)
			{
				_certificate = CloudEnvironment.GetCertificate(certificateThumbprint.Value);
			}

			// early evaluate management status for intrinsic fault states, to skip further processing
			if (!_deploymentId.HasValue || !_subscriptionId.HasValue || !certificateThumbprint.HasValue)
			{
				_status = ManagementStatus.ConfigurationMissing;
				return;
			}
			if (!_certificate.HasValue)
			{
				_status = ManagementStatus.CertificateMissing;
				return;
			}

			// ok, now try find service matching the deployment
			_enabled = true;
			TryFindDeployment();
		}
Exemplo n.º 8
0
 public virtual void Remove()
 {
     try
     {
         wmisession.RemoveValue(name);
         writefail = false;
         status    = ManagementStatus.NoError;
     }
     catch (ManagementException me)
     {
         status = me.ErrorCode;
         if (me.ErrorCode == ManagementStatus.AccessDenied)
         {
             if (!writefail)
             {
                 wmisession.Log("Remove failed: " + name + " Access Denied");
                 writefail = true;
             }
         }
         else
         {
             wmisession.Log("Remove failed: " + name + " " + me.ErrorCode.ToString());
             throw;
         }
     }
     catch {
         status = ManagementStatus.Failed;
         wmisession.Log("Remove failed: " + name);
         throw;
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// <para>Initializes a empty new instance of the <see cref='System.Management.ManagementException'/> class </para>
 /// <param name='message'>The message that describes the error.</param>
 /// <param name='innerException'>The exception that is the cause of the current exception. If the innerException
 /// parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch
 /// block that handles the inner exception.</param>
 /// </summary>
 public ManagementException(string message, Exception innerException) : this(innerException, message, null)
 {
     // if the exception passed is not a ManagementException, then initialize the ErrorCode to Failed
     if (!(innerException is ManagementException))
     {
         errorCode = ManagementStatus.Failed;
     }
 }
Exemplo n.º 10
0
    public static ManagementObject CreateObject(string _name, ManagementStatus _status, ManagementType _type, string _description)
    {
        // this creates the scriptable object and saves it in the correct path location
        ManagementObject asset = ScriptableObject.CreateInstance <ManagementObject>();

        asset.itemName        = _name;
        asset.itemStatus      = _status;
        asset.itemType        = _type;
        asset.itemDescription = _description;

        // this is the path location
        AssetDatabase.CreateAsset(asset, "Assets/ProjectManagement/" + _name + ".asset");
        AssetDatabase.SaveAssets();


        EditorUtility.FocusProjectWindow();
        Selection.activeObject = asset;

        return(asset);
    }
        private static string GetMessage(ManagementStatus errorCode)
        {
            string messageText       = null;
            IWbemStatusCodeText text = null;

            text = (IWbemStatusCodeText) new WbemStatusCodeText();
            if (text != null)
            {
                try
                {
                    if (text.GetErrorCodeText_((int)errorCode, 0, 1, out messageText) != 0)
                    {
                        int num = text.GetErrorCodeText_((int)errorCode, 0, 0, out messageText);
                    }
                }
                catch
                {
                }
            }
            return(messageText);
        }
Exemplo n.º 12
0
        private static string GetMessage(ManagementStatus errorCode)
        {
            string str = null;
            IWbemStatusCodeText wbemStatusCodeText = (IWbemStatusCodeText)(new WbemStatusCodeText());

            if (wbemStatusCodeText != null)
            {
                try
                {
                    int errorCodeText_ = wbemStatusCodeText.GetErrorCodeText_((int)errorCode, 0, 1, out str);
                    if (errorCodeText_ != 0)
                    {
                        errorCodeText_ = wbemStatusCodeText.GetErrorCodeText_((int)errorCode, 0, 0, out str);
                    }
                }
                catch
                {
                }
            }
            return(str);
        }
        internal static void ThrowWithExtendedInfo(ManagementStatus errorCode)
        {
            ManagementBaseObject errObj = null;
            string msg = null;
            IWbemClassObjectFreeThreaded errorInfo = WbemErrorInfo.GetErrorInfo();

            if (errorInfo != null)
            {
                errObj = new ManagementBaseObject(errorInfo);
            }
            if (((msg = GetMessage(errorCode)) == null) && (errObj != null))
            {
                try
                {
                    msg = (string)errObj["Description"];
                }
                catch
                {
                }
            }
            throw new ManagementException(errorCode, msg, errObj);
        }
Exemplo n.º 14
0
        internal static void ThrowWithExtendedInfo(ManagementStatus errorCode)
        {
            ManagementBaseObject         managementBaseObject = null;
            IWbemClassObjectFreeThreaded errorInfo            = WbemErrorInfo.GetErrorInfo();

            if (errorInfo != null)
            {
                managementBaseObject = new ManagementBaseObject(errorInfo);
            }
            string message = ManagementException.GetMessage(errorCode);
            string item    = message;

            if (message == null && managementBaseObject != null)
            {
                try
                {
                    item = (string)managementBaseObject["Description"];
                }
                catch
                {
                }
            }
            throw new ManagementException(errorCode, item, managementBaseObject);
        }
Exemplo n.º 15
0
        private static string GetMessage(ManagementStatus errorCode)
        {
            string msg = null;
            IWbemStatusCodeText statusCode = null;
            int hr;

            statusCode = (IWbemStatusCodeText) new WbemStatusCodeText();
            if (statusCode != null)
            {
                try {
                    hr = statusCode.GetErrorCodeText_((int)errorCode, 0, 1, out msg);

                    // Just in case it didn't like the flag=1, try it again
                    // with flag=0.
                    if (hr != 0)
                    {
                        hr = statusCode.GetErrorCodeText_((int)errorCode, 0, 0, out msg);
                    }
                }
                catch {}
            }

            return(msg);
        }
Exemplo n.º 16
0
		internal ManagementException(ManagementStatus errorCode, string msg, ManagementBaseObject errObj) : base(msg)
		{
			this.errorCode = errorCode;
			this.errorObject = errObj;
		}
Exemplo n.º 17
0
		internal static void ThrowWithExtendedInfo(ManagementStatus errorCode)
		{
			ManagementBaseObject managementBaseObject = null;
			IWbemClassObjectFreeThreaded errorInfo = WbemErrorInfo.GetErrorInfo();
			if (errorInfo != null)
			{
				managementBaseObject = new ManagementBaseObject(errorInfo);
			}
			string message = ManagementException.GetMessage(errorCode);
			string item = message;
			if (message == null && managementBaseObject != null)
			{
				try
				{
					item = (string)managementBaseObject["Description"];
				}
				catch
				{
				}
			}
			throw new ManagementException(errorCode, item, managementBaseObject);
		}
Exemplo n.º 18
0
		private static string GetMessage(ManagementStatus errorCode)
		{
			string str = null;
			IWbemStatusCodeText wbemStatusCodeText = (IWbemStatusCodeText)(new WbemStatusCodeText());
			if (wbemStatusCodeText != null)
			{
				try
				{
					int errorCodeText_ = wbemStatusCodeText.GetErrorCodeText_((int)errorCode, 0, 1, out str);
					if (errorCodeText_ != 0)
					{
						errorCodeText_ = wbemStatusCodeText.GetErrorCodeText_((int)errorCode, 0, 0, out str);
					}
				}
				catch
				{
				}
			}
			return str;
		}
Exemplo n.º 19
0
 internal BrokerCompletedEventArgs(Boolean success, ManagementBaseObject statusObject, ManagementStatus status)
 {
     this.Success = success;
     this.StatusObject = statusObject;
     this.Status = status;
 }
Exemplo n.º 20
0
		internal StoppedEventArgs (ManagementStatus status)
		{
			this.status = status;
		}
Exemplo n.º 21
0
 internal ManagementException(ManagementStatus errorCode, string msg, ManagementBaseObject errObj) : base(msg)
 {
     this.errorCode   = errorCode;
     this.errorObject = errObj;
 }
Exemplo n.º 22
0
		bool TryFindDeployment()
		{
			if (!_enabled || _status != ManagementStatus.Unknown)
			{
				throw new InvalidOperationException();
			}

			if (_channel == null)
			{
				if (_client == null)
				{
					_client = new ManagementClient(_certificate.Value);
				}

				_channel = _client.CreateChannel();
			}


			var deployments = new List<Pair<Deployment, HostedService>>();
			try
			{
				var hostedServices = _retryPolicy.Get(() => _channel.ListHostedServices(_subscriptionId.Value));
				foreach (var hostedService in hostedServices)
				{
					var service = _retryPolicy.Get(() => _channel.GetHostedServiceWithDetails(_subscriptionId.Value, hostedService.ServiceName, true));
					if (service == null || service.Deployments == null)
					{
						_log.Warn("Azure Self-Management: skipped unexpected null service or deployment list");
						continue;
					}

					foreach (var deployment in service.Deployments)
					{
						deployments.Add(Tuple.From(deployment, service));
					}
				}
			}
			catch (MessageSecurityException)
			{
				_status = ManagementStatus.AuthenticationFailed;
				return false;
			}
			catch (Exception ex)
			{
				_log.Error(ex, "Azure Self-Management: unexpected error when listing all hosted services.");
				return false;
			}

			if (deployments.Count == 0)
			{
				_log.Warn("Azure Self-Management: found no hosted service deployments");
				_status = ManagementStatus.DeploymentNotFound;
				return false;
			}

			var selfServiceAndDeployment = deployments.FirstOrEmpty(pair => pair.Key.PrivateID == _deploymentId.Value);
			if (!selfServiceAndDeployment.HasValue)
			{
				_log.WarnFormat("Azure Self-Management: no hosted service deployment matches {0}", _deploymentId.Value);
				_status = ManagementStatus.DeploymentNotFound;
				return false;
			}

			_status = ManagementStatus.Available;
			_service = selfServiceAndDeployment.Value.Value;
			_deployment = selfServiceAndDeployment.Value.Key;
			return true;
		}
Exemplo n.º 23
0
 public virtual void Remove()
 {
     try
     {
             wmisession.RemoveValue(name);
             writefail = false;
             status = ManagementStatus.NoError;
     }
     catch(ManagementException me)
     {
         status = me.ErrorCode;
         if (me.ErrorCode == ManagementStatus.AccessDenied) {
             if (!writefail)
             {
                 wmisession.Log("Remove failed: " + name + " Access Denied");
                 writefail = true;
             }
         }
         else {
             wmisession.Log("Remove failed: " + name +" "+me.ErrorCode.ToString());
             throw;
         }
     }
     catch {
         status = ManagementStatus.Failed;
         wmisession.Log("Remove failed: " + name);
         throw;
     }
 }
		internal ManagementException(Exception e, string msg, ManagementBaseObject errObj) : base (msg, e)
		{
			try 
			{
				if (e is ManagementException)
				{
					errorCode = ((ManagementException)e).ErrorCode;

					// May/may not have extended error info.
					//
					if (errorObject != null)
						errorObject = (ManagementBaseObject)((ManagementException)e).errorObject.Clone();
					else
						errorObject = null;
				}
				else if (e is COMException)
					errorCode = (ManagementStatus)((COMException)e).ErrorCode;
				else
					errorCode = (ManagementStatus)this.HResult;
			}
			catch {}
		}
		/// <summary>
		/// <para>Initializes a empty new instance of the <see cref='System.Management.ManagementException'/> class </para>
		/// <param name='message'>The message that describes the error.</param>
		/// <param name='innerException'>The exception that is the cause of the current exception. If the innerException 
		/// parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch 
		/// block that handles the inner exception.</param>
		/// </summary>
		public ManagementException(string message,Exception innerException):this(innerException, message, null)
		{	
			// if the exception passed is not a ManagementException, then initialize the ErrorCode to Failed
			if (!(innerException is ManagementException))
				errorCode = ManagementStatus.Failed;
		}
		private static string GetMessage(ManagementStatus errorCode)
		{
			string msg = null;
			IWbemStatusCodeText statusCode = null;
			int hr;

			statusCode = (IWbemStatusCodeText) new WbemStatusCodeText();
			if (statusCode != null)
			{
				try {
					hr = statusCode.GetErrorCodeText_((int)errorCode, 0, 1, out msg);

					// Just in case it didn't like the flag=1, try it again
					// with flag=0.
					if (hr != 0)
						hr = statusCode.GetErrorCodeText_((int)errorCode, 0, 0, out msg);
				}
				catch {}
			}

			return msg;
		}
 private static string GetMessage(ManagementStatus errorCode)
 {
     string messageText = null;
     IWbemStatusCodeText text = null;
     text = (IWbemStatusCodeText) new WbemStatusCodeText();
     if (text != null)
     {
         try
         {
             if (text.GetErrorCodeText_((int) errorCode, 0, 1, out messageText) != 0)
             {
                 int num = text.GetErrorCodeText_((int) errorCode, 0, 0, out messageText);
             }
         }
         catch
         {
         }
     }
     return messageText;
 }
Exemplo n.º 28
0
		protected ManagementException(SerializationInfo info, StreamingContext context) : base(info, context)
		{
			this.errorCode = (ManagementStatus)info.GetValue("errorCode", typeof(ManagementStatus));
			this.errorObject = info.GetValue("errorObject", typeof(ManagementBaseObject)) as ManagementBaseObject;
		}
		internal static void ThrowWithExtendedInfo(ManagementStatus errorCode)
		{
			ManagementBaseObject errObj = null;
			string msg = null;

			//Try to get extended error info first, and save in errorObject member
			IWbemClassObjectFreeThreaded obj = WbemErrorInfo.GetErrorInfo();
			if (obj != null)
				errObj = new ManagementBaseObject(obj);

			//If the error code is not a WMI one and there's an extended error object available, stick the message
			//from the extended error object in.
			if (((msg = GetMessage(errorCode)) == null) && (errObj != null))
				try 
				{
					msg = (string)errObj["Description"];
				} 
				catch {}

			throw new ManagementException(errorCode, msg, errObj);
		}
Exemplo n.º 30
0
 internal BrokerCompletedEventArgs(Boolean success, ManagementBaseObject statusObject, ManagementStatus status)
 {
     this.Success      = success;
     this.StatusObject = statusObject;
     this.Status       = status;
 }
Exemplo n.º 31
0
 /// <summary>
 /// <para>Initializes a new instance of the <see cref='System.Management.ManagementException'/> class that is serializable.</para>
 /// </summary>
 /// <param name='info'>The <see cref='System.Runtime.Serialization.SerializationInfo'/> to populate with data.</param>
 /// <param name='context'>The destination (see <see cref='System.Runtime.Serialization.StreamingContext'/> ) for this serialization.</param>
 protected ManagementException(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     errorCode   = (ManagementStatus)info.GetValue("errorCode", typeof(ManagementStatus));
     errorObject = info.GetValue("errorObject", typeof(ManagementBaseObject)) as ManagementBaseObject;
 }
 internal static void ThrowWithExtendedInfo(ManagementStatus errorCode)
 {
     ManagementBaseObject errObj = null;
     string msg = null;
     IWbemClassObjectFreeThreaded errorInfo = WbemErrorInfo.GetErrorInfo();
     if (errorInfo != null)
     {
         errObj = new ManagementBaseObject(errorInfo);
     }
     if (((msg = GetMessage(errorCode)) == null) && (errObj != null))
     {
         try
         {
             msg = (string) errObj["Description"];
         }
         catch
         {
         }
     }
     throw new ManagementException(errorCode, msg, errObj);
 }
Exemplo n.º 33
0
 internal StoppedEventArgs(ManagementStatus status)
 {
     this.status = status;
 }