Changeset 474

Show
Ignore:
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
  • branches/trunk-pmd-intproto/server/storage.py

    r473 r474  
    138138class Entry: 
    139139        '''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 
    148140 
    149141        def __init__(self, name, type='FILE'): 
    150142                '''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 
    151151                if not name: 
    152152                        raise ValueError, 'Must specify a valid name.' 
     
    192192class StorageData: 
    193193        '''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 
    202194 
    203195        def __init__(self, layer=''): 
    204196                '''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 
    205205                if layer == '': 
    206206                        return 
     
    302302class Layer: 
    303303        '''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 
    309304 
    310305        def __init__(self, layer): 
    311306                '''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 
    312312                self.name = os.path.realpath(os.path.expanduser(layer)) 
    313313                if not os.path.isdir(self.name): 
     
    551551                        raise RuntimeError, '\'' + name + '\' is locked; it cannot be removed' 
    552552                if name == '.': 
    553                         if not is_controlled(self.name)
     553                        if not self.storage
    554554                                return #nothing to do if not under control 
    555555                        if self.is_locked('.', True): 
     
    558558                                _l = Layer(os.path.join(self.storage.path, dir)) 
    559559                                _l.remove('.') 
     560                        for file in self.list_controlled_files(): 
     561                                self.remove(file) 
    560562                        full_path = self.storage.path 
    561563                        self.storage.remove_dir('.') 
     
    563565                        self.entries.clear() 
    564566                        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, '..')): 
    566568                                _l = Layer(os.path.join(full_path, '..')) 
    567569                                _l.remove(os.path.basename(self.name)) 
     
    996998class NodeLayerData: 
    997999        '''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 
    10021000 
    10031001        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 
    10041006                assert is_controlled(layer_path) 
    10051007                self.layer_path = layer_path 
     
    10201022class Node: 
    10211023        '''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 
    10311024 
    10321025        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 
    10331035                if not id: 
    10341036                        raise ValueError, 'Node must have a valid id.'