2023-01-24 15:29:31 +01:00
/ * Copyright ( c ) Cloud Software Group , Inc .
2018-03-22 13:30:43 +01:00
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
*
* 1 ) Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
*
* 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 .
*
* 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 .
* /
using System ;
using System.Collections ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Globalization ;
2021-04-13 11:05:38 +02:00
using System.Linq ;
2018-03-22 13:30:43 +01:00
using Newtonsoft.Json ;
namespace XenAPI
{
/// <summary>
/// A set of properties that describe one result element of SR.probe. Result elements and properties can change dynamically based on changes to the the SR.probe input-parameters or the target.
2022-06-17 15:02:24 +02:00
/// First published in XenServer 7.6.
2018-03-22 13:30:43 +01:00
/// </summary>
public partial class Probe_result : XenObject < Probe_result >
{
2019-06-19 10:11:30 +02:00
#region Constructors
2018-03-22 13:30:43 +01:00
public Probe_result ( )
{
}
public Probe_result ( Dictionary < string , string > configuration ,
bool complete ,
Sr_stat sr ,
Dictionary < string , string > extra_info )
{
this . configuration = configuration ;
this . complete = complete ;
this . sr = sr ;
this . extra_info = extra_info ;
}
2019-06-19 10:11:30 +02:00
/// <summary>
/// Creates a new Probe_result 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 Probe_result ( Hashtable table )
: this ( )
{
UpdateFrom ( table ) ;
}
2018-03-22 13:30:43 +01:00
/// <summary>
/// Creates a new Probe_result from a Proxy_Probe_result.
/// </summary>
/// <param name="proxy"></param>
public Probe_result ( Proxy_Probe_result proxy )
{
2019-06-19 10:11:30 +02:00
UpdateFrom ( proxy ) ;
2018-03-22 13:30:43 +01:00
}
2019-06-19 10:11:30 +02:00
#endregion
2018-03-22 13:30:43 +01:00
/// <summary>
/// Updates each field of this instance with the value of
/// the corresponding field of a given Probe_result.
/// </summary>
2021-04-13 11:05:38 +02:00
public override void UpdateFrom ( Probe_result record )
2018-03-22 13:30:43 +01:00
{
2021-04-13 11:05:38 +02:00
configuration = record . configuration ;
complete = record . complete ;
sr = record . sr ;
extra_info = record . extra_info ;
2018-03-22 13:30:43 +01:00
}
2019-06-19 10:11:30 +02:00
internal void UpdateFrom ( Proxy_Probe_result proxy )
2018-03-22 13:30:43 +01:00
{
configuration = proxy . configuration = = null ? null : Maps . convert_from_proxy_string_string ( proxy . configuration ) ;
complete = ( bool ) proxy . complete ;
2018-04-10 15:04:11 +02:00
sr = proxy . sr = = null ? null : new Sr_stat ( proxy . sr ) ;
2018-03-22 13:30:43 +01:00
extra_info = proxy . extra_info = = null ? null : Maps . convert_from_proxy_string_string ( proxy . extra_info ) ;
}
/// <summary>
/// Given a Hashtable with field-value pairs, it updates the fields of this Probe_result
/// 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.
/// </summary>
/// <param name="table"></param>
public void UpdateFrom ( Hashtable table )
{
if ( table . ContainsKey ( "configuration" ) )
configuration = Maps . convert_from_proxy_string_string ( Marshalling . ParseHashTable ( table , "configuration" ) ) ;
if ( table . ContainsKey ( "complete" ) )
complete = Marshalling . ParseBool ( table , "complete" ) ;
if ( table . ContainsKey ( "sr" ) )
sr = ( Sr_stat ) Marshalling . convertStruct ( typeof ( Sr_stat ) , Marshalling . ParseHashTable ( table , "sr" ) ) ; ;
if ( table . ContainsKey ( "extra_info" ) )
extra_info = Maps . convert_from_proxy_string_string ( Marshalling . ParseHashTable ( table , "extra_info" ) ) ;
}
2021-04-13 11:05:38 +02:00
public Proxy_Probe_result ToProxy ( )
{
Proxy_Probe_result result_ = new Proxy_Probe_result ( ) ;
result_ . configuration = Maps . convert_to_proxy_string_string ( configuration ) ;
result_ . complete = complete ;
result_ . sr = sr = = null ? null : sr . ToProxy ( ) ;
result_ . extra_info = Maps . convert_to_proxy_string_string ( extra_info ) ;
return result_ ;
}
2018-03-22 13:30:43 +01:00
public bool DeepEquals ( Probe_result other )
{
if ( ReferenceEquals ( null , other ) )
return false ;
if ( ReferenceEquals ( this , other ) )
return true ;
return Helper . AreEqual2 ( this . _configuration , other . _configuration ) & &
Helper . AreEqual2 ( this . _complete , other . _complete ) & &
Helper . AreEqual2 ( this . _sr , other . _sr ) & &
Helper . AreEqual2 ( this . _extra_info , other . _extra_info ) ;
}
public override string SaveChanges ( Session session , string opaqueRef , Probe_result 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" ) ;
}
}
2021-04-13 11:05:38 +02:00
2018-03-22 13:30:43 +01:00
/// <summary>
/// Plugin-specific configuration which describes where and how to locate the storage repository. This may include the physical block device name, a remote NFS server and path or an RBD storage pool.
/// </summary>
[JsonConverter(typeof(StringStringMapConverter))]
public virtual Dictionary < string , string > configuration
{
get { return _configuration ; }
set
{
if ( ! Helper . AreEqual ( value , _configuration ) )
{
_configuration = value ;
NotifyPropertyChanged ( "configuration" ) ;
}
}
}
private Dictionary < string , string > _configuration = new Dictionary < string , string > ( ) { } ;
/// <summary>
/// True if this configuration is complete and can be used to call SR.create. False if it requires further iterative calls to SR.probe, to potentially narrow down on a configuration that can be used.
/// </summary>
public virtual bool complete
{
get { return _complete ; }
set
{
if ( ! Helper . AreEqual ( value , _complete ) )
{
_complete = value ;
NotifyPropertyChanged ( "complete" ) ;
}
}
}
private bool _complete ;
/// <summary>
/// Existing SR found for this configuration
/// </summary>
public virtual Sr_stat sr
{
get { return _sr ; }
set
{
if ( ! Helper . AreEqual ( value , _sr ) )
{
_sr = value ;
NotifyPropertyChanged ( "sr" ) ;
}
}
}
private Sr_stat _sr ;
/// <summary>
/// Additional plugin-specific information about this configuration, that might be of use for an API user. This can for example include the LUN or the WWPN.
/// </summary>
[JsonConverter(typeof(StringStringMapConverter))]
public virtual Dictionary < string , string > extra_info
{
get { return _extra_info ; }
set
{
if ( ! Helper . AreEqual ( value , _extra_info ) )
{
_extra_info = value ;
NotifyPropertyChanged ( "extra_info" ) ;
}
}
}
private Dictionary < string , string > _extra_info = new Dictionary < string , string > ( ) { } ;
}
}