예제 #1
0
파일: vfiler.py 프로젝트: jpwarren/docgen
    def configure_optional_attributes(self, node, defaults):
        DynamicNamedXMLConfigurable.configure_optional_attributes(
            self, node, defaults)

        # If a vlan number is defined, use that vlan, otherwise
        # use the first project vlan we find.
        # FIXME: Need to cope with non-VLAN projects
        # Ticket: #48
        if self.vlan_number is not None:
            self.vlan = [
                vlan for vlan in self.site.get_vlans()
                if vlan.number == self.vlan_number
            ][0]
        else:
            try:
                self.vlan = [
                    vlan for vlan in self.site.get_vlans()
                    if vlan.type == 'project'
                ][0]
            except IndexError:
                log.warn("No VLANs defined.")
                self.vlan = None
            pass

        if self.dns_domain is None:
            try:
                self.dns_domain = defaults.get('vfiler', 'default_dns_domain')
            except (NoSectionError, NoOptionError):
                pass
예제 #2
0
    def configure_optional_attributes(self, node, defaults):
        """
        Do some extra parameter checking after configuring attributes
        """
        DynamicNamedXMLConfigurable.configure_optional_attributes(self, node, defaults)
        # Default filer type to 'filer'
        if self.type is None:
            self.type = defaults.get('filer', 'default_type')

        # vfiler type must be one of the known types
        if self.type not in self.FILER_TYPES:
            raise ValueError("Filer '%s' type '%s' not valid" % ( self.name, self.type) )
예제 #3
0
    def configure_optional_attributes(self, node, defaults):
        """
        Configure optional Lun attributes
        """
        DynamicNamedXMLConfigurable.configure_optional_attributes(
            self, node, defaults)
        # Check to see if we need to restart the lunid numbering
        if self.restartnumbering is not None:
            self.parent.set_current_lunid(int(self.restartnumbering), defaults)
            pass

        # Check to see if the lunid is specified for this lun
        if self.lunid is not None:
            self.lunid = int(self.lunid)
            log.debug("lunid manually specified: %d", self.lunid)
        else:
            self.lunid = self.parent.get_next_lunid(defaults)

        try:
            self.size = float(self.size)
        except TypeError:
            log.debug("No LUN size specified. Figuring it out...")

            # If you specify LUN sizes, the system will use exactly
            # what you define in the config file.
            # If you don't specify the LUN size, then the system will
            # divide up however much storage is left in the volume evenly
            # between the number of LUNs that don't have a size specified.

            # Count the number of LUNs with no size specified. Available
            # usable storage will be divided evenly between them
            nosize_luns = len(
                node.xpath("parent::*/descendant-or-self::lun[not(@size)]"))
            log.debug("unsized luns are: %s", nosize_luns)
            # total the number of sized luns
            sized_luns = node.xpath(
                "parent::*/descendant-or-self::lun[(@size)]")

            sized_total = sum([int(lun.attrib['size']) for lun in sized_luns])
            log.debug("sized total is: %s", sized_total)

            log.debug("Available for allocation: %s",
                      self.parent.get_iscsi_usable() - sized_total)

            self.size = float(self.parent.get_iscsi_usable() -
                              sized_total) / nosize_luns
            log.debug("calculated lun size of: %s", self.size)
            pass

        log.debug("Allocating %sg storage to LUN", self.size)
        self.parent.add_to_lun_total(self.size)
예제 #4
0
파일: lun.py 프로젝트: jpwarren/docgen
    def configure_optional_attributes(self, node, defaults):
        """
        Configure optional Lun attributes
        """
        DynamicNamedXMLConfigurable.configure_optional_attributes(self, node, defaults)        
        # Check to see if we need to restart the lunid numbering
        if self.restartnumbering is not None:
            self.parent.set_current_lunid( int(self.restartnumbering), defaults)
            pass
        
        # Check to see if the lunid is specified for this lun
        if self.lunid is not None:
            self.lunid = int(self.lunid)
            log.debug("lunid manually specified: %d", self.lunid)
        else:
            self.lunid = self.parent.get_next_lunid(defaults)
            
        try:
            self.size = float(self.size)
        except TypeError:
            log.debug("No LUN size specified. Figuring it out...")

            # If you specify LUN sizes, the system will use exactly
            # what you define in the config file.
            # If you don't specify the LUN size, then the system will
            # divide up however much storage is left in the volume evenly
            # between the number of LUNs that don't have a size specified.

            # Count the number of LUNs with no size specified. Available
            # usable storage will be divided evenly between them
            nosize_luns = len(node.xpath("parent::*/descendant-or-self::lun[not(@size)]"))
            log.debug("unsized luns are: %s", nosize_luns)
            # total the number of sized luns
            sized_luns = node.xpath("parent::*/descendant-or-self::lun[(@size)]")

            sized_total = sum([ int(lun.attrib['size']) for lun in sized_luns ])
            log.debug("sized total is: %s", sized_total)

            log.debug("Available for allocation: %s", self.parent.get_iscsi_usable() - sized_total)

            self.size = float(self.parent.get_iscsi_usable() - sized_total) / nosize_luns
            log.debug("calculated lun size of: %s", self.size)
            pass
        
        log.debug("Allocating %sg storage to LUN", self.size)
        self.parent.add_to_lun_total(self.size)
예제 #5
0
파일: vfiler.py 프로젝트: jpwarren/docgen
    def configure_optional_attributes(self, node, defaults):
        DynamicNamedXMLConfigurable.configure_optional_attributes(self, node, defaults)

        # If a vlan number is defined, use that vlan, otherwise
        # use the first project vlan we find.
        # FIXME: Need to cope with non-VLAN projects
        # Ticket: #48
        if self.vlan_number is not None:
            self.vlan = [vlan for vlan in self.site.get_vlans() if vlan.number == self.vlan_number][0]
        else:
            try:
                self.vlan = [vlan for vlan in self.site.get_vlans() if vlan.type == "project"][0]
            except IndexError:
                log.warn("No VLANs defined.")
                self.vlan = None
            pass

        if self.dns_domain is None:
            try:
                self.dns_domain = defaults.get("vfiler", "default_dns_domain")
            except (NoSectionError, NoOptionError):
                pass