use of org.ovirt.vdsm.jsonrpc.client.JsonRpcClient in project ovirt-engine by oVirt.
the class MarshallingTestCase method testGetCapabilities.
@SuppressWarnings("unchecked")
@Test
public void testGetCapabilities() throws Exception {
// Given
String capabilitiesJson = "{\"jsonrpc\": \"2.0\", \"id\": \"aed1feb4-42cf-4bf4-8ddf-852251152b68\", \"result\": {\"HBAInventory\": {\"iSCSI\": " + "[{\"InitiatorName\": \"iqn.1994-05.com.redhat:d990cf85cdeb\"}], \"FC\": []}, \"packages2\": {\"kernel\": {\"release\": \"200.fc19.x86_64\"," + " \"buildtime\": 1384356599.0, \"version\": \"3.11.8\"}, \"spice-server\": {\"release\": \"3.fc19\", \"buildtime\": 1383130020, " + "\"version\": \"0.12.4\"}, \"vdsm\": {\"release\": \"163.git9adad51.fc19\", \"buildtime\": 1385064768, \"version\": \"4.13.0\"}, " + "\"qemu-kvm\": {\"release\": \"13.fc19\", \"buildtime\": 1383700301, \"version\": \"1.4.2\"}, \"libvirt\": {\"release\": " + "\"1.fc19\", \"buildtime\": 1383765188, \"version\": \"1.0.5.7\"}, \"qemu-img\": {\"release\": \"13.fc19\", \"buildtime\": " + "1383700301, \"version\": \"1.4.2\"}, \"mom\": {\"release\": \"3.13.giteb3985f.fc19\", \"buildtime\": 1384283536, \"version\"" + ": \"0.3.2\"}}, \"cpuModel\": \"Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz\", \"hooks\": {}, \"cpuSockets\": \"1\", \"vmTypes\": " + "[\"kvm\"], \"networks\": {\"ovirtmgmt\": {\"iface\": \"ovirtmgmt\", \"addr\":" + " \"192.168.1.10\", \"cfg\": {\"DEFROUTE\": \"yes\", \"IPADDR\": \"192.168.1.10\", \"GATEWAY\": \"192.168.1.1\", \"DELAY\":" + " \"0\", \"NM_CONTROLLED\": \"no\", \"NETMASK\": \"255.255.255.0\", \"BOOTPROTO\": \"none\", \"STP\": \"no\", \"DEVICE\": " + "\"ovirtmgmt\", \"TYPE\": \"Bridge\", \"ONBOOT\": \"yes\"}, \"ipv6addrs\": [\"fe80::baca:3aff:fea9:77e2/64\"], \"gateway\":" + " \"192.168.1.1\", \"netmask\": \"255.255.255.0\", \"stp\": \"off\", \"bridged\": true, \"qosInbound\": \"\", \"qosOutbound\":" + " \"\", \"mtu\": \"1500\", \"ipv6gateway\": \"::\", \"ports\": [\"em1\"]}}, \"bridges\": {\"ovirtmgmt\": {\"addr\": \"192.168.1.10\"," + " \"cfg\": {\"DEFROUTE\": \"yes\", \"IPADDR\": \"192.168.1.10\", \"GATEWAY\": \"192.168.1.1\", \"DELAY\": \"0\", \"NM_CONTROLLED\":" + " \"no\", \"NETMASK\": \"255.255.255.0\", \"BOOTPROTO\": \"none\", \"STP\": \"no\", \"DEVICE\": \"ovirtmgmt\", \"TYPE\": \"Bridge\"," + " \"ONBOOT\": \"yes\"}, \"ipv6addrs\": [\"fe80::baca:3aff:fea9:77e2/64\"], \"mtu\": \"1500\", \"netmask\": \"255.255.255.0\", " + "\"stp\": \"off\", \"ipv6gateway\": \"::\", \"gateway\": \"192.168.1.1\", \"ports\": [\"em1\"]}}, \"uuid\": \"4C4C4544-0046-4E10-8032-B2C04F385A31\"," + " \"nics\": {\"em1\": {\"netmask\": \"\", \"addr\": \"\", \"hwaddr\": \"b8:ca:3a:a9:77:e2\", \"cfg\": {\"BRIDGE\": \"ovirtmgmt\", \"NM_CONTROLLED\":" + " \"no\", \"HWADDR\": \"b8:ca:3a:a9:77:e2\", \"STP\": \"no\", \"DEVICE\": \"em1\", \"ONBOOT\": \"yes\"}, \"ipv6addrs\": [\"fe80::baca:3aff:fea9:77e2/64\"]," + " \"speed\": 100, \"mtu\": \"1500\"}}, \"software_revision\": \"163\", \"clusterLevels\": [\"3.0\", \"3.1\", \"3.2\", \"3.3\"], \"cpuFlags\": " + "\"fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,sep,mtrr,pge,mca,cmov,pat,pse36,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,syscall,nx,rdtscp,lm,constant_" + "tsc,arch_perfmon,pebs,bts,rep_good,nopl,xtopology,nonstop_tsc,aperfmperf,eagerfpu,pni,pclmulqdq,dtes64,monitor,ds_cpl,vmx,smx,est,tm2,ssse3,cx16,xtpr,pdcm," + "pcid,sse4_1,sse4_2,x2apic,popcnt,tsc_deadline_timer,aes,xsave,avx,f16c,rdrand,lahf_lm,ida,arat,epb,xsaveopt,pln,pts,dtherm,tpr_shadow,vnmi,flexpriority,ept," + "vpid,fsgsbase,smep,erms,model_Nehalem,model_Conroe,model_coreduo,model_core2duo,model_Penryn,model_Westmere,model_n270,model_SandyBridge\", \"ISCSIInitiatorName\"" + ": \"iqn.1994-05.com.redhat:d990cf85cdeb\", \"netConfigDirty\": \"False\", \"supportedENGINEs\": [\"3.0\", \"3.1\", \"3.2\", \"3.3\"], \"reservedMem\": \"321\"," + " \"bondings\": {\"bond0\": {\"netmask\": \"\", \"addr\": \"\", \"slaves\": [], \"hwaddr\": \"6e:31:40:a3:e3:d7\", \"cfg\": {}, \"ipv6addrs\": [], \"mtu\": \"1500\"}}," + " \"software_version\": \"4.13\", \"memSize\": \"15937\", \"cpuSpeed\": \"3400.000\", \"version_name\": \"Snow Man\", \"vlans\": {}, \"cpuCores\": \"4\", \"kvmEnabled\":" + " \"true\", \"guestOverhead\": \"65\", \"cpuThreads\": \"8\", \"emulatedMachines\": [\"pc\", \"q35\", \"isapc\", \"pc-0.10\", \"pc-0.11\", \"pc-0.12\", \"pc-0.13\", " + "\"pc-0.14\", \"pc-0.15\", \"pc-1.0\", \"pc-1.1\", \"pc-1.2\", \"pc-1.3\", \"none\"], \"operatingSystem\": {\"release\": \"4\", \"version\": \"19\", \"name\": \"Fedora\"}}}";
ObjectMapper mapper = new ObjectMapper();
JsonRpcResponse response = JsonRpcResponse.fromJsonNode(mapper.readTree(capabilitiesJson));
Future<JsonRpcResponse> future = mock(Future.class);
when(future.get()).thenReturn(response);
JsonRpcClient client = mock(JsonRpcClient.class);
JsonRpcRequest request = mock(JsonRpcRequest.class);
when(client.call(request)).thenReturn(future);
// When
Map<String, Object> map = new FutureMap(client, request);
// Then
VDSInfoReturn vdsInfo = new VDSInfoReturn(map);
Status status = vdsInfo.status;
assertEquals("Done", status.message);
assertEquals(0, status.code);
Map<String, Object> info = vdsInfo.info;
assertTrue(!info.isEmpty());
Map<String, Object> bonds = (Map<String, Object>) info.get("bondings");
for (Entry<String, Object> entry : bonds.entrySet()) {
Map<String, Object> bond = (Map<String, Object>) entry.getValue();
assertEquals(0, ((Object[]) bond.get("slaves")).length);
}
}
use of org.ovirt.vdsm.jsonrpc.client.JsonRpcClient in project ovirt-engine by oVirt.
the class MarshallingTestCase method testEmptyListVDS.
@SuppressWarnings("unchecked")
@Test
public void testEmptyListVDS() throws Exception {
// Given
String json = "{\"jsonrpc\": \"2.0\", \"id\": \"3a0a4c64-1b67-4b48-bc31-e4e0cb7538b1\", \"result\": []}";
ObjectMapper mapper = new ObjectMapper();
JsonRpcResponse response = JsonRpcResponse.fromJsonNode(mapper.readTree(json));
Future<JsonRpcResponse> future = mock(Future.class);
when(future.get()).thenReturn(response);
JsonRpcClient client = mock(JsonRpcClient.class);
JsonRpcRequest request = mock(JsonRpcRequest.class);
when(client.call(request)).thenReturn(future);
// When
Map<String, Object> map = new FutureMap(client, request).withResponseKey("vmList").withResponseType(Object[].class);
// Then
VMListReturn vmList = new VMListReturn(map);
Status status = vmList.status;
assertEquals("Done", status.message);
assertEquals(0, status.code);
assertEquals(0, vmList.vmList.length);
}
use of org.ovirt.vdsm.jsonrpc.client.JsonRpcClient in project ovirt-engine by oVirt.
the class JsonRpcIntegrationTest method testGetVdsCapabilities.
@Test
public void testGetVdsCapabilities() throws InterruptedException, ExecutionException, ClientConnectionException {
JsonRpcClient client = JsonRpcUtils.createStompClient(HOST_ADDRESS, PORT, TIMEOUT, 0, TIMEOUT, TIMEOUT, true, "TLSv1", Runtime.getRuntime().availableProcessors(), DEFAULT_REQUEST_QUEUE, DEFAULT_RESPONSE_QUEUE, DEFAULT_EVENTS_QUEUE, Executors.newScheduledThreadPool(1));
final JsonRpcRequest request = new RequestBuilder("Host.getCapabilities").build();
Map<String, Object> map = new FutureMap(client, request);
assertTrue(map.isEmpty());
}
use of org.ovirt.vdsm.jsonrpc.client.JsonRpcClient in project ovirt-engine by oVirt.
the class MarshallingTestCase method testDiscoverSendTargets.
@SuppressWarnings("unchecked")
@Test
public void testDiscoverSendTargets() throws Exception {
// Given
String json = "{\"jsonrpc\": \"2.0\", \"id\": \"9afac443-3473-454d-b6c7-80f0b7876ff7\", \"result\": [\"10.35.16.25:3260,1 iqn.1994-05.com.redhat.com:ahadas-iscsi\"," + " \"10.35.16.25:3260,1 iqn.1994-05.com.redhat.com:sgotliv-iscsi\", \"10.35.16.25:3260,1 iqn.1994-05.com.redhat.com:sgotliv-iscsi2\", " + "\"10.35.16.25:3260,1 iqn.1994-05.com.redhat:nsoffer-target1\", \"10.35.16.25:3260,1 iqn.1994-05.com.redhat:nsoffer-target2\"," + " \"10.35.16.25:3260,1 iqn.1994-05.com.redhat:pkliczew\", \"10.35.16.25:3260,1 iqn.1994-05.com.redhat:ybronhei-target\", \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:achub-iscsi\"," + " \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:ashakarc-iscsi\", \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:derez-iscsi\"," + " \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:drankevi-iscsi\", \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:ecohen-iscsi\"," + " \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:gchaplik-iscsi\", \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:mkolesnik-iscsi\"," + " \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:mpastern-iscsi\", \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:oliel-iscsi\"," + " \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:oliel-iscsi2\", \"10.35.16.25:3260,1 iqn.2011-05.com.redhat:tnisan-iscsi\"," + " \"10.35.16.25:3260,1 iqn.2011-06.com.redhat:jchoate-iscsi\", \"10.35.16.25:3260,1 iqn.2011-06.com.redhat:msalem-iscsi\"," + " \"10.35.16.25:3260,1 iqn.2011-06.com.redhat:ofrenkel-iscsi\", \"10.35.16.25:3260,1 iqn.2011-08.com.redhat:mlipchuk-iscsi\"," + " \"10.35.16.25:3260,1 iqn.2011-08.com.redhat:oourfali1\", \"10.35.16.25:3260,1 iqn.2011-08.com.redhat:shavivi1\", \"10.35.16.25:3260,1 iqn.2011-08.com.redhat:shavivi2\"," + " \"10.35.16.25:3260,1 iqn.2011-09.com.redhat:masayag-iscsi\", \"10.35.16.25:3260,1 iqn.2012-01.com.redhat:storage-negative-test1\", \"10.35.16.25:3260,1 iqn.2012-03.com.redhat:rami-api\"," + " \"10.35.16.25:3260,1 iqn.2012-04.com.redhat:rhevm-em1\", \"10.35.16.25:3260,1 iqn.2012-06.com.redhat:rgolan1\", \"10.35.16.25:3260,1 iqn.2012-06.com.redhat:tnisan1\"," + " \"10.35.16.25:3260,1 iqn.2012-09.com.redhat.com:omasad1\", \"10.35.16.25:3260,1 iqn.2012-12.com.redhat.com:rnori\", \"10.35.16.25:3260,1 iqn.2013-01.redhat.com:vered1\"," + " \"10.35.16.25:3260,1 iqn.2013-04.redhat.com:abonas-target1\", \"10.35.16.25:3260,1 iqn.2013-04.redhat.com:abonas-target2\", \"10.35.16.25:3260,1 iqn.2013-04.redhat.com:mtayer1\"]}";
ObjectMapper mapper = new ObjectMapper();
JsonRpcResponse response = JsonRpcResponse.fromJsonNode(mapper.readTree(json));
Future<JsonRpcResponse> future = mock(Future.class);
when(future.get()).thenReturn(response);
JsonRpcClient client = mock(JsonRpcClient.class);
JsonRpcRequest request = mock(JsonRpcRequest.class);
when(client.call(request)).thenReturn(future);
// When
Map<String, Object> map = new FutureMap(client, request).withResponseKey("fullTargets");
IQNListReturn list = new IQNListReturn(map);
assertEquals("Done", list.getStatus().message);
assertEquals(0, list.getStatus().code);
assertEquals(37, parseFullTargets(list.getIqnList()).size());
}
use of org.ovirt.vdsm.jsonrpc.client.JsonRpcClient in project ovirt-engine by oVirt.
the class MarshallingTestCase method testGetIsoListWithoutIsos.
@SuppressWarnings("unchecked")
@Test
public void testGetIsoListWithoutIsos() throws Exception {
// Given
String json = "{\"jsonrpc\": \"2.0\", \"id\": \"c1796b67-8932-4e90-a6f9-aa68266493f8\", \"result\": []}";
ObjectMapper mapper = new ObjectMapper();
JsonRpcResponse response = JsonRpcResponse.fromJsonNode(mapper.readTree(json));
Future<JsonRpcResponse> future = mock(Future.class);
when(future.get()).thenReturn(response);
JsonRpcClient client = mock(JsonRpcClient.class);
JsonRpcRequest request = mock(JsonRpcRequest.class);
when(client.call(request)).thenReturn(future);
// When
Map<String, Object> map = new FutureMap(client, request).withResponseKey("iso_list").withResponseType(Object[].class);
// Then
FileStatsReturn isoList = new FileStatsReturn(map);
assertEquals("Done", isoList.getStatus().message);
assertEquals(0, isoList.getStatus().code);
assertEquals(0, isoList.getFileStats().size());
}
Aggregations