Skip to content

Instantly share code, notes, and snippets.

@gaborigloi
Created October 12, 2017 08:46
Show Gist options
  • Save gaborigloi/a979f8109e4987fc0b90f500a0750c67 to your computer and use it in GitHub Desktop.
Save gaborigloi/a979f8109e4987fc0b90f500a0750c67 to your computer and use it in GitHub Desktop.
Testing the VDI.get_nbd_info call in the Java XenServer / XenAPI SDK
/* To run: change https to http in TestBase.java, add it to RunTests.java, comment out the other tests,
run with:
java -cp :xmlrpc-client-3.1.3.jar:xmlrpc-common-3.1.3.jar:ws-commons-util-1.0.2.jar RunTests ...
*/
/*
* 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.
*/
import java.util.Date;
import java.util.Random;
import com.xensource.xenapi.VDI;
import com.xensource.xenapi.VdiNbdServerInfo;
import java.util.Set;
public class GetVdiNbdServerInfo extends TestBase
{
public String getTestName() {
return "GetVdiNbdServerInfo";
}
/**
* Get the NBD info for a given VDI.
*/
protected void TestCore() throws Exception {
String uuid = "2465431d-7672-4f7f-9351-5a502a642570";
VDI vdi = VDI.getByUuid(connection, uuid);
Set<VdiNbdServerInfo.Record> infos = vdi.getNbdInfo(connection);
log("VDI uuid: " + vdi.getUuid(connection));
for (VdiNbdServerInfo.Record info : infos) {
log("info: " + info.toString());
logf("exportname: %s port: %d cert: %s subject: %s address: %s", info.exportname, info.port, info.cert, info.subject, info.address);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment