def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes( self, node, defaults) # Aggregate type defaults to 'data' if self.type is None: self.type = 'data'
def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes(self, node, defaults) # If targetvolume isn't defined, targetaggregate is required. if self.targetvolume is None and self.targetaggregate is None: raise KeyError("'%s' node attribute 'targetaggregate' is not set" % self.xmltag) # Use a default multiplier if one isn't specified if self.multiplier is None: try: self.multiplier = defaults.getfloat(self.defaults_section, "multiplier") except (NoSectionError, NoOptionError): self.multiplier = 2.5 pass else: self.multiplier = float(self.multiplier) # Convert targetusable from text to a float if self.targetusable is not None: self.targetusable = float(self.targetusable) pass if self.targetsuffix is None: try: self.targetsuffix = defaults.get(self.defaults_section, "volsuffix") except (NoSectionError, NoOptionError): self.targetsuffix = "b" pass pass
def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes( self, node, defaults) # If targetvolume isn't defined, targetaggregate is required. if self.targetvolume is None and self.targetaggregate is None: raise KeyError("'%s' node attribute 'targetaggregate' is not set" % self.xmltag) # Use a default multiplier if one isn't specified if self.multiplier is None: try: self.multiplier = defaults.getfloat(self.defaults_section, 'multiplier') except (NoSectionError, NoOptionError): self.multiplier = 2.5 pass else: self.multiplier = float(self.multiplier) # Convert targetusable from text to a float if self.targetusable is not None: self.targetusable = float(self.targetusable) pass if self.targetsuffix is None: try: self.targetsuffix = defaults.get(self.defaults_section, 'volsuffix') except (NoSectionError, NoOptionError): self.targetsuffix = 'b' pass pass
def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes(self, node, defaults) if getattr(self, 'security', None) is None: try: self.security = defaults.get('qtree', 'default_security') except (NoSectionError, NoOptionError): self.security = 'unix'
def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes( self, node, defaults) if getattr(self, 'security', None) is None: try: self.security = defaults.get('qtree', 'default_security') except (NoSectionError, NoOptionError): self.security = 'unix'
def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes(self, node, defaults) # If the location for the host is set, use that, else # default to the same location as the containing site if self.location is None: location = self.parent.location # Is the host virtual or physical? if self.is_virtual is None: self.is_virtual = False elif self.is_virtual.lower() == 'yes': self.is_virtual = True log.debug("Host '%s' is virtual.", hostname) else: self.is_virtual = False
def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes( self, node, defaults) # If the location for the host is set, use that, else # default to the same location as the containing site if self.location is None: location = self.parent.location # Is the host virtual or physical? if self.is_virtual is None: self.is_virtual = False elif self.is_virtual.lower() == 'yes': self.is_virtual = True log.debug("Host '%s' is virtual.", hostname) else: self.is_virtual = False
def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes(self, node, defaults) # Set volume name prefix self.prefix = getattr(self, 'prefix', '') # Set volume name suffix self.suffix = getattr(self, 'suffix', '') # Set volume name suffix if self.type is None: self.type = defaults.get('volume', 'default_vol_type') # Check to see if we want to restart the volume numbering # FIXME: Get the current volume numbering thing from parent volnum = getattr(self, 'restartnumbering', None) if volnum is None: # Don't grab a new number if this is the root volume # for a vfiler. Only number data volumes. if self.type != 'root': self.volnum = self.parent.get_next_volnum() else: self.volnum = int(volnum) parent.set_volnum(self.volnum) # Set usable storage if getattr(self, 'usable', None) is None: self.usable = defaults.getfloat('volume', 'default_size') else: self.usable = float(self.usable) # Set allowable protocols for the volume # The volume protocol is either a protocol set in the volume definition # using the 'proto' attribute, or it will be the first protocol in # the list of possible protocols for the vfiler. # If neither of these are set, it will be set to the default try: self.protocol = node.attrib['protocol'].lower() log.debug("Proto defined for volume: %s", self.protocol) except KeyError: try: self.protocol = node.xpath("ancestor::*/vfiler/protocol/text()")[0].lower() #log.debug("Found proto in vfiler ancestor: %s", self.protocol) except IndexError: self.protocol = defaults.get('protocol', 'default_storage_protocol') log.debug("Proto set to default: %s", self.protocol) # Set snapreserve and iSCSI snapspace if getattr(self, 'snapreserve', None) is None: # If the volume is a type that we know has a high rate of change, # we set a different snapreserve. try: highdelta_types = defaults.get('volume', 'high_delta_types') except (NoSectionError, NoOptionError): highdelta_types = [] pass if self.type in highdelta_types: self.snapreserve = defaults.getint('volume', 'default_highdelta_snapreserve') else: self.snapreserve = defaults.getint('volume', 'default_snapreserve') else: self.snapreserve = float(self.snapreserve) pass # Round the snapreserve self.snapreserve = int(round(self.snapreserve)) # A special kind of usable that is used for the actual iscsi LUN space # iSCSI really is a pain to allocate on WAFL self.iscsi_usable = self.usable try: self.iscsi_snapspace = defaults.get('volume', 'iscsi_snapspace') except (NoOptionError, NoSectionError): self.iscsi_snapspace = 0 if getattr(self, 'raw', None) is None: try: self.raw = self.usable / ( (100 - float(self.snapreserve) )/100 ) except ZeroDivisionError, e: log.critical("snapreserve of 100% is not a valid value. You probably mean 50%.") raise ZeroDivisionError(e)
def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes(self, node, defaults) # Aggregate type defaults to 'data' if self.type is None: self.type = 'data'
def configure_optional_attributes(self, node, defaults): DynamicNamedXMLConfigurable.configure_optional_attributes( self, node, defaults) # Set volume name prefix self.prefix = getattr(self, 'prefix', '') # Set volume name suffix self.suffix = getattr(self, 'suffix', '') # Set volume name suffix if self.type is None: self.type = defaults.get('volume', 'default_vol_type') # Check to see if we want to restart the volume numbering # FIXME: Get the current volume numbering thing from parent volnum = getattr(self, 'restartnumbering', None) if volnum is None: # Don't grab a new number if this is the root volume # for a vfiler. Only number data volumes. if self.type != 'root': self.volnum = self.parent.get_next_volnum() else: self.volnum = int(volnum) parent.set_volnum(self.volnum) # Set usable storage if getattr(self, 'usable', None) is None: self.usable = defaults.getfloat('volume', 'default_size') else: self.usable = float(self.usable) # Set allowable protocols for the volume # The volume protocol is either a protocol set in the volume definition # using the 'proto' attribute, or it will be the first protocol in # the list of possible protocols for the vfiler. # If neither of these are set, it will be set to the default try: self.protocol = node.attrib['protocol'].lower() log.debug("Proto defined for volume: %s", self.protocol) except KeyError: try: self.protocol = node.xpath( "ancestor::*/vfiler/protocol/text()")[0].lower() #log.debug("Found proto in vfiler ancestor: %s", self.protocol) except IndexError: self.protocol = defaults.get('protocol', 'default_storage_protocol') log.debug("Proto set to default: %s", self.protocol) # Set snapreserve and iSCSI snapspace if getattr(self, 'snapreserve', None) is None: # If the volume is a type that we know has a high rate of change, # we set a different snapreserve. try: highdelta_types = defaults.get('volume', 'high_delta_types') except (NoSectionError, NoOptionError): highdelta_types = [] pass if self.type in highdelta_types: self.snapreserve = defaults.getint( 'volume', 'default_highdelta_snapreserve') else: self.snapreserve = defaults.getint('volume', 'default_snapreserve') else: self.snapreserve = float(self.snapreserve) pass # Round the snapreserve self.snapreserve = int(round(self.snapreserve)) # A special kind of usable that is used for the actual iscsi LUN space # iSCSI really is a pain to allocate on WAFL self.iscsi_usable = self.usable try: self.iscsi_snapspace = defaults.get('volume', 'iscsi_snapspace') except (NoOptionError, NoSectionError): self.iscsi_snapspace = 0 if getattr(self, 'raw', None) is None: try: self.raw = self.usable / ( (100 - float(self.snapreserve)) / 100) except ZeroDivisionError, e: log.critical( "snapreserve of 100% is not a valid value. You probably mean 50%." ) raise ZeroDivisionError(e)