Search in sources :

Example 1 with Hooks

use of org.ovirt.engine.api.model.Hooks in project ovirt-engine by oVirt.

the class HostMapper method map.

@Mapping(from = HashMap.class, to = Hooks.class)
public static Hooks map(HashMap<String, HashMap<String, HashMap<String, String>>> dictionary, Hooks hooks) {
    if (hooks == null) {
        hooks = new Hooks();
    }
    for (Map.Entry<String, HashMap<String, HashMap<String, String>>> keyValuePair : dictionary.entrySet()) {
        // events
        for (Map.Entry<String, HashMap<String, String>> keyValuePair1 : // hooks
        keyValuePair.getValue().entrySet()) {
            Hook hook = createHook(keyValuePair, keyValuePair1);
            hooks.getHooks().add(hook);
        }
    }
    return hooks;
}
Also used : Hook(org.ovirt.engine.api.model.Hook) HashMap(java.util.HashMap) Hooks(org.ovirt.engine.api.model.Hooks) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with Hooks

use of org.ovirt.engine.api.model.Hooks in project ovirt-engine by oVirt.

the class BackendHostHookResourceTest method getHooks.

private Hooks getHooks() {
    Hooks hooks = new Hooks();
    Hook hook = new Hook();
    hook.setId(SOME_ID);
    hook.setEventName(EVENT_1_NAME);
    hook.setName(HOOK_1_NAME);
    hook.setMd5(MD5_1);
    hooks.getHooks().add(hook);
    hook = new Hook();
    hook.setId(EVENT2_HOOK2_MD52_HASH);
    hook.setEventName(EVENT_2_NAME);
    hook.setName(HOOK_2_NAME);
    hook.setMd5(MD5_2);
    hooks.getHooks().add(hook);
    return hooks;
}
Also used : Hook(org.ovirt.engine.api.model.Hook) Hooks(org.ovirt.engine.api.model.Hooks)

Example 3 with Hooks

use of org.ovirt.engine.api.model.Hooks in project ovirt-engine by oVirt.

the class V3HostInAdapter method adapt.

