Search in sources :

Example 1 with VDSInfoReturn

use of org.ovirt.engine.core.vdsbroker.vdsbroker.VDSInfoReturn in project ovirt-engine by oVirt.

the class JsonRpcVdsServer method getVdsStats.

@Override
public VDSInfoReturn getVdsStats() {
    JsonRpcRequest request = new RequestBuilder("Host.getStats").build();
    Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("info");
    return new VDSInfoReturn(response);
}
Also used : VDSInfoReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSInfoReturn) JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder)

Example 2 with VDSInfoReturn

use of org.ovirt.engine.core.vdsbroker.vdsbroker.VDSInfoReturn in project ovirt-engine by oVirt.

the class JsonRpcVdsServer method getHardwareInfo.

@Override
public VDSInfoReturn getHardwareInfo() {
    JsonRpcRequest request = new RequestBuilder("Host.getHardwareInfo").build();
    Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("info");
    return new VDSInfoReturn(response);
}
Also used : VDSInfoReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSInfoReturn) JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder)

Example 3 with VDSInfoReturn

use of org.ovirt.engine.core.vdsbroker.vdsbroker.VDSInfoReturn 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);
    }
}
Also used : JsonRpcResponse(org.ovirt.vdsm.jsonrpc.client.JsonRpcResponse) Status(org.ovirt.engine.core.vdsbroker.vdsbroker.Status) JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) VDSInfoReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSInfoReturn) JsonRpcClient(org.ovirt.vdsm.jsonrpc.client.JsonRpcClient) HashMap(java.util.HashMap) Map(java.util.Map) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test)

Example 4 with VDSInfoReturn

use of org.ovirt.engine.core.vdsbroker.vdsbroker.VDSInfoReturn in project ovirt-engine by oVirt.

the class JsonRpcVdsServer method getCapabilities.

@Override
public VDSInfoReturn getCapabilities() {
    JsonRpcRequest request = new RequestBuilder("Host.getCapabilities").build();
    Map<String, Object> response = new FutureMap(this.client, request).withResponseKey("info");
    return new VDSInfoReturn(response);
}
Also used : VDSInfoReturn(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSInfoReturn) JsonRpcRequest(org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest) RequestBuilder(org.ovirt.vdsm.jsonrpc.client.RequestBuilder)

Aggregations

VDSInfoReturn (org.ovirt.engine.core.vdsbroker.vdsbroker.VDSInfoReturn)4 JsonRpcRequest (org.ovirt.vdsm.jsonrpc.client.JsonRpcRequest)4 RequestBuilder (org.ovirt.vdsm.jsonrpc.client.RequestBuilder)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 Test (org.junit.Test)1 Status (org.ovirt.engine.core.vdsbroker.vdsbroker.Status)1 JsonRpcClient (org.ovirt.vdsm.jsonrpc.client.JsonRpcClient)1 JsonRpcResponse (org.ovirt.vdsm.jsonrpc.client.JsonRpcResponse)1