Search in sources :

Example 16 with GlusterServerService

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService in project ovirt-engine by oVirt.

the class ManageGlusterServiceCommandTest method mockBackend.

private void mockBackend(boolean succeeded, EngineError errorCode, GlusterServiceStatus status) {
    VDSReturnValue vdsReturnValue = new VDSReturnValue();
    vdsReturnValue.setSucceeded(succeeded);
    if (!succeeded) {
        vdsReturnValue.setVdsError(new VDSError(errorCode, ""));
    } else {
        if (status == GlusterServiceStatus.STOPPED) {
            vdsReturnValue.setReturnValue(getGlusterServerServicesByServerIdAndServiceType(Guid.newGuid(), ServiceType.GLUSTER_SWIFT, status));
        } else {
            // Adding one additional service for the case of stop so that save mechanism can be tested out
            Guid serverId = Guid.newGuid();
            List<GlusterServerService> serverServiceList = getGlusterServerServicesByServerIdAndServiceType(serverId, ServiceType.GLUSTER_SWIFT, status);
            GlusterServerService srvc3 = new GlusterServerService();
            srvc3.setMessage("test-msg3");
            srvc3.setPid(10000);
            srvc3.setPort(20000);
            srvc3.setServerId(serverId);
            srvc3.setServiceId(Guid.newGuid());
            srvc3.setServiceName("srvc3");
            srvc3.setServiceType(ServiceType.GLUSTER_SWIFT);
            srvc3.setStatus(status);
            serverServiceList.add(srvc3);
            vdsReturnValue.setReturnValue(serverServiceList);
        }
    }
    when(vdsBrokerFrontend.runVdsCommand(eq(VDSCommandType.ManageGlusterService), any())).thenReturn(vdsReturnValue);
}
Also used : VDSError(org.ovirt.engine.core.common.errors.VDSError) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) Guid(org.ovirt.engine.core.compat.Guid) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Example 17 with GlusterServerService

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService in project ovirt-engine by oVirt.

the class GlusterSwiftServiceModel method onEntityChanged.

@Override
protected void onEntityChanged() {
    super.onEntityChanged();
    GlusterServerService service = getEntity();
    if (service == null || service.getStatus() == GlusterServiceStatus.NOT_AVAILABLE) {
        getStartSwift().setIsChangeable(false);
        getStopSwift().setIsChangeable(false);
        getRestartSwift().setIsChangeable(false);
    } else {
        getStartSwift().setIsChangeable(service.getStatus() != GlusterServiceStatus.RUNNING);
        getStopSwift().setIsChangeable(service.getStatus() != GlusterServiceStatus.STOPPED);
        getRestartSwift().setIsChangeable(true);
    }
}
Also used : GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService)

Example 18 with GlusterServerService

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService in project ovirt-engine by oVirt.

the class ClusterGeneralModel method getGroupedGlusterSwiftServices.

private List<GlusterSwiftServiceModel> getGroupedGlusterSwiftServices(List<GlusterServerService> serviceList) {
    Map<Guid, GlusterSwiftServiceModel> serverSwiftMap = new HashMap<>();
    for (GlusterServerService service : serviceList) {
        GlusterSwiftServiceModel serverSwiftModel = serverSwiftMap.get(service.getServerId());
        if (serverSwiftModel == null) {
            GlusterServerService serverSwift = new GlusterServerService();
            serverSwift.setHostName(service.getHostName());
            serverSwift.setServerId(service.getServerId());
            serverSwift.setServiceType(ServiceType.GLUSTER_SWIFT);
            serverSwift.setStatus(service.getStatus());
            serverSwiftModel = new GlusterSwiftServiceModel(serverSwift);
            serverSwiftMap.put(service.getServerId(), serverSwiftModel);
        }
        serverSwiftModel.getInternalServiceList().add(service);
    }
    return new ArrayList<>(serverSwiftMap.values());
}
Also used : HashMap(java.util.HashMap) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 19 with GlusterServerService

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService in project ovirt-engine by oVirt.

the class GlusterServerServiceDaoTest method testUpdateByServerIdAndServiceType.

@Test
public void testUpdateByServerIdAndServiceType() {
    GlusterServerService existingService = dao.get(SERVER1_SERVICE_ID);
    assertNotNull(existingService);
    assertEquals(GlusterServiceStatus.RUNNING, existingService.getStatus());
    GlusterServerService serviceToModify = dao.get(SERVER1_SERVICE_ID);
    serviceToModify.setStatus(GlusterServiceStatus.STOPPED);
    dao.updateByServerIdAndServiceType(serviceToModify);
    GlusterServerService modifiedService = dao.get(SERVER1_SERVICE_ID);
    assertNotNull(modifiedService);
    assertEquals(GlusterServiceStatus.STOPPED, modifiedService.getStatus());
    assertEquals(GlusterServiceStatus.RUNNING, existingService.getStatus());
    assertFalse(existingService.equals(modifiedService));
}
Also used : GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) Test(org.junit.Test)

Example 20 with GlusterServerService

use of org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService in project ovirt-engine by oVirt.

the class GlusterServerServiceDaoTest method testUpdate.

@Test
public void testUpdate() {
    GlusterServerService existingService = dao.get(SERVER1_SERVICE_ID);
    assertNotNull(existingService);
    assertEquals(GlusterServiceStatus.RUNNING, existingService.getStatus());
    GlusterServerService serviceToModify = dao.get(SERVER1_SERVICE_ID);
    serviceToModify.setStatus(GlusterServiceStatus.STOPPED);
    dao.update(serviceToModify);
    GlusterServerService modifiedService = dao.get(SERVER1_SERVICE_ID);
    assertNotNull(modifiedService);
    assertEquals(GlusterServiceStatus.STOPPED, modifiedService.getStatus());
    assertEquals(GlusterServiceStatus.RUNNING, existingService.getStatus());
    assertFalse(existingService.equals(modifiedService));
}
Also used : GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) Test(org.junit.Test)

Aggregations

GlusterServerService (org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService)23 Guid (org.ovirt.engine.core.compat.Guid)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)5 Test (org.junit.Test)4 GlusterServiceStatus (org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus)4 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)4 List (java.util.List)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 GlusterService (org.ovirt.engine.core.common.businessentities.gluster.GlusterService)2 ServiceType (org.ovirt.engine.core.common.businessentities.gluster.ServiceType)2 GlusterServiceVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterServiceVDSParameters)2 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)2 Context (com.google.gwt.cell.client.Cell.Context)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 Column (com.google.gwt.user.cellview.client.Column)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1