Exemple #1
0
 def to_normalized_wwn(self, wwn):
     '''
     Checks whether or not the provided WWN is valid for this fabric module
     according to the spec, and returns a tuple of our preferred string 
     representation of the wwn, and what type it turned out to be.
     '''
     return normalize_wwn(self.wwn_types, wwn, self.wwns)
Exemple #2
0
 def to_normalized_wwn(self, wwn):
     '''
     Checks whether or not the provided WWN is valid for this fabric module
     according to the spec, and returns a tuple of our preferred string 
     representation of the wwn, and what type it turned out to be.
     '''
     return normalize_wwn(self.wwn_types, wwn)
Exemple #3
0
    def __init__(self, parent_tpg, node_wwn, mode="any"):
        """
        @param parent_tpg: The parent TPG object.
        @type parent_tpg: TPG
        @param node_wwn: The wwn of the initiator node for which the ACL is
        created.
        @type node_wwn: string
        @param mode:An optionnal string containing the object creation mode:
            - I{'any'} means the configFS object will be either looked up or
            created.
            - I{'lookup'} means the object MUST already exist configFS.
            - I{'create'} means the object must NOT already exist in configFS.
        @type mode:string
        @return: A NodeACL object.
        """

        super(NodeACL, self).__init__()

        if isinstance(parent_tpg, TPG):
            self._parent_tpg = parent_tpg
        else:
            raise RTSLibError("Invalid parent TPG.")

        fm = self.parent_tpg.parent_target.fabric_module
        self._node_wwn, self.wwn_type = normalize_wwn(fm.wwn_types, node_wwn)
        self._path = "%s/acls/%s" % (self.parent_tpg.path, fm.to_fabric_wwn(self.node_wwn))
        self._create_in_cfs_ine(mode)
Exemple #4
0
    def __init__(self, parent_tpg, node_wwn, mode='any'):
        '''
        @param parent_tpg: The parent TPG object.
        @type parent_tpg: TPG
        @param node_wwn: The wwn of the initiator node for which the ACL is
        created.
        @type node_wwn: string
        @param mode:An optionnal string containing the object creation mode:
            - I{'any'} means the configFS object will be either looked up or
            created.
            - I{'lookup'} means the object MUST already exist configFS.
            - I{'create'} means the object must NOT already exist in configFS.
        @type mode:string
        @return: A NodeACL object.
        '''

        super(NodeACL, self).__init__()

        if isinstance(parent_tpg, TPG):
            self._parent_tpg = parent_tpg
        else:
            raise RTSLibError("Invalid parent TPG.")

        fm = self.parent_tpg.parent_target.fabric_module
        self._node_wwn, self.wwn_type = normalize_wwn(fm.wwn_types, node_wwn)
        self._path = "%s/acls/%s" % (self.parent_tpg.path,
                                     fm.to_fabric_wwn(self.node_wwn))
        self._create_in_cfs_ine(mode)
Exemple #5
0
    def _set_nexus(self, nexus_wwn=None):
        '''
        Sets the nexus initiator WWN. Raises an exception if the nexus is
        already set or if the TPG does not use a nexus.
        '''
        self._check_self()

        if not self.has_feature('nexus'):
            raise RTSLibError("The TPG does not use a nexus.")
        if self._get_nexus():
            raise RTSLibError("The TPG's nexus initiator WWN is already set.")

        # Nexus wwn type should match parent target
        wwn_type = self.parent_target.wwn_type
        if nexus_wwn:
            # Not using fabric-specific version of normalize_wwn, since we
            # want to make sure wwn conforms to regexp, but don't check
            # against target wwn_list, since we're setting the "initiator" here.
            nexus_wwn = normalize_wwn((wwn_type, ), nexus_wwn)[0]
        else:
            nexus_wwn = generate_wwn(wwn_type)

        fm = self.parent_target.fabric_module

        fwrite("%s/nexus" % self.path, fm.to_fabric_wwn(nexus_wwn))
Exemple #6
0
    def _set_nexus(self, nexus_wwn=None):
        '''
        Sets the nexus initiator WWN. Raises an exception if the nexus is
        already set or if the TPG does not use a nexus.
        '''
        self._check_self()

        if not self.has_feature('nexus'):
            raise RTSLibError("The TPG does not use a nexus.")
        if self._get_nexus():
            raise RTSLibError("The TPG's nexus initiator WWN is already set.")

        # Nexus wwn type should match parent target
        wwn_type = self.parent_target.wwn_type
        if nexus_wwn:
            # Not using fabric-specific version of normalize_wwn, since we
            # want to make sure wwn conforms to regexp, but don't check
            # against target wwn_list, since we're setting the "initiator" here.
            nexus_wwn = normalize_wwn((wwn_type,), nexus_wwn)[0]
        else:
            nexus_wwn = generate_wwn(wwn_type)

        fm = self.parent_target.fabric_module

        fwrite("%s/nexus" % self.path, fm.to_fabric_wwn(nexus_wwn))