Search in sources :

Example 6 with Option

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

the class BackendGlusterVolumeResourceTest method testSetOptionInvalidParams.

@Test
public void testSetOptionInvalidParams() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    resource.setUriInfo(setUpBasicUriExpectations());
    try {
        Action action = new Action();
        action.setOption(new Option());
        resource.setOption(action);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Option", "setOption", "name, value");
    }
}
Also used : Action(org.ovirt.engine.api.model.Action) WebApplicationException(javax.ws.rs.WebApplicationException) Option(org.ovirt.engine.api.model.Option) Test(org.junit.Test) AbstractBackendSubResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)

Example 7 with Option

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

the class BackendGlusterVolumeResourceTest method testResetOptionInvalidParams.

@Test
public void testResetOptionInvalidParams() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    resource.setUriInfo(setUpBasicUriExpectations());
    try {
        Action action = new Action();
        action.setOption(new Option());
        resource.resetOption(action);
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Option", "resetOption", "name");
    }
}
Also used : Action(org.ovirt.engine.api.model.Action) WebApplicationException(javax.ws.rs.WebApplicationException) Option(org.ovirt.engine.api.model.Option) Test(org.junit.Test) AbstractBackendSubResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)

Example 8 with Option

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

the class BackendGlusterVolumeResourceTest method testSetOption.

@Test
public void testSetOption() throws Exception {
    setupParentExpectations();
    resource.setParent(volumesResourceMock);
    setUriInfo(setUpActionExpectations(ActionType.SetGlusterVolumeOption, GlusterVolumeOptionParameters.class, new String[] { "VolumeId" }, new Object[] { GUIDS[0] }));
    Action action = new Action();
    action.setOption(new Option());
    action.getOption().setName("auth.allow");
    action.getOption().setValue("*");
    verifyActionResponse(resource.setOption(action));
}
Also used : GlusterVolumeOptionParameters(org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters) Action(org.ovirt.engine.api.model.Action) Option(org.ovirt.engine.api.model.Option) Test(org.junit.Test) AbstractBackendSubResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)

Example 9 with Option

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

the class FenceOptionsParser method parseOption.

/* Format is <name=value>
     */
private static Option parseOption(String str, Map<String, String> types, boolean ignoreValues) {
    String[] parts = str.split("=", -1);
    if (parts.length != 2) {
        log.error("Invalid fencing option description \"{}\".", str);
        return null;
    }
    Option ret = new Option();
    ret.setName(parts[0]);
    if (!ignoreValues) {
        ret.setValue(parts[1]);
    }
    if (types.containsKey(parts[0])) {
        ret.setType(types.get(parts[0]));
    } else {
        log.error("No type specified for fencing option \"{}\".", parts[0]);
        return null;
    }
    return ret;
}
Also used : Option(org.ovirt.engine.api.model.Option)

Example 10 with Option

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

the class FenceOptionsParserTest method verifyResult.

private void verifyResult(Agent result, String type, String... options) {
    assertEquals(type, result.getType());
    assertNotNull(result.getOptions());
    assertEquals(options.length, result.getOptions().getOptions().size() * 3);
    for (int i = 0; i < options.length; i += 3) {
        Option opt = result.getOptions().getOptions().get(i / 3);
        assertEquals(options[i], opt.getName());
        assertEquals(options[i + 1], opt.getType());
        assertEquals(options[i + 2], opt.getValue());
    }
}
Also used : Option(org.ovirt.engine.api.model.Option)

Aggregations

Option (org.ovirt.engine.api.model.Option)13 Test (org.junit.Test)4 Action (org.ovirt.engine.api.model.Action)4 AbstractBackendSubResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)4 Options (org.ovirt.engine.api.model.Options)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 GlusterVolumeOptionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters)2 GlusterVolumeOptionEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors.joining (java.util.stream.Collectors.joining)1 StringUtils (org.apache.commons.lang.StringUtils)1 Bonding (org.ovirt.engine.api.model.Bonding)1 BootProtocol (org.ovirt.engine.api.model.BootProtocol)1 GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)1 HostNic (org.ovirt.engine.api.model.HostNic)1 HostNicVirtualFunctionsConfiguration (org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration)1 Ip (org.ovirt.engine.api.model.Ip)1 IpVersion (org.ovirt.engine.api.model.IpVersion)1 Mac (org.ovirt.engine.api.model.Mac)1