Package lcmc.drbd.ui.resource

Examples of lcmc.drbd.ui.resource.BlockDevInfo


                devNr = mDev.group(1);
            }
            /* get blockdevice object from device */
            final String disk = getBackingDisk(devNr, hostName);
            if (disk != null) {
                final BlockDevInfo bdi = drbdGraph.findBlockDevInfo(hostName, disk);
                if (bdi != null) {
                    if (bdi.getBlockDevice().isDifferent(cs, ro1, ds1, flags)) {
                        bdi.getBlockDevice().setDrbdBackingDisk(disk);
                        bdi.getBlockDevice().setConnectionState(cs);
                        bdi.getBlockDevice().setNodeState(ro1);
                        bdi.getBlockDevice().setDiskState(ds1);
                        bdi.getBlockDevice().setNodeStateOther(ro2);
                        bdi.getBlockDevice().setDiskStateOther(ds2);
                        bdi.getBlockDevice().setDrbdFlags(flags);
                        bdi.updateInfo();
                        return true;
                    } else {
                        return false;
                    }
                }
            }
            return false;
        }
        /* 19 SP 0 16.9 */
        p = Pattern.compile("^(\\d+)\\s+SP\\s+(\\S+)\\s(\\d+\\.\\d+).*");
        m = p.matcher(output);
        if (m.matches()) {
            /* String counter      = m.group(1); // not used */
            final String devNrString = m.group(2);
            final String synced = m.group(3);

            final Matcher mDev = pDev.matcher(devNrString);
            String devNr = devNrString;
            if (mDev.matches()) { /* since 8.4 */
                devNr = mDev.group(1);
            }
            final BlockDevInfo bdi = getBlockDevInfo(devNr, hostName, drbdGraph);
            if (bdi != null && bdi.getBlockDevice().isDrbd()) {
                if (Tools.areEqual(bdi.getBlockDevice().getSyncedProgress(), synced)) {
                    return false;
                } else {
                    bdi.getBlockDevice().setSyncedProgressInPercents(synced);
                    bdi.updateInfo();
                    return true;
                }
            }
            return false;
        }
        /* 19 UH 1 split-brain */
        p = Pattern.compile("^(\\d+)\\s+UH\\s+(\\S+)\\s([a-z-]+).*");
        m = p.matcher(output);
        if (m.matches()) {
            /* String counter      = m.group(1); // not used */
            final String devNrString = m.group(2);
            final String what = m.group(3);
            final Matcher mDev = pDev.matcher(devNrString);
            String devNr = devNrString;
            if (mDev.matches()) { /* since 8.4 */
                devNr = mDev.group(1);
            }
            LOG.debug("parseDrbdEvent: event: " + devNr + " - " + what);
            if ("split-brain".equals(what)) {
                final BlockDevInfo bdi = getBlockDevInfo(devNr, hostName, drbdGraph);

                if (bdi != null && bdi.getBlockDevice().isDrbd()) {
                    if (bdi.getBlockDevice().isSplitBrain()) {
                        return false;
                    } else {
                        bdi.getBlockDevice().setSplitBrain(true);
                        bdi.updateInfo();
                        return true;
                    }
                }
            }
            return false;
View Full Code Here


        return pane;
    }

    private boolean vgCreate(final Host host, final String vgName, final Collection<String> pvNames) {
        for (final String pv : pvNames) {
            final BlockDevInfo bdi = host.getBrowser().getDrbdGraph().findBlockDevInfo(host.getName(), pv);
            if (bdi != null) {
                bdi.getBlockDevice().setVolumeGroupOnPhysicalVolume(vgName);
                bdi.getBrowser().getDrbdGraph().startAnimation(bdi);
            }
        }
        final boolean ret = LVM.vgCreate(host, vgName, pvNames, Application.RunMode.LIVE);
        if (ret) {
            answerPaneAddText("Volume group " + vgName + " was successfully created " + " on " + host.getName() + '.');
View Full Code Here

    /** Check if it is DRBD device and if it could be resized. */
    private boolean checkDRBD() {
        if (blockDevInfo.getBlockDevice().isDrbd()) {
            final VolumeInfo dvi = blockDevInfo.getDrbdVolumeInfo();
            final BlockDevInfo oBDI = blockDevInfo.getOtherBlockDevInfo();
            if (!dvi.isConnected(Application.RunMode.LIVE)) {
                printErrorAndRetry("Not resizing. DRBD resource is not connected.");
                sizeWidget.setEnabled(false);
                resizeButton.setEnabled(false);
                return false;
            } else if (dvi.isSyncing()) {
                printErrorAndRetry("Not resizing. DRBD resource is syncing.");
                sizeWidget.setEnabled(false);
                resizeButton.setEnabled(false);
                return false;
            } else if (!oBDI.getBlockDevice().isAttached()) {
                printErrorAndRetry("Not resizing. DRBD resource is not attached on " + oBDI.getHost() + '.');
                sizeWidget.setEnabled(false);
                resizeButton.setEnabled(false);
                return false;
            } else if (!blockDevInfo.getBlockDevice().isAttached()) {
                printErrorAndRetry("Not resizing. DRBD resource is not attached on " + blockDevInfo.getHost() + '.');
                sizeWidget.setEnabled(false);
                resizeButton.setEnabled(false);
                return false;
            } else if (!oBDI.getBlockDevice().isPrimary() && !blockDevInfo.getBlockDevice().isPrimary()) {
                printErrorAndRetry("Not resizing. Must be primary at least on one node.");
                sizeWidget.setEnabled(false);
                resizeButton.setEnabled(false);
                return false;
            }
View Full Code Here

                                       Application.RunMode.LIVE);
        if (ret) {
            answerPaneSetText("Logical volume was successfully resized on " + blockDevInfo.getHost() + '.');
            /* resize lvm volume on the other node. */
            final String lvm = blockDevInfo.getBlockDevice().getName();
            final BlockDevInfo oBDI = blockDevInfo.getOtherBlockDevInfo();
            boolean resizingFailed = false;
            for (final Map.Entry<Host, JCheckBox> hostEntry : hostCheckBoxes.entrySet()) {
                if (hostEntry.getKey() == blockDevInfo.getHost() || !hostEntry.getValue().isSelected()) {
                    continue;
                }
                for (final BlockDevice b : hostEntry.getKey().getBlockDevices()) {
                    if (lvm.equals(b.getName()) || (oBDI != null && oBDI.getBlockDevice() == b)) {
                        /* drbd or selected other host */
                        final boolean oRet = LVM.resize(hostEntry.getKey(),
                                                        b.getName(),
                                                        size,
                                                        Application.RunMode.LIVE);
View Full Code Here

        final long free = blockDevInfo.getFreeInVolumeGroup() / 1024;

        String maxBlockSize = "0";
        try {
            final long taken = Long.parseLong(blockDevInfo.getBlockDevice().getBlockSize());
            final BlockDevInfo oBDI = blockDevInfo.getOtherBlockDevInfo();
            long max = free + taken;
            final String lvm = blockDevInfo.getBlockDevice().getName();
            if (hostCheckBoxes != null) {
                for (final Map.Entry<Host, JCheckBox> hostEntry : hostCheckBoxes.entrySet()) {
                    if (blockDevInfo.getHost() == hostEntry.getKey()) {
                        continue;
                    }
                    if (hostEntry.getValue().isSelected()) {
                        for (final BlockDevice b : hostEntry.getKey().getBlockDevices()) {
                            if (lvm.equals(b.getName()) || (oBDI != null && oBDI.getBlockDevice() == b)) {
                                final long oFree = hostEntry.getKey().getFreeInVolumeGroup(b.getVolumeGroup())
                                 / 1024;
                                final long oTaken = Long.parseLong(b.getBlockSize());
                                if (oFree + oTaken < max) {
                                    /* take the smaller maximum. */
 
View Full Code Here

     * Returns next dialog plus it calls drbd up command for both devices and
     * returns the drbd config create fs dialog.
     */
    @Override
    public WizardDialog nextDialog() {
        final BlockDevInfo bdi1 = getDrbdVolumeInfo().getFirstBlockDevInfo();
        final BlockDevInfo bdi2 = getDrbdVolumeInfo().getSecondBlockDevInfo();
        final String clusterName = bdi1.getHost().getCluster().getName();
        guiData.startProgressIndicator(clusterName, "scanning block devices...");
        final Application.RunMode runMode = Application.RunMode.LIVE;
        if (getDrbdVolumeInfo().getDrbdResourceInfo().isProxy(bdi1.getHost())) {
            DRBD.proxyUp(bdi1.getHost(), getDrbdVolumeInfo().getDrbdResourceInfo().getName(), null, runMode);
        }
        if (getDrbdVolumeInfo().getDrbdResourceInfo().isProxy(bdi2.getHost())) {
            DRBD.proxyUp(bdi2.getHost(), getDrbdVolumeInfo().getDrbdResourceInfo().getName(), null, runMode);
        }
        DRBD.adjustApply(bdi1.getHost(),
                         getDrbdVolumeInfo().getDrbdResourceInfo().getName(),
                         getDrbdVolumeInfo().getName(),
                         runMode);
        DRBD.adjustApply(bdi2.getHost(),
                         getDrbdVolumeInfo().getDrbdResourceInfo().getName(),
                         getDrbdVolumeInfo().getName(),
                         runMode);
        final String device = getDrbdVolumeInfo().getDevice();
        final ClusterBrowser browser = getDrbdVolumeInfo().getDrbdResourceInfo().getBrowser();
        browser.updateHWInfo(bdi1.getHost(), !Host.UPDATE_LVM);
        browser.updateHWInfo(bdi2.getHost(), !Host.UPDATE_LVM);
        bdi1.getBlockDevice().setDrbdBlockDevice(bdi1.getHost().getDrbdBlockDevice(device));
        bdi2.getBlockDevice().setDrbdBlockDevice(bdi2.getHost().getDrbdBlockDevice(device));
        guiData.stopProgressIndicator(clusterName, "scanning block devices...");
        createFSDialog.init(this, getDrbdVolumeInfo());
        return createFSDialog;
    }
View Full Code Here

     * Finishes the dialog. If primary bd was choosen it is forced to be a
     * primary.
     */
    @Override
    protected void finishDialog() {
        final BlockDevInfo bdiPri = getPrimaryBlockDevice();
        if (bdiPri != null) {
            final Application.RunMode runMode = Application.RunMode.LIVE;
            if (SKIP_SYNC_TRUE.equals(skipInitialSyncWidget.getValue())) {
                bdiPri.skipInitialFullSync(runMode);
            }
            bdiPri.forcePrimary(runMode);
        }
    }
View Full Code Here

            bdiPri.forcePrimary(runMode);
        }
    }

    protected BlockDevInfo getPrimaryBlockDevice() {
        final BlockDevInfo bdi1 = getDrbdVolumeInfo().getFirstBlockDevInfo();
        final BlockDevInfo bdi2 = getDrbdVolumeInfo().getSecondBlockDevInfo();
        final String h = hostChoiceWidget.getStringValue();
        if (h.equals(bdi1.getHost().getName())) {
            return bdi1;
        } else if (h.equals(bdi2.getHost().getName())) {
            return bdi2;
        } else {
            return null;
        }
    }
View Full Code Here

                    public void run() {
                        buttonClass(finishButton()).setEnabled(false);
                        makeFileSystemButton.setEnabled(false);
                    }
                });
                final BlockDevInfo bdiPri = getPrimaryBlockDevice();
                final Application.RunMode runMode = Application.RunMode.LIVE;
                if (SKIP_SYNC_TRUE.equals(skipInitialSyncWidget.getValue())) {
                    bdiPri.skipInitialFullSync(runMode);
                }
                bdiPri.forcePrimary(runMode);
                final String fs = filesystemWidget.getStringValue();
                bdiPri.makeFilesystem(fs, runMode);
                if (bdiPri.getDrbdVolumeInfo() != null) {
                    /* could be canceled */
                    getDrbdVolumeInfo().setCreatedFs(fs);
                    bdiPri.setSecondary(runMode);
                    hostChoiceWidget.setValue(NO_HOST_STRING);
                    filesystemWidget.setValue(NO_FILESYSTEM_STRING);
                    answerPaneSetText(Tools.getString("Dialog.DrbdConfig.CreateFS.MakeFS.Done"));
                }
                progressBarDone();
View Full Code Here

        return pane;
    }

    private boolean skipSyncAvailable() {
        final BlockDevInfo bdi1 = getDrbdVolumeInfo().getFirstBlockDevInfo();
        final BlockDevInfo bdi2 = getDrbdVolumeInfo().getSecondBlockDevInfo();
        try {
            return bdi1.getHost().drbdVersionHigherOrEqual("8.3.2") && bdi2.getHost().drbdVersionHigherOrEqual("8.3.2");
        } catch (final Exceptions.IllegalVersionException e) {
            LOG.appWarning("skipSyncAvailable: " + e.getMessage(), e);
            return false;
        }
    }
View Full Code Here

TOP

Related Classes of lcmc.drbd.ui.resource.BlockDevInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.