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
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) )
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)
def configure_from_node(self, node, defaults, filer): """ Customise the configuration from a node slightly. """ self.filer = filer self.site = filer.site DynamicNamedXMLConfigurable.configure_from_node(self, node, defaults, filer) # Attempt to create a root aggregate if one hasn't # been defined manually self.create_root_aggregate(defaults) # Create a root volume if one hasn't been manually defined self.create_root_volume(defaults)
def configure_from_node(self, node, defaults, parent): DynamicNamedXMLConfigurable.configure_from_node(self, node, defaults, parent) # # Once the project is configured, set up some other bits and pieces # self.setup_drhosts(defaults) self.setup_exports(defaults) self.setup_igroups(defaults) self.setup_snapmirrors(defaults) self.setup_snapvaults(defaults)
def configure_from_node(self, node, defaults, filer): """ Customise the configuration from a node slightly. """ self.filer = filer self.site = filer.site DynamicNamedXMLConfigurable.configure_from_node( self, node, defaults, filer) # Attempt to create a root aggregate if one hasn't # been defined manually self.create_root_aggregate(defaults) # Create a root volume if one hasn't been manually defined self.create_root_volume(defaults)
def configure_from_node(self, node, defaults, parent): DynamicNamedXMLConfigurable.configure_from_node( self, node, defaults, parent) # # Once the project is configured, set up some other bits and pieces # self.setup_drhosts(defaults) self.setup_exports(defaults) self.setup_igroups(defaults) self.setup_snapmirrors(defaults) self.setup_snapvaults(defaults)
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)
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
def configure_mandatory_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_mandatory_attributes( self, node, defaults) if self.type not in self.setref_types: raise ValueError("%s type '%s' not a valid type" % (self.xmltag, self.type))
def configure_from_node(self, node, defaults, site): self.site = site DynamicNamedXMLConfigurable.configure_from_node(self, node, defaults, site)
def configure_mandatory_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_mandatory_attributes(self, node, defaults) if self.type not in self.setref_types: raise ValueError("%s type '%s' not a valid type" % (self.xmltag, self.type) )
def configure_from_node(self, node, defaults, parent): DynamicNamedXMLConfigurable.configure_from_node(self, node, defaults, parent) # Find igroup members self.children['member'] = node.findall('member')