Changeset 474
- Timestamp:
- 05/20/08 16:26:48
(8 months ago)
- Author:
- jmowery
- Message:
remove works now
moved all members into init to avoid shared instances
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r473 |
r474 |
|
| 138 | 138 | class Entry: |
|---|
| 139 | 139 | '''An Entry object represents the state information for a single storage object.''' |
|---|
| 140 | | name = '' # Name of the file represented by this entry or '.' for current directory |
|---|
| 141 | | type = '' # One of entry_types what kind of entry this is |
|---|
| 142 | | applied = 0 # Current time of the file as applied to clients |
|---|
| 143 | | initial = 0 # Initial time at which this entry was added to the store |
|---|
| 144 | | latest = 0 # Latest version of this entry that exists |
|---|
| 145 | | lock = False # If locked, this entry may not be changed by add or remove commands |
|---|
| 146 | | local = True # If local, the store manages the state of this file when considering updates, otherwise it accepts remote changes for updates |
|---|
| 147 | | group = '' # The group from which the file belongs; ignored for directories and local files |
|---|
| 148 | 140 | |
|---|
| 149 | 141 | def __init__(self, name, type='FILE'): |
|---|
| 150 | 142 | '''Initialize an Entry; name must not be empty.''' |
|---|
| | 143 | self.name = '' # Name of the file represented by this entry or '.' for current directory |
|---|
| | 144 | self.type = '' # One of entry_types what kind of entry this is |
|---|
| | 145 | self.applied = 0 # Current time of the file as applied to clients |
|---|
| | 146 | self.initial = 0 # Initial time at which this entry was added to the store |
|---|
| | 147 | self.latest = 0 # Latest version of this entry that exists |
|---|
| | 148 | self.lock = False # If locked, this entry may not be changed by add or remove commands |
|---|
| | 149 | self.local = True # If local, the store manages the state of this file when considering updates, otherwise it accepts remote changes for updates |
|---|
| | 150 | self.group = '' # The group from which the file belongs; ignored for directories and local files |
|---|
| 151 | 151 | if not name: |
|---|
| 152 | 152 | raise ValueError, 'Must specify a valid name.' |
|---|
| … | … | |
| 192 | 192 | class StorageData: |
|---|
| 193 | 193 | '''The StorageData object maintains all filesystem related state data for the store.''' |
|---|
| 194 | | path = '' # base path of the storage files/directories at this level of the hierarchy |
|---|
| 195 | | status_path = '' # path of the status file |
|---|
| 196 | | storage_dir = '' # path of the storage directory containing all versions of controlled files |
|---|
| 197 | | root = '' # path of the root of the store |
|---|
| 198 | | logs_dir = '' # path of the log storage directory (always in root) |
|---|
| 199 | | nodes_dir = '' # path of the node data directory |
|---|
| 200 | | time = 0 # time of last sync to disk for the store data |
|---|
| 201 | | config = ConfigParser.ConfigParser() # internal parser for the status file |
|---|
| 202 | 194 | |
|---|
| 203 | 195 | def __init__(self, layer=''): |
|---|
| 204 | 196 | '''Initialize a store object, if the layer parameter is set read status data from disk''' |
|---|
| | 197 | self.path = '' # base path of the storage files/directories at this level of the hierarchy |
|---|
| | 198 | self.status_path = '' # path of the status file |
|---|
| | 199 | self.storage_dir = '' # path of the storage directory containing all versions of controlled files |
|---|
| | 200 | self.root = '' # path of the root of the store |
|---|
| | 201 | self.logs_dir = '' # path of the log storage directory (always in root) |
|---|
| | 202 | self.nodes_dir = '' # path of the node data directory |
|---|
| | 203 | self.time = 0 # time of last sync to disk for the store data |
|---|
| | 204 | self.config = ConfigParser.ConfigParser() # internal parser for the status file |
|---|
| 205 | 205 | if layer == '': |
|---|
| 206 | 206 | return |
|---|
| … | … | |
| 302 | 302 | class Layer: |
|---|
| 303 | 303 | '''The Layer object maintains all data relevant to a single hierarchical group.''' |
|---|
| 304 | | modified = False # set to True if the data in any field has changed since last sync to disk |
|---|
| 305 | | name = '' # The name of a Layer is the relative path to the storage_root/.. |
|---|
| 306 | | description = '' # User configurable description of the type of files contained in the Layer |
|---|
| 307 | | entries = {} # Dictionary of file name, Entry pairs per controlled file |
|---|
| 308 | | storage = None # StorageData object representing the file system level data for this Layer |
|---|
| 309 | 304 | |
|---|
| 310 | 305 | def __init__(self, layer): |
|---|
| 311 | 306 | '''Initialize all available fields of a Layer; note that if the directory layer is not controlled storage will be None''' |
|---|
| | 307 | self.modified = False # set to True if the data in any field has changed since last sync to disk |
|---|
| | 308 | self.name = '' # The name of a Layer is the relative path to the storage_root/.. |
|---|
| | 309 | self.description = '' # User configurable description of the type of files contained in the Layer |
|---|
| | 310 | self.entries = {} # Dictionary of file name, Entry pairs per controlled file |
|---|
| | 311 | self.storage = None # StorageData object representing the file system level data for this Layer |
|---|
| 312 | 312 | self.name = os.path.realpath(os.path.expanduser(layer)) |
|---|
| 313 | 313 | if not os.path.isdir(self.name): |
|---|
| … | … | |
| 551 | 551 | raise RuntimeError, '\'' + name + '\' is locked; it cannot be removed' |
|---|
| 552 | 552 | if name == '.': |
|---|
| 553 | | if not is_controlled(self.name): |
|---|
| | 553 | if not self.storage: |
|---|
| 554 | 554 | return #nothing to do if not under control |
|---|
| 555 | 555 | if self.is_locked('.', True): |
|---|
| … | … | |
| 558 | 558 | _l = Layer(os.path.join(self.storage.path, dir)) |
|---|
| 559 | 559 | _l.remove('.') |
|---|
| | 560 | for file in self.list_controlled_files(): |
|---|
| | 561 | self.remove(file) |
|---|
| 560 | 562 | full_path = self.storage.path |
|---|
| 561 | 563 | self.storage.remove_dir('.') |
|---|
| … | … | |
| 563 | 565 | self.entries.clear() |
|---|
| 564 | 566 | self.modified = False #changes don't matter everything is gone |
|---|
| 565 | | if is_controlled(os.path.join(self.name, '..')): |
|---|
| | 567 | if is_controlled(os.path.join(full_path, '..')): |
|---|
| 566 | 568 | _l = Layer(os.path.join(full_path, '..')) |
|---|
| 567 | 569 | _l.remove(os.path.basename(self.name)) |
|---|
| … | … | |
| 996 | 998 | class NodeLayerData: |
|---|
| 997 | 999 | '''Represents the data stored on disk about the status of files sent to this node relative to a single Layer.''' |
|---|
| 998 | | layer_path = '' # Path of the layer represented |
|---|
| 999 | | group_name = '' # Group name for the layer |
|---|
| 1000 | | config_path = '' # path to the file containing the on disk record of the state of the Node's files for this layer |
|---|
| 1001 | | config = ConfigParser.ConfigParser() # parser object for the file config_path |
|---|
| 1002 | 1000 | |
|---|
| 1003 | 1001 | def __init__(self, id, layer_path): |
|---|
| | 1002 | self.layer_path = '' # Path of the layer represented |
|---|
| | 1003 | self.group_name = '' # Group name for the layer |
|---|
| | 1004 | self.config_path = '' # path to the file containing the on disk record of the state of the Node's files for this layer |
|---|
| | 1005 | self.config = ConfigParser.ConfigParser() # parser object for the file config_path |
|---|
| 1004 | 1006 | assert is_controlled(layer_path) |
|---|
| 1005 | 1007 | self.layer_path = layer_path |
|---|
| … | … | |
| 1020 | 1022 | class Node: |
|---|
| 1021 | 1023 | '''The node object holds all storage relevant data about a single node connected to the store.''' |
|---|
| 1022 | | modified = False # Set whenever the status data has been modified since last sync to disk |
|---|
| 1023 | | id = '' # Id of the node (currently its IP address) |
|---|
| 1024 | | classification = '' # Group name of the most specific layer containing the node |
|---|
| 1025 | | description = '' # User defined string providing description of the node (possibly a name) |
|---|
| 1026 | | bools = {} # Status of each boolean on the node system keyed by bool name value is bool not string |
|---|
| 1027 | | entries = {} # Entry per module to be sent to the node applied time is last sent version |
|---|
| 1028 | | enforcing = 'Unknown' # Enforcing status of the node |
|---|
| 1029 | | layers = {} # NodeLayerData per layer path for each layer in classification |
|---|
| 1030 | | root = '' # Root of store contianing data for this node |
|---|
| 1031 | 1024 | |
|---|
| 1032 | 1025 | def __init__(self, id, root): |
|---|
| | 1026 | self.modified = False # Set whenever the status data has been modified since last sync to disk |
|---|
| | 1027 | self.id = '' # Id of the node (currently its IP address) |
|---|
| | 1028 | self.classification = '' # Group name of the most specific layer containing the node |
|---|
| | 1029 | self.description = '' # User defined string providing description of the node (possibly a name) |
|---|
| | 1030 | self.bools = {} # Status of each boolean on the node system keyed by bool name value is bool not string |
|---|
| | 1031 | self.entries = {} # Entry per module to be sent to the node applied time is last sent version |
|---|
| | 1032 | self.enforcing = 'Unknown' # Enforcing status of the node |
|---|
| | 1033 | self.layers = {} # NodeLayerData per layer path for each layer in classification |
|---|
| | 1034 | self.root = '' # Root of store contianing data for this node |
|---|
| 1033 | 1035 | if not id: |
|---|
| 1034 | 1036 | raise ValueError, 'Node must have a valid id.' |
|---|
Download in other formats:
* Generating other formats may take time.