Beispiel #1
0
    def configure_from_node(self, node, defaults, parent):
        DynamicNamedXMLConfigurable.configure_from_node(self, node, defaults, parent)

        # Add drhost bits, if available.
        # This is done here, rather than as a separate object,
        # to avoid a separate class that may not really be necessary
        self.children['drhostname'] = [x.attrib['name'] for x in node.findall('drhost')]
Beispiel #2
0
    def configure_from_node(self, node, defaults, parent):
        DynamicNamedXMLConfigurable.configure_from_node(
            self, node, defaults, parent)
        self.volume = parent
        self.qtreenode = node

        self.children['exportalias'] = [
            x.text for x in node.findall('exportalias')
        ]
Beispiel #3
0
    def configure_from_node(self, node, defaults, parent):
        DynamicNamedXMLConfigurable.configure_from_node(
            self, node, defaults, parent)

        # Add drhost bits, if available.
        # This is done here, rather than as a separate object,
        # to avoid a separate class that may not really be necessary
        self.children['drhostname'] = [
            x.attrib['name'] for x in node.findall('drhost')
        ]
Beispiel #4
0
    def configure_from_node(self, node, defaults, parent):
        """
        Volume configuration is quite complex, due to the way we attempt
        to cater for all kinds of situations automatically, using configurable
        defaults and various overrides.
        """
        self.parent = parent
        DynamicNamedXMLConfigurable.configure_from_node(self, node, defaults, parent)

        # Check if iscsi is an enabled protocol. If so, use 'iscsi_snapspace' instead
        # of snapreserve
        #if 'iscsi' in [ x.name for x in self.get_protocols() ]:
        if 'iscsi' == self.protocol:
            self.snapreserve = 0
            if getattr(self, 'iscsi_snapspace', None):
                self.iscsi_snapspace = defaults.getint('volume', 'default_iscsi_snapspace')
            else:
                self.iscsi_snapspace = int(self.iscsi_snapspace)
                pass
            pass

            # iSCSI LUN sizing is... interesting
            # Best practice is to have no snapreserve for volumes
            # used for iscsi, but we need to have some storage
            # available for snapshots. Because LUNs are just files full
            # of blocks, we have to allocate enough storage for all
            # of the blocks to change, so we need 2 * LUNsize GiB to
            # store the snapshots.
            # If you're not using snapshots, you will need a little extra
            # space in the volume so the LUN can fit within it. The LUN
            # can't take up 100% of the volume (i.e.: A LUN of 100GiB
            # will require a volume of 101GiB in size)

            log.debug("volume proto is iscsi")
            # If snapshots are configured, double the usable storage to allow for 50% 'snapreserve'
            if len(self.get_snaprefs()) > 0 or \
                    len(self.get_snapvaultrefs()) > 0 or \
                    len(self.get_snapmirrorrefs()) > 0 or \
                    len(self.get_snapvaultmirrorrefs()) > 0:
                
                log.debug("snapshots present. doubling usable space of %s GiB for iscsi volume", self.usable)
                #snapdiv = (100 - float(iscsi_snapspace))/100
                snapspace = self.usable * ( float(iscsi_snapspace)/100 )
                log.debug("Adding iscsi_snapspace (%s%%) of %s GiB", iscsi_snapspace, snapspace)
                self.usable = (self.usable * 2.0) + snapspace
                log.debug("usable is now: %s GiB, iscsi_usable is: %s GiB", self.usable, self.iscsi_usable)
            else:
                # If no snapshots are configured, make the raw slightly more than usable
                log.debug("No snapshots, adding 1 GiB usable to volume size.")
                self.raw = self.usable + 1
                pass
            pass
        
#         self.snapref = snapref
#         self.snapvaultref = snapvaultref
#         self.snapmirrorref = snapmirrorref
#         self.snapvaultmirrorref = snapvaultmirrorref

        # Lists of the actual snapX objects, added when they're created
        self.snaps = []
        self.snapvaults = []
        self.snapmirrors = []

        #self.qtrees = {}

        # Set volume options as a dictionary
        options = {}
        if len(self.children['option']) == 0:
            # FIXME: deal with user errors in the config file better
            for opt in defaults.get('volume', 'default_options').split(','):
                name, value = opt.split('=')
                options[name] = value
                pass
        else:
            for opt in self.children['option']:
                name, value = opt.split('=')
                options[name] = value
                pass
            pass
        self.children['option'] = options

        self.volnode = node

        # If volume export is not allowed, check that qtrees exist in the
        # volume. If not, create a single default data qtree.
        self.check_volume_export_allowed(defaults)

        self.autosize = None
        self.autodelete = None

        log.debug("volume usable is: %f", self.usable)
