2013-06-24 13:41:48 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) Citrix Systems, Inc.
|
|
|
|
* All rights reserved.
|
2017-09-13 18:14:07 +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-13 18:14:07 +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-13 18:14:07 +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-13 18:14:07 +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;
|
2017-09-13 18:14:07 +02:00
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Globalization;
|
2021-04-13 11:05:38 +02:00
|
|
|
using System.Linq;
|
2017-09-13 18:14:07 +02:00
|
|
|
using Newtonsoft.Json;
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
namespace XenAPI
|
|
|
|
{
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// A virtual TPM device
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
2013-06-24 13:41:48 +02:00
|
|
|
public partial class VTPM : XenObject<VTPM>
|
|
|
|
{
|
2019-06-19 10:11:30 +02:00
|
|
|
#region Constructors
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
public VTPM()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public VTPM(string uuid,
|
|
|
|
XenRef<VM> VM,
|
|
|
|
XenRef<VM> backend)
|
|
|
|
{
|
|
|
|
this.uuid = uuid;
|
|
|
|
this.VM = VM;
|
|
|
|
this.backend = backend;
|
|
|
|
}
|
|
|
|
|
2019-06-19 10:11:30 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new VTPM from a Hashtable.
|
|
|
|
/// Note that the fields not contained in the Hashtable
|
|
|
|
/// will be created with their default values.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="table"></param>
|
|
|
|
public VTPM(Hashtable table)
|
|
|
|
: this()
|
|
|
|
{
|
|
|
|
UpdateFrom(table);
|
|
|
|
}
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new VTPM from a Proxy_VTPM.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="proxy"></param>
|
|
|
|
public VTPM(Proxy_VTPM proxy)
|
|
|
|
{
|
2019-06-19 10:11:30 +02:00
|
|
|
UpdateFrom(proxy);
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2019-06-19 10:11:30 +02:00
|
|
|
#endregion
|
|
|
|
|
2018-02-16 17:27:30 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Updates each field of this instance with the value of
|
|
|
|
/// the corresponding field of a given VTPM.
|
|
|
|
/// </summary>
|
2021-04-13 11:05:38 +02:00
|
|
|
public override void UpdateFrom(VTPM record)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2021-04-13 11:05:38 +02:00
|
|
|
uuid = record.uuid;
|
|
|
|
VM = record.VM;
|
|
|
|
backend = record.backend;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2019-06-19 10:11:30 +02:00
|
|
|
internal void UpdateFrom(Proxy_VTPM proxy)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2018-03-22 13:30:43 +01:00
|
|
|
uuid = proxy.uuid == null ? null : proxy.uuid;
|
2013-06-24 13:41:48 +02:00
|
|
|
VM = proxy.VM == null ? null : XenRef<VM>.Create(proxy.VM);
|
|
|
|
backend = proxy.backend == null ? null : XenRef<VM>.Create(proxy.backend);
|
|
|
|
}
|
|
|
|
|
2018-02-16 17:27:30 +01:00
|
|
|
/// <summary>
|
|
|
|
/// Given a Hashtable with field-value pairs, it updates the fields of this VTPM
|
|
|
|
/// with the values listed in the Hashtable. Note that only the fields contained
|
|
|
|
/// in the Hashtable will be updated and the rest will remain the same.
|
2013-06-24 13:41:48 +02:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="table"></param>
|
2018-02-16 17:27:30 +01:00
|
|
|
public void UpdateFrom(Hashtable table)
|
2013-06-24 13:41:48 +02:00
|
|
|
{
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("uuid"))
|
2018-02-23 17:06:32 +01:00
|
|
|
uuid = Marshalling.ParseString(table, "uuid");
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("VM"))
|
2018-02-23 17:06:32 +01:00
|
|
|
VM = Marshalling.ParseRef<VM>(table, "VM");
|
2018-02-16 17:27:30 +01:00
|
|
|
if (table.ContainsKey("backend"))
|
2018-02-23 17:06:32 +01:00
|
|
|
backend = Marshalling.ParseRef<VM>(table, "backend");
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2021-04-13 11:05:38 +02:00
|
|
|
public Proxy_VTPM ToProxy()
|
|
|
|
{
|
|
|
|
Proxy_VTPM result_ = new Proxy_VTPM();
|
|
|
|
result_.uuid = uuid ?? "";
|
|
|
|
result_.VM = VM ?? "";
|
|
|
|
result_.backend = backend ?? "";
|
|
|
|
return result_;
|
|
|
|
}
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
public bool DeepEquals(VTPM other)
|
|
|
|
{
|
|
|
|
if (ReferenceEquals(null, other))
|
|
|
|
return false;
|
|
|
|
if (ReferenceEquals(this, other))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return Helper.AreEqual2(this._uuid, other._uuid) &&
|
|
|
|
Helper.AreEqual2(this._VM, other._VM) &&
|
|
|
|
Helper.AreEqual2(this._backend, other._backend);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override string SaveChanges(Session session, string opaqueRef, VTPM server)
|
|
|
|
{
|
|
|
|
if (opaqueRef == null)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
var reference = create(session, this);
|
|
|
|
return reference == null ? null : reference.opaque_ref;
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException("This type has no read/write properties");
|
|
|
|
}
|
|
|
|
}
|
2021-04-13 11:05:38 +02:00
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get a record containing the current state of the given VTPM.
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_vtpm">The opaque_ref of the given vtpm</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static VTPM get_record(Session session, string _vtpm)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.vtpm_get_record(session.opaque_ref, _vtpm);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return new VTPM(session.XmlRpcProxy.vtpm_get_record(session.opaque_ref, _vtpm ?? "").parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get a reference to the VTPM instance with the specified UUID.
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_uuid">UUID of object to return</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static XenRef<VTPM> get_by_uuid(Session session, string _uuid)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.vtpm_get_by_uuid(session.opaque_ref, _uuid);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<VTPM>.Create(session.XmlRpcProxy.vtpm_get_by_uuid(session.opaque_ref, _uuid ?? "").parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Create a new VTPM instance, and return its handle.
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_record">All constructor arguments</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static XenRef<VTPM> create(Session session, VTPM _record)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.vtpm_create(session.opaque_ref, _record);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<VTPM>.Create(session.XmlRpcProxy.vtpm_create(session.opaque_ref, _record.ToProxy()).parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Create a new VTPM instance, and return its handle.
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_record">All constructor arguments</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static XenRef<Task> async_create(Session session, VTPM _record)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.async_vtpm_create(session.opaque_ref, _record);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<Task>.Create(session.XmlRpcProxy.async_vtpm_create(session.opaque_ref, _record.ToProxy()).parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Destroy the specified VTPM instance.
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_vtpm">The opaque_ref of the given vtpm</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static void destroy(Session session, string _vtpm)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
session.JsonRpcClient.vtpm_destroy(session.opaque_ref, _vtpm);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
session.XmlRpcProxy.vtpm_destroy(session.opaque_ref, _vtpm ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Destroy the specified VTPM instance.
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_vtpm">The opaque_ref of the given vtpm</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static XenRef<Task> async_destroy(Session session, string _vtpm)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.async_vtpm_destroy(session.opaque_ref, _vtpm);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<Task>.Create(session.XmlRpcProxy.async_vtpm_destroy(session.opaque_ref, _vtpm ?? "").parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the uuid field of the given VTPM.
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_vtpm">The opaque_ref of the given vtpm</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static string get_uuid(Session session, string _vtpm)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.vtpm_get_uuid(session.opaque_ref, _vtpm);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return session.XmlRpcProxy.vtpm_get_uuid(session.opaque_ref, _vtpm ?? "").parse();
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the VM field of the given VTPM.
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_vtpm">The opaque_ref of the given vtpm</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static XenRef<VM> get_VM(Session session, string _vtpm)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.vtpm_get_vm(session.opaque_ref, _vtpm);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<VM>.Create(session.XmlRpcProxy.vtpm_get_vm(session.opaque_ref, _vtpm ?? "").parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Get the backend field of the given VTPM.
|
|
|
|
/// First published in XenServer 4.0.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="session">The session</param>
|
|
|
|
/// <param name="_vtpm">The opaque_ref of the given vtpm</param>
|
2013-06-24 13:41:48 +02:00
|
|
|
public static XenRef<VM> get_backend(Session session, string _vtpm)
|
|
|
|
{
|
2017-09-13 18:14:07 +02:00
|
|
|
if (session.JsonRpcClient != null)
|
2018-02-23 17:06:32 +01:00
|
|
|
return session.JsonRpcClient.vtpm_get_backend(session.opaque_ref, _vtpm);
|
2017-09-13 18:14:07 +02:00
|
|
|
else
|
2020-01-30 01:02:24 +01:00
|
|
|
return XenRef<VM>.Create(session.XmlRpcProxy.vtpm_get_backend(session.opaque_ref, _vtpm ?? "").parse());
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Unique identifier/object reference
|
|
|
|
/// </summary>
|
|
|
|
public virtual string uuid
|
|
|
|
{
|
|
|
|
get { return _uuid; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _uuid))
|
|
|
|
{
|
|
|
|
_uuid = value;
|
|
|
|
NotifyPropertyChanged("uuid");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 18:14:07 +02:00
|
|
|
private string _uuid = "";
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// the virtual machine
|
|
|
|
/// </summary>
|
2017-09-13 18:14:07 +02:00
|
|
|
[JsonConverter(typeof(XenRefConverter<VM>))]
|
2014-05-16 17:58:13 +02:00
|
|
|
public virtual XenRef<VM> VM
|
|
|
|
{
|
|
|
|
get { return _VM; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _VM))
|
|
|
|
{
|
|
|
|
_VM = value;
|
|
|
|
NotifyPropertyChanged("VM");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 18:14:07 +02:00
|
|
|
private XenRef<VM> _VM = new XenRef<VM>(Helper.NullOpaqueRef);
|
2013-06-24 13:41:48 +02:00
|
|
|
|
2014-05-16 17:58:13 +02:00
|
|
|
/// <summary>
|
|
|
|
/// the domain where the backend is located
|
|
|
|
/// </summary>
|
2017-09-13 18:14:07 +02:00
|
|
|
[JsonConverter(typeof(XenRefConverter<VM>))]
|
2014-05-16 17:58:13 +02:00
|
|
|
public virtual XenRef<VM> backend
|
|
|
|
{
|
|
|
|
get { return _backend; }
|
|
|
|
set
|
|
|
|
{
|
|
|
|
if (!Helper.AreEqual(value, _backend))
|
|
|
|
{
|
|
|
|
_backend = value;
|
|
|
|
NotifyPropertyChanged("backend");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-13 18:14:07 +02:00
|
|
|
private XenRef<VM> _backend = new XenRef<VM>(Helper.NullOpaqueRef);
|
2013-06-24 13:41:48 +02:00
|
|
|
}
|
|
|
|
}
|