Skip to content

Commit 2ce2645

Browse files
Devdeep Singhchipchilders
authored andcommitted
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>
1 parent 1e74501 commit 2ce2645

50 files changed

Lines changed: 48464 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/* Copyright (c) Citrix Systems, Inc.
2+
* All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* 1) Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* 2) Redistributions in binary form must reproduce the above
12+
* copyright notice, this list of conditions and the following
13+
* disclaimer in the documentation and/or other materials
14+
* provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20+
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27+
* OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*/
29+
30+
package com.xensource.xenapi;
31+
32+
public enum APIVersion
33+
{
34+
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;
35+
36+
public static APIVersion latest()
37+
{
38+
return API_1_10;
39+
}
40+
41+
public static APIVersion fromMajorMinor(long major, long minor)
42+
{
43+
if (major == 1 && minor == 10)
44+
{
45+
return API_1_10;
46+
}
47+
else if (major == 1 && minor == 9)
48+
{
49+
return API_1_9;
50+
}
51+
else if (major == 1 && minor == 8)
52+
{
53+
return API_1_8;
54+
}
55+
else if (major == 1 && minor == 7)
56+
{
57+
return API_1_7;
58+
}
59+
else if (major == 1 && minor == 6)
60+
{
61+
return API_1_6;
62+
}
63+
else if (major == 1 && minor == 5)
64+
{
65+
return API_1_5;
66+
}
67+
else if (major == 1 && minor == 4)
68+
{
69+
return API_1_4;
70+
}
71+
else if (major == 1 && minor == 3)
72+
{
73+
return API_1_3;
74+
}
75+
else if (major == 1 && minor == 2)
76+
{
77+
return API_1_2;
78+
}
79+
else if (major == 1 && minor == 1)
80+
{
81+
return API_1_1;
82+
}
83+
else
84+
{
85+
return UNKNOWN;
86+
}
87+
}
88+
89+
@Override
90+
public String toString()
91+
{
92+
switch (this)
93+
{
94+
case API_1_1:
95+
return "1.1";
96+
case API_1_2:
97+
return "1.2";
98+
case API_1_3:
99+
return "1.3";
100+
case API_1_4:
101+
return "1.4";
102+
case API_1_5:
103+
return "1.5";
104+
case API_1_6:
105+
return "1.6";
106+
case API_1_7:
107+
return "1.7";
108+
case API_1_8:
109+
return "1.8";
110+
case API_1_9:
111+
return "1.9";
112+
case API_1_10:
113+
return "1.10";
114+
default:
115+
return "Unknown";
116+
}
117+
}
118+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
* Copyright (c) Citrix Systems, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
*
9+
* 1) Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* 2) Redistributions in binary form must reproduce the above
13+
* copyright notice, this list of conditions and the following
14+
* disclaimer in the documentation and/or other materials
15+
* provided with the distribution.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21+
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28+
* OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
32+
package com.xensource.xenapi;
33+
34+
import com.xensource.xenapi.Types.BadServerResponse;
35+
import com.xensource.xenapi.Types.VersionException;
36+
import com.xensource.xenapi.Types.XenAPIException;
37+
38+
import java.io.PrintWriter;
39+
import java.io.StringWriter;
40+
import java.util.Date;
41+
import java.util.HashMap;
42+
import java.util.LinkedHashSet;
43+
import java.util.Map;
44+
import java.util.Set;
45+
46+
import org.apache.xmlrpc.XmlRpcException;
47+
48+
/**
49+
* Management of remote authentication services
50+
*
51+
* @author Citrix Systems, Inc.
52+
*/
53+
public class Auth extends XenAPIObject {
54+
55+
56+
public String toWireString() {
57+
return null;
58+
}
59+
60+
/**
61+
* This call queries the external directory service to obtain the subject_identifier as a string from the human-readable subject_name
62+
*
63+
* @param subjectName The human-readable subject_name, such as a username or a groupname
64+
* @return the subject_identifier obtained from the external directory service
65+
*/
66+
public static String getSubjectIdentifier(Connection c, String subjectName) throws
67+
BadServerResponse,
68+
XenAPIException,
69+
XmlRpcException {
70+
String method_call = "auth.get_subject_identifier";
71+
String session = c.getSessionReference();
72+
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectName)};
73+
Map response = c.dispatch(method_call, method_params);
74+
Object result = response.get("Value");
75+
return Types.toString(result);
76+
}
77+
78+
/**
79+
* This call queries the external directory service to obtain the user information (e.g. username, organization etc) from the specified subject_identifier
80+
*
81+
* @param subjectIdentifier A string containing the subject_identifier, unique in the external directory service
82+
* @return key-value pairs containing at least a key called subject_name
83+
*/
84+
public static Map<String, String> getSubjectInformationFromIdentifier(Connection c, String subjectIdentifier) throws
85+
BadServerResponse,
86+
XenAPIException,
87+
XmlRpcException {
88+
String method_call = "auth.get_subject_information_from_identifier";
89+
String session = c.getSessionReference();
90+
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)};
91+
Map response = c.dispatch(method_call, method_params);
92+
Object result = response.get("Value");
93+
return Types.toMapOfStringString(result);
94+
}
95+
96+
/**
97+
* This calls queries the external directory service to obtain the transitively-closed set of groups that the the subject_identifier is member of.
98+
*
99+
* @param subjectIdentifier A string containing the subject_identifier, unique in the external directory service
100+
* @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.
101+
*/
102+
public static Set<String> getGroupMembership(Connection c, String subjectIdentifier) throws
103+
BadServerResponse,
104+
XenAPIException,
105+
XmlRpcException {
106+
String method_call = "auth.get_group_membership";
107+
String session = c.getSessionReference();
108+
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(subjectIdentifier)};
109+
Map response = c.dispatch(method_call, method_params);
110+
Object result = response.get("Value");
111+
return Types.toSetOfString(result);
112+
}
113+
114+
}

0 commit comments

Comments
 (0)