Beispiel #5
0
    def configure_from_node(self, node, defaults, parent):
        DynamicNamedXMLConfigurable.configure_from_node(self, node, defaults, parent)
        self.volume = parent
        self.qtreenode = node

        self.children['exportalias'] = [ x.text for x in node.findall('exportalias') ]
Beispiel #6
0
    def configure_from_node(self, node, defaults, parent):
        """
        Volume configuration is quite complex, due to the way we attempt
        to cater for all kinds of situations automatically, using configurable
        defaults and various overrides.
        """
        self.parent = parent
        DynamicNamedXMLConfigurable.configure_from_node(
            self, node, defaults, parent)

        # Check if iscsi is an enabled protocol. If so, use 'iscsi_snapspace' instead
        # of snapreserve
        #if 'iscsi' in [ x.name for x in self.get_protocols() ]:
        if 'iscsi' == self.protocol:
            self.snapreserve = 0
            if getattr(self, 'iscsi_snapspace', None):
                self.iscsi_snapspace = defaults.getint(
                    'volume', 'default_iscsi_snapspace')
            else:
                self.iscsi_snapspace = int(self.iscsi_snapspace)
                pass
            pass

            # iSCSI LUN sizing is... interesting
            # Best practice is to have no snapreserve for volumes
            # used for iscsi, but we need to have some storage
            # available for snapshots. Because LUNs are just files full
            # of blocks, we have to allocate enough storage for all
            # of the blocks to change, so we need 2 * LUNsize GiB to
            # store the snapshots.
            # If you're not using snapshots, you will need a little extra
            # space in the volume so the LUN can fit within it. The LUN
            # can't take up 100% of the volume (i.e.: A LUN of 100GiB
            # will require a volume of 101GiB in size)

            log.debug("volume proto is iscsi")
            # If snapshots are configured, double the usable storage to allow for 50% 'snapreserve'
            if len(self.get_snaprefs()) > 0 or \
                    len(self.get_snapvaultrefs()) > 0 or \
                    len(self.get_snapmirrorrefs()) > 0 or \
                    len(self.get_snapvaultmirrorrefs()) > 0:

                log.debug(
                    "snapshots present. doubling usable space of %s GiB for iscsi volume",
                    self.usable)
                #snapdiv = (100 - float(iscsi_snapspace))/100
                snapspace = self.usable * (float(iscsi_snapspace) / 100)
                log.debug("Adding iscsi_snapspace (%s%%) of %s GiB",
                          iscsi_snapspace, snapspace)
                self.usable = (self.usable * 2.0) + snapspace
                log.debug("usable is now: %s GiB, iscsi_usable is: %s GiB",
                          self.usable, self.iscsi_usable)
            else:
                # If no snapshots are configured, make the raw slightly more than usable
                log.debug("No snapshots, adding 1 GiB usable to volume size.")
                self.raw = self.usable + 1
                pass
            pass


#         self.snapref = snapref
#         self.snapvaultref = snapvaultref
#         self.snapmirrorref = snapmirrorref
#         self.snapvaultmirrorref = snapvaultmirrorref

# Lists of the actual snapX objects, added when they're created
        self.snaps = []
        self.snapvaults = []
        self.snapmirrors = []

        #self.qtrees = {}

        # Set volume options as a dictionary
        options = {}
        if len(self.children['option']) == 0:
            # FIXME: deal with user errors in the config file better
            for opt in defaults.get('volume', 'default_options').split(','):
                name, value = opt.split('=')
                options[name] = value
                pass
        else:
            for opt in self.children['option']:
                name, value = opt.split('=')
                options[name] = value
                pass
            pass
        self.children['option'] = options

        self.volnode = node

        # If volume export is not allowed, check that qtrees exist in the
        # volume. If not, create a single default data qtree.
        self.check_volume_export_allowed(defaults)

        self.autosize = None
        self.autodelete = None

        log.debug("volume usable is: %f", self.usable)