Search in sources :

Example 1 with GlusterServerService

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

the class ClusterServiceModel method filterServices.

private void filterServices() {
    VDS selectedVds = hostList.getSelectedItem();
    ServiceType serviceType = serviceTypeList.getSelectedItem();
    ArrayList<EntityModel<GlusterServerService>> list = new ArrayList<>();
    List<GlusterServerService> serviceList = new ArrayList<>(getActualServiceList());
    Collections.sort(serviceList, Comparator.comparing(GlusterServerService::getHostName).thenComparing(g -> g.getServiceType().toString()));
    for (GlusterServerService service : serviceList) {
        if ((selectedVds == null || service.getHostName().equals(selectedVds.getHostName())) && (serviceType == null || service.getServiceType() == serviceType)) {
            list.add(new EntityModel<>(service));
        }
    }
    getServiceList().setItems(list);
}
Also used : ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Comparator(java.util.Comparator) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) VDS(org.ovirt.engine.core.common.businessentities.VDS) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList)

Example 2 with GlusterServerService

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

the class ManageGlusterSwiftPopupView method initEditors.

private void initEditors() {
    swiftStatusEditor = new EntityModelLabelEditor<>(new EnumRenderer<GlusterServiceStatus>());
    // $NON-NLS-1$
    startSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
    // $NON-NLS-1$
    stopSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
    // $NON-NLS-1$
    restartSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
    manageSwiftServerLevel = new EntityModelCheckBoxEditor(Align.RIGHT);
    hostServicesTable = new EntityModelCellTable<>(false, true);
    hostServicesTable.addColumn(new AbstractEntityModelTextColumn<GlusterServerService>() {

        @Override
        public String getText(GlusterServerService entity) {
            return entity.getHostName();
        }
    }, constants.hostGlusterSwift());
    hostServicesTable.addColumn(new AbstractEnumColumn<EntityModel, ServiceType>() {

        @Override
        protected ServiceType getRawValue(EntityModel object) {
            return ((GlusterSwiftServiceModel) object).getEntity().getServiceType();
        }
    }, constants.serviceNameGlusterSwift());
    hostServicesTable.addColumn(new AbstractEnumColumn<EntityModel, GlusterServiceStatus>() {

        @Override
        protected GlusterServiceStatus getRawValue(EntityModel object) {
            return ((GlusterSwiftServiceModel) object).getEntity().getStatus();
        }
    }, constants.serviceStatusGlusterSwift());
    Column<EntityModel, Boolean> startSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {

        @Override
        public Boolean getValue(EntityModel object) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            return swiftServiceModel.getStartSwift().getEntity();
        }

        @Override
        public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            if (swiftServiceModel.getStartSwift().getIsChangable()) {
                super.render(context, object, sb);
            }
        }
    };
    startSwiftColumn.setFieldUpdater((index, object, value) -> {
        GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
        swiftModel.getStartSwift().setEntity(value);
        if (value) {
            swiftModel.getStopSwift().setEntity(false);
            swiftModel.getRestartSwift().setEntity(false);
            hostServicesTable.redraw();
        }
    });
    hostServicesTable.addColumn(startSwiftColumn, constants.startGlusterSwift());
    Column<EntityModel, Boolean> stopSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {

        @Override
        public Boolean getValue(EntityModel object) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            return swiftServiceModel.getStopSwift().getEntity();
        }

        @Override
        public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            if (swiftServiceModel.getStopSwift().getIsChangable()) {
                super.render(context, object, sb);
            }
        }
    };
    stopSwiftColumn.setFieldUpdater((index, object, value) -> {
        GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
        if (swiftModel.getStopSwift().getIsChangable()) {
            swiftModel.getStopSwift().setEntity(value);
            if (value) {
                swiftModel.getStartSwift().setEntity(false);
                swiftModel.getRestartSwift().setEntity(false);
                hostServicesTable.redraw();
            }
        }
    });
    hostServicesTable.addColumn(stopSwiftColumn, constants.stopGlusterSwift());
    Column<EntityModel, Boolean> restartSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {

        @Override
        public Boolean getValue(EntityModel object) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            return swiftServiceModel.getRestartSwift().getEntity();
        }

        @Override
        public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            if (swiftServiceModel.getRestartSwift().getIsChangable()) {
                super.render(context, object, sb);
            }
        }
    };
    restartSwiftColumn.setFieldUpdater((index, object, value) -> {
        GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
        swiftModel.getRestartSwift().setEntity(value);
        if (value) {
            swiftModel.getStartSwift().setEntity(false);
            swiftModel.getStopSwift().setEntity(false);
            hostServicesTable.redraw();
        }
    });
    hostServicesTable.addColumn(restartSwiftColumn, constants.restartGlusterSwift());
}
Also used : Context(com.google.gwt.cell.client.Cell.Context) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) RadioboxCell(org.ovirt.engine.ui.common.widget.table.cell.RadioboxCell) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) EnumRenderer(org.ovirt.engine.ui.common.widget.renderer.EnumRenderer) GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) AbstractEntityModelTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) Column(com.google.gwt.user.cellview.client.Column) ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) GlusterSwiftServiceModel(org.ovirt.engine.ui.uicommonweb.models.clusters.GlusterSwiftServiceModel) EntityModelRadioButtonEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor)

