2013-06-24 13:41:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) Citrix Systems, Inc.
|
|
|
|
* All rights reserved.
|
2017-09-05 11:43:20 +02:00
|
|
|
*
|
2013-06-24 13:41:48 +02:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
2017-09-05 11:43:20 +02:00
|
|
|
*
|
2013-06-24 13:41:48 +02:00
|
|
|
* 1) Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
2017-09-05 11:43:20 +02:00
|
|
|
*
|
2013-06-24 13:41:48 +02:00
|
|
|
* 2) Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials
|
|
|
|
* provided with the distribution.
|
2017-09-05 11:43:20 +02:00
|
|
|
*
|
2013-06-24 13:41:48 +02:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2013-07-03 12:22:08 +02:00
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace XenAPI
|
|
|
|
{
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Data sources for logging in RRDs
|
|
|
|
/// First published in XenServer 5.0.
|
|
|
|
/// </summary>
|
2013-06-24 13:41:48 +02:00
|
|
|
public partial class Data_source : XenObject<Data_source>
|
|
|
|
{
|
|
|
|
public Data_source()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public Data_source(string name_label,
|
|
|
|
string name_description,
|
|
|
|
bool enabled,
|
|
|
|
bool standard,
|
|
|
|
string units,
|
|
|
|
double min,
|
|
|
|
double max,
|
|
|
|
double value)
|
|
|
|
{
|
|
|
|
this.name_label = name_label;
|
|
|
|
this.name_description = name_description;
|
|
|
|
this.enabled = enabled;
|
|
|
|
this.standard = standard;
|
|
|
|
this.units = units;
|
|
|
|
this.min = min;
|
|
|
|
this.max = max;
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a new Data_source from a Proxy_Data_source.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="proxy"></param>
|
|
|
|
public Data_source(Proxy_Data_source proxy)
|
|
|
|
{
|
|
|
|
this.UpdateFromProxy(proxy);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void UpdateFrom(Data_source update)
|
|
|
|
{
|
|
|
|
name_label = update.name_label;
|
|
|
|
name_description = update.name_description;
|
|
|
|
enabled = update.enabled;
|
|
|
|
standard = update.standard;
|
|
|
|
units = update.units;
|
|
|
|
min = update.min;
|
|
|
|
max = update.max;
|
|
|
|
value = update.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal void UpdateFromProxy(Proxy_Data_source proxy)
|
|
|
|
{
|
|
|
|
name_label = proxy.name_label == null ? null : (string)proxy.name_label;
|
|
|
|
name_description = proxy.name_description == null ? null : (string)proxy.name_description;
|
|
|
|
enabled = (bool)proxy.enabled;
|
|
|
|
standard = (bool)proxy.standard;
|
|
|
|
units = proxy.units == null ? null : (string)proxy.units;
|
|
|
|
min = Convert.ToDouble(proxy.min);
|
|
|
|
max = Convert.ToDouble(proxy.max);
|
|
|
|
value = Convert.ToDouble(proxy.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Proxy_Data_source ToProxy()
|
|
|
|
{
|
|
|
|
Proxy_Data_source result_ = new Proxy_Data_source();
|
2017-09-05 11:43:20 +02:00
|
|
|
result_.name_label = name_label ?? "";
|
|
|
|
result_.name_description = name_description ?? "";
|
2013-06-24 13:41:48 +02:00
|
|
|
result_.enabled = enabled;
|
|
|
|
result_.standard = standard;
|
2017-09-05 11:43:20 +02:00
|
|
|
result_.units = units ?? "";
|
2013-06-24 13:41:48 +02:00
|
|
|
result_.min = min;
|
|
|
|
result_.max = max;
|
|
|
|
result_.value = value;
|
|
|
|
return result_;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a new Data_source from a Hashtable.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="table"></param>
|
|
|
|
public Data_source(Hashtable table)
|
|
|
|
{
|
|
|
|
name_label = Marshalling.ParseString(table, "name_label");
|
|
|
|
name_description = Marshalling.ParseString(table, "name_description");
|
|
|
|
enabled = Marshalling.ParseBool(table, "enabled");
|
|
|
|
standard = Marshalling.ParseBool(table, "standard");
|
|
|
|
units = Marshalling.ParseString(table, "units");
|
|
|
|
min = Marshalling.ParseDouble(table, "min");
|
|
|
|
max = Marshalling.ParseDouble(table, "max");
|
|
|
|
value = Marshalling.ParseDouble(table, "value");
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool DeepEquals(Data_source other)
|
|
|
|
{
|
|
|
|
if (ReferenceEquals(null, other))
|
|
|
|
return false;
|
|
|
|
if (ReferenceEquals(this, other))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return Helper.AreEqual2(this._name_label, other._name_label) &&
|
|
|
|
Helper.AreEqual2(this._name_description, other._name_description) &&
|
|
|
|
Helper.AreEqual2(this._enabled, other._enabled) &&
|
|
|
|
Helper.AreEqual2(this._standard, other._standard) &&
|
|
|
|
Helper.AreEqual2(this._units, other._units) &&
|
|
|
|
Helper.AreEqual2(this._min, other._min) &&
|
|
|
|
Helper.AreEqual2(this._max, other._max) &&
|
|
|
|
Helper.AreEqual2(this._value, other._value);
|
|
|
|
}
|
|
|
|
|
2017-11-16 16:18:10 +01:00
|
|
|
internal static List<Data_source> ProxyArrayToObjectList(Proxy_Data_source[] input)
|
|
|
|
{
|
|
|
|
var result = new List<Data_source>();
|
|
|
|
foreach (var item in input)
|
|
|
|
result.Add(new Data_source(item));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
public override string SaveChanges(Session session, string opaqueRef, Data_source server)
|
|
|
|
{
|
|
|
|
if (opaqueRef == null)
|
|
|
|
{
|
|
|
|
System.Diagnostics.Debug.Assert(false, "Cannot create instances of this type on the server");
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("This type has no read/write properties");
|
|
|
|
}
|
|
|
|
}
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// a human-readable name
|
|
|
|
/// </summary>
|
|
|
|
public virtual string name_label
|
|
|
|
{
|
|
|
|
get { return _name_label; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _name_label))
|
|
|
|
{
|
|
|
|
_name_label = value;
|
|
|
|
Changed = true;
|
|
|
|
NotifyPropertyChanged("name_label");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private string _name_label;
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// a notes field containing human-readable description
|
|
|
|
/// </summary>
|
|
|
|
public virtual string name_description
|
|
|
|
{
|
|
|
|
get { return _name_description; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _name_description))
|
|
|
|
{
|
|
|
|
_name_description = value;
|
|
|
|
Changed = true;
|
|
|
|
NotifyPropertyChanged("name_description");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private string _name_description;
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// true if the data source is being logged
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool enabled
|
|
|
|
{
|
|
|
|
get { return _enabled; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _enabled))
|
|
|
|
{
|
|
|
|
_enabled = value;
|
|
|
|
Changed = true;
|
|
|
|
NotifyPropertyChanged("enabled");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private bool _enabled;
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// true if the data source is enabled by default. Non-default data sources cannot be disabled
|
|
|
|
/// </summary>
|
|
|
|
public virtual bool standard
|
|
|
|
{
|
|
|
|
get { return _standard; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _standard))
|
|
|
|
{
|
|
|
|
_standard = value;
|
|
|
|
Changed = true;
|
|
|
|
NotifyPropertyChanged("standard");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private bool _standard;
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// the units of the value
|
|
|
|
/// </summary>
|
|
|
|
public virtual string units
|
|
|
|
{
|
|
|
|
get { return _units; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _units))
|
|
|
|
{
|
|
|
|
_units = value;
|
|
|
|
Changed = true;
|
|
|
|
NotifyPropertyChanged("units");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private string _units;
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// the minimum value of the data source
|
|
|
|
/// </summary>
|
|
|
|
public virtual double min
|
|
|
|
{
|
|
|
|
get { return _min; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _min))
|
|
|
|
{
|
|
|
|
_min = value;
|
|
|
|
Changed = true;
|
|
|
|
NotifyPropertyChanged("min");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private double _min;
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// the maximum value of the data source
|
|
|
|
/// </summary>
|
|
|
|
public virtual double max
|
|
|
|
{
|
|
|
|
get { return _max; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _max))
|
|
|
|
{
|
|
|
|
_max = value;
|
|
|
|
Changed = true;
|
|
|
|
NotifyPropertyChanged("max");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private double _max;
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// current value of the data source
|
|
|
|
/// </summary>
|
|
|
|
public virtual double value
|
|
|
|
{
|
|
|
|
get { return _value; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _value))
|
|
|
|
{
|
|
|
|
_value = value;
|
|
|
|
Changed = true;
|
|
|
|
NotifyPropertyChanged("value");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-24 13:41:48 +02:00
|
|
|
private double _value;
|
|
|
|
}
|
|
|
|
}
|