@Override
public Host adapt(V3Host from) {
    Host to = new Host();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetAddress()) {
        to.setAddress(from.getAddress());
    }
    if (from.isSetAutoNumaStatus()) {
        to.setAutoNumaStatus(AutoNumaStatus.fromValue(from.getAutoNumaStatus()));
    }
    if (from.isSetCertificate()) {
        to.setCertificate(adaptIn(from.getCertificate()));
    }
    if (from.isSetCluster()) {
        to.setCluster(adaptIn(from.getCluster()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetCpu()) {
        to.setCpu(adaptIn(from.getCpu()));
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDevicePassthrough()) {
        to.setDevicePassthrough(adaptIn(from.getDevicePassthrough()));
    }
    if (from.isSetDisplay()) {
        to.setDisplay(adaptIn(from.getDisplay()));
    }
    if (from.isSetExternalHostProvider()) {
        to.setExternalHostProvider(adaptIn(from.getExternalHostProvider()));
    }
    if (from.isSetExternalStatus() && from.getExternalStatus().isSetState()) {
        to.setExternalStatus(ExternalStatus.fromValue(from.getExternalStatus().getState()));
    }
    if (from.isSetHardwareInformation()) {
        to.setHardwareInformation(adaptIn(from.getHardwareInformation()));
    }
    if (from.isSetHooks()) {
        to.setHooks(new Hooks());
        to.getHooks().getHooks().addAll(adaptIn(from.getHooks().getHooks()));
    }
    if (from.isSetHostedEngine()) {
        to.setHostedEngine(adaptIn(from.getHostedEngine()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetIscsi()) {
        to.setIscsi(adaptIn(from.getIscsi()));
    }
    if (from.isSetKatelloErrata()) {
        to.setKatelloErrata(new KatelloErrata());
        to.getKatelloErrata().getKatelloErrata().addAll(adaptIn(from.getKatelloErrata().getKatelloErrata()));
    }
    if (from.isSetKdumpStatus()) {
        to.setKdumpStatus(KdumpStatus.fromValue(from.getKdumpStatus()));
    }
    if (from.isSetKsm()) {
        to.setKsm(adaptIn(from.getKsm()));
    }
    if (from.isSetLibvirtVersion()) {
        to.setLibvirtVersion(adaptIn(from.getLibvirtVersion()));
    }
    if (from.isSetMaxSchedulingMemory()) {
        to.setMaxSchedulingMemory(from.getMaxSchedulingMemory());
    }
    if (from.isSetMemory()) {
        to.setMemory(from.getMemory());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetNumaSupported()) {
        to.setNumaSupported(from.isNumaSupported());
    }
    if (from.isSetOs()) {
        to.setOs(adaptIn(from.getOs()));
    }
    if (from.isSetOverrideIptables()) {
        to.setOverrideIptables(from.isOverrideIptables());
    }
    if (from.isSetPort()) {
        to.setPort(from.getPort());
    }
    if (from.isSetPowerManagement()) {
        to.setPowerManagement(adaptIn(from.getPowerManagement()));
    }
    if (from.isSetRootPassword()) {
        to.setRootPassword(from.getRootPassword());
    }
    if (from.isSetSelinux()) {
        to.setSeLinux(adaptIn(from.getSelinux()));
    }
    // This is for the old and deprecated "storage_manager" element:
    V3StorageManager storageManager = from.getStorageManager();
    if (storageManager != null) {
        Spm spm = new Spm();
        Boolean value = storageManager.isValue();
        if (value != null) {
            spm.setStatus(value ? SpmStatus.SPM : SpmStatus.NONE);
        }
        Integer priority = spm.getPriority();
        if (storageManager.getPriority() != null) {
            spm.setPriority(priority);
        }
        to.setSpm(spm);
    }
    // element to override the old element when both are provided):
    if (from.isSetSpm()) {
        to.setSpm(adaptIn(from.getSpm()));
    }
    if (from.isSetSsh()) {
        to.setSsh(adaptIn(from.getSsh()));
    }
    if (from.isSetStatistics()) {
        to.setStatistics(new Statistics());
        to.getStatistics().getStatistics().addAll(adaptIn(from.getStatistics().getStatistics()));
    }
    V3Status status = from.getStatus();
    if (status != null) {
        if (status.isSetState()) {
            to.setStatus(HostStatus.fromValue(status.getState()));
        }
        if (status.isSetDetail()) {
            to.setStatusDetail(status.getDetail());
        }
    }
    if (from.isSetStorageConnectionExtensions()) {
        to.setStorageConnectionExtensions(new StorageConnectionExtensions());
        to.getStorageConnectionExtensions().getStorageConnectionExtensions().addAll(adaptIn(from.getStorageConnectionExtensions().getStorageConnectionExtension()));
    }
    if (from.isSetSummary()) {
        to.setSummary(adaptIn(from.getSummary()));
    }
    if (from.isSetTransparentHugepages()) {
        to.setTransparentHugepages(adaptIn(from.getTransparentHugepages()));
    }
    if (from.isSetType()) {
        // In version 3 of the API the string for the RHEV_H value was "rhev-h", with a dash instead of an
        // underscore, and we need to accept that for backwards compatibility:
        String fromType = from.getType();
        HostType toType = fromType.equalsIgnoreCase("rhev-h") ? HostType.RHEV_H : HostType.fromValue(fromType);
        to.setType(toType);
    }
    if (from.isSetUpdateAvailable()) {
        to.setUpdateAvailable(from.isUpdateAvailable());
    }
    if (from.isSetVersion()) {
        to.setVersion(adaptIn(from.getVersion()));
    }
    return to;
}
Also used : Spm(org.ovirt.engine.api.model.Spm) HostType(org.ovirt.engine.api.model.HostType) KatelloErrata(org.ovirt.engine.api.model.KatelloErrata) Host(org.ovirt.engine.api.model.Host) V3Host(org.ovirt.engine.api.v3.types.V3Host) Hooks(org.ovirt.engine.api.model.Hooks) V3Status(org.ovirt.engine.api.v3.types.V3Status) StorageConnectionExtensions(org.ovirt.engine.api.model.StorageConnectionExtensions) Statistics(org.ovirt.engine.api.model.Statistics) V3StorageManager(org.ovirt.engine.api.v3.types.V3StorageManager)

Example 4 with Hooks

use of org.ovirt.engine.api.model.Hooks in project ovirt-engine by oVirt.

the class V3HooksInAdapter method adapt.

@Override
public Hooks adapt(V3Hooks from) {
    Hooks to = new Hooks();
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetActive()) {
        to.setActive(from.getActive());
    }
    if (from.isSetSize()) {
        to.setSize(from.getSize());
    }
    if (from.isSetTotal()) {
        to.setTotal(from.getTotal());
    }
    to.getHooks().addAll(adaptIn(from.getHooks()));
    return to;
}
Also used : Hooks(org.ovirt.engine.api.model.Hooks) V3Hooks(org.ovirt.engine.api.v3.types.V3Hooks)

Example 5 with Hooks

use of org.ovirt.engine.api.model.Hooks in project ovirt-engine by oVirt.

the class BackendHostHooksResourceTest method testList.

@Test
public void testList() throws Exception {
    resource.setUriInfo(setUpBasicUriExpectations());
    setUpGetEntityExpectations(QueryType.GetVdsHooksById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Hooks hooks = resource.list();
    assertNotNull(hooks.getHooks());
    assertEquals(4, hooks.getHooks().size());
}
Also used : Hooks(org.ovirt.engine.api.model.Hooks) Test(org.junit.Test)

Aggregations

Hooks (org.ovirt.engine.api.model.Hooks)5 Hook (org.ovirt.engine.api.model.Hook)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 Host (org.ovirt.engine.api.model.Host)1 HostType (org.ovirt.engine.api.model.HostType)1 KatelloErrata (org.ovirt.engine.api.model.KatelloErrata)1 Spm (org.ovirt.engine.api.model.Spm)1 Statistics (org.ovirt.engine.api.model.Statistics)1 StorageConnectionExtensions (org.ovirt.engine.api.model.StorageConnectionExtensions)1 V3Hooks (org.ovirt.engine.api.v3.types.V3Hooks)1 V3Host (org.ovirt.engine.api.v3.types.V3Host)1 V3Status (org.ovirt.engine.api.v3.types.V3Status)1 V3StorageManager (org.ovirt.engine.api.v3.types.V3StorageManager)1