Skip to content

Commit

Permalink
CLOUDSTACK-6058: XenServer 6.2sp1 xenapi customization as per CloudSt…
Browse files Browse the repository at this point in the history
…ack resource code.

Signed-off-by: Hugo Trippaers <[email protected]>
  • Loading branch information
sanjaytripathi authored and spark404 committed Feb 25, 2014
1 parent 2ff9aba commit 505da76
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
12 changes: 8 additions & 4 deletions deps/XenServerJava/src/com/xensource/xenapi/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class Connection

private APIVersion apiVersion;

protected int _wait = 600;

/**
* Updated when Session.login_with_password() is called.
*/
Expand Down Expand Up @@ -142,10 +144,10 @@ public Connection(String client, String username, String password) throws java.n
* 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)
public Connection(URL url, int wait)
{
deprecatedConstructorUsed = false;

_wait = wait;
this.client = getClientFromURL(url);
}

Expand Down Expand Up @@ -257,6 +259,8 @@ private XmlRpcClient getClientFromURL(URL url)
{
config.setTimeZone(TimeZone.getTimeZone("UTC"));
config.setServerURL(url);
config.setReplyTimeout(_wait * 1000);
config.setConnectionTimeout(5000);
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
return client;
Expand All @@ -276,7 +280,7 @@ public String getSessionReference()
/**
* 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
protected Map dispatch(String method_call, Object[] method_params) throws XmlRpcException, XenAPIException
{
Map response = (Map) client.execute(method_call, method_params);

Expand Down Expand Up @@ -320,7 +324,7 @@ else if (method_call.equals("session.logout"))
new Connection(new URL(client_url.getProtocol(),
(String)error[1],
client_url.getPort(),
client_url.getFile()));
client_url.getFile()), _wait);
tmp_conn.sessionReference = sessionReference;
try
{
Expand Down
15 changes: 15 additions & 0 deletions deps/XenServerJava/src/com/xensource/xenapi/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,19 @@ public static String inject(Connection c, String clazz, String ref) throws
return Types.toString(result);
}

public static Map properFrom(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");
Map value = (Map)result;
Map<String, Object> from = new HashMap<String, Object>();
from.put("token", value.get("token"));
from.put("events", Types.toSetOfEventRecord(value.get("events")));
return from;
}

}
21 changes: 21 additions & 0 deletions deps/XenServerJava/src/com/xensource/xenapi/VDI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,27 @@ public void update(Connection c) throws
return;
}

/**
* Copy either a full VDI or the block differences between two VDIs into either a fresh VDI or an existing VDI.
*
* @param sr The destination SR (only required if the destination VDI is not specified
* @param baseVdi The base VDI (only required if copying only changed blocks, by default all blocks will be copied)
* @param intoVdi The destination VDI to copy blocks into (if omitted then a destination SR must be provided and a fresh VDI will be created)
* @return Task
*/
public Task copyAsync2(Connection c, SR sr, VDI baseVdi, VDI intoVdi) throws
BadServerResponse,
XenAPIException,
XmlRpcException,
Types.VdiReadonly {
String method_call = "Async.VDI.copy";
String session = c.getSessionReference();
Object[] method_params = {Marshalling.toXMLRPC(session), Marshalling.toXMLRPC(this.ref), Marshalling.toXMLRPC(sr), Marshalling.toXMLRPC(baseVdi), Marshalling.toXMLRPC(intoVdi)};
Map response = c.dispatch(method_call, method_params);
Object result = response.get("Value");
return Types.toTask(result);
}

/**
* Make a fresh VDI in the specified SR and copy the supplied VDI's data to the new disk
*
Expand Down

0 comments on commit 505da76

Please sign in to comment.