mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-594: Updating the XenServer java bindings used in cloudstack - part2
Updating the xenserver java bindings used in cloudstack. This is part 2 of the change and it introduces the latest java bindings published with XenServer 6.1. 1. https://reviews.apache.org/r/8566/ - removes the old bindings. 2. https://reviews.apache.org/r/8567/ - introduces the latest bindings. 3. https://reviews.apache.org/r/8568/ - adds the customization's made to them for cloudstack. Signed-off-by: Chip Childers <chip.childers@gmail.com>
This commit is contained in:
parent
1e74501739
commit
2ce2645cd1
118
deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java
vendored
Normal file
118
deps/XenServerJava/src/com/xensource/xenapi/APIVersion.java
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
/* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
public enum APIVersion
|
||||
{
|
||||
API_1_1, API_1_2, API_1_3, API_1_4, API_1_5, API_1_6, API_1_7, API_1_8, API_1_9, API_1_10, UNKNOWN;
|
||||
|
||||
public static APIVersion latest()
|
||||
{
|
||||
return API_1_10;
|
||||
}
|
||||
|
||||
public static APIVersion fromMajorMinor(long major, long minor)
|
||||
{
|
||||
if (major == 1 && minor == 10)
|
||||
{
|
||||
return API_1_10;
|
||||
}
|
||||
else if (major == 1 && minor == 9)
|
||||
{
|
||||
return API_1_9;
|
||||
}
|
||||
else if (major == 1 && minor == 8)
|
||||
{
|
||||
return API_1_8;
|
||||
}
|
||||
else if (major == 1 && minor == 7)
|
||||
{
|
||||
return API_1_7;
|
||||
}
|
||||
else if (major == 1 && minor == 6)
|
||||
{
|
||||
return API_1_6;
|
||||
}
|
||||
else if (major == 1 && minor == 5)
|
||||
{
|
||||
return API_1_5;
|
||||
}
|
||||
else if (major == 1 && minor == 4)
|
||||
{
|
||||
return API_1_4;
|
||||
}
|
||||
else if (major == 1 && minor == 3)
|
||||
{
|
||||
return API_1_3;
|
||||
}
|
||||
else if (major == 1 && minor == 2)
|
||||
{
|
||||
return API_1_2;
|
||||
}
|
||||
else if (major == 1 && minor == 1)
|
||||
{
|
||||
return API_1_1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
switch (this)
|
||||
{
|
||||
case API_1_1:
|
||||
return "1.1";
|
||||
case API_1_2:
|
||||
return "1.2";
|
||||
case API_1_3:
|
||||
return "1.3";
|
||||
case API_1_4:
|
||||
return "1.4";
|
||||
case API_1_5:
|
||||
return "1.5";
|
||||
case API_1_6:
|
||||
return "1.6";
|
||||
case API_1_7:
|
||||
return "1.7";
|
||||
case API_1_8:
|
||||
return "1.8";
|
||||
case API_1_9:
|
||||
return "1.9";
|
||||
case API_1_10:
|
||||
return "1.10";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
114
deps/XenServerJava/src/com/xensource/xenapi/Auth.java
vendored
Normal file
114
deps/XenServerJava/src/com/xensource/xenapi/Auth.java
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* Management of remote authentication services
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Auth extends XenAPIObject {
|
||||
|
||||
|
||||
public String toWireString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This call queries the external directory service to obtain the subject_identifier as a string from the human-readable subject_name
|
||||
*
|
||||
* @param subjectName The human-readable subject_name, such as a username or a groupname
|
||||
* @return the subject_identifier obtained from the external directory service
|
||||
*/
|
||||
public static String getSubjectIdentifier(Connection c, String subjectName) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "auth.get_subject_identifier";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectName)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This call queries the external directory service to obtain the user information (e.g. username, organization etc) from the specified subject_identifier
|
||||
*
|
||||
* @param subjectIdentifier A string containing the subject_identifier, unique in the external directory service
|
||||
* @return key-value pairs containing at least a key called subject_name
|
||||
*/
|
||||
public static Map<String, String> getSubjectInformationFromIdentifier(Connection c, String subjectIdentifier) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "auth.get_subject_information_from_identifier";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This calls queries the external directory service to obtain the transitively-closed set of groups that the the subject_identifier is member of.
|
||||
*
|
||||
* @param subjectIdentifier A string containing the subject_identifier, unique in the external directory service
|
||||
* @return set of subject_identifiers that provides the group membership of subject_identifier passed as argument, it contains, recursively, all groups a subject_identifier is member of.
|
||||
*/
|
||||
public static Set<String> getGroupMembership(Connection c, String subjectIdentifier) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "auth.get_group_membership";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
}
|
||||
446
deps/XenServerJava/src/com/xensource/xenapi/Blob.java
vendored
Normal file
446
deps/XenServerJava/src/com/xensource/xenapi/Blob.java
vendored
Normal file
@ -0,0 +1,446 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A placeholder for a binary blob
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Blob extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Blob(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Blob, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Blob)
|
||||
{
|
||||
Blob other = (Blob) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Blob
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "size", this.size);
|
||||
print.printf("%1$20s: %2$s\n", "_public", this._public);
|
||||
print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated);
|
||||
print.printf("%1$20s: %2$s\n", "mimeType", this.mimeType);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a blob.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("size", this.size == null ? 0 : this.size);
|
||||
map.put("public", this._public == null ? false : this._public);
|
||||
map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated);
|
||||
map.put("mime_type", this.mimeType == null ? "" : this.mimeType);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* a human-readable name
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* a notes field containing human-readable description
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* Size of the binary data, in bytes
|
||||
*/
|
||||
public Long size;
|
||||
/**
|
||||
* True if the blob is publicly accessible
|
||||
*/
|
||||
public Boolean _public;
|
||||
/**
|
||||
* Time at which the data in the blob was last updated
|
||||
*/
|
||||
public Date lastUpdated;
|
||||
/**
|
||||
* The mime type associated with this object. Defaults to 'application/octet-stream' if the empty string is supplied
|
||||
*/
|
||||
public String mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given blob.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Blob.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBlobRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the blob instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Blob getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBlob(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the blob instances with the given label.
|
||||
*
|
||||
* @param label label of object to return
|
||||
* @return references to objects with matching names
|
||||
*/
|
||||
public static Set<Blob> getByNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_by_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfBlob(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given blob.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/label field of the given blob.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/description field of the given blob.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameDescription(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size field of the given blob.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getSize(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_size";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the public field of the given blob.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getPublic(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_public";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last_updated field of the given blob.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getLastUpdated(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_last_updated";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mime_type field of the given blob.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getMimeType(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_mime_type";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name/label field of the given blob.
|
||||
*
|
||||
* @param label New value to set
|
||||
*/
|
||||
public void setNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.set_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name/description field of the given blob.
|
||||
*
|
||||
* @param description New value to set
|
||||
*/
|
||||
public void setNameDescription(Connection c, String description) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.set_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the public field of the given blob.
|
||||
*
|
||||
* @param _public New value to set
|
||||
*/
|
||||
public void setPublic(Connection c, Boolean _public) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.set_public";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(_public)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a placeholder for a binary blob
|
||||
*
|
||||
* @param mimeType The mime-type of the blob. Defaults to 'application/octet-stream' if the empty string is supplied
|
||||
* @param _public True if the blob should be publicly available
|
||||
* @return The reference to the created blob
|
||||
*/
|
||||
public static Blob create(Connection c, String mimeType, Boolean _public) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBlob(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the blobs known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Blob> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfBlob(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of blob references to blob records for all blobs known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Blob, Blob.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "blob.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfBlobBlobRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
564
deps/XenServerJava/src/com/xensource/xenapi/Bond.java
vendored
Normal file
564
deps/XenServerJava/src/com/xensource/xenapi/Bond.java
vendored
Normal file
@ -0,0 +1,564 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Bond extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Bond(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Bond, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Bond)
|
||||
{
|
||||
Bond other = (Bond) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Bond
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "master", this.master);
|
||||
print.printf("%1$20s: %2$s\n", "slaves", this.slaves);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
print.printf("%1$20s: %2$s\n", "primarySlave", this.primarySlave);
|
||||
print.printf("%1$20s: %2$s\n", "mode", this.mode);
|
||||
print.printf("%1$20s: %2$s\n", "properties", this.properties);
|
||||
print.printf("%1$20s: %2$s\n", "linksUp", this.linksUp);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Bond.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("master", this.master == null ? new PIF("OpaqueRef:NULL") : this.master);
|
||||
map.put("slaves", this.slaves == null ? new LinkedHashSet<PIF>() : this.slaves);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
map.put("primary_slave", this.primarySlave == null ? new PIF("OpaqueRef:NULL") : this.primarySlave);
|
||||
map.put("mode", this.mode == null ? Types.BondMode.UNRECOGNIZED : this.mode);
|
||||
map.put("properties", this.properties == null ? new HashMap<String, String>() : this.properties);
|
||||
map.put("links_up", this.linksUp == null ? 0 : this.linksUp);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* The bonded interface
|
||||
*/
|
||||
public PIF master;
|
||||
/**
|
||||
* The interfaces which are part of this bond
|
||||
*/
|
||||
public Set<PIF> slaves;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
/**
|
||||
* The PIF of which the IP configuration and MAC were copied to the bond, and which will receive all configuration/VLANs/VIFs on the bond if the bond is destroyed
|
||||
*/
|
||||
public PIF primarySlave;
|
||||
/**
|
||||
* The algorithm used to distribute traffic among the bonded NICs
|
||||
*/
|
||||
public Types.BondMode mode;
|
||||
/**
|
||||
* Additional configuration properties specific to the bond mode.
|
||||
*/
|
||||
public Map<String, String> properties;
|
||||
/**
|
||||
* Number of links up in this bond
|
||||
*/
|
||||
public Long linksUp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given Bond.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Bond.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBondRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the Bond instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Bond getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBond(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given Bond.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the master field of the given Bond.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public PIF getMaster(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_master";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPIF(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the slaves field of the given Bond.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<PIF> getSlaves(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_slaves";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPIF(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given Bond.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the primary_slave field of the given Bond.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public PIF getPrimarySlave(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_primary_slave";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPIF(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mode field of the given Bond.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Types.BondMode getMode(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_mode";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBondMode(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the properties field of the given Bond.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getProperties(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_properties";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the links_up field of the given Bond.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getLinksUp(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_links_up";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given Bond.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given Bond.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given Bond. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an interface bond
|
||||
*
|
||||
* @param network Network to add the bonded PIF to
|
||||
* @param members PIFs to add to this bond
|
||||
* @param MAC The MAC address to use on the bond itself. If this parameter is the empty string then the bond will inherit its MAC address from the primary slave.
|
||||
* @param mode Bonding mode to use for the new bond
|
||||
* @param properties Additional configuration parameters specific to the bond mode
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, Network network, Set<PIF> members, String MAC, Types.BondMode mode, Map<String, String> properties) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.Bond.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(members), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(properties)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an interface bond
|
||||
*
|
||||
* @param network Network to add the bonded PIF to
|
||||
* @param members PIFs to add to this bond
|
||||
* @param MAC The MAC address to use on the bond itself. If this parameter is the empty string then the bond will inherit its MAC address from the primary slave.
|
||||
* @param mode Bonding mode to use for the new bond
|
||||
* @param properties Additional configuration parameters specific to the bond mode
|
||||
* @return The reference of the created Bond object
|
||||
*/
|
||||
public static Bond create(Connection c, Network network, Set<PIF> members, String MAC, Types.BondMode mode, Map<String, String> properties) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(network), Marshalling.toXMLRPC(members), Marshalling.toXMLRPC(MAC), Marshalling.toXMLRPC(mode), Marshalling.toXMLRPC(properties)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBond(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an interface bond
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.Bond.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an interface bond
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the bond mode
|
||||
*
|
||||
* @param value The new bond mode
|
||||
* @return Task
|
||||
*/
|
||||
public Task setModeAsync(Connection c, Types.BondMode value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.Bond.set_mode";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the bond mode
|
||||
*
|
||||
* @param value The new bond mode
|
||||
*/
|
||||
public void setMode(Connection c, Types.BondMode value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.set_mode";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of a property of the bond
|
||||
*
|
||||
* @param name The property name
|
||||
* @param value The property value
|
||||
* @return Task
|
||||
*/
|
||||
public Task setPropertyAsync(Connection c, String name, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.Bond.set_property";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of a property of the bond
|
||||
*
|
||||
* @param name The property name
|
||||
* @param value The property value
|
||||
*/
|
||||
public void setProperty(Connection c, String name, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.set_property";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the Bonds known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Bond> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfBond(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of Bond references to Bond records for all Bonds known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Bond, Bond.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Bond.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfBondBondRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
380
deps/XenServerJava/src/com/xensource/xenapi/Connection.java
vendored
Normal file
380
deps/XenServerJava/src/com/xensource/xenapi/Connection.java
vendored
Normal file
@ -0,0 +1,380 @@
|
||||
/* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
import org.apache.xmlrpc.client.XmlRpcClient;
|
||||
import org.apache.xmlrpc.client.XmlRpcClientConfig;
|
||||
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
|
||||
import org.apache.xmlrpc.client.XmlRpcHttpClientConfig;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.SessionAuthenticationFailed;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
/**
|
||||
* Represents a connection to a XenServer. Creating a new instance of this class initialises a new XmlRpcClient that is
|
||||
* then used by all method calls: each method call in xenapi takes a Connection as a parameter, composes an XMLRPC
|
||||
* method call, and dispatches it on the Connection's client via the dispatch method.
|
||||
*/
|
||||
public class Connection
|
||||
{
|
||||
/**
|
||||
* The version of the bindings that this class belongs to.
|
||||
*/
|
||||
public static final String BINDINGS_VERSION = "6.1.0-1";
|
||||
|
||||
/**
|
||||
* true if the connection is to the Rio edition of XenServer. Certain function calls are not allowed.
|
||||
*
|
||||
* @deprecated Use getAPIVersion() instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public Boolean rioConnection = false;
|
||||
|
||||
private APIVersion apiVersion;
|
||||
|
||||
/**
|
||||
* Updated when Session.login_with_password() is called.
|
||||
*/
|
||||
public APIVersion getAPIVersion()
|
||||
{
|
||||
return apiVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* The opaque reference to the session used by this connection
|
||||
*/
|
||||
private String sessionReference;
|
||||
|
||||
/**
|
||||
* As seen by the xmlrpc library. From our point of view it's a server.
|
||||
*/
|
||||
private final XmlRpcClient client;
|
||||
|
||||
private final boolean deprecatedConstructorUsed;
|
||||
|
||||
/**
|
||||
* Creates a connection to a particular server using a given username and password. This object can then be passed
|
||||
* in to any other API calls.
|
||||
*
|
||||
* This constructor calls Session.loginWithPassword, passing itself as the first parameter.
|
||||
*
|
||||
* When this constructor is used, a call to dispose() (also called in the Connection's finalizer) will attempt a
|
||||
* Session.logout on this connection.
|
||||
*
|
||||
* @deprecated Use a constructor that takes a URL as the first parameter instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public Connection(String client, String username, String password) throws java.net.MalformedURLException,
|
||||
XmlRpcException, BadServerResponse, SessionAuthenticationFailed, XenAPIException
|
||||
{
|
||||
deprecatedConstructorUsed = true;
|
||||
|
||||
// To login normally we call login_with_password(username, password, "1.X"). On rio this call fails and we
|
||||
// should use login_with_password(username,password) instead, and note that we are talking to a rio host so that we
|
||||
// can refuse to make certain miami-specific calls
|
||||
final String ApiVersion = APIVersion.latest().toString();
|
||||
this.client = getClientFromURL(new URL(client));
|
||||
try
|
||||
{
|
||||
//first try to login the modern way
|
||||
this.sessionReference = loginWithPassword(this.client, username, password, ApiVersion);
|
||||
} catch (BadServerResponse e)
|
||||
{
|
||||
//oops, something went wrong
|
||||
String[] errDesc = e.errorDescription;
|
||||
//was the problem that the host was running rio? If so it will have complained that it got three parameters
|
||||
//instead of two. Let us carefully verify the details of this complaint
|
||||
if (0 == errDesc[0].compareTo("MESSAGE_PARAMETER_COUNT_MISMATCH")
|
||||
&& 0 == errDesc[1].compareTo("session.login_with_password")
|
||||
&& 0 == errDesc[2].compareTo("2")
|
||||
&& 0 == errDesc[3].compareTo("3"))
|
||||
{
|
||||
//and if so, we can have another go, using the older login method, and see how that goes.
|
||||
this.sessionReference = loginWithPassword(this.client, username, password);
|
||||
//success!. Note that we are talking to an old host on this connection
|
||||
this.rioConnection = true;
|
||||
} else
|
||||
{
|
||||
//Hmm... Can't solve this here. Let upstairs know about the problem.
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
setAPIVersion(new Session(sessionReference));
|
||||
}
|
||||
catch (XenAPIException exn)
|
||||
{
|
||||
dispose();
|
||||
throw exn;
|
||||
}
|
||||
catch (XmlRpcException exn)
|
||||
{
|
||||
dispose();
|
||||
throw exn;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a connection to a particular server using a given username and password. This object can then be passed
|
||||
* in to any other API calls.
|
||||
*
|
||||
* Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it,
|
||||
* passing the Connection as a parameter. No attempt to connect to the server is made until login is called.
|
||||
*
|
||||
* When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually
|
||||
* logging out the Session.
|
||||
*/
|
||||
public Connection(URL url)
|
||||
{
|
||||
deprecatedConstructorUsed = false;
|
||||
|
||||
this.client = getClientFromURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a connection to a particular server using a given username and password. This object can then be passed
|
||||
* in to any other API calls.
|
||||
*
|
||||
* The additional sessionReference parameter must be a reference to a logged-in Session. Any method calls on this
|
||||
* Connection will use it. This constructor does not call Session.loginWithPassword, and dispose() on the resulting
|
||||
* Connection object does not call Session.logout. The programmer is responsible for ensuring the Session is logged
|
||||
* in and out correctly.
|
||||
*/
|
||||
public Connection(URL url, String sessionReference)
|
||||
{
|
||||
deprecatedConstructorUsed = false;
|
||||
|
||||
this.client = getClientFromURL(url);
|
||||
this.sessionReference = sessionReference;
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable
|
||||
{
|
||||
dispose();
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Nothrow guarantee.
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
if (!deprecatedConstructorUsed)
|
||||
{
|
||||
// We only need to do the Session.logout if they used the old deprecated constructor.
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (sessionReference != null)
|
||||
{
|
||||
String method_call = "session.logout";
|
||||
Object[] method_params = { Marshalling.toXMLRPC(this.sessionReference) };
|
||||
client.execute(method_call, method_params);
|
||||
sessionReference = null;
|
||||
}
|
||||
}
|
||||
catch (XmlRpcException exn)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The programmer is now responsible for calling login/logout themselves.
|
||||
*/
|
||||
@Deprecated
|
||||
private static String loginWithPassword(XmlRpcClient client, String username, String password)
|
||||
throws BadServerResponse, XmlRpcException, SessionAuthenticationFailed
|
||||
{
|
||||
String method_call = "session.login_with_password";
|
||||
Object[] method_params = { Marshalling.toXMLRPC(username), Marshalling.toXMLRPC(password) };
|
||||
Map response = (Map) client.execute(method_call, method_params);
|
||||
if (response.get("Status").equals("Success"))
|
||||
{
|
||||
return (String) response.get("Value");
|
||||
} else if (response.get("Status").equals("Failure"))
|
||||
{
|
||||
Object[] error = (Object[]) response.get("ErrorDescription");
|
||||
if (error[0].equals("SESSION_AUTHENTICATION_FAILED"))
|
||||
{
|
||||
throw new SessionAuthenticationFailed();
|
||||
}
|
||||
}
|
||||
throw new BadServerResponse(response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated The programmer is now responsible for calling login/logout themselves.
|
||||
*/
|
||||
@Deprecated
|
||||
private static String loginWithPassword(XmlRpcClient client, String username, String password, String ApiVersion)
|
||||
throws BadServerResponse, XmlRpcException, SessionAuthenticationFailed
|
||||
{
|
||||
String method_call = "session.login_with_password";
|
||||
Object[] method_params = { Marshalling.toXMLRPC(username), Marshalling.toXMLRPC(password),
|
||||
Marshalling.toXMLRPC(ApiVersion) };
|
||||
Map response = (Map) client.execute(method_call, method_params);
|
||||
if (response.get("Status").equals("Success"))
|
||||
{
|
||||
return (String) response.get("Value");
|
||||
} else if (response.get("Status").equals("Failure"))
|
||||
{
|
||||
Object[] error = (Object[]) response.get("ErrorDescription");
|
||||
if (error[0].equals("SESSION_AUTHENTICATION_FAILED"))
|
||||
{
|
||||
throw new SessionAuthenticationFailed();
|
||||
}
|
||||
}
|
||||
throw new BadServerResponse(response);
|
||||
}
|
||||
|
||||
private XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
|
||||
|
||||
public XmlRpcClientConfigImpl getConfig()
|
||||
{
|
||||
return config;
|
||||
}
|
||||
private XmlRpcClient getClientFromURL(URL url)
|
||||
{
|
||||
config.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
config.setServerURL(url);
|
||||
XmlRpcClient client = new XmlRpcClient();
|
||||
client.setConfig(config);
|
||||
return client;
|
||||
}
|
||||
|
||||
/*
|
||||
* Because the binding calls are constructing their own parameter lists, they need to be able to get to
|
||||
* the session reference directly. This is all rather ugly and needs redone
|
||||
* Changed to public to allow easier integration with HTTP-level streaming interface,
|
||||
* see CA-15447
|
||||
*/
|
||||
public String getSessionReference()
|
||||
{
|
||||
return this.sessionReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* The (auto-generated parts of) the bindings dispatch XMLRPC calls on this Connection's client through this method.
|
||||
*/
|
||||
Map dispatch(String method_call, Object[] method_params) throws XmlRpcException, XenAPIException
|
||||
{
|
||||
Map response = (Map) client.execute(method_call, method_params);
|
||||
|
||||
if (!deprecatedConstructorUsed)
|
||||
{
|
||||
// We are using the new-style constructor which doesn't perform login.
|
||||
// Set this Connection's Session reference from the value returned on the wire.
|
||||
if (method_call.equals("session.login_with_password") &&
|
||||
response.get("Status").equals("Success"))
|
||||
{
|
||||
// Store the Session reference and ask the server what the
|
||||
// API version it's using is.
|
||||
Session session = Types.toSession(response.get("Value"));
|
||||
sessionReference = session.ref;
|
||||
setAPIVersion(session);
|
||||
}
|
||||
else if (method_call.equals("session.slave_local_login_with_password") &&
|
||||
response.get("Status").equals("Success"))
|
||||
{
|
||||
// Store the Session reference and assume the latest API version.
|
||||
sessionReference = Types.toSession(response.get("Value")).ref;
|
||||
apiVersion = APIVersion.latest();
|
||||
}
|
||||
else if (method_call.equals("session.logout"))
|
||||
{
|
||||
// Work around a bug in XenServer 5.0 and below.
|
||||
// session.login_with_password should have rejected us with
|
||||
// HOST_IS_SLAVE, but instead we don't find out until later.
|
||||
// We don't want to leak the session, so we need to log out
|
||||
// this session from the master instead.
|
||||
if (response.get("Status").equals("Failure"))
|
||||
{
|
||||
Object[] error = (Object[]) response.get("ErrorDescription");
|
||||
if (error.length == 2 && error[0].equals("HOST_IS_SLAVE"))
|
||||
{
|
||||
try
|
||||
{
|
||||
URL client_url =
|
||||
((XmlRpcHttpClientConfig)client.getClientConfig()).getServerURL();
|
||||
Connection tmp_conn =
|
||||
new Connection(new URL(client_url.getProtocol(),
|
||||
(String)error[1],
|
||||
client_url.getPort(),
|
||||
client_url.getFile()));
|
||||
tmp_conn.sessionReference = sessionReference;
|
||||
try
|
||||
{
|
||||
Session.logout(tmp_conn);
|
||||
}
|
||||
finally
|
||||
{
|
||||
tmp_conn.dispose();
|
||||
}
|
||||
}
|
||||
catch (Exception exn2)
|
||||
{
|
||||
// Ignore -- we're going to throw HostIsSlave anyway.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the stored Session reference.
|
||||
this.sessionReference = null;
|
||||
}
|
||||
}
|
||||
|
||||
return Types.checkResponse(response);
|
||||
}
|
||||
|
||||
|
||||
private void setAPIVersion(Session session) throws XenAPIException, XmlRpcException
|
||||
{
|
||||
try
|
||||
{
|
||||
long major = session.getThisHost(this).getAPIVersionMajor(this);
|
||||
long minor = session.getThisHost(this).getAPIVersionMinor(this);
|
||||
apiVersion = APIVersion.fromMajorMinor(major, minor);
|
||||
}
|
||||
catch (BadServerResponse exn)
|
||||
{
|
||||
apiVersion = APIVersion.API_1_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
419
deps/XenServerJava/src/com/xensource/xenapi/Console.java
vendored
Normal file
419
deps/XenServerJava/src/com/xensource/xenapi/Console.java
vendored
Normal file
@ -0,0 +1,419 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A console
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Console extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Console(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Console, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Console)
|
||||
{
|
||||
Console other = (Console) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Console
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "protocol", this.protocol);
|
||||
print.printf("%1$20s: %2$s\n", "location", this.location);
|
||||
print.printf("%1$20s: %2$s\n", "VM", this.VM);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a console.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("protocol", this.protocol == null ? Types.ConsoleProtocol.UNRECOGNIZED : this.protocol);
|
||||
map.put("location", this.location == null ? "" : this.location);
|
||||
map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* the protocol used by this console
|
||||
*/
|
||||
public Types.ConsoleProtocol protocol;
|
||||
/**
|
||||
* URI for the console service
|
||||
*/
|
||||
public String location;
|
||||
/**
|
||||
* VM to which this console is attached
|
||||
*/
|
||||
public VM VM;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given console.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Console.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toConsoleRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the console instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Console getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toConsole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new console instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, Console.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.console.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new console instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return reference to the newly created object
|
||||
*/
|
||||
public static Console create(Connection c, Console.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toConsole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified console instance.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.console.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified console instance.
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given console.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the protocol field of the given console.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Types.ConsoleProtocol getProtocol(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.get_protocol";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toConsoleProtocol(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the location field of the given console.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getLocation(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.get_location";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VM field of the given console.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public VM getVM(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.get_VM";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given console.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given console.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given console.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given console. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the consoles known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Console> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfConsole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of console references to console records for all consoles known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Console, Console.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "console.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfConsoleConsoleRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
358
deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java
vendored
Normal file
358
deps/XenServerJava/src/com/xensource/xenapi/Crashdump.java
vendored
Normal file
@ -0,0 +1,358 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A VM crashdump
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Crashdump extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Crashdump(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Crashdump, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Crashdump)
|
||||
{
|
||||
Crashdump other = (Crashdump) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Crashdump
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "VM", this.VM);
|
||||
print.printf("%1$20s: %2$s\n", "VDI", this.VDI);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a crashdump.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM);
|
||||
map.put("VDI", this.VDI == null ? new VDI("OpaqueRef:NULL") : this.VDI);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* the virtual machine
|
||||
*/
|
||||
public VM VM;
|
||||
/**
|
||||
* the virtual disk
|
||||
*/
|
||||
public VDI VDI;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given crashdump.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Crashdump.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toCrashdumpRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the crashdump instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Crashdump getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toCrashdump(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given crashdump.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VM field of the given crashdump.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public VM getVM(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.get_VM";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VDI field of the given crashdump.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public VDI getVDI(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.get_VDI";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVDI(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given crashdump.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given crashdump.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given crashdump.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given crashdump. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified crashdump
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.crashdump.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified crashdump
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the crashdumps known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Crashdump> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfCrashdump(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of crashdump references to crashdump records for all crashdumps known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Crashdump, Crashdump.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "crashdump.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfCrashdumpCrashdumpRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
303
deps/XenServerJava/src/com/xensource/xenapi/DRTask.java
vendored
Normal file
303
deps/XenServerJava/src/com/xensource/xenapi/DRTask.java
vendored
Normal file
@ -0,0 +1,303 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* DR task
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class DRTask extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
DRTask(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a DRTask, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof DRTask)
|
||||
{
|
||||
DRTask other = (DRTask) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a DRTask
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "introducedSRs", this.introducedSRs);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a DR_task.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("introduced_SRs", this.introducedSRs == null ? new LinkedHashSet<SR>() : this.introducedSRs);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* All SRs introduced by this appliance
|
||||
*/
|
||||
public Set<SR> introducedSRs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given DR_task.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public DRTask.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "DR_task.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDRTaskRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the DR_task instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static DRTask getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "DR_task.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDRTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given DR_task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "DR_task.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the introduced_SRs field of the given DR_task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<SR> getIntroducedSRs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "DR_task.get_introduced_SRs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfSR(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a disaster recovery task which will query the supplied list of devices
|
||||
*
|
||||
* @param type The SR driver type of the SRs to introduce
|
||||
* @param deviceConfig The device configuration of the SRs to introduce
|
||||
* @param whitelist The devices to use for disaster recovery
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, String type, Map<String, String> deviceConfig, Set<String> whitelist) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.DR_task.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(whitelist)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a disaster recovery task which will query the supplied list of devices
|
||||
*
|
||||
* @param type The SR driver type of the SRs to introduce
|
||||
* @param deviceConfig The device configuration of the SRs to introduce
|
||||
* @param whitelist The devices to use for disaster recovery
|
||||
* @return The reference to the created task
|
||||
*/
|
||||
public static DRTask create(Connection c, String type, Map<String, String> deviceConfig, Set<String> whitelist) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "DR_task.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(type), Marshalling.toXMLRPC(deviceConfig), Marshalling.toXMLRPC(whitelist)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDRTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the disaster recovery task, detaching and forgetting any SRs introduced which are no longer required
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.DR_task.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the disaster recovery task, detaching and forgetting any SRs introduced which are no longer required
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "DR_task.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the DR_tasks known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<DRTask> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "DR_task.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfDRTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of DR_task references to DR_task records for all DR_tasks known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<DRTask, DRTask.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "DR_task.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfDRTaskDRTaskRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
164
deps/XenServerJava/src/com/xensource/xenapi/DataSource.java
vendored
Normal file
164
deps/XenServerJava/src/com/xensource/xenapi/DataSource.java
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* Data sources for logging in RRDs
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class DataSource extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
DataSource(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a DataSource, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof DataSource)
|
||||
{
|
||||
DataSource other = (DataSource) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a DataSource
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "enabled", this.enabled);
|
||||
print.printf("%1$20s: %2$s\n", "standard", this.standard);
|
||||
print.printf("%1$20s: %2$s\n", "units", this.units);
|
||||
print.printf("%1$20s: %2$s\n", "min", this.min);
|
||||
print.printf("%1$20s: %2$s\n", "max", this.max);
|
||||
print.printf("%1$20s: %2$s\n", "value", this.value);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a data_source.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("enabled", this.enabled == null ? false : this.enabled);
|
||||
map.put("standard", this.standard == null ? false : this.standard);
|
||||
map.put("units", this.units == null ? "" : this.units);
|
||||
map.put("min", this.min == null ? 0.0 : this.min);
|
||||
map.put("max", this.max == null ? 0.0 : this.max);
|
||||
map.put("value", this.value == null ? 0.0 : this.value);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* a human-readable name
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* a notes field containing human-readable description
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* true if the data source is being logged
|
||||
*/
|
||||
public Boolean enabled;
|
||||
/**
|
||||
* true if the data source is enabled by default. Non-default data sources cannot be disabled
|
||||
*/
|
||||
public Boolean standard;
|
||||
/**
|
||||
* the units of the value
|
||||
*/
|
||||
public String units;
|
||||
/**
|
||||
* the minimum value of the data source
|
||||
*/
|
||||
public Double min;
|
||||
/**
|
||||
* the maximum value of the data source
|
||||
*/
|
||||
public Double max;
|
||||
/**
|
||||
* current value of the data source
|
||||
*/
|
||||
public Double value;
|
||||
}
|
||||
|
||||
}
|
||||
304
deps/XenServerJava/src/com/xensource/xenapi/Event.java
vendored
Normal file
304
deps/XenServerJava/src/com/xensource/xenapi/Event.java
vendored
Normal file
@ -0,0 +1,304 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* Asynchronous event registration and handling
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Event extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Event(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Event, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Event)
|
||||
{
|
||||
Event other = (Event) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Event
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "id", this.id);
|
||||
print.printf("%1$20s: %2$s\n", "timestamp", this.timestamp);
|
||||
print.printf("%1$20s: %2$s\n", "clazz", this.clazz);
|
||||
print.printf("%1$20s: %2$s\n", "operation", this.operation);
|
||||
print.printf("%1$20s: %2$s\n", "ref", this.ref);
|
||||
print.printf("%1$20s: %2$s\n", "objUuid", this.objUuid);
|
||||
print.printf("%1$20s: %2$s\n", "snapshot", this.snapshot);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a event.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("id", this.id == null ? 0 : this.id);
|
||||
map.put("timestamp", this.timestamp == null ? new Date(0) : this.timestamp);
|
||||
map.put("class", this.clazz == null ? "" : this.clazz);
|
||||
map.put("operation", this.operation == null ? Types.EventOperation.UNRECOGNIZED : this.operation);
|
||||
map.put("ref", this.ref == null ? "" : this.ref);
|
||||
map.put("obj_uuid", this.objUuid == null ? "" : this.objUuid);
|
||||
map.put("snapshot", this.snapshot);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* An ID, monotonically increasing, and local to the current session
|
||||
*/
|
||||
public Long id;
|
||||
/**
|
||||
* The time at which the event occurred
|
||||
*/
|
||||
public Date timestamp;
|
||||
/**
|
||||
* The name of the class of the object that changed
|
||||
*/
|
||||
public String clazz;
|
||||
/**
|
||||
* The operation that was performed
|
||||
*/
|
||||
public Types.EventOperation operation;
|
||||
/**
|
||||
* A reference to the object that changed
|
||||
*/
|
||||
public String ref;
|
||||
/**
|
||||
* The uuid of the object that changed
|
||||
*/
|
||||
public String objUuid;
|
||||
/**
|
||||
* The record of the database object that was added, changed or deleted
|
||||
* (the actual type will be VM.Record, VBD.Record or similar)
|
||||
*/
|
||||
public Object snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this session with the event system. Specifying * as the desired class will register for all classes.
|
||||
*
|
||||
* @param classes register for events for the indicated classes
|
||||
* @return Task
|
||||
*/
|
||||
public static Task registerAsync(Connection c, Set<String> classes) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.event.register";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this session with the event system. Specifying * as the desired class will register for all classes.
|
||||
*
|
||||
* @param classes register for events for the indicated classes
|
||||
*/
|
||||
public static void register(Connection c, Set<String> classes) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "event.register";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this session with the event system
|
||||
*
|
||||
* @param classes remove this session's registration for the indicated classes
|
||||
* @return Task
|
||||
*/
|
||||
public static Task unregisterAsync(Connection c, Set<String> classes) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.event.unregister";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this session with the event system
|
||||
*
|
||||
* @param classes remove this session's registration for the indicated classes
|
||||
*/
|
||||
public static void unregister(Connection c, Set<String> classes) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "event.unregister";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocking call which returns a (possibly empty) batch of events
|
||||
*
|
||||
* @return the batch of events
|
||||
*/
|
||||
public static Set<Event.Record> next(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.SessionNotRegistered,
|
||||
Types.EventsLost {
|
||||
String method_call = "event.next";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfEventRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocking call which returns a (possibly empty) batch of events
|
||||
*
|
||||
* @param classes register for events for the indicated classes
|
||||
* @param token A token representing the point from which to generate database events. The empty string represents the beginning.
|
||||
* @param timeout Return after this many seconds if no events match
|
||||
* @return the batch of events
|
||||
*/
|
||||
public static Set<Event.Record> from(Connection c, Set<String> classes, String token, Double timeout) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.SessionNotRegistered,
|
||||
Types.EventsLost {
|
||||
String method_call = "event.from";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(classes), Marshalling.toXMLRPC(token), Marshalling.toXMLRPC(timeout)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfEventRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the ID of the next event to be generated by the system
|
||||
*
|
||||
* @return the event ID
|
||||
*/
|
||||
public static Long getCurrentId(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "event.get_current_id";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects an artificial event on the given object and return the corresponding ID
|
||||
*
|
||||
* @param clazz class of the object
|
||||
* @param ref A reference to the object that will be changed.
|
||||
* @return the event ID
|
||||
*/
|
||||
public static String inject(Connection c, String clazz, String ref) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "event.inject";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(clazz), Marshalling.toXMLRPC(ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
}
|
||||
445
deps/XenServerJava/src/com/xensource/xenapi/GPUGroup.java
vendored
Normal file
445
deps/XenServerJava/src/com/xensource/xenapi/GPUGroup.java
vendored
Normal file
@ -0,0 +1,445 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A group of compatible GPUs across the resource pool
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class GPUGroup extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
GPUGroup(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a GPUGroup, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof GPUGroup)
|
||||
{
|
||||
GPUGroup other = (GPUGroup) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a GPUGroup
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "PGPUs", this.PGPUs);
|
||||
print.printf("%1$20s: %2$s\n", "VGPUs", this.VGPUs);
|
||||
print.printf("%1$20s: %2$s\n", "GPUTypes", this.GPUTypes);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a GPU_group.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("PGPUs", this.PGPUs == null ? new LinkedHashSet<PGPU>() : this.PGPUs);
|
||||
map.put("VGPUs", this.VGPUs == null ? new LinkedHashSet<VGPU>() : this.VGPUs);
|
||||
map.put("GPU_types", this.GPUTypes == null ? new LinkedHashSet<String>() : this.GPUTypes);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* a human-readable name
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* a notes field containing human-readable description
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* List of pGPUs in the group
|
||||
*/
|
||||
public Set<PGPU> PGPUs;
|
||||
/**
|
||||
* List of vGPUs using the group
|
||||
*/
|
||||
public Set<VGPU> VGPUs;
|
||||
/**
|
||||
* List of GPU types (vendor+device ID) that can be in this group
|
||||
*/
|
||||
public Set<String> GPUTypes;
|
||||
/**
|
||||
* Additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given GPU_group.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public GPUGroup.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toGPUGroupRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the GPU_group instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static GPUGroup getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toGPUGroup(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the GPU_group instances with the given label.
|
||||
*
|
||||
* @param label label of object to return
|
||||
* @return references to objects with matching names
|
||||
*/
|
||||
public static Set<GPUGroup> getByNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_by_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfGPUGroup(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given GPU_group.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/label field of the given GPU_group.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/description field of the given GPU_group.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameDescription(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PGPUs field of the given GPU_group.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<PGPU> getPGPUs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_PGPUs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPGPU(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VGPUs field of the given GPU_group.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<VGPU> getVGPUs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_VGPUs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVGPU(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the GPU_types field of the given GPU_group.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<String> getGPUTypes(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_GPU_types";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given GPU_group.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name/label field of the given GPU_group.
|
||||
*
|
||||
* @param label New value to set
|
||||
*/
|
||||
public void setNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.set_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name/description field of the given GPU_group.
|
||||
*
|
||||
* @param description New value to set
|
||||
*/
|
||||
public void setNameDescription(Connection c, String description) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.set_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given GPU_group.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given GPU_group.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given GPU_group. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the GPU_groups known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<GPUGroup> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfGPUGroup(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of GPU_group references to GPU_group records for all GPU_groups known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<GPUGroup, GPUGroup.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "GPU_group.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfGPUGroupGPUGroupRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
2919
deps/XenServerJava/src/com/xensource/xenapi/Host.java
vendored
Normal file
2919
deps/XenServerJava/src/com/xensource/xenapi/Host.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
536
deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java
vendored
Normal file
536
deps/XenServerJava/src/com/xensource/xenapi/HostCpu.java
vendored
Normal file
@ -0,0 +1,536 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A physical CPU
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class HostCpu extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
HostCpu(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a HostCpu, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof HostCpu)
|
||||
{
|
||||
HostCpu other = (HostCpu) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a HostCpu
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "host", this.host);
|
||||
print.printf("%1$20s: %2$s\n", "number", this.number);
|
||||
print.printf("%1$20s: %2$s\n", "vendor", this.vendor);
|
||||
print.printf("%1$20s: %2$s\n", "speed", this.speed);
|
||||
print.printf("%1$20s: %2$s\n", "modelname", this.modelname);
|
||||
print.printf("%1$20s: %2$s\n", "family", this.family);
|
||||
print.printf("%1$20s: %2$s\n", "model", this.model);
|
||||
print.printf("%1$20s: %2$s\n", "stepping", this.stepping);
|
||||
print.printf("%1$20s: %2$s\n", "flags", this.flags);
|
||||
print.printf("%1$20s: %2$s\n", "features", this.features);
|
||||
print.printf("%1$20s: %2$s\n", "utilisation", this.utilisation);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a host_cpu.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host);
|
||||
map.put("number", this.number == null ? 0 : this.number);
|
||||
map.put("vendor", this.vendor == null ? "" : this.vendor);
|
||||
map.put("speed", this.speed == null ? 0 : this.speed);
|
||||
map.put("modelname", this.modelname == null ? "" : this.modelname);
|
||||
map.put("family", this.family == null ? 0 : this.family);
|
||||
map.put("model", this.model == null ? 0 : this.model);
|
||||
map.put("stepping", this.stepping == null ? "" : this.stepping);
|
||||
map.put("flags", this.flags == null ? "" : this.flags);
|
||||
map.put("features", this.features == null ? "" : this.features);
|
||||
map.put("utilisation", this.utilisation == null ? 0.0 : this.utilisation);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* the host the CPU is in
|
||||
*/
|
||||
public Host host;
|
||||
/**
|
||||
* the number of the physical CPU within the host
|
||||
*/
|
||||
public Long number;
|
||||
/**
|
||||
* the vendor of the physical CPU
|
||||
*/
|
||||
public String vendor;
|
||||
/**
|
||||
* the speed of the physical CPU
|
||||
*/
|
||||
public Long speed;
|
||||
/**
|
||||
* the model name of the physical CPU
|
||||
*/
|
||||
public String modelname;
|
||||
/**
|
||||
* the family (number) of the physical CPU
|
||||
*/
|
||||
public Long family;
|
||||
/**
|
||||
* the model number of the physical CPU
|
||||
*/
|
||||
public Long model;
|
||||
/**
|
||||
* the stepping of the physical CPU
|
||||
*/
|
||||
public String stepping;
|
||||
/**
|
||||
* the flags of the physical CPU (a decoded version of the features field)
|
||||
*/
|
||||
public String flags;
|
||||
/**
|
||||
* the physical CPU feature bitmap
|
||||
*/
|
||||
public String features;
|
||||
/**
|
||||
* the current CPU utilisation
|
||||
*/
|
||||
public Double utilisation;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given host_cpu.
|
||||
* @deprecated
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
@Deprecated public HostCpu.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHostCpuRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the host_cpu instance with the specified UUID.
|
||||
* @deprecated
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
@Deprecated public static HostCpu getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHostCpu(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Host getHost(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_host";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHost(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getNumber(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_number";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vendor field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getVendor(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_vendor";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the speed field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getSpeed(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_speed";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the modelname field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getModelname(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_modelname";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the family field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getFamily(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_family";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the model field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getModel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_model";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stepping field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getStepping(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_stepping";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the flags field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getFlags(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_flags";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the features field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getFeatures(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_features";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the utilisation field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Double getUtilisation(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_utilisation";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDouble(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given host_cpu.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given host_cpu.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given host_cpu.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given host_cpu. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the host_cpus known to the system.
|
||||
* @deprecated
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
@Deprecated public static Set<HostCpu> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfHostCpu(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of host_cpu references to host_cpu records for all host_cpus known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<HostCpu, HostCpu.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_cpu.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfHostCpuHostCpuRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
417
deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java
vendored
Normal file
417
deps/XenServerJava/src/com/xensource/xenapi/HostCrashdump.java
vendored
Normal file
@ -0,0 +1,417 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* Represents a host crash dump
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class HostCrashdump extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
HostCrashdump(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a HostCrashdump, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof HostCrashdump)
|
||||
{
|
||||
HostCrashdump other = (HostCrashdump) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a HostCrashdump
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "host", this.host);
|
||||
print.printf("%1$20s: %2$s\n", "timestamp", this.timestamp);
|
||||
print.printf("%1$20s: %2$s\n", "size", this.size);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a host_crashdump.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host);
|
||||
map.put("timestamp", this.timestamp == null ? new Date(0) : this.timestamp);
|
||||
map.put("size", this.size == null ? 0 : this.size);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* Host the crashdump relates to
|
||||
*/
|
||||
public Host host;
|
||||
/**
|
||||
* Time the crash happened
|
||||
*/
|
||||
public Date timestamp;
|
||||
/**
|
||||
* Size of the crashdump
|
||||
*/
|
||||
public Long size;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given host_crashdump.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public HostCrashdump.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHostCrashdumpRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the host_crashdump instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static HostCrashdump getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHostCrashdump(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given host_crashdump.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host field of the given host_crashdump.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Host getHost(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.get_host";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHost(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the timestamp field of the given host_crashdump.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getTimestamp(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.get_timestamp";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size field of the given host_crashdump.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getSize(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.get_size";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given host_crashdump.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given host_crashdump.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given host_crashdump.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given host_crashdump. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy specified host crash dump, removing it from the disk.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.host_crashdump.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy specified host crash dump, removing it from the disk.
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload the specified host crash dump to a specified URL
|
||||
*
|
||||
* @param url The URL to upload to
|
||||
* @param options Extra configuration operations
|
||||
* @return Task
|
||||
*/
|
||||
public Task uploadAsync(Connection c, String url, Map<String, String> options) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.host_crashdump.upload";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload the specified host crash dump to a specified URL
|
||||
*
|
||||
* @param url The URL to upload to
|
||||
* @param options Extra configuration operations
|
||||
*/
|
||||
public void upload(Connection c, String url, Map<String, String> options) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.upload";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(url), Marshalling.toXMLRPC(options)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the host_crashdumps known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<HostCrashdump> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfHostCrashdump(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of host_crashdump references to host_crashdump records for all host_crashdumps known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<HostCrashdump, HostCrashdump.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_crashdump.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfHostCrashdumpHostCrashdumpRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
373
deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java
vendored
Normal file
373
deps/XenServerJava/src/com/xensource/xenapi/HostMetrics.java
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* The metrics associated with a host
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class HostMetrics extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
HostMetrics(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a HostMetrics, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof HostMetrics)
|
||||
{
|
||||
HostMetrics other = (HostMetrics) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a HostMetrics
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "memoryTotal", this.memoryTotal);
|
||||
print.printf("%1$20s: %2$s\n", "memoryFree", this.memoryFree);
|
||||
print.printf("%1$20s: %2$s\n", "live", this.live);
|
||||
print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a host_metrics.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("memory_total", this.memoryTotal == null ? 0 : this.memoryTotal);
|
||||
map.put("memory_free", this.memoryFree == null ? 0 : this.memoryFree);
|
||||
map.put("live", this.live == null ? false : this.live);
|
||||
map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* Total host memory (bytes)
|
||||
*/
|
||||
public Long memoryTotal;
|
||||
/**
|
||||
* Free host memory (bytes)
|
||||
*/
|
||||
public Long memoryFree;
|
||||
/**
|
||||
* Pool master thinks this host is live
|
||||
*/
|
||||
public Boolean live;
|
||||
/**
|
||||
* Time at which this information was last updated
|
||||
*/
|
||||
public Date lastUpdated;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given host_metrics.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public HostMetrics.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHostMetricsRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the host_metrics instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static HostMetrics getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHostMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given host_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the memory/total field of the given host_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getMemoryTotal(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_memory_total";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the memory/free field of the given host_metrics.
|
||||
* @deprecated
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
@Deprecated public Long getMemoryFree(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_memory_free";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the live field of the given host_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getLive(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_live";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last_updated field of the given host_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getLastUpdated(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_last_updated";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given host_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given host_metrics.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given host_metrics.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given host_metrics. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the host_metrics instances known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<HostMetrics> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfHostMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of host_metrics references to host_metrics records for all host_metrics instances known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<HostMetrics, HostMetrics.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_metrics.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfHostMetricsHostMetricsRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
552
deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java
vendored
Normal file
552
deps/XenServerJava/src/com/xensource/xenapi/HostPatch.java
vendored
Normal file
@ -0,0 +1,552 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* Represents a patch stored on a server
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class HostPatch extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
HostPatch(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a HostPatch, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof HostPatch)
|
||||
{
|
||||
HostPatch other = (HostPatch) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a HostPatch
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "version", this.version);
|
||||
print.printf("%1$20s: %2$s\n", "host", this.host);
|
||||
print.printf("%1$20s: %2$s\n", "applied", this.applied);
|
||||
print.printf("%1$20s: %2$s\n", "timestampApplied", this.timestampApplied);
|
||||
print.printf("%1$20s: %2$s\n", "size", this.size);
|
||||
print.printf("%1$20s: %2$s\n", "poolPatch", this.poolPatch);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a host_patch.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("version", this.version == null ? "" : this.version);
|
||||
map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host);
|
||||
map.put("applied", this.applied == null ? false : this.applied);
|
||||
map.put("timestamp_applied", this.timestampApplied == null ? new Date(0) : this.timestampApplied);
|
||||
map.put("size", this.size == null ? 0 : this.size);
|
||||
map.put("pool_patch", this.poolPatch == null ? new PoolPatch("OpaqueRef:NULL") : this.poolPatch);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* a human-readable name
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* a notes field containing human-readable description
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* Patch version number
|
||||
*/
|
||||
public String version;
|
||||
/**
|
||||
* Host the patch relates to
|
||||
*/
|
||||
public Host host;
|
||||
/**
|
||||
* True if the patch has been applied
|
||||
*/
|
||||
public Boolean applied;
|
||||
/**
|
||||
* Time the patch was applied
|
||||
*/
|
||||
public Date timestampApplied;
|
||||
/**
|
||||
* Size of the patch
|
||||
*/
|
||||
public Long size;
|
||||
/**
|
||||
* The patch applied
|
||||
*/
|
||||
public PoolPatch poolPatch;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given host_patch.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public HostPatch.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHostPatchRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the host_patch instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static HostPatch getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHostPatch(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the host_patch instances with the given label.
|
||||
*
|
||||
* @param label label of object to return
|
||||
* @return references to objects with matching names
|
||||
*/
|
||||
public static Set<HostPatch> getByNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_by_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfHostPatch(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/label field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/description field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameDescription(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getVersion(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_version";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Host getHost(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_host";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHost(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the applied field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getApplied(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_applied";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the timestamp_applied field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getTimestampApplied(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_timestamp_applied";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getSize(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_size";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pool_patch field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public PoolPatch getPoolPatch(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_pool_patch";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPoolPatch(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given host_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given host_patch.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given host_patch.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given host_patch. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified host patch, removing it from the disk. This does NOT reverse the patch
|
||||
* @deprecated
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
@Deprecated public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.host_patch.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified host patch, removing it from the disk. This does NOT reverse the patch
|
||||
* @deprecated
|
||||
*
|
||||
*/
|
||||
@Deprecated public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the selected patch and return its output
|
||||
* @deprecated
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
@Deprecated public Task applyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.host_patch.apply";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the selected patch and return its output
|
||||
* @deprecated
|
||||
*
|
||||
* @return the output of the patch application process
|
||||
*/
|
||||
@Deprecated public String apply(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.apply";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the host_patchs known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<HostPatch> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfHostPatch(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of host_patch references to host_patch records for all host_patchs known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<HostPatch, HostPatch.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "host_patch.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfHostPatchHostPatchRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
76
deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java
vendored
Normal file
76
deps/XenServerJava/src/com/xensource/xenapi/Marshalling.java
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
/* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Marshalls Java types onto the wire.
|
||||
* Does not cope with records. Use individual record.toMap()
|
||||
*/
|
||||
public final class Marshalling {
|
||||
/**
|
||||
* Converts Integers to Strings
|
||||
* and Sets to Lists recursively.
|
||||
*/
|
||||
public static Object toXMLRPC(Object o) {
|
||||
if (o instanceof String ||
|
||||
o instanceof Boolean ||
|
||||
o instanceof Double ||
|
||||
o instanceof Date) {
|
||||
return o;
|
||||
} else if (o instanceof Long) {
|
||||
return o.toString();
|
||||
} else if (o instanceof Map) {
|
||||
Map<Object, Object> result = new HashMap<Object, Object>();
|
||||
Map m = (Map)o;
|
||||
for (Object k : m.keySet())
|
||||
{
|
||||
result.put(toXMLRPC(k), toXMLRPC(m.get(k)));
|
||||
}
|
||||
return result;
|
||||
} else if (o instanceof Set) {
|
||||
List<Object> result = new ArrayList<Object>();
|
||||
for (Object e : ((Set)o))
|
||||
{
|
||||
result.add(toXMLRPC(e));
|
||||
}
|
||||
return result;
|
||||
} else if (o instanceof XenAPIObject) {
|
||||
return ((XenAPIObject) o).toWireString();
|
||||
} else if (o instanceof Enum) {
|
||||
return o.toString();
|
||||
}else if (o == null){
|
||||
return "";
|
||||
} else {
|
||||
throw new RuntimeException ("=============don't know how to marshall:({[" + o + "]})");
|
||||
}
|
||||
}
|
||||
}
|
||||
320
deps/XenServerJava/src/com/xensource/xenapi/Message.java
vendored
Normal file
320
deps/XenServerJava/src/com/xensource/xenapi/Message.java
vendored
Normal file
@ -0,0 +1,320 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* An message for the attention of the administrator
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Message extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Message(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Message, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Message)
|
||||
{
|
||||
Message other = (Message) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Message
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "name", this.name);
|
||||
print.printf("%1$20s: %2$s\n", "priority", this.priority);
|
||||
print.printf("%1$20s: %2$s\n", "cls", this.cls);
|
||||
print.printf("%1$20s: %2$s\n", "objUuid", this.objUuid);
|
||||
print.printf("%1$20s: %2$s\n", "timestamp", this.timestamp);
|
||||
print.printf("%1$20s: %2$s\n", "body", this.body);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a message.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name", this.name == null ? "" : this.name);
|
||||
map.put("priority", this.priority == null ? 0 : this.priority);
|
||||
map.put("cls", this.cls == null ? Types.Cls.UNRECOGNIZED : this.cls);
|
||||
map.put("obj_uuid", this.objUuid == null ? "" : this.objUuid);
|
||||
map.put("timestamp", this.timestamp == null ? new Date(0) : this.timestamp);
|
||||
map.put("body", this.body == null ? "" : this.body);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* The name of the message
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* The message priority, 0 being low priority
|
||||
*/
|
||||
public Long priority;
|
||||
/**
|
||||
* The class of the object this message is associated with
|
||||
*/
|
||||
public Types.Cls cls;
|
||||
/**
|
||||
* The uuid of the object this message is associated with
|
||||
*/
|
||||
public String objUuid;
|
||||
/**
|
||||
* The time at which the message was created
|
||||
*/
|
||||
public Date timestamp;
|
||||
/**
|
||||
* The body of the message
|
||||
*/
|
||||
public String body;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param name The name of the message
|
||||
* @param priority The priority of the message
|
||||
* @param cls The class of object this message is associated with
|
||||
* @param objUuid The uuid of the object this message is associated with
|
||||
* @param body The body of the message
|
||||
* @return The reference of the created message
|
||||
*/
|
||||
public static Message create(Connection c, String name, Long priority, Types.Cls cls, String objUuid, String body) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "message.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(priority), Marshalling.toXMLRPC(cls), Marshalling.toXMLRPC(objUuid), Marshalling.toXMLRPC(body)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMessage(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "message.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param cls The class of object
|
||||
* @param objUuid The uuid of the object
|
||||
* @param since The cutoff time
|
||||
* @return The relevant messages
|
||||
*/
|
||||
public static Map<Message, Message.Record> get(Connection c, Types.Cls cls, String objUuid, Date since) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "message.get";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(cls), Marshalling.toXMLRPC(objUuid), Marshalling.toXMLRPC(since)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfMessageMessageRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return The references to the messages
|
||||
*/
|
||||
public static Set<Message> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "message.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfMessage(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param since The cutoff time
|
||||
* @return The relevant messages
|
||||
*/
|
||||
public static Map<Message, Message.Record> getSince(Connection c, Date since) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "message.get_since";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(since)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfMessageMessageRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return The message record
|
||||
*/
|
||||
public Message.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "message.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMessageRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param uuid The uuid of the message
|
||||
* @return The message reference
|
||||
*/
|
||||
public static Message getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "message.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMessage(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return The messages
|
||||
*/
|
||||
public static Map<Message, Message.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "message.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfMessageMessageRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param expr The expression to match (not currently used)
|
||||
* @return The messages
|
||||
*/
|
||||
public static Map<Message, Message.Record> getAllRecordsWhere(Connection c, String expr) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "message.get_all_records_where";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(expr)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfMessageMessageRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
791
deps/XenServerJava/src/com/xensource/xenapi/Network.java
vendored
Normal file
791
deps/XenServerJava/src/com/xensource/xenapi/Network.java
vendored
Normal file
@ -0,0 +1,791 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A virtual network
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Network extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Network(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Network, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Network)
|
||||
{
|
||||
Network other = (Network) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Network
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations);
|
||||
print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations);
|
||||
print.printf("%1$20s: %2$s\n", "VIFs", this.VIFs);
|
||||
print.printf("%1$20s: %2$s\n", "PIFs", this.PIFs);
|
||||
print.printf("%1$20s: %2$s\n", "MTU", this.MTU);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
print.printf("%1$20s: %2$s\n", "bridge", this.bridge);
|
||||
print.printf("%1$20s: %2$s\n", "blobs", this.blobs);
|
||||
print.printf("%1$20s: %2$s\n", "tags", this.tags);
|
||||
print.printf("%1$20s: %2$s\n", "defaultLockingMode", this.defaultLockingMode);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a network.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet<Types.NetworkOperations>() : this.allowedOperations);
|
||||
map.put("current_operations", this.currentOperations == null ? new HashMap<String, Types.NetworkOperations>() : this.currentOperations);
|
||||
map.put("VIFs", this.VIFs == null ? new LinkedHashSet<VIF>() : this.VIFs);
|
||||
map.put("PIFs", this.PIFs == null ? new LinkedHashSet<PIF>() : this.PIFs);
|
||||
map.put("MTU", this.MTU == null ? 0 : this.MTU);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
map.put("bridge", this.bridge == null ? "" : this.bridge);
|
||||
map.put("blobs", this.blobs == null ? new HashMap<String, Blob>() : this.blobs);
|
||||
map.put("tags", this.tags == null ? new LinkedHashSet<String>() : this.tags);
|
||||
map.put("default_locking_mode", this.defaultLockingMode == null ? Types.NetworkDefaultLockingMode.UNRECOGNIZED : this.defaultLockingMode);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* a human-readable name
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* a notes field containing human-readable description
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client.
|
||||
*/
|
||||
public Set<Types.NetworkOperations> allowedOperations;
|
||||
/**
|
||||
* links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task.
|
||||
*/
|
||||
public Map<String, Types.NetworkOperations> currentOperations;
|
||||
/**
|
||||
* list of connected vifs
|
||||
*/
|
||||
public Set<VIF> VIFs;
|
||||
/**
|
||||
* list of connected pifs
|
||||
*/
|
||||
public Set<PIF> PIFs;
|
||||
/**
|
||||
* MTU in octets
|
||||
*/
|
||||
public Long MTU;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
/**
|
||||
* name of the bridge corresponding to this network on the local host
|
||||
*/
|
||||
public String bridge;
|
||||
/**
|
||||
* Binary blobs associated with this network
|
||||
*/
|
||||
public Map<String, Blob> blobs;
|
||||
/**
|
||||
* user-specified tags for categorization purposes
|
||||
*/
|
||||
public Set<String> tags;
|
||||
/**
|
||||
* The network will use this value to determine the behaviour of all VIFs where locking_mode = default
|
||||
*/
|
||||
public Types.NetworkDefaultLockingMode defaultLockingMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given network.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Network.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toNetworkRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the network instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Network getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toNetwork(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new network instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, Network.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.network.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new network instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return reference to the newly created object
|
||||
*/
|
||||
public static Network create(Connection c, Network.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toNetwork(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified network instance.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.network.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified network instance.
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the network instances with the given label.
|
||||
*
|
||||
* @param label label of object to return
|
||||
* @return references to objects with matching names
|
||||
*/
|
||||
public static Set<Network> getByNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_by_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfNetwork(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/label field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/description field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameDescription(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the allowed_operations field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<Types.NetworkOperations> getAllowedOperations(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_allowed_operations";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfNetworkOperations(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current_operations field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, Types.NetworkOperations> getCurrentOperations(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_current_operations";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringNetworkOperations(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VIFs field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<VIF> getVIFs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_VIFs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVIF(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PIFs field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<PIF> getPIFs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_PIFs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPIF(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MTU field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getMTU(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_MTU";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the bridge field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getBridge(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_bridge";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the blobs field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, Blob> getBlobs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_blobs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringBlob(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tags field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<String> getTags(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_tags";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default_locking_mode field of the given network.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Types.NetworkDefaultLockingMode getDefaultLockingMode(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_default_locking_mode";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toNetworkDefaultLockingMode(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name/label field of the given network.
|
||||
*
|
||||
* @param label New value to set
|
||||
*/
|
||||
public void setNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.set_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name/description field of the given network.
|
||||
*
|
||||
* @param description New value to set
|
||||
*/
|
||||
public void setNameDescription(Connection c, String description) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.set_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the MTU field of the given network.
|
||||
*
|
||||
* @param MTU New value to set
|
||||
*/
|
||||
public void setMTU(Connection c, Long MTU) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.set_MTU";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(MTU)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given network.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given network.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given network. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tags field of the given network.
|
||||
*
|
||||
* @param tags New value to set
|
||||
*/
|
||||
public void setTags(Connection c, Set<String> tags) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.set_tags";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(tags)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given value to the tags field of the given network. If the value is already in that Set, then do nothing.
|
||||
*
|
||||
* @param value New value to add
|
||||
*/
|
||||
public void addTags(Connection c, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.add_tags";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given value from the tags field of the given network. If the value is not in that Set, then do nothing.
|
||||
*
|
||||
* @param value Value to remove
|
||||
*/
|
||||
public void removeTags(Connection c, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.remove_tags";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a placeholder for a named binary blob of data that is associated with this pool
|
||||
*
|
||||
* @param name The name associated with the blob
|
||||
* @param mimeType The mime type for the data. Empty string translates to application/octet-stream
|
||||
* @param _public True if the blob should be publicly available
|
||||
* @return Task
|
||||
*/
|
||||
public Task createNewBlobAsync(Connection c, String name, String mimeType, Boolean _public) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.network.create_new_blob";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a placeholder for a named binary blob of data that is associated with this pool
|
||||
*
|
||||
* @param name The name associated with the blob
|
||||
* @param mimeType The mime type for the data. Empty string translates to application/octet-stream
|
||||
* @param _public True if the blob should be publicly available
|
||||
* @return The reference of the blob, needed for populating its data
|
||||
*/
|
||||
public Blob createNewBlob(Connection c, String name, String mimeType, Boolean _public) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.create_new_blob";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(name), Marshalling.toXMLRPC(mimeType), Marshalling.toXMLRPC(_public)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBlob(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default locking mode for VIFs attached to this network
|
||||
*
|
||||
* @param value The default locking mode for VIFs attached to this network.
|
||||
* @return Task
|
||||
*/
|
||||
public Task setDefaultLockingModeAsync(Connection c, Types.NetworkDefaultLockingMode value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.network.set_default_locking_mode";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default locking mode for VIFs attached to this network
|
||||
*
|
||||
* @param value The default locking mode for VIFs attached to this network.
|
||||
*/
|
||||
public void setDefaultLockingMode(Connection c, Types.NetworkDefaultLockingMode value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.set_default_locking_mode";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the networks known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Network> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfNetwork(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of network references to network records for all networks known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Network, Network.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "network.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfNetworkNetworkRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
542
deps/XenServerJava/src/com/xensource/xenapi/PBD.java
vendored
Normal file
542
deps/XenServerJava/src/com/xensource/xenapi/PBD.java
vendored
Normal file
@ -0,0 +1,542 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* The physical block devices through which hosts access SRs
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class PBD extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
PBD(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a PBD, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof PBD)
|
||||
{
|
||||
PBD other = (PBD) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a PBD
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "host", this.host);
|
||||
print.printf("%1$20s: %2$s\n", "SR", this.SR);
|
||||
print.printf("%1$20s: %2$s\n", "deviceConfig", this.deviceConfig);
|
||||
print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a PBD.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host);
|
||||
map.put("SR", this.SR == null ? new SR("OpaqueRef:NULL") : this.SR);
|
||||
map.put("device_config", this.deviceConfig == null ? new HashMap<String, String>() : this.deviceConfig);
|
||||
map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* physical machine on which the pbd is available
|
||||
*/
|
||||
public Host host;
|
||||
/**
|
||||
* the storage repository that the pbd realises
|
||||
*/
|
||||
public SR SR;
|
||||
/**
|
||||
* a config string to string map that is provided to the host's SR-backend-driver
|
||||
*/
|
||||
public Map<String, String> deviceConfig;
|
||||
/**
|
||||
* is the SR currently attached on this host?
|
||||
*/
|
||||
public Boolean currentlyAttached;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given PBD.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public PBD.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPBDRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the PBD instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static PBD getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPBD(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PBD instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, PBD.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.PBD.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PBD instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return reference to the newly created object
|
||||
*/
|
||||
public static PBD create(Connection c, PBD.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPBD(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified PBD instance.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.PBD.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified PBD instance.
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given PBD.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host field of the given PBD.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Host getHost(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_host";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHost(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SR field of the given PBD.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public SR getSR(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_SR";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSR(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the device_config field of the given PBD.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getDeviceConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_device_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently_attached field of the given PBD.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getCurrentlyAttached(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_currently_attached";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given PBD.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given PBD.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given PBD.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given PBD. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the specified PBD, causing the referenced SR to be attached and scanned
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task plugAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.SrUnknownDriver {
|
||||
String method_call = "Async.PBD.plug";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the specified PBD, causing the referenced SR to be attached and scanned
|
||||
*
|
||||
*/
|
||||
public void plug(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.SrUnknownDriver {
|
||||
String method_call = "PBD.plug";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate the specified PBD, causing the referenced SR to be detached and nolonger scanned
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task unplugAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.PBD.unplug";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate the specified PBD, causing the referenced SR to be detached and nolonger scanned
|
||||
*
|
||||
*/
|
||||
public void unplug(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.unplug";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PBD's device_config field
|
||||
*
|
||||
* @param value The new value of the PBD's device_config
|
||||
* @return Task
|
||||
*/
|
||||
public Task setDeviceConfigAsync(Connection c, Map<String, String> value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.PBD.set_device_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the PBD's device_config field
|
||||
*
|
||||
* @param value The new value of the PBD's device_config
|
||||
*/
|
||||
public void setDeviceConfig(Connection c, Map<String, String> value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.set_device_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the PBDs known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<PBD> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPBD(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of PBD references to PBD records for all PBDs known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<PBD, PBD.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PBD.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfPBDPBDRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
418
deps/XenServerJava/src/com/xensource/xenapi/PCI.java
vendored
Normal file
418
deps/XenServerJava/src/com/xensource/xenapi/PCI.java
vendored
Normal file
@ -0,0 +1,418 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A PCI device
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class PCI extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
PCI(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a PCI, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof PCI)
|
||||
{
|
||||
PCI other = (PCI) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a PCI
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "clazzName", this.clazzName);
|
||||
print.printf("%1$20s: %2$s\n", "vendorName", this.vendorName);
|
||||
print.printf("%1$20s: %2$s\n", "deviceName", this.deviceName);
|
||||
print.printf("%1$20s: %2$s\n", "host", this.host);
|
||||
print.printf("%1$20s: %2$s\n", "pciId", this.pciId);
|
||||
print.printf("%1$20s: %2$s\n", "dependencies", this.dependencies);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a PCI.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("class_name", this.clazzName == null ? "" : this.clazzName);
|
||||
map.put("vendor_name", this.vendorName == null ? "" : this.vendorName);
|
||||
map.put("device_name", this.deviceName == null ? "" : this.deviceName);
|
||||
map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host);
|
||||
map.put("pci_id", this.pciId == null ? "" : this.pciId);
|
||||
map.put("dependencies", this.dependencies == null ? new LinkedHashSet<PCI>() : this.dependencies);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* PCI class name
|
||||
*/
|
||||
public String clazzName;
|
||||
/**
|
||||
* Vendor name
|
||||
*/
|
||||
public String vendorName;
|
||||
/**
|
||||
* Device name
|
||||
*/
|
||||
public String deviceName;
|
||||
/**
|
||||
* Physical machine that owns the PCI device
|
||||
*/
|
||||
public Host host;
|
||||
/**
|
||||
* PCI ID of the physical device
|
||||
*/
|
||||
public String pciId;
|
||||
/**
|
||||
* List of dependent PCI devices
|
||||
*/
|
||||
public Set<PCI> dependencies;
|
||||
/**
|
||||
* Additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given PCI.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public PCI.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPCIRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the PCI instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static PCI getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPCI(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given PCI.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class_name field of the given PCI.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getClazzName(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_class_name";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vendor_name field of the given PCI.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getVendorName(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_vendor_name";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the device_name field of the given PCI.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getDeviceName(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_device_name";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host field of the given PCI.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Host getHost(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_host";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHost(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pci_id field of the given PCI.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getPciId(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_pci_id";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dependencies field of the given PCI.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<PCI> getDependencies(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_dependencies";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPCI(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given PCI.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given PCI.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given PCI.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given PCI. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the PCIs known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<PCI> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPCI(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of PCI references to PCI records for all PCIs known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<PCI, PCI.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PCI.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfPCIPCIRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
349
deps/XenServerJava/src/com/xensource/xenapi/PGPU.java
vendored
Normal file
349
deps/XenServerJava/src/com/xensource/xenapi/PGPU.java
vendored
Normal file
@ -0,0 +1,349 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A physical GPU (pGPU)
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class PGPU extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
PGPU(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a PGPU, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof PGPU)
|
||||
{
|
||||
PGPU other = (PGPU) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a PGPU
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "PCI", this.PCI);
|
||||
print.printf("%1$20s: %2$s\n", "GPUGroup", this.GPUGroup);
|
||||
print.printf("%1$20s: %2$s\n", "host", this.host);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a PGPU.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("PCI", this.PCI == null ? new PCI("OpaqueRef:NULL") : this.PCI);
|
||||
map.put("GPU_group", this.GPUGroup == null ? new GPUGroup("OpaqueRef:NULL") : this.GPUGroup);
|
||||
map.put("host", this.host == null ? new Host("OpaqueRef:NULL") : this.host);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* Link to underlying PCI device
|
||||
*/
|
||||
public PCI PCI;
|
||||
/**
|
||||
* GPU group the pGPU is contained in
|
||||
*/
|
||||
public GPUGroup GPUGroup;
|
||||
/**
|
||||
* Host that own the GPU
|
||||
*/
|
||||
public Host host;
|
||||
/**
|
||||
* Additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given PGPU.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public PGPU.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPGPURecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the PGPU instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static PGPU getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPGPU(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given PGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PCI field of the given PGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public PCI getPCI(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.get_PCI";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPCI(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the GPU_group field of the given PGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public GPUGroup getGPUGroup(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.get_GPU_group";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toGPUGroup(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host field of the given PGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Host getHost(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.get_host";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHost(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given PGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given PGPU.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given PGPU.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given PGPU. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the PGPUs known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<PGPU> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPGPU(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of PGPU references to PGPU records for all PGPUs known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<PGPU, PGPU.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PGPU.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfPGPUPGPURecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
1374
deps/XenServerJava/src/com/xensource/xenapi/PIF.java
vendored
Normal file
1374
deps/XenServerJava/src/com/xensource/xenapi/PIF.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
533
deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java
vendored
Normal file
533
deps/XenServerJava/src/com/xensource/xenapi/PIFMetrics.java
vendored
Normal file
@ -0,0 +1,533 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* The metrics associated with a physical network interface
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class PIFMetrics extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
PIFMetrics(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a PIFMetrics, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof PIFMetrics)
|
||||
{
|
||||
PIFMetrics other = (PIFMetrics) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a PIFMetrics
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "ioReadKbs", this.ioReadKbs);
|
||||
print.printf("%1$20s: %2$s\n", "ioWriteKbs", this.ioWriteKbs);
|
||||
print.printf("%1$20s: %2$s\n", "carrier", this.carrier);
|
||||
print.printf("%1$20s: %2$s\n", "vendorId", this.vendorId);
|
||||
print.printf("%1$20s: %2$s\n", "vendorName", this.vendorName);
|
||||
print.printf("%1$20s: %2$s\n", "deviceId", this.deviceId);
|
||||
print.printf("%1$20s: %2$s\n", "deviceName", this.deviceName);
|
||||
print.printf("%1$20s: %2$s\n", "speed", this.speed);
|
||||
print.printf("%1$20s: %2$s\n", "duplex", this.duplex);
|
||||
print.printf("%1$20s: %2$s\n", "pciBusPath", this.pciBusPath);
|
||||
print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a PIF_metrics.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("io_read_kbs", this.ioReadKbs == null ? 0.0 : this.ioReadKbs);
|
||||
map.put("io_write_kbs", this.ioWriteKbs == null ? 0.0 : this.ioWriteKbs);
|
||||
map.put("carrier", this.carrier == null ? false : this.carrier);
|
||||
map.put("vendor_id", this.vendorId == null ? "" : this.vendorId);
|
||||
map.put("vendor_name", this.vendorName == null ? "" : this.vendorName);
|
||||
map.put("device_id", this.deviceId == null ? "" : this.deviceId);
|
||||
map.put("device_name", this.deviceName == null ? "" : this.deviceName);
|
||||
map.put("speed", this.speed == null ? 0 : this.speed);
|
||||
map.put("duplex", this.duplex == null ? false : this.duplex);
|
||||
map.put("pci_bus_path", this.pciBusPath == null ? "" : this.pciBusPath);
|
||||
map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* Read bandwidth (KiB/s)
|
||||
*/
|
||||
public Double ioReadKbs;
|
||||
/**
|
||||
* Write bandwidth (KiB/s)
|
||||
*/
|
||||
public Double ioWriteKbs;
|
||||
/**
|
||||
* Report if the PIF got a carrier or not
|
||||
*/
|
||||
public Boolean carrier;
|
||||
/**
|
||||
* Report vendor ID
|
||||
*/
|
||||
public String vendorId;
|
||||
/**
|
||||
* Report vendor name
|
||||
*/
|
||||
public String vendorName;
|
||||
/**
|
||||
* Report device ID
|
||||
*/
|
||||
public String deviceId;
|
||||
/**
|
||||
* Report device name
|
||||
*/
|
||||
public String deviceName;
|
||||
/**
|
||||
* Speed of the link (if available)
|
||||
*/
|
||||
public Long speed;
|
||||
/**
|
||||
* Full duplex capability of the link (if available)
|
||||
*/
|
||||
public Boolean duplex;
|
||||
/**
|
||||
* PCI bus path of the pif (if available)
|
||||
*/
|
||||
public String pciBusPath;
|
||||
/**
|
||||
* Time at which this information was last updated
|
||||
*/
|
||||
public Date lastUpdated;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given PIF_metrics.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public PIFMetrics.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPIFMetricsRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the PIF_metrics instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static PIFMetrics getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPIFMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the io/read_kbs field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Double getIoReadKbs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_io_read_kbs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDouble(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the io/write_kbs field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Double getIoWriteKbs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_io_write_kbs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDouble(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the carrier field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getCarrier(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_carrier";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vendor_id field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getVendorId(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_vendor_id";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vendor_name field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getVendorName(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_vendor_name";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the device_id field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getDeviceId(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_device_id";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the device_name field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getDeviceName(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_device_name";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the speed field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getSpeed(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_speed";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the duplex field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getDuplex(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_duplex";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pci_bus_path field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getPciBusPath(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_pci_bus_path";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last_updated field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getLastUpdated(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_last_updated";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given PIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given PIF_metrics.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given PIF_metrics.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given PIF_metrics. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the PIF_metrics instances known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<PIFMetrics> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPIFMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of PIF_metrics references to PIF_metrics records for all PIF_metrics instances known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<PIFMetrics, PIFMetrics.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "PIF_metrics.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfPIFMetricsPIFMetricsRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
2324
deps/XenServerJava/src/com/xensource/xenapi/Pool.java
vendored
Normal file
2324
deps/XenServerJava/src/com/xensource/xenapi/Pool.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
693
deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java
vendored
Normal file
693
deps/XenServerJava/src/com/xensource/xenapi/PoolPatch.java
vendored
Normal file
@ -0,0 +1,693 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* Pool-wide patches
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class PoolPatch extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
PoolPatch(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a PoolPatch, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof PoolPatch)
|
||||
{
|
||||
PoolPatch other = (PoolPatch) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a PoolPatch
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "version", this.version);
|
||||
print.printf("%1$20s: %2$s\n", "size", this.size);
|
||||
print.printf("%1$20s: %2$s\n", "poolApplied", this.poolApplied);
|
||||
print.printf("%1$20s: %2$s\n", "hostPatches", this.hostPatches);
|
||||
print.printf("%1$20s: %2$s\n", "afterApplyGuidance", this.afterApplyGuidance);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a pool_patch.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("version", this.version == null ? "" : this.version);
|
||||
map.put("size", this.size == null ? 0 : this.size);
|
||||
map.put("pool_applied", this.poolApplied == null ? false : this.poolApplied);
|
||||
map.put("host_patches", this.hostPatches == null ? new LinkedHashSet<HostPatch>() : this.hostPatches);
|
||||
map.put("after_apply_guidance", this.afterApplyGuidance == null ? new LinkedHashSet<Types.AfterApplyGuidance>() : this.afterApplyGuidance);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* a human-readable name
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* a notes field containing human-readable description
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* Patch version number
|
||||
*/
|
||||
public String version;
|
||||
/**
|
||||
* Size of the patch
|
||||
*/
|
||||
public Long size;
|
||||
/**
|
||||
* This patch should be applied across the entire pool
|
||||
*/
|
||||
public Boolean poolApplied;
|
||||
/**
|
||||
* This hosts this patch is applied to.
|
||||
*/
|
||||
public Set<HostPatch> hostPatches;
|
||||
/**
|
||||
* What the client should do after this patch has been applied.
|
||||
*/
|
||||
public Set<Types.AfterApplyGuidance> afterApplyGuidance;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given pool_patch.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public PoolPatch.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPoolPatchRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the pool_patch instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static PoolPatch getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPoolPatch(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the pool_patch instances with the given label.
|
||||
*
|
||||
* @param label label of object to return
|
||||
* @return references to objects with matching names
|
||||
*/
|
||||
public static Set<PoolPatch> getByNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_by_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPoolPatch(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given pool_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/label field of the given pool_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/description field of the given pool_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameDescription(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version field of the given pool_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getVersion(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_version";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size field of the given pool_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getSize(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_size";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pool_applied field of the given pool_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getPoolApplied(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_pool_applied";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the host_patches field of the given pool_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<HostPatch> getHostPatches(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_host_patches";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfHostPatch(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the after_apply_guidance field of the given pool_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<Types.AfterApplyGuidance> getAfterApplyGuidance(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_after_apply_guidance";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfAfterApplyGuidance(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given pool_patch.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given pool_patch.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given pool_patch.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given pool_patch. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the selected patch to a host and return its output
|
||||
*
|
||||
* @param host The host to apply the patch too
|
||||
* @return Task
|
||||
*/
|
||||
public Task applyAsync(Connection c, Host host) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.pool_patch.apply";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the selected patch to a host and return its output
|
||||
*
|
||||
* @param host The host to apply the patch too
|
||||
* @return the output of the patch application process
|
||||
*/
|
||||
public String apply(Connection c, Host host) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.apply";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the selected patch to all hosts in the pool and return a map of host_ref -> patch output
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task poolApplyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.pool_patch.pool_apply";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the selected patch to all hosts in the pool and return a map of host_ref -> patch output
|
||||
*
|
||||
*/
|
||||
public void poolApply(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.pool_apply";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the precheck stage of the selected patch on a host and return its output
|
||||
*
|
||||
* @param host The host to run the prechecks on
|
||||
* @return Task
|
||||
*/
|
||||
public Task precheckAsync(Connection c, Host host) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.pool_patch.precheck";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the precheck stage of the selected patch on a host and return its output
|
||||
*
|
||||
* @param host The host to run the prechecks on
|
||||
* @return the output of the patch prechecks
|
||||
*/
|
||||
public String precheck(Connection c, Host host) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.precheck";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patch's files from the server
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task cleanAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.pool_patch.clean";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patch's files from the server
|
||||
*
|
||||
*/
|
||||
public void clean(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.clean";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patch's files from all hosts in the pool, but does not remove the database entries
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task poolCleanAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.pool_patch.pool_clean";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patch's files from all hosts in the pool, but does not remove the database entries
|
||||
*
|
||||
*/
|
||||
public void poolClean(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.pool_clean";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patch's files from all hosts in the pool, and removes the database entries. Only works on unapplied patches.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.pool_patch.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patch's files from all hosts in the pool, and removes the database entries. Only works on unapplied patches.
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patch's files from the specified host
|
||||
*
|
||||
* @param host The host on which to clean the patch
|
||||
* @return Task
|
||||
*/
|
||||
public Task cleanOnHostAsync(Connection c, Host host) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.pool_patch.clean_on_host";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the patch's files from the specified host
|
||||
*
|
||||
* @param host The host on which to clean the patch
|
||||
*/
|
||||
public void cleanOnHost(Connection c, Host host) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.clean_on_host";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(host)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the pool_patchs known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<PoolPatch> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfPoolPatch(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of pool_patch references to pool_patch records for all pool_patchs known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<PoolPatch, PoolPatch.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "pool_patch.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfPoolPatchPoolPatchRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
364
deps/XenServerJava/src/com/xensource/xenapi/Role.java
vendored
Normal file
364
deps/XenServerJava/src/com/xensource/xenapi/Role.java
vendored
Normal file
@ -0,0 +1,364 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A set of permissions associated with a subject
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Role extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Role(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Role, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Role)
|
||||
{
|
||||
Role other = (Role) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Role
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "subroles", this.subroles);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a role.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("subroles", this.subroles == null ? new LinkedHashSet<Role>() : this.subroles);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* a short user-friendly name for the role
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* what this role is for
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* a list of pointers to other roles or permissions
|
||||
*/
|
||||
public Set<Role> subroles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given role.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Role.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toRoleRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the role instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Role getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toRole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the role instances with the given label.
|
||||
*
|
||||
* @param label label of object to return
|
||||
* @return references to objects with matching names
|
||||
*/
|
||||
public static Set<Role> getByNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_by_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfRole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given role.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/label field of the given role.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/description field of the given role.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameDescription(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subroles field of the given role.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<Role> getSubroles(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_subroles";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfRole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This call returns a list of permissions given a role
|
||||
*
|
||||
* @return a list of permissions
|
||||
*/
|
||||
public Set<Role> getPermissions(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_permissions";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfRole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This call returns a list of permission names given a role
|
||||
*
|
||||
* @return a list of permission names
|
||||
*/
|
||||
public Set<String> getPermissionsNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_permissions_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This call returns a list of roles given a permission
|
||||
*
|
||||
* @return a list of references to roles
|
||||
*/
|
||||
public Set<Role> getByPermission(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_by_permission";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfRole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This call returns a list of roles given a permission name
|
||||
*
|
||||
* @param label The short friendly name of the role
|
||||
* @return a list of references to roles
|
||||
*/
|
||||
public static Set<Role> getByPermissionNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_by_permission_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfRole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the roles known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Role> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfRole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of role references to role records for all roles known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Role, Role.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "role.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfRoleRoleRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
528
deps/XenServerJava/src/com/xensource/xenapi/SM.java
vendored
Normal file
528
deps/XenServerJava/src/com/xensource/xenapi/SM.java
vendored
Normal file
@ -0,0 +1,528 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A storage manager plugin
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class SM extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
SM(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a SM, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof SM)
|
||||
{
|
||||
SM other = (SM) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a SM
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "type", this.type);
|
||||
print.printf("%1$20s: %2$s\n", "vendor", this.vendor);
|
||||
print.printf("%1$20s: %2$s\n", "copyright", this.copyright);
|
||||
print.printf("%1$20s: %2$s\n", "version", this.version);
|
||||
print.printf("%1$20s: %2$s\n", "requiredApiVersion", this.requiredApiVersion);
|
||||
print.printf("%1$20s: %2$s\n", "configuration", this.configuration);
|
||||
print.printf("%1$20s: %2$s\n", "capabilities", this.capabilities);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
print.printf("%1$20s: %2$s\n", "driverFilename", this.driverFilename);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a SM.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("type", this.type == null ? "" : this.type);
|
||||
map.put("vendor", this.vendor == null ? "" : this.vendor);
|
||||
map.put("copyright", this.copyright == null ? "" : this.copyright);
|
||||
map.put("version", this.version == null ? "" : this.version);
|
||||
map.put("required_api_version", this.requiredApiVersion == null ? "" : this.requiredApiVersion);
|
||||
map.put("configuration", this.configuration == null ? new HashMap<String, String>() : this.configuration);
|
||||
map.put("capabilities", this.capabilities == null ? new LinkedHashSet<String>() : this.capabilities);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
map.put("driver_filename", this.driverFilename == null ? "" : this.driverFilename);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* a human-readable name
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* a notes field containing human-readable description
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* SR.type
|
||||
*/
|
||||
public String type;
|
||||
/**
|
||||
* Vendor who created this plugin
|
||||
*/
|
||||
public String vendor;
|
||||
/**
|
||||
* Entity which owns the copyright of this plugin
|
||||
*/
|
||||
public String copyright;
|
||||
/**
|
||||
* Version of the plugin
|
||||
*/
|
||||
public String version;
|
||||
/**
|
||||
* Minimum SM API version required on the server
|
||||
*/
|
||||
public String requiredApiVersion;
|
||||
/**
|
||||
* names and descriptions of device config keys
|
||||
*/
|
||||
public Map<String, String> configuration;
|
||||
/**
|
||||
* capabilities of the SM plugin
|
||||
*/
|
||||
public Set<String> capabilities;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
/**
|
||||
* filename of the storage driver
|
||||
*/
|
||||
public String driverFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given SM.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public SM.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSMRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the SM instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static SM getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the SM instances with the given label.
|
||||
*
|
||||
* @param label label of object to return
|
||||
* @return references to objects with matching names
|
||||
*/
|
||||
public static Set<SM> getByNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_by_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfSM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/label field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/description field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameDescription(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getType(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_type";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the vendor field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getVendor(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_vendor";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the copyright field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getCopyright(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_copyright";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getVersion(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_version";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the required_api_version field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getRequiredApiVersion(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_required_api_version";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getConfiguration(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_configuration";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the capabilities field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<String> getCapabilities(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_capabilities";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the driver_filename field of the given SM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getDriverFilename(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_driver_filename";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given SM.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given SM.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given SM. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the SMs known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<SM> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfSM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of SM references to SM records for all SMs known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<SM, SM.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "SM.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfSMSMRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
1639
deps/XenServerJava/src/com/xensource/xenapi/SR.java
vendored
Normal file
1639
deps/XenServerJava/src/com/xensource/xenapi/SR.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
389
deps/XenServerJava/src/com/xensource/xenapi/Secret.java
vendored
Normal file
389
deps/XenServerJava/src/com/xensource/xenapi/Secret.java
vendored
Normal file
@ -0,0 +1,389 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A secret
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Secret extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Secret(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Secret, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Secret)
|
||||
{
|
||||
Secret other = (Secret) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Secret
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "value", this.value);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a secret.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("value", this.value == null ? "" : this.value);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* the secret
|
||||
*/
|
||||
public String value;
|
||||
/**
|
||||
* other_config
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given secret.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Secret.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSecretRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the secret instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Secret getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSecret(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new secret instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, Secret.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.secret.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new secret instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return reference to the newly created object
|
||||
*/
|
||||
public static Secret create(Connection c, Secret.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSecret(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified secret instance.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.secret.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified secret instance.
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given secret.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value field of the given secret.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getValue(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.get_value";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given secret.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value field of the given secret.
|
||||
*
|
||||
* @param value New value to set
|
||||
*/
|
||||
public void setValue(Connection c, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.set_value";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given secret.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given secret.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given secret. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the secrets known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Secret> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfSecret(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of secret references to secret records for all secrets known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Secret, Secret.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "secret.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfSecretSecretRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
675
deps/XenServerJava/src/com/xensource/xenapi/Session.java
vendored
Normal file
675
deps/XenServerJava/src/com/xensource/xenapi/Session.java
vendored
Normal file
@ -0,0 +1,675 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A session
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Session extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Session(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Session, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Session)
|
||||
{
|
||||
Session other = (Session) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Session
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "thisHost", this.thisHost);
|
||||
print.printf("%1$20s: %2$s\n", "thisUser", this.thisUser);
|
||||
print.printf("%1$20s: %2$s\n", "lastActive", this.lastActive);
|
||||
print.printf("%1$20s: %2$s\n", "pool", this.pool);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
print.printf("%1$20s: %2$s\n", "isLocalSuperuser", this.isLocalSuperuser);
|
||||
print.printf("%1$20s: %2$s\n", "subject", this.subject);
|
||||
print.printf("%1$20s: %2$s\n", "validationTime", this.validationTime);
|
||||
print.printf("%1$20s: %2$s\n", "authUserSid", this.authUserSid);
|
||||
print.printf("%1$20s: %2$s\n", "authUserName", this.authUserName);
|
||||
print.printf("%1$20s: %2$s\n", "rbacPermissions", this.rbacPermissions);
|
||||
print.printf("%1$20s: %2$s\n", "tasks", this.tasks);
|
||||
print.printf("%1$20s: %2$s\n", "parent", this.parent);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a session.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("this_host", this.thisHost == null ? new Host("OpaqueRef:NULL") : this.thisHost);
|
||||
map.put("this_user", this.thisUser == null ? new User("OpaqueRef:NULL") : this.thisUser);
|
||||
map.put("last_active", this.lastActive == null ? new Date(0) : this.lastActive);
|
||||
map.put("pool", this.pool == null ? false : this.pool);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
map.put("is_local_superuser", this.isLocalSuperuser == null ? false : this.isLocalSuperuser);
|
||||
map.put("subject", this.subject == null ? new Subject("OpaqueRef:NULL") : this.subject);
|
||||
map.put("validation_time", this.validationTime == null ? new Date(0) : this.validationTime);
|
||||
map.put("auth_user_sid", this.authUserSid == null ? "" : this.authUserSid);
|
||||
map.put("auth_user_name", this.authUserName == null ? "" : this.authUserName);
|
||||
map.put("rbac_permissions", this.rbacPermissions == null ? new LinkedHashSet<String>() : this.rbacPermissions);
|
||||
map.put("tasks", this.tasks == null ? new LinkedHashSet<Task>() : this.tasks);
|
||||
map.put("parent", this.parent == null ? new Session("OpaqueRef:NULL") : this.parent);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* Currently connected host
|
||||
*/
|
||||
public Host thisHost;
|
||||
/**
|
||||
* Currently connected user
|
||||
*/
|
||||
public User thisUser;
|
||||
/**
|
||||
* Timestamp for last time session was active
|
||||
*/
|
||||
public Date lastActive;
|
||||
/**
|
||||
* True if this session relates to a intra-pool login, false otherwise
|
||||
*/
|
||||
public Boolean pool;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
/**
|
||||
* true iff this session was created using local superuser credentials
|
||||
*/
|
||||
public Boolean isLocalSuperuser;
|
||||
/**
|
||||
* references the subject instance that created the session. If a session instance has is_local_superuser set, then the value of this field is undefined.
|
||||
*/
|
||||
public Subject subject;
|
||||
/**
|
||||
* time when session was last validated
|
||||
*/
|
||||
public Date validationTime;
|
||||
/**
|
||||
* the subject identifier of the user that was externally authenticated. If a session instance has is_local_superuser set, then the value of this field is undefined.
|
||||
*/
|
||||
public String authUserSid;
|
||||
/**
|
||||
* the subject name of the user that was externally authenticated. If a session instance has is_local_superuser set, then the value of this field is undefined.
|
||||
*/
|
||||
public String authUserName;
|
||||
/**
|
||||
* list with all RBAC permissions for this session
|
||||
*/
|
||||
public Set<String> rbacPermissions;
|
||||
/**
|
||||
* list of tasks created using the current session
|
||||
*/
|
||||
public Set<Task> tasks;
|
||||
/**
|
||||
* references the parent session that created this session
|
||||
*/
|
||||
public Session parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given session.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Session.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSessionRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the session instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Session getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSession(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the this_host field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Host getThisHost(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_this_host";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHost(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the this_user field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public User getThisUser(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_this_user";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toUser(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last_active field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getLastActive(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_last_active";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the pool field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getPool(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_pool";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the is_local_superuser field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getIsLocalSuperuser(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_is_local_superuser";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subject field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Subject getSubject(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_subject";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSubject(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation_time field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getValidationTime(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_validation_time";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the auth_user_sid field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getAuthUserSid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_auth_user_sid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the auth_user_name field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getAuthUserName(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_auth_user_name";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rbac_permissions field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<String> getRbacPermissions(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_rbac_permissions";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tasks field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<Task> getTasks(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_tasks";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the parent field of the given session.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Session getParent(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_parent";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSession(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given session.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given session.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given session. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate the user, returning a session reference if successful
|
||||
*
|
||||
* @param uname Username for login.
|
||||
* @param pwd Password for login.
|
||||
* @param version Client API version.
|
||||
* @return reference of newly created session
|
||||
*/
|
||||
public static Session loginWithPassword(Connection c, String uname, String pwd, String version) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.SessionAuthenticationFailed {
|
||||
String method_call = "session.login_with_password";
|
||||
Object[] method_params = {Marshalling.toXMLRPC(uname), Marshalling.toXMLRPC(pwd), Marshalling.toXMLRPC(version)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSession(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out of a session
|
||||
*
|
||||
*/
|
||||
public static void logout(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.logout";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the account password; if your session is authenticated with root priviledges then the old_pwd is validated and the new_pwd is set regardless
|
||||
*
|
||||
* @param oldPwd Old password for account
|
||||
* @param newPwd New password for account
|
||||
*/
|
||||
public static void changePassword(Connection c, String oldPwd, String newPwd) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.change_password";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(oldPwd), Marshalling.toXMLRPC(newPwd)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate locally against a slave in emergency mode. Note the resulting sessions are only good for use on this host.
|
||||
*
|
||||
* @param uname Username for login.
|
||||
* @param pwd Password for login.
|
||||
* @return ID of newly created session
|
||||
*/
|
||||
public static Session slaveLocalLoginWithPassword(Connection c, String uname, String pwd) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.slave_local_login_with_password";
|
||||
Object[] method_params = {Marshalling.toXMLRPC(uname), Marshalling.toXMLRPC(pwd)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSession(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out of local session.
|
||||
*
|
||||
*/
|
||||
public static void localLogout(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.local_logout";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the user subject-identifiers of all existing sessions
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public static Task getAllSubjectIdentifiersAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.session.get_all_subject_identifiers";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the user subject-identifiers of all existing sessions
|
||||
*
|
||||
* @return The list of user subject-identifiers of all existing sessions
|
||||
*/
|
||||
public static Set<String> getAllSubjectIdentifiers(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.get_all_subject_identifiers";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out all sessions associated to a user subject-identifier, except the session associated with the context calling this function
|
||||
*
|
||||
* @param subjectIdentifier User subject-identifier of the sessions to be destroyed
|
||||
* @return Task
|
||||
*/
|
||||
public static Task logoutSubjectIdentifierAsync(Connection c, String subjectIdentifier) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.session.logout_subject_identifier";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log out all sessions associated to a user subject-identifier, except the session associated with the context calling this function
|
||||
*
|
||||
* @param subjectIdentifier User subject-identifier of the sessions to be destroyed
|
||||
*/
|
||||
public static void logoutSubjectIdentifier(Connection c, String subjectIdentifier) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "session.logout_subject_identifier";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
396
deps/XenServerJava/src/com/xensource/xenapi/Subject.java
vendored
Normal file
396
deps/XenServerJava/src/com/xensource/xenapi/Subject.java
vendored
Normal file
@ -0,0 +1,396 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A user or group that can log in xapi
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Subject extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Subject(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Subject, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Subject)
|
||||
{
|
||||
Subject other = (Subject) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Subject
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "subjectIdentifier", this.subjectIdentifier);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
print.printf("%1$20s: %2$s\n", "roles", this.roles);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a subject.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("subject_identifier", this.subjectIdentifier == null ? "" : this.subjectIdentifier);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
map.put("roles", this.roles == null ? new LinkedHashSet<Role>() : this.roles);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* the subject identifier, unique in the external directory service
|
||||
*/
|
||||
public String subjectIdentifier;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
/**
|
||||
* the roles associated with this subject
|
||||
*/
|
||||
public Set<Role> roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given subject.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Subject.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSubjectRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the subject instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Subject getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSubject(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new subject instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, Subject.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.subject.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new subject instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return reference to the newly created object
|
||||
*/
|
||||
public static Subject create(Connection c, Subject.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSubject(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified subject instance.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.subject.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified subject instance.
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given subject.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subject_identifier field of the given subject.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getSubjectIdentifier(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.get_subject_identifier";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given subject.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the roles field of the given subject.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<Role> getRoles(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.get_roles";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfRole(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This call adds a new role to a subject
|
||||
*
|
||||
* @param role The unique role reference
|
||||
*/
|
||||
public void addToRoles(Connection c, Role role) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.add_to_roles";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(role)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This call removes a role from a subject
|
||||
*
|
||||
* @param role The unique role reference in the subject's roles field
|
||||
*/
|
||||
public void removeFromRoles(Connection c, Role role) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.remove_from_roles";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(role)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This call returns a list of permission names given a subject
|
||||
*
|
||||
* @return a list of permission names
|
||||
*/
|
||||
public Set<String> getPermissionsNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.get_permissions_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the subjects known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Subject> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfSubject(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of subject references to subject records for all subjects known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Subject, Subject.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "subject.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfSubjectSubjectRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
688
deps/XenServerJava/src/com/xensource/xenapi/Task.java
vendored
Normal file
688
deps/XenServerJava/src/com/xensource/xenapi/Task.java
vendored
Normal file
@ -0,0 +1,688 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A long-running asynchronous task
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Task extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Task(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Task, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Task)
|
||||
{
|
||||
Task other = (Task) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Task
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations);
|
||||
print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations);
|
||||
print.printf("%1$20s: %2$s\n", "created", this.created);
|
||||
print.printf("%1$20s: %2$s\n", "finished", this.finished);
|
||||
print.printf("%1$20s: %2$s\n", "status", this.status);
|
||||
print.printf("%1$20s: %2$s\n", "residentOn", this.residentOn);
|
||||
print.printf("%1$20s: %2$s\n", "progress", this.progress);
|
||||
print.printf("%1$20s: %2$s\n", "type", this.type);
|
||||
print.printf("%1$20s: %2$s\n", "result", this.result);
|
||||
print.printf("%1$20s: %2$s\n", "errorInfo", this.errorInfo);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
print.printf("%1$20s: %2$s\n", "subtaskOf", this.subtaskOf);
|
||||
print.printf("%1$20s: %2$s\n", "subtasks", this.subtasks);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a task.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet<Types.TaskAllowedOperations>() : this.allowedOperations);
|
||||
map.put("current_operations", this.currentOperations == null ? new HashMap<String, Types.TaskAllowedOperations>() : this.currentOperations);
|
||||
map.put("created", this.created == null ? new Date(0) : this.created);
|
||||
map.put("finished", this.finished == null ? new Date(0) : this.finished);
|
||||
map.put("status", this.status == null ? Types.TaskStatusType.UNRECOGNIZED : this.status);
|
||||
map.put("resident_on", this.residentOn == null ? new Host("OpaqueRef:NULL") : this.residentOn);
|
||||
map.put("progress", this.progress == null ? 0.0 : this.progress);
|
||||
map.put("type", this.type == null ? "" : this.type);
|
||||
map.put("result", this.result == null ? "" : this.result);
|
||||
map.put("error_info", this.errorInfo == null ? new LinkedHashSet<String>() : this.errorInfo);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
map.put("subtask_of", this.subtaskOf == null ? new Task("OpaqueRef:NULL") : this.subtaskOf);
|
||||
map.put("subtasks", this.subtasks == null ? new LinkedHashSet<Task>() : this.subtasks);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* a human-readable name
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* a notes field containing human-readable description
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client.
|
||||
*/
|
||||
public Set<Types.TaskAllowedOperations> allowedOperations;
|
||||
/**
|
||||
* links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task.
|
||||
*/
|
||||
public Map<String, Types.TaskAllowedOperations> currentOperations;
|
||||
/**
|
||||
* Time task was created
|
||||
*/
|
||||
public Date created;
|
||||
/**
|
||||
* Time task finished (i.e. succeeded or failed). If task-status is pending, then the value of this field has no meaning
|
||||
*/
|
||||
public Date finished;
|
||||
/**
|
||||
* current status of the task
|
||||
*/
|
||||
public Types.TaskStatusType status;
|
||||
/**
|
||||
* the host on which the task is running
|
||||
*/
|
||||
public Host residentOn;
|
||||
/**
|
||||
* This field contains the estimated fraction of the task which is complete. This field should not be used to determine whether the task is complete - for this the status field of the task should be used.
|
||||
*/
|
||||
public Double progress;
|
||||
/**
|
||||
* if the task has completed successfully, this field contains the type of the encoded result (i.e. name of the class whose reference is in the result field). Undefined otherwise.
|
||||
*/
|
||||
public String type;
|
||||
/**
|
||||
* if the task has completed successfully, this field contains the result value (either Void or an object reference). Undefined otherwise.
|
||||
*/
|
||||
public String result;
|
||||
/**
|
||||
* if the task has failed, this field contains the set of associated error strings. Undefined otherwise.
|
||||
*/
|
||||
public Set<String> errorInfo;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
/**
|
||||
* Ref pointing to the task this is a substask of.
|
||||
*/
|
||||
public Task subtaskOf;
|
||||
/**
|
||||
* List pointing to all the substasks.
|
||||
*/
|
||||
public Set<Task> subtasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given task.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Task.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTaskRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the task instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Task getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the task instances with the given label.
|
||||
*
|
||||
* @param label label of object to return
|
||||
* @return references to objects with matching names
|
||||
*/
|
||||
public static Set<Task> getByNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_by_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/label field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/description field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameDescription(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the allowed_operations field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<Types.TaskAllowedOperations> getAllowedOperations(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_allowed_operations";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfTaskAllowedOperations(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current_operations field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, Types.TaskAllowedOperations> getCurrentOperations(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_current_operations";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringTaskAllowedOperations(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the created field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getCreated(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_created";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the finished field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getFinished(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_finished";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Types.TaskStatusType getStatus(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_status";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTaskStatusType(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the resident_on field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Host getResidentOn(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_resident_on";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toHost(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the progress field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Double getProgress(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_progress";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDouble(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the type field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getType(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_type";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the result field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getResult(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_result";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error_info field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<String> getErrorInfo(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_error_info";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subtask_of field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Task getSubtaskOf(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_subtask_of";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the subtasks field of the given task.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<Task> getSubtasks(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_subtasks";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given task.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given task.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given task. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new task object which must be manually destroyed.
|
||||
*
|
||||
* @param label short label for the new task
|
||||
* @param description longer description for the new task
|
||||
* @return The reference of the created task object
|
||||
*/
|
||||
public static Task create(Connection c, String label, String description) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label), Marshalling.toXMLRPC(description)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the task object
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request that a task be cancelled. Note that a task may fail to be cancelled and may complete or fail normally and note that, even when a task does cancel, it might take an arbitrary amount of time.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task cancelAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationNotAllowed {
|
||||
String method_call = "Async.task.cancel";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Request that a task be cancelled. Note that a task may fail to be cancelled and may complete or fail normally and note that, even when a task does cancel, it might take an arbitrary amount of time.
|
||||
*
|
||||
*/
|
||||
public void cancel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationNotAllowed {
|
||||
String method_call = "task.cancel";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the tasks known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Task> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of task references to task records for all tasks known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Task, Task.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "task.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfTaskTaskRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
474
deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java
vendored
Normal file
474
deps/XenServerJava/src/com/xensource/xenapi/Tunnel.java
vendored
Normal file
@ -0,0 +1,474 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A tunnel for network traffic
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class Tunnel extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
Tunnel(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a Tunnel, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof Tunnel)
|
||||
{
|
||||
Tunnel other = (Tunnel) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a Tunnel
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "accessPIF", this.accessPIF);
|
||||
print.printf("%1$20s: %2$s\n", "transportPIF", this.transportPIF);
|
||||
print.printf("%1$20s: %2$s\n", "status", this.status);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a tunnel.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("access_PIF", this.accessPIF == null ? new PIF("OpaqueRef:NULL") : this.accessPIF);
|
||||
map.put("transport_PIF", this.transportPIF == null ? new PIF("OpaqueRef:NULL") : this.transportPIF);
|
||||
map.put("status", this.status == null ? new HashMap<String, String>() : this.status);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* The interface through which the tunnel is accessed
|
||||
*/
|
||||
public PIF accessPIF;
|
||||
/**
|
||||
* The interface used by the tunnel
|
||||
*/
|
||||
public PIF transportPIF;
|
||||
/**
|
||||
* Status information about the tunnel
|
||||
*/
|
||||
public Map<String, String> status;
|
||||
/**
|
||||
* Additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given tunnel.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public Tunnel.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTunnelRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the tunnel instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static Tunnel getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTunnel(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given tunnel.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the access_PIF field of the given tunnel.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public PIF getAccessPIF(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.get_access_PIF";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPIF(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transport_PIF field of the given tunnel.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public PIF getTransportPIF(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.get_transport_PIF";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPIF(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the status field of the given tunnel.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getStatus(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.get_status";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given tunnel.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status field of the given tunnel.
|
||||
*
|
||||
* @param status New value to set
|
||||
*/
|
||||
public void setStatus(Connection c, Map<String, String> status) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.set_status";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(status)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the status field of the given tunnel.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToStatus(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.add_to_status";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the status field of the given tunnel. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromStatus(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.remove_from_status";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given tunnel.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given tunnel.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given tunnel. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a tunnel
|
||||
*
|
||||
* @param transportPIF PIF which receives the tagged traffic
|
||||
* @param network Network to receive the tunnelled traffic
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, PIF transportPIF, Network network) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OpenvswitchNotActive,
|
||||
Types.TransportPifNotConfigured,
|
||||
Types.IsTunnelAccessPif {
|
||||
String method_call = "Async.tunnel.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(transportPIF), Marshalling.toXMLRPC(network)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a tunnel
|
||||
*
|
||||
* @param transportPIF PIF which receives the tagged traffic
|
||||
* @param network Network to receive the tunnelled traffic
|
||||
* @return The reference of the created tunnel object
|
||||
*/
|
||||
public static Tunnel create(Connection c, PIF transportPIF, Network network) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OpenvswitchNotActive,
|
||||
Types.TransportPifNotConfigured,
|
||||
Types.IsTunnelAccessPif {
|
||||
String method_call = "tunnel.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(transportPIF), Marshalling.toXMLRPC(network)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTunnel(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a tunnel
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.tunnel.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a tunnel
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the tunnels known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<Tunnel> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfTunnel(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of tunnel references to tunnel records for all tunnels known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<Tunnel, Tunnel.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "tunnel.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfTunnelTunnelRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
13057
deps/XenServerJava/src/com/xensource/xenapi/Types.java
vendored
Normal file
13057
deps/XenServerJava/src/com/xensource/xenapi/Types.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
384
deps/XenServerJava/src/com/xensource/xenapi/User.java
vendored
Normal file
384
deps/XenServerJava/src/com/xensource/xenapi/User.java
vendored
Normal file
@ -0,0 +1,384 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A user of the system
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class User extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
User(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a User, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof User)
|
||||
{
|
||||
User other = (User) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a User
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "shortName", this.shortName);
|
||||
print.printf("%1$20s: %2$s\n", "fullname", this.fullname);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a user.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("short_name", this.shortName == null ? "" : this.shortName);
|
||||
map.put("fullname", this.fullname == null ? "" : this.fullname);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* short name (e.g. userid)
|
||||
*/
|
||||
public String shortName;
|
||||
/**
|
||||
* full name
|
||||
*/
|
||||
public String fullname;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given user.
|
||||
* @deprecated
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
@Deprecated public User.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toUserRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the user instance with the specified UUID.
|
||||
* @deprecated
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
@Deprecated public static User getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toUser(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance, and return its handle.
|
||||
* @deprecated
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return Task
|
||||
*/
|
||||
@Deprecated public static Task createAsync(Connection c, User.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.user.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance, and return its handle.
|
||||
* @deprecated
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return reference to the newly created object
|
||||
*/
|
||||
@Deprecated public static User create(Connection c, User.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toUser(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified user instance.
|
||||
* @deprecated
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
@Deprecated public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.user.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified user instance.
|
||||
* @deprecated
|
||||
*
|
||||
*/
|
||||
@Deprecated public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given user.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the short_name field of the given user.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getShortName(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.get_short_name";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fullname field of the given user.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getFullname(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.get_fullname";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given user.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fullname field of the given user.
|
||||
*
|
||||
* @param fullname New value to set
|
||||
*/
|
||||
public void setFullname(Connection c, String fullname) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.set_fullname";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(fullname)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given user.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given user.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given user. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "user.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
1161
deps/XenServerJava/src/com/xensource/xenapi/VBD.java
vendored
Normal file
1161
deps/XenServerJava/src/com/xensource/xenapi/VBD.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
349
deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java
vendored
Normal file
349
deps/XenServerJava/src/com/xensource/xenapi/VBDMetrics.java
vendored
Normal file
@ -0,0 +1,349 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* The metrics associated with a virtual block device
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class VBDMetrics extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
VBDMetrics(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a VBDMetrics, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof VBDMetrics)
|
||||
{
|
||||
VBDMetrics other = (VBDMetrics) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a VBDMetrics
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "ioReadKbs", this.ioReadKbs);
|
||||
print.printf("%1$20s: %2$s\n", "ioWriteKbs", this.ioWriteKbs);
|
||||
print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a VBD_metrics.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("io_read_kbs", this.ioReadKbs == null ? 0.0 : this.ioReadKbs);
|
||||
map.put("io_write_kbs", this.ioWriteKbs == null ? 0.0 : this.ioWriteKbs);
|
||||
map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* Read bandwidth (KiB/s)
|
||||
*/
|
||||
public Double ioReadKbs;
|
||||
/**
|
||||
* Write bandwidth (KiB/s)
|
||||
*/
|
||||
public Double ioWriteKbs;
|
||||
/**
|
||||
* Time at which this information was last updated
|
||||
*/
|
||||
public Date lastUpdated;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given VBD_metrics.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public VBDMetrics.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVBDMetricsRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the VBD_metrics instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static VBDMetrics getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVBDMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given VBD_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the io/read_kbs field of the given VBD_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Double getIoReadKbs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.get_io_read_kbs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDouble(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the io/write_kbs field of the given VBD_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Double getIoWriteKbs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.get_io_write_kbs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDouble(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last_updated field of the given VBD_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getLastUpdated(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.get_last_updated";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given VBD_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given VBD_metrics.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given VBD_metrics.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given VBD_metrics. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the VBD_metrics instances known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<VBDMetrics> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVBDMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of VBD_metrics references to VBD_metrics records for all VBD_metrics instances known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<VBDMetrics, VBDMetrics.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VBD_metrics.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfVBDMetricsVBDMetricsRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
2100
deps/XenServerJava/src/com/xensource/xenapi/VDI.java
vendored
Normal file
2100
deps/XenServerJava/src/com/xensource/xenapi/VDI.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
446
deps/XenServerJava/src/com/xensource/xenapi/VGPU.java
vendored
Normal file
446
deps/XenServerJava/src/com/xensource/xenapi/VGPU.java
vendored
Normal file
@ -0,0 +1,446 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A virtual GPU (vGPU)
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class VGPU extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
VGPU(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a VGPU, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof VGPU)
|
||||
{
|
||||
VGPU other = (VGPU) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a VGPU
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "VM", this.VM);
|
||||
print.printf("%1$20s: %2$s\n", "GPUGroup", this.GPUGroup);
|
||||
print.printf("%1$20s: %2$s\n", "device", this.device);
|
||||
print.printf("%1$20s: %2$s\n", "currentlyAttached", this.currentlyAttached);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a VGPU.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM);
|
||||
map.put("GPU_group", this.GPUGroup == null ? new GPUGroup("OpaqueRef:NULL") : this.GPUGroup);
|
||||
map.put("device", this.device == null ? "" : this.device);
|
||||
map.put("currently_attached", this.currentlyAttached == null ? false : this.currentlyAttached);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* VM that owns the vGPU
|
||||
*/
|
||||
public VM VM;
|
||||
/**
|
||||
* GPU group used by the vGPU
|
||||
*/
|
||||
public GPUGroup GPUGroup;
|
||||
/**
|
||||
* Order in which the devices are plugged into the VM
|
||||
*/
|
||||
public String device;
|
||||
/**
|
||||
* Reflects whether the virtual device is currently connected to a physical device
|
||||
*/
|
||||
public Boolean currentlyAttached;
|
||||
/**
|
||||
* Additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given VGPU.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public VGPU.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVGPURecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the VGPU instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static VGPU getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVGPU(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given VGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VM field of the given VGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public VM getVM(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_VM";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the GPU_group field of the given VGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public GPUGroup getGPUGroup(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_GPU_group";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toGPUGroup(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the device field of the given VGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getDevice(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_device";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently_attached field of the given VGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getCurrentlyAttached(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_currently_attached";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given VGPU.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given VGPU.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given VGPU.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given VGPU. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param VM
|
||||
* @param GPUGroup
|
||||
* @param device
|
||||
* @param otherConfig
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, VM VM, GPUGroup GPUGroup, String device, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.VGPU.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(VM), Marshalling.toXMLRPC(GPUGroup), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param VM
|
||||
* @param GPUGroup
|
||||
* @param device
|
||||
* @param otherConfig
|
||||
* @return reference to the newly created object
|
||||
*/
|
||||
public static VGPU create(Connection c, VM VM, GPUGroup GPUGroup, String device, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(VM), Marshalling.toXMLRPC(GPUGroup), Marshalling.toXMLRPC(device), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVGPU(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.VGPU.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the VGPUs known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<VGPU> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVGPU(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of VGPU references to VGPU records for all VGPUs known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<VGPU, VGPU.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VGPU.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfVGPUVGPURecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
1186
deps/XenServerJava/src/com/xensource/xenapi/VIF.java
vendored
Normal file
1186
deps/XenServerJava/src/com/xensource/xenapi/VIF.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
349
deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java
vendored
Normal file
349
deps/XenServerJava/src/com/xensource/xenapi/VIFMetrics.java
vendored
Normal file
@ -0,0 +1,349 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* The metrics associated with a virtual network device
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class VIFMetrics extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
VIFMetrics(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a VIFMetrics, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof VIFMetrics)
|
||||
{
|
||||
VIFMetrics other = (VIFMetrics) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a VIFMetrics
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "ioReadKbs", this.ioReadKbs);
|
||||
print.printf("%1$20s: %2$s\n", "ioWriteKbs", this.ioWriteKbs);
|
||||
print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a VIF_metrics.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("io_read_kbs", this.ioReadKbs == null ? 0.0 : this.ioReadKbs);
|
||||
map.put("io_write_kbs", this.ioWriteKbs == null ? 0.0 : this.ioWriteKbs);
|
||||
map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* Read bandwidth (KiB/s)
|
||||
*/
|
||||
public Double ioReadKbs;
|
||||
/**
|
||||
* Write bandwidth (KiB/s)
|
||||
*/
|
||||
public Double ioWriteKbs;
|
||||
/**
|
||||
* Time at which this information was last updated
|
||||
*/
|
||||
public Date lastUpdated;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given VIF_metrics.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public VIFMetrics.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVIFMetricsRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the VIF_metrics instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static VIFMetrics getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVIFMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given VIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the io/read_kbs field of the given VIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Double getIoReadKbs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.get_io_read_kbs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDouble(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the io/write_kbs field of the given VIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Double getIoWriteKbs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.get_io_write_kbs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDouble(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last_updated field of the given VIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getLastUpdated(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.get_last_updated";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given VIF_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given VIF_metrics.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given VIF_metrics.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given VIF_metrics. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the VIF_metrics instances known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<VIFMetrics> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVIFMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of VIF_metrics references to VIF_metrics records for all VIF_metrics instances known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<VIFMetrics, VIFMetrics.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VIF_metrics.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfVIFMetricsVIFMetricsRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
421
deps/XenServerJava/src/com/xensource/xenapi/VLAN.java
vendored
Normal file
421
deps/XenServerJava/src/com/xensource/xenapi/VLAN.java
vendored
Normal file
@ -0,0 +1,421 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A VLAN mux/demux
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class VLAN extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
VLAN(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a VLAN, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof VLAN)
|
||||
{
|
||||
VLAN other = (VLAN) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a VLAN
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "taggedPIF", this.taggedPIF);
|
||||
print.printf("%1$20s: %2$s\n", "untaggedPIF", this.untaggedPIF);
|
||||
print.printf("%1$20s: %2$s\n", "tag", this.tag);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a VLAN.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("tagged_PIF", this.taggedPIF == null ? new PIF("OpaqueRef:NULL") : this.taggedPIF);
|
||||
map.put("untagged_PIF", this.untaggedPIF == null ? new PIF("OpaqueRef:NULL") : this.untaggedPIF);
|
||||
map.put("tag", this.tag == null ? 0 : this.tag);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* interface on which traffic is tagged
|
||||
*/
|
||||
public PIF taggedPIF;
|
||||
/**
|
||||
* interface on which traffic is untagged
|
||||
*/
|
||||
public PIF untaggedPIF;
|
||||
/**
|
||||
* VLAN tag in use
|
||||
*/
|
||||
public Long tag;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given VLAN.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public VLAN.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVLANRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the VLAN instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static VLAN getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVLAN(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given VLAN.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tagged_PIF field of the given VLAN.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public PIF getTaggedPIF(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.get_tagged_PIF";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPIF(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the untagged_PIF field of the given VLAN.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public PIF getUntaggedPIF(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.get_untagged_PIF";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toPIF(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag field of the given VLAN.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getTag(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.get_tag";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given VLAN.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given VLAN.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given VLAN.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given VLAN. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a VLAN mux/demuxer
|
||||
*
|
||||
* @param taggedPIF PIF which receives the tagged traffic
|
||||
* @param tag VLAN tag to use
|
||||
* @param network Network to receive the untagged traffic
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, PIF taggedPIF, Long tag, Network network) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.VLAN.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(taggedPIF), Marshalling.toXMLRPC(tag), Marshalling.toXMLRPC(network)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a VLAN mux/demuxer
|
||||
*
|
||||
* @param taggedPIF PIF which receives the tagged traffic
|
||||
* @param tag VLAN tag to use
|
||||
* @param network Network to receive the untagged traffic
|
||||
* @return The reference of the created VLAN object
|
||||
*/
|
||||
public static VLAN create(Connection c, PIF taggedPIF, Long tag, Network network) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.create";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(taggedPIF), Marshalling.toXMLRPC(tag), Marshalling.toXMLRPC(network)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVLAN(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a VLAN mux/demuxer
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.VLAN.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a VLAN mux/demuxer
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the VLANs known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<VLAN> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVLAN(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of VLAN references to VLAN records for all VLANs known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<VLAN, VLAN.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VLAN.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfVLANVLANRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
4891
deps/XenServerJava/src/com/xensource/xenapi/VM.java
vendored
Normal file
4891
deps/XenServerJava/src/com/xensource/xenapi/VM.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
655
deps/XenServerJava/src/com/xensource/xenapi/VMAppliance.java
vendored
Normal file
655
deps/XenServerJava/src/com/xensource/xenapi/VMAppliance.java
vendored
Normal file
@ -0,0 +1,655 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* VM appliance
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class VMAppliance extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
VMAppliance(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a VMAppliance, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof VMAppliance)
|
||||
{
|
||||
VMAppliance other = (VMAppliance) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a VMAppliance
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "nameLabel", this.nameLabel);
|
||||
print.printf("%1$20s: %2$s\n", "nameDescription", this.nameDescription);
|
||||
print.printf("%1$20s: %2$s\n", "allowedOperations", this.allowedOperations);
|
||||
print.printf("%1$20s: %2$s\n", "currentOperations", this.currentOperations);
|
||||
print.printf("%1$20s: %2$s\n", "VMs", this.VMs);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a VM_appliance.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("name_label", this.nameLabel == null ? "" : this.nameLabel);
|
||||
map.put("name_description", this.nameDescription == null ? "" : this.nameDescription);
|
||||
map.put("allowed_operations", this.allowedOperations == null ? new LinkedHashSet<Types.VmApplianceOperation>() : this.allowedOperations);
|
||||
map.put("current_operations", this.currentOperations == null ? new HashMap<String, Types.VmApplianceOperation>() : this.currentOperations);
|
||||
map.put("VMs", this.VMs == null ? new LinkedHashSet<VM>() : this.VMs);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* a human-readable name
|
||||
*/
|
||||
public String nameLabel;
|
||||
/**
|
||||
* a notes field containing human-readable description
|
||||
*/
|
||||
public String nameDescription;
|
||||
/**
|
||||
* list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client.
|
||||
*/
|
||||
public Set<Types.VmApplianceOperation> allowedOperations;
|
||||
/**
|
||||
* links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task.
|
||||
*/
|
||||
public Map<String, Types.VmApplianceOperation> currentOperations;
|
||||
/**
|
||||
* all VMs in this appliance
|
||||
*/
|
||||
public Set<VM> VMs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given VM_appliance.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public VMAppliance.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVMApplianceRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the VM_appliance instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static VMAppliance getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVMAppliance(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new VM_appliance instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, VMAppliance.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.VM_appliance.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new VM_appliance instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return reference to the newly created object
|
||||
*/
|
||||
public static VMAppliance create(Connection c, VMAppliance.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVMAppliance(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified VM_appliance instance.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.VM_appliance.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified VM_appliance instance.
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the VM_appliance instances with the given label.
|
||||
*
|
||||
* @param label label of object to return
|
||||
* @return references to objects with matching names
|
||||
*/
|
||||
public static Set<VMAppliance> getByNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_by_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVMAppliance(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given VM_appliance.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/label field of the given VM_appliance.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameLabel(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name/description field of the given VM_appliance.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getNameDescription(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the allowed_operations field of the given VM_appliance.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<Types.VmApplianceOperation> getAllowedOperations(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_allowed_operations";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVmApplianceOperation(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current_operations field of the given VM_appliance.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, Types.VmApplianceOperation> getCurrentOperations(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_current_operations";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringVmApplianceOperation(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VMs field of the given VM_appliance.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<VM> getVMs(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_VMs";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name/label field of the given VM_appliance.
|
||||
*
|
||||
* @param label New value to set
|
||||
*/
|
||||
public void setNameLabel(Connection c, String label) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.set_name_label";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(label)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name/description field of the given VM_appliance.
|
||||
*
|
||||
* @param description New value to set
|
||||
*/
|
||||
public void setNameDescription(Connection c, String description) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.set_name_description";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(description)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start all VMs in the appliance
|
||||
*
|
||||
* @param paused Instantiate all VMs belonging to this appliance in paused state if set to true.
|
||||
* @return Task
|
||||
*/
|
||||
public Task startAsync(Connection c, Boolean paused) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationPartiallyFailed {
|
||||
String method_call = "Async.VM_appliance.start";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(paused)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start all VMs in the appliance
|
||||
*
|
||||
* @param paused Instantiate all VMs belonging to this appliance in paused state if set to true.
|
||||
*/
|
||||
public void start(Connection c, Boolean paused) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationPartiallyFailed {
|
||||
String method_call = "VM_appliance.start";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(paused)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a clean shutdown of all the VMs in the appliance
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task cleanShutdownAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationPartiallyFailed {
|
||||
String method_call = "Async.VM_appliance.clean_shutdown";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a clean shutdown of all the VMs in the appliance
|
||||
*
|
||||
*/
|
||||
public void cleanShutdown(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationPartiallyFailed {
|
||||
String method_call = "VM_appliance.clean_shutdown";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a hard shutdown of all the VMs in the appliance
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task hardShutdownAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationPartiallyFailed {
|
||||
String method_call = "Async.VM_appliance.hard_shutdown";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a hard shutdown of all the VMs in the appliance
|
||||
*
|
||||
*/
|
||||
public void hardShutdown(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationPartiallyFailed {
|
||||
String method_call = "VM_appliance.hard_shutdown";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* For each VM in the appliance, try to shut it down cleanly. If this fails, perform a hard shutdown of the VM.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task shutdownAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationPartiallyFailed {
|
||||
String method_call = "Async.VM_appliance.shutdown";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* For each VM in the appliance, try to shut it down cleanly. If this fails, perform a hard shutdown of the VM.
|
||||
*
|
||||
*/
|
||||
public void shutdown(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.OperationPartiallyFailed {
|
||||
String method_call = "VM_appliance.shutdown";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert whether all SRs required to recover this VM appliance are available.
|
||||
*
|
||||
* @param sessionTo The session to which the VM appliance is to be recovered.
|
||||
* @return Task
|
||||
*/
|
||||
public Task assertCanBeRecoveredAsync(Connection c, Session sessionTo) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.VmRequiresSr {
|
||||
String method_call = "Async.VM_appliance.assert_can_be_recovered";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert whether all SRs required to recover this VM appliance are available.
|
||||
*
|
||||
* @param sessionTo The session to which the VM appliance is to be recovered.
|
||||
*/
|
||||
public void assertCanBeRecovered(Connection c, Session sessionTo) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.VmRequiresSr {
|
||||
String method_call = "VM_appliance.assert_can_be_recovered";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover the VM appliance
|
||||
*
|
||||
* @param sessionTo The session to which the VM appliance is to be recovered.
|
||||
* @param force Whether the VMs should replace newer versions of themselves.
|
||||
* @return Task
|
||||
*/
|
||||
public Task recoverAsync(Connection c, Session sessionTo, Boolean force) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.VmRequiresSr {
|
||||
String method_call = "Async.VM_appliance.recover";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo), Marshalling.toXMLRPC(force)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recover the VM appliance
|
||||
*
|
||||
* @param sessionTo The session to which the VM appliance is to be recovered.
|
||||
* @param force Whether the VMs should replace newer versions of themselves.
|
||||
*/
|
||||
public void recover(Connection c, Session sessionTo, Boolean force) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException,
|
||||
Types.VmRequiresSr {
|
||||
String method_call = "VM_appliance.recover";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sessionTo), Marshalling.toXMLRPC(force)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the VM_appliances known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<VMAppliance> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVMAppliance(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of VM_appliance references to VM_appliance records for all VM_appliances known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<VMAppliance, VMAppliance.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_appliance.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfVMApplianceVMApplianceRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
487
deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java
vendored
Normal file
487
deps/XenServerJava/src/com/xensource/xenapi/VMGuestMetrics.java
vendored
Normal file
@ -0,0 +1,487 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* The metrics reported by the guest (as opposed to inferred from outside)
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class VMGuestMetrics extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
VMGuestMetrics(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a VMGuestMetrics, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof VMGuestMetrics)
|
||||
{
|
||||
VMGuestMetrics other = (VMGuestMetrics) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a VMGuestMetrics
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "osVersion", this.osVersion);
|
||||
print.printf("%1$20s: %2$s\n", "PVDriversVersion", this.PVDriversVersion);
|
||||
print.printf("%1$20s: %2$s\n", "PVDriversUpToDate", this.PVDriversUpToDate);
|
||||
print.printf("%1$20s: %2$s\n", "memory", this.memory);
|
||||
print.printf("%1$20s: %2$s\n", "disks", this.disks);
|
||||
print.printf("%1$20s: %2$s\n", "networks", this.networks);
|
||||
print.printf("%1$20s: %2$s\n", "other", this.other);
|
||||
print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
print.printf("%1$20s: %2$s\n", "live", this.live);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a VM_guest_metrics.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("os_version", this.osVersion == null ? new HashMap<String, String>() : this.osVersion);
|
||||
map.put("PV_drivers_version", this.PVDriversVersion == null ? new HashMap<String, String>() : this.PVDriversVersion);
|
||||
map.put("PV_drivers_up_to_date", this.PVDriversUpToDate == null ? false : this.PVDriversUpToDate);
|
||||
map.put("memory", this.memory == null ? new HashMap<String, String>() : this.memory);
|
||||
map.put("disks", this.disks == null ? new HashMap<String, String>() : this.disks);
|
||||
map.put("networks", this.networks == null ? new HashMap<String, String>() : this.networks);
|
||||
map.put("other", this.other == null ? new HashMap<String, String>() : this.other);
|
||||
map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
map.put("live", this.live == null ? false : this.live);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* version of the OS
|
||||
*/
|
||||
public Map<String, String> osVersion;
|
||||
/**
|
||||
* version of the PV drivers
|
||||
*/
|
||||
public Map<String, String> PVDriversVersion;
|
||||
/**
|
||||
* true if the PV drivers appear to be up to date
|
||||
*/
|
||||
public Boolean PVDriversUpToDate;
|
||||
/**
|
||||
* free/used/total memory
|
||||
*/
|
||||
public Map<String, String> memory;
|
||||
/**
|
||||
* disk configuration/free space
|
||||
*/
|
||||
public Map<String, String> disks;
|
||||
/**
|
||||
* network configuration
|
||||
*/
|
||||
public Map<String, String> networks;
|
||||
/**
|
||||
* anything else
|
||||
*/
|
||||
public Map<String, String> other;
|
||||
/**
|
||||
* Time at which this information was last updated
|
||||
*/
|
||||
public Date lastUpdated;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
/**
|
||||
* True if the guest is sending heartbeat messages via the guest agent
|
||||
*/
|
||||
public Boolean live;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given VM_guest_metrics.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public VMGuestMetrics.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVMGuestMetricsRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the VM_guest_metrics instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static VMGuestMetrics getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVMGuestMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the os_version field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOsVersion(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_os_version";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PV_drivers_version field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getPVDriversVersion(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_PV_drivers_version";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PV_drivers_up_to_date field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getPVDriversUpToDate(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_PV_drivers_up_to_date";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the memory field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getMemory(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_memory";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the disks field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getDisks(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_disks";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the networks field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getNetworks(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_networks";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOther(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_other";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last_updated field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getLastUpdated(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_last_updated";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the live field of the given VM_guest_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Boolean getLive(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_live";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toBoolean(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given VM_guest_metrics.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given VM_guest_metrics.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given VM_guest_metrics. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the VM_guest_metrics instances known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<VMGuestMetrics> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVMGuestMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of VM_guest_metrics references to VM_guest_metrics records for all VM_guest_metrics instances known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<VMGuestMetrics, VMGuestMetrics.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_guest_metrics.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfVMGuestMetricsVMGuestMetricsRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
510
deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java
vendored
Normal file
510
deps/XenServerJava/src/com/xensource/xenapi/VMMetrics.java
vendored
Normal file
@ -0,0 +1,510 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* The metrics associated with a VM
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class VMMetrics extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
VMMetrics(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a VMMetrics, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof VMMetrics)
|
||||
{
|
||||
VMMetrics other = (VMMetrics) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a VMMetrics
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "memoryActual", this.memoryActual);
|
||||
print.printf("%1$20s: %2$s\n", "VCPUsNumber", this.VCPUsNumber);
|
||||
print.printf("%1$20s: %2$s\n", "VCPUsUtilisation", this.VCPUsUtilisation);
|
||||
print.printf("%1$20s: %2$s\n", "VCPUsCPU", this.VCPUsCPU);
|
||||
print.printf("%1$20s: %2$s\n", "VCPUsParams", this.VCPUsParams);
|
||||
print.printf("%1$20s: %2$s\n", "VCPUsFlags", this.VCPUsFlags);
|
||||
print.printf("%1$20s: %2$s\n", "state", this.state);
|
||||
print.printf("%1$20s: %2$s\n", "startTime", this.startTime);
|
||||
print.printf("%1$20s: %2$s\n", "installTime", this.installTime);
|
||||
print.printf("%1$20s: %2$s\n", "lastUpdated", this.lastUpdated);
|
||||
print.printf("%1$20s: %2$s\n", "otherConfig", this.otherConfig);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a VM_metrics.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("memory_actual", this.memoryActual == null ? 0 : this.memoryActual);
|
||||
map.put("VCPUs_number", this.VCPUsNumber == null ? 0 : this.VCPUsNumber);
|
||||
map.put("VCPUs_utilisation", this.VCPUsUtilisation == null ? new HashMap<Long, Double>() : this.VCPUsUtilisation);
|
||||
map.put("VCPUs_CPU", this.VCPUsCPU == null ? new HashMap<Long, Long>() : this.VCPUsCPU);
|
||||
map.put("VCPUs_params", this.VCPUsParams == null ? new HashMap<String, String>() : this.VCPUsParams);
|
||||
map.put("VCPUs_flags", this.VCPUsFlags == null ? new HashMap<Long, Set<String>>() : this.VCPUsFlags);
|
||||
map.put("state", this.state == null ? new LinkedHashSet<String>() : this.state);
|
||||
map.put("start_time", this.startTime == null ? new Date(0) : this.startTime);
|
||||
map.put("install_time", this.installTime == null ? new Date(0) : this.installTime);
|
||||
map.put("last_updated", this.lastUpdated == null ? new Date(0) : this.lastUpdated);
|
||||
map.put("other_config", this.otherConfig == null ? new HashMap<String, String>() : this.otherConfig);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* Guest's actual memory (bytes)
|
||||
*/
|
||||
public Long memoryActual;
|
||||
/**
|
||||
* Current number of VCPUs
|
||||
*/
|
||||
public Long VCPUsNumber;
|
||||
/**
|
||||
* Utilisation for all of guest's current VCPUs
|
||||
*/
|
||||
public Map<Long, Double> VCPUsUtilisation;
|
||||
/**
|
||||
* VCPU to PCPU map
|
||||
*/
|
||||
public Map<Long, Long> VCPUsCPU;
|
||||
/**
|
||||
* The live equivalent to VM.VCPUs_params
|
||||
*/
|
||||
public Map<String, String> VCPUsParams;
|
||||
/**
|
||||
* CPU flags (blocked,online,running)
|
||||
*/
|
||||
public Map<Long, Set<String>> VCPUsFlags;
|
||||
/**
|
||||
* The state of the guest, eg blocked, dying etc
|
||||
*/
|
||||
public Set<String> state;
|
||||
/**
|
||||
* Time at which this VM was last booted
|
||||
*/
|
||||
public Date startTime;
|
||||
/**
|
||||
* Time at which the VM was installed
|
||||
*/
|
||||
public Date installTime;
|
||||
/**
|
||||
* Time at which this information was last updated
|
||||
*/
|
||||
public Date lastUpdated;
|
||||
/**
|
||||
* additional configuration
|
||||
*/
|
||||
public Map<String, String> otherConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given VM_metrics.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public VMMetrics.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVMMetricsRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the VM_metrics instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static VMMetrics getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVMMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the memory/actual field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getMemoryActual(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_memory_actual";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VCPUs/number field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Long getVCPUsNumber(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_VCPUs_number";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VCPUs/utilisation field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<Long, Double> getVCPUsUtilisation(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_VCPUs_utilisation";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfLongDouble(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VCPUs/CPU field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<Long, Long> getVCPUsCPU(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_VCPUs_CPU";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfLongLong(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VCPUs/params field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getVCPUsParams(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_VCPUs_params";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VCPUs/flags field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<Long, Set<String>> getVCPUsFlags(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_VCPUs_flags";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfLongSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the state field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Set<String> getState(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_state";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the start_time field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getStartTime(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_start_time";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the install_time field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getInstallTime(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_install_time";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last_updated field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Date getLastUpdated(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_last_updated";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toDate(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the other_config field of the given VM_metrics.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public Map<String, String> getOtherConfig(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfStringString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the other_config field of the given VM_metrics.
|
||||
*
|
||||
* @param otherConfig New value to set
|
||||
*/
|
||||
public void setOtherConfig(Connection c, Map<String, String> otherConfig) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.set_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(otherConfig)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the given key-value pair to the other_config field of the given VM_metrics.
|
||||
*
|
||||
* @param key Key to add
|
||||
* @param value Value to add
|
||||
*/
|
||||
public void addToOtherConfig(Connection c, String key, String value) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.add_to_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key), Marshalling.toXMLRPC(value)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the given key and its corresponding value from the other_config field of the given VM_metrics. If the key is not in that Map, then do nothing.
|
||||
*
|
||||
* @param key Key to remove
|
||||
*/
|
||||
public void removeFromOtherConfig(Connection c, String key) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.remove_from_other_config";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(key)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of all the VM_metrics instances known to the system.
|
||||
*
|
||||
* @return references to all objects
|
||||
*/
|
||||
public static Set<VMMetrics> getAll(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_all";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toSetOfVMMetrics(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a map of VM_metrics references to VM_metrics records for all VM_metrics instances known to the system.
|
||||
*
|
||||
* @return records of all objects
|
||||
*/
|
||||
public static Map<VMMetrics, VMMetrics.Record> getAllRecords(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VM_metrics.get_all_records";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toMapOfVMMetricsVMMetricsRecord(result);
|
||||
}
|
||||
|
||||
}
|
||||
1158
deps/XenServerJava/src/com/xensource/xenapi/VMPP.java
vendored
Normal file
1158
deps/XenServerJava/src/com/xensource/xenapi/VMPP.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
290
deps/XenServerJava/src/com/xensource/xenapi/VTPM.java
vendored
Normal file
290
deps/XenServerJava/src/com/xensource/xenapi/VTPM.java
vendored
Normal file
@ -0,0 +1,290 @@
|
||||
/*
|
||||
* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
import com.xensource.xenapi.Types.BadServerResponse;
|
||||
import com.xensource.xenapi.Types.VersionException;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
/**
|
||||
* A virtual TPM device
|
||||
*
|
||||
* @author Citrix Systems, Inc.
|
||||
*/
|
||||
public class VTPM extends XenAPIObject {
|
||||
|
||||
/**
|
||||
* The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
protected final String ref;
|
||||
|
||||
/**
|
||||
* For internal use only.
|
||||
*/
|
||||
VTPM(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The XenAPI reference (OpaqueRef) to this object.
|
||||
*/
|
||||
public String toWireString() {
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* If obj is a VTPM, compares XenAPI references for equality.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null && obj instanceof VTPM)
|
||||
{
|
||||
VTPM other = (VTPM) obj;
|
||||
return other.ref.equals(this.ref);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ref.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents all the fields in a VTPM
|
||||
*/
|
||||
public static class Record implements Types.Record {
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter print = new PrintWriter(writer);
|
||||
print.printf("%1$20s: %2$s\n", "uuid", this.uuid);
|
||||
print.printf("%1$20s: %2$s\n", "VM", this.VM);
|
||||
print.printf("%1$20s: %2$s\n", "backend", this.backend);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a VTPM.Record to a Map
|
||||
*/
|
||||
public Map<String,Object> toMap() {
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("uuid", this.uuid == null ? "" : this.uuid);
|
||||
map.put("VM", this.VM == null ? new VM("OpaqueRef:NULL") : this.VM);
|
||||
map.put("backend", this.backend == null ? new VM("OpaqueRef:NULL") : this.backend);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier/object reference
|
||||
*/
|
||||
public String uuid;
|
||||
/**
|
||||
* the virtual machine
|
||||
*/
|
||||
public VM VM;
|
||||
/**
|
||||
* the domain where the backend is located
|
||||
*/
|
||||
public VM backend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a record containing the current state of the given VTPM.
|
||||
*
|
||||
* @return all fields from the object
|
||||
*/
|
||||
public VTPM.Record getRecord(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VTPM.get_record";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVTPMRecord(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a reference to the VTPM instance with the specified UUID.
|
||||
*
|
||||
* @param uuid UUID of object to return
|
||||
* @return reference to the object
|
||||
*/
|
||||
public static VTPM getByUuid(Connection c, String uuid) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VTPM.get_by_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(uuid)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVTPM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new VTPM instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return Task
|
||||
*/
|
||||
public static Task createAsync(Connection c, VTPM.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.VTPM.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new VTPM instance, and return its handle.
|
||||
*
|
||||
* @param record All constructor arguments
|
||||
* @return reference to the newly created object
|
||||
*/
|
||||
public static VTPM create(Connection c, VTPM.Record record) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VTPM.create";
|
||||
String session = c.getSessionReference();
|
||||
Map<String, Object> record_map = record.toMap();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(record_map)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVTPM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified VTPM instance.
|
||||
*
|
||||
* @return Task
|
||||
*/
|
||||
public Task destroyAsync(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "Async.VTPM.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toTask(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy the specified VTPM instance.
|
||||
*
|
||||
*/
|
||||
public void destroy(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VTPM.destroy";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the uuid field of the given VTPM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public String getUuid(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VTPM.get_uuid";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toString(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VM field of the given VTPM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public VM getVM(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VTPM.get_VM";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVM(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the backend field of the given VTPM.
|
||||
*
|
||||
* @return value of the field
|
||||
*/
|
||||
public VM getBackend(Connection c) throws
|
||||
BadServerResponse,
|
||||
XenAPIException,
|
||||
XmlRpcException {
|
||||
String method_call = "VTPM.get_backend";
|
||||
String session = c.getSessionReference();
|
||||
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref)};
|
||||
Map response = c.dispatch(method_call, method_params);
|
||||
Object result = response.get("Value");
|
||||
return Types.toVM(result);
|
||||
}
|
||||
|
||||
}
|
||||
35
deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java
vendored
Normal file
35
deps/XenServerJava/src/com/xensource/xenapi/XenAPIObject.java
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/* Copyright (c) Citrix Systems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.xensource.xenapi;
|
||||
|
||||
public abstract class XenAPIObject
|
||||
{
|
||||
public abstract String toWireString();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user