コード例 #1
0
ファイル: DiskDir.py プロジェクト: zyt19941113/gluster-swift
    def __init__(self, root, drive, account, logger, **kwargs):
        super(DiskAccount, self).__init__(root, drive, account, logger,
                                          **kwargs)

        if self.account == 'gsexpiring':
            # Do not bother updating object count, container count and bytes
            # used. Return immediately before metadata validation and
            # creation happens.
            info = do_stat(self.datadir)
            if info and stat.S_ISDIR(info.st_mode):
                self._dir_exists = True
            semi_fake_md = {
                'X-Object-Count': (0, 0),
                'X-Container-Count': (0, 0),
                'X-Timestamp': ((normalize_timestamp(info.st_ctime)), 0),
                'X-Type': ('Account', 0),
                'X-PUT-Timestamp': ((normalize_timestamp(info.st_mtime)), 0),
                'X-Bytes-Used': (0, 0)
            }
            self.metadata = semi_fake_md
            return

        # Since accounts should always exist (given an account maps to a
        # gluster volume directly, and the mount has already been checked at
        # the beginning of the REST API handling), just assert that that
        # assumption still holds.
        assert self._dir_exists_read_metadata()
        assert self._dir_exists

        if not self.metadata or not validate_account(self.metadata):
            create_account_metadata(self.datadir)
            self.metadata = _read_metadata(self.datadir)
コード例 #2
0
ファイル: test_utils.py プロジェクト: gluster/gluster-swift
 def test_validate_account_good_type(self):
     md = {utils.X_TYPE: (utils.ACCOUNT, 0),
           utils.X_TIMESTAMP: ('na', 0),
           utils.X_PUT_TIMESTAMP: ('na', 0),
           utils.X_OBJECTS_COUNT: ('na', 0),
           utils.X_BYTES_USED: ('na', 0),
           utils.X_CONTAINER_COUNT: ('na', 0)}
     ret = utils.validate_account(md)
     assert ret
コード例 #3
0
ファイル: test_utils.py プロジェクト: notmyname/gluster-swift
 def test_validate_account_bad_type(self):
     md = {
         utils.X_TYPE: ("bad", 0),
         utils.X_TIMESTAMP: ("na", 0),
         utils.X_PUT_TIMESTAMP: ("na", 0),
         utils.X_OBJECTS_COUNT: ("na", 0),
         utils.X_BYTES_USED: ("na", 0),
         utils.X_CONTAINER_COUNT: ("na", 0),
     }
     ret = utils.validate_account(md)
     assert not ret
コード例 #4
0
ファイル: test_utils.py プロジェクト: crisbud/swiftonfile
 def test_validate_account_good_type(self):
     md = {
         utils.X_TYPE: (utils.ACCOUNT, 0),
         utils.X_TIMESTAMP: ('na', 0),
         utils.X_PUT_TIMESTAMP: ('na', 0),
         utils.X_OBJECTS_COUNT: ('na', 0),
         utils.X_BYTES_USED: ('na', 0),
         utils.X_CONTAINER_COUNT: ('na', 0)
     }
     ret = utils.validate_account(md)
     assert ret
コード例 #5
0
ファイル: DiskDir.py プロジェクト: navidshaikh/gluster-swift
    def __init__(self, root, drive, account, logger):
        super(DiskAccount, self).__init__(root, drive, account, logger)

        # Since accounts should always exist (given an account maps to a
        # gluster volume directly, and the mount has already been checked at
        # the beginning of the REST API handling), just assert that that
        # assumption still holds.
        assert self._dir_exists_read_metadata()
        assert self._dir_exists

        if not self.metadata or not validate_account(self.metadata):
            create_account_metadata(self.datadir)
            self.metadata = _read_metadata(self.datadir)
コード例 #6
0
ファイル: DiskDir.py プロジェクト: steveh/glusterfs
 def __init__(self,
              path,
              account,
              container,
              logger,
              uid=DEFAULT_UID,
              gid=DEFAULT_GID):
     self.root = path
     if container:
         self.container = container
     else:
         self.container = None
     if self.container:
         self.datadir = os.path.join(path, account, self.container)
     else:
         self.datadir = os.path.join(path, account)
     # Note that the account name has a one-to-one mapping to the gluster
     # mount point, or volume name.
     self.account = account
     assert logger is not None
     self.logger = logger
     self.metadata = {}
     self.container_info = None
     self.object_info = None
     self.uid = int(uid)
     self.gid = int(gid)
     self.db_file = _db_file
     self.dir_exists = os.path.exists(self.datadir)
     if self.dir_exists:
         try:
             self.metadata = _read_metadata(self.datadir)
         except EOFError:
             create_container_metadata(self.datadir)
     else:
         return
     if self.container:
         if not self.metadata:
             create_container_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_container(self.metadata):
                 create_container_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
     else:
         if not self.metadata:
             create_account_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_account(self.metadata):
                 create_account_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
