Exemple #1
0
    def _create_in_cfs_ine(self, mode):
        '''
        Creates the configFS node if it does not already exist depending on
        the mode.
        any -> makes sure it exists, also works if the node already does exist
        lookup -> make sure it does NOT exist
        create -> create the node which must not exist beforehand
        Upon success (no exception raised), self._fresh is True if a node was
        created, else self._fresh is False.
        '''
        if mode not in ['any', 'lookup', 'create']:
            raise RTSLibError("Invalid mode: %s" % mode)
        if self and mode == 'create':
            raise RTSLibError("This %s already exists in configFS." %
                              self.__class__.__name__)
        elif not self and mode == 'lookup':
            raise RTSLibNotInCFS("No such %s in configfs: %s." %
                                 (self.__class__.__name__, self.path))
        if self:
            self._fresh = False
            return

        try:
            os.mkdir(self.path)
            self._fresh = True
        except Exception as e:
            raise RTSLibError("Could not create %s: %s" % (self.path, e))
Exemple #2
0
    def _create_in_cfs_ine(self, mode):
        '''
        Creates the configFS node if it does not already exist, depending on
        the mode.
        any -> makes sure it exists, also works if the node already does exist
        lookup -> make sure it does NOT exist
        create -> create the node which must not exist beforehand
        '''
        if mode not in ['any', 'lookup', 'create']:
            raise RTSLibError("Invalid mode: %s" % mode)
        if self.exists and mode == 'create':
            raise RTSLibError("This %s already exists in configFS." %
                              self.__class__.__name__)
        elif not self.exists and mode == 'lookup':
            raise RTSLibNotInCFS("No such %s in configfs: %s." %
                                 (self.__class__.__name__, self.path))

        if not self.exists:
            try:
                os.mkdir(self.path)
            except:
                raise RTSLibError("Could not create %s in configFS." %
                                  self.__class__.__name__)
Exemple #3
0
 def _check_self(self):
     if not self.exists:
         raise RTSLibNotInCFS("This %s does not exist in configFS." %
                              self.__class__.__name__)