use of org.ovirt.engine.sdk4.types.IscsiDetails in project ovirt-engine-sdk-java by oVirt.
the class IscsiDiscover method main.
public static void main(String[] args) throws Exception {
// Create the connection to the server:
Connection connection = connection().url("https://engine40.example.com/ovirt-engine/api").user("admin@internal").password("redhat123").trustStoreFile("truststore.jks").build();
// Get the reference to the hosts service:
HostsService hostsService = connection.systemService().hostsService();
// Find the host:
Host host = hostsService.list().search("name=myhost").send().hosts().get(0);
// Locate the service that manages the host, as that is where the action methods are defined:
HostService hostService = hostsService.hostService(host.id());
// Call the "iscsiDiscover" method of the service to start it:
HostService.IscsiDiscoverResponse response = hostService.iscsiDiscover().iscsi(iscsiDetails().address("myaddress")).send();
// Print only targets:
for (String target : response.iscsiTargets()) {
System.out.println(target);
}
// Print only address corresponding to target:
for (IscsiDetails detail : response.discoveredTargets()) {
System.out.println(detail.address() + ":" + detail.target());
}
// Close the connection to the server:
connection.close();
}
use of org.ovirt.engine.sdk4.types.IscsiDetails in project ovirt-engine-sdk-java by oVirt.
the class IscsiDiscoverTest method testActionParameters.
/**
* Test we don't get null vm service for existing vm id and correct object
*/
@Test
public void testActionParameters() {
HostsService hostsService = connection.systemService().hostsService();
HostService hostService = hostsService.hostService("123");
HostService.IscsiDiscoverResponse response = hostService.iscsiDiscover().iscsi(iscsiDetails().address("iscsi.example.com").port(3260)).send();
assertEquals("<action>" + "<iscsi>" + "<address>iscsi.example.com</address>" + "<port>3260</port>" + "</iscsi>" + "</action>", getLastRequestContent());
assertEquals("192.168.121.102", response.discoveredTargets().get(0).address());
assertEquals(BigInteger.valueOf(3260), response.discoveredTargets().get(0).port());
assertEquals("myiqn", response.iscsiTargets().get(0));
}
Aggregations