Example 3 with GlusterServerService

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

the class GlusterServicesReturn method getService.

private GlusterServerService getService(Map<String, Object> serviceMap) {
    GlusterServerService serverService = new GlusterServerService();
    serverService.setServiceName((String) serviceMap.get(NAME));
    String pid = (String) serviceMap.get(PID);
    serverService.setPid(StringUtils.isEmpty(pid) ? null : Integer.parseInt(pid));
    serverService.setStatus(GlusterServiceStatus.valueOf((String) serviceMap.get(STATUS)));
    serverService.setMessage((String) serviceMap.get(MESSAGE));
    serverService.setServerId(serverId);
    GlusterService service = servicesMap.get(serverService.getServiceName());
    if (service != null) {
        serverService.setServiceId(service.getId());
        serverService.setServiceType(service.getServiceType());
    }
    return serverService;
}
Also used : GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) GlusterService(org.ovirt.engine.core.common.businessentities.gluster.GlusterService)

Example 4 with GlusterServerService

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

the class GlusterVolumeStatusReturn method prepareServiceInfo.

private void prepareServiceInfo(Map<String, Object> statusInfo, List<GlusterServerService> serviceInfoList, String service) {
    if (statusInfo.containsKey(service)) {
        Object[] serviceInfo = (Object[]) statusInfo.get(service);
        for (Object serviceObj : serviceInfo) {
            Map<String, Object> serviceMap = (Map<String, Object>) serviceObj;
            GlusterServerService parsedServiceInfo = parseServiceInfo(serviceMap);
            parsedServiceInfo.setServiceType(service.equals(NFS_KEY) ? ServiceType.NFS : ServiceType.SHD);
            serviceInfoList.add(parsedServiceInfo);
        }
    }
}
Also used : GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) Map(java.util.Map)

Example 5 with GlusterServerService

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

the class HostGlusterSwiftListModel method updateActionAvailability.

private void updateActionAvailability() {
    boolean enableStart = false;
    boolean enableStop = false;
    boolean enableRestart = false;
    List<GlusterServerService> serviceList = (List<GlusterServerService>) getItems();
    if (serviceList == null || serviceList.isEmpty()) {
        enableStart = false;
        enableStop = false;
        enableRestart = false;
    } else {
        for (GlusterServerService service : serviceList) {
            if (service.getStatus() != GlusterServiceStatus.NOT_AVAILABLE) {
                if (service.getStatus() != GlusterServiceStatus.RUNNING) {
                    enableStart = true;
                }
                if (service.getStatus() != GlusterServiceStatus.STOPPED) {
                    enableStop = true;
                }
                enableRestart = true;
            }
            if (enableStart && enableStop && enableStart) {
                break;
            }
        }
    }
    getStartSwiftCommand().setIsExecutionAllowed(enableStart);
    getStopSwiftCommand().setIsExecutionAllowed(enableStop);
    getRestartSwiftCommand().setIsExecutionAllowed(enableRestart);
}
Also used : GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) List(java.util.List)

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