Beispiel #1
0
    def define_snapshots(self):
        """
        Process each of the discovered volumes to look for any
        associated snapshots
        """

        # process each discovered volume
        for volume_name in self.volume:

            this_volume = self.volume[volume_name]

            cmd = GlusterCommand("gluster snap list %s" % volume_name, \
                                 timeout=cfg.CMD_TIMEOUT)
            cmd.run()
            # (rc, snap_info) = issueCMD("gluster snap list %s"%(volume_name))

            if cmd.rc == 0:
                # process the snap information
                if not cmd.stdout[0].lower().startswith('no snapshots'):



                    for snap in cmd.stdout:
                        snap_name = snap.strip()

                        if cfg.debug:
                            print "defineSnapshots. Creating a snapshot instance for volume '%s' called '%s'" % (volume_name, snap_name)

                        new_snapshot = Snapshot(snap_name, this_volume, volume_name)
                        this_volume.snapshot_list.append(new_snapshot)

                    this_volume.snapshot_count = len(this_volume.snapshot_list)

            if cfg.debug:
                print "defineSnapshots. Volume '%s' has %d snapshots" % (volume_name, this_volume.snapshot_count)
Beispiel #2
0
    def initialise(self):
        """ call the node, volume 'generator' to create the child objects
            (bricks are created within the volume logic) """

        self.has_volumes = True if glob(
            '/var/lib/glusterd/vols/*/trusted-*-fuse.vol') else False

        set_active_peer(
        )  # setup GlusterCommand class to have a valid node for commands

        # if has_volumes is populated we have vol files, then it's ok to
        # run the queries to define the node and volume objects
        if self.has_volumes:

            self.define_nodes()

            self.define_volumes()

            # if this cluster supports snapshots, take a look to see if
            # there are any

            self.snapshot_capable = version_ok(self.glfs_version,
                                               cfg.snapshot_support)

            if self.snapshot_capable:
                self.define_snapshots()

                self.snapshot_count = Snapshot.snap_count()

        else:
            # no volumes in this cluster, print a message and abort
            print("This cluster doesn't have any volumes/daemons running.")
            print(
                "The output below shows the current nodes attached to this host.\n"
            )

            cmd = GlusterCommand('gluster pool list', timeout=cfg.CMD_TIMEOUT)
            cmd.run()
            for line in cmd.stdout:
                print(line)
            print()
            exit(12)
Beispiel #3
0
    def initialise(self):
        """ call the node, volume 'generator' to create the child objects
            (bricks are created within the volume logic) """

        self.has_volumes = True if glob('/var/lib/glusterd/vols/*/trusted-*-fuse.vol') else False

        set_active_peer()  # setup GlusterCommand class to have a valid node for commands

        # if has_volumes is populated we have vol files, then it's ok to
        # run the queries to define the node and volume objects
        if self.has_volumes:

            self.define_nodes()

            self.define_volumes()

            # if this cluster supports snapshots, take a look to see if
            # there are any

            self.snapshot_capable = version_ok(self.glfs_version, cfg.snapshot_support)

            if self.snapshot_capable:
                self.define_snapshots()

                self.snapshot_count = Snapshot.snap_count()

        else:
            # no volumes in this cluster, print a message and abort
            print "This cluster doesn't have any volumes/daemons running."
            print "The output below shows the current nodes attached to this host.\n"

            cmd = GlusterCommand('gluster pool list')
            cmd.run()
            for line in cmd.stdout:
                print line
            print
            exit(12)