コード例 #7
0
ファイル: DiskDir.py プロジェクト: crisbud/swiftonfile
    def __init__(self, root, drive, account, logger, **kwargs):
        super(DiskAccount, self).__init__(root, drive, account, logger,
                                          **kwargs)

        # Since accounts should always exist (given an account maps to a
        # gluster volume directly, and the mount has already been checked at
        # the beginning of the REST API handling), just assert that that
        # assumption still holds.
        assert self._dir_exists_read_metadata()
        assert self._dir_exists

        if not self.metadata or not validate_account(self.metadata):
            create_account_metadata(self.datadir)
            self.metadata = _read_metadata(self.datadir)
コード例 #8
0
ファイル: DiskDir.py プロジェクト: kururu-lu/swift-lfs
 def _initialize(self):
     if self.container:
         if not self.metadata:
             create_container_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_container(self.metadata):
                 create_container_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
     else:
         if not self.metadata:
             create_account_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_account(self.metadata):
                 create_account_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
コード例 #9
0
ファイル: DiskDir.py プロジェクト: gbraad/glusterfs
 def __init__(self, path, account, container, logger,
              uid=DEFAULT_UID, gid=DEFAULT_GID):
     self.root = path
     if container:
         self.container = container
     else:
         self.container = None
     if self.container:
         self.datadir = os.path.join(path, account, self.container)
     else:
         self.datadir = os.path.join(path, account)
     # Note that the account name has a one-to-one mapping to the gluster
     # mount point, or volume name.
     self.account = account
     assert logger is not None
     self.logger = logger
     self.metadata = {}
     self.container_info = None
     self.object_info = None
     self.uid = int(uid)
     self.gid = int(gid)
     self.db_file = _db_file
     self.dir_exists = os.path.exists(self.datadir)
     if self.dir_exists:
         try:
             self.metadata = _read_metadata(self.datadir)
         except EOFError:
             create_container_metadata(self.datadir)
     else:
         return
     if self.container:
         if not self.metadata:
             create_container_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_container(self.metadata):
                 create_container_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
     else:
         if not self.metadata:
             create_account_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_account(self.metadata):
                 create_account_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
コード例 #10
0
ファイル: DiskDir.py プロジェクト: zhufeng001/gluster
 def __init__(self, path, drive, account, container, logger,
              uid=DEFAULT_UID, gid=DEFAULT_GID):
     self.root = path
     if container:
         self.container = container
     else:
         self.container = None
     if self.container:
         self.datadir = os.path.join(path, drive, self.container)
     else:
         self.datadir = os.path.join(path, drive)
     self.account = account
     assert logger is not None
     self.logger = logger
     self.metadata = {}
     self.container_info = None
     self.object_info = None
     self.uid = int(uid)
     self.gid = int(gid)
     self.db_file = _db_file
     self.dir_exists = os.path.exists(self.datadir)
     if self.dir_exists:
         try:
             self.metadata = _read_metadata(self.datadir)
         except EOFError:
             create_container_metadata(self.datadir)
     else:
         return
     if self.container:
         if not self.metadata:
             create_container_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_container(self.metadata):
                 create_container_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
     else:
         if not self.metadata:
             create_account_metadata(self.datadir)
             self.metadata = _read_metadata(self.datadir)
         else:
             if not validate_account(self.metadata):
                 create_account_metadata(self.datadir)
                 self.metadata = _read_metadata(self.datadir)
コード例 #11
0
ファイル: test_utils.py プロジェクト: gluster/gluster-swift
 def test_validate_account_missing_keys(self):
     ret = utils.validate_account({'foo': 'bar'})
     assert not ret
コード例 #12
0
ファイル: test_utils.py プロジェクト: gluster/gluster-swift
 def test_validate_account_empty(self):
     ret = utils.validate_account({})
     assert not ret
コード例 #13
0
ファイル: test_utils.py プロジェクト: notmyname/gluster-swift
 def test_validate_account_missing_keys(self):
     ret = utils.validate_account({"foo": "bar"})
     assert not ret
コード例 #14
0
ファイル: test_utils.py プロジェクト: crisbud/swiftonfile
 def test_validate_account_missing_keys(self):
     ret = utils.validate_account({'foo': 'bar'})
     assert not ret
コード例 #15
0
ファイル: test_utils.py プロジェクト: crisbud/swiftonfile
 def test_validate_account_empty(self):
     ret = utils.validate_account({})
     assert not ret