def __init__(self, conf): self.volumes = VolumeHelper(conf) self.exports = ExportHelper(conf) self.backups = BackupHelper(conf) self.cgroups = CgroupHelper(conf) self.api_server = conf.string('storage', 'api_server', "http://localhost:8080") self.api_retry = conf.int('storage', 'api_retry', 1) # name of node registration self.name = conf.string('storage', 'name', socket.gethostname()) self.affinity_group = conf.string('storage', 'affinity_group', '') # management interface self.management_host = conf.string('server:main', 'host', '0.0.0.0') if self.management_host == '0.0.0.0': self.management_host = my_ip(self.api_server) self.management_port = conf.int('server:main', 'port', 8081) # storage interface self.storage_host = conf.string('storage', 'host', '127.0.0.1') self.storage_port = conf.int('storage', 'port', 3260) self.volume_type = conf.string('storage', 'volume_type', 'vtype') # cinder self.cinder_args = cinderclient.get_args(conf) self.rax_auth = conf.bool('cinder', 'rax_auth', True) if self.rax_auth: self.client = cinderclient.CinderClient(**self.cinder_args) self.cinder_host = conf.string('storage', 'cinder_host', self.management_host)
def backup(self, id=None, src=None, timestamp=None): """ This runs a backup job outside of the storage api, which is useful for performance testing backups """ # Set basic Logging logging.basicConfig() # Get the lunr logger log = logger.get_logger() # Output Debug level info log.logger.setLevel(logging.DEBUG) # Load the local storage configuration conf = LunrConfig.from_storage_conf() # If no time provided, use current time timestamp = timestamp or time() # Init our helpers volume = VolumeHelper(conf) backup = BackupHelper(conf) try: # Create the snapshot snapshot = volume.create_snapshot(src, id, timestamp) # For testing non-snapshot speeds #snapshot = volume.get(src) #snapshot['backup_id'] = id #snapshot['origin'] = src #snapshot['timestamp'] = 1338410885.0 #del snapshot['volume'] print("Created snap-shot: ", pprint(snapshot)) with self.timeit(snapshot['size']): # Backup the snapshot print("Starting Backup") backup.save(snapshot, id) finally: # Delete the snapshot if it was created if 'snapshot' in locals(): self._remove_volume(snapshot['path'])
def setUp(self): IetTest.setUp(self) self.tempdir = mkdtemp() self.conf = self.config(self.tempdir) self.volume = VolumeHelper(self.conf) self.backup = BackupHelper(self.conf)