예제 #1
0
def reset_environment():
    call(['resetchase'])
    pids = {}
    try:
        port2server = {}
        for s, p in (('account', 6002), ('container', 6001), ('object', 6000)):
            for n in xrange(1, 5):
                pids['%s%d' % (s, n)] = \
                    Popen(['chase-%s-server' % s,
                           '/etc/chase/%s-server/%d.conf' % (s, n)]).pid
                port2server[p + (n * 10)] = '%s%d' % (s, n)
        pids['proxy'] = Popen(
            ['chase-proxy-server', '/etc/chase/proxy-server.conf']).pid
        account_ring = Ring('/etc/chase/account.ring.gz')
        container_ring = Ring('/etc/chase/container.ring.gz')
        object_ring = Ring('/etc/chase/object.ring.gz')
        attempt = 0
        while True:
            attempt += 1
            try:
                url, token = get_auth('http://127.0.0.1:8080/auth/v1.0',
                                      'test:tester', 'testing')
                account = url.split('/')[-1]
                break
            except Exception, err:
                if attempt > 9:
                    print err
                    print 'Giving up after %s retries.' % attempt
                    raise err
                print err
                print 'Retrying in 2 seconds...'
                sleep(2)
    except BaseException, err:
        kill_pids(pids)
        raise err
예제 #2
0
파일: sync.py 프로젝트: wendy-king/x7_venv
 def __init__(self, conf, container_ring=None, object_ring=None):
     #: The dict of configuration values from the [container-sync] section
     #: of the container-server.conf.
     self.conf = conf
     #: Logger to use for container-sync log lines.
     self.logger = get_logger(conf, log_route='container-sync')
     #: Path to the local device mount points.
     self.devices = conf.get('devices', '/srv/node')
     #: Indicates whether mount points should be verified as actual mount
     #: points (normally true, false for tests and SAIO).
     self.mount_check = \
         conf.get('mount_check', 'true').lower() in TRUE_VALUES
     #: Minimum time between full scans. This is to keep the daemon from
     #: running wild on near empty systems.
     self.interval = int(conf.get('interval', 300))
     #: Maximum amount of time to spend syncing a container before moving on
     #: to the next one. If a conatiner sync hasn't finished in this time,
     #: it'll just be resumed next scan.
     self.container_time = int(conf.get('container_time', 60))
     #: The list of hosts we're allowed to send syncs to.
     self.allowed_sync_hosts = [
         h.strip()
         for h in conf.get('allowed_sync_hosts', '127.0.0.1').split(',')
         if h.strip()
     ]
     self.proxy = conf.get('sync_proxy')
     #: Number of containers with sync turned on that were successfully
     #: synced.
     self.container_syncs = 0
     #: Number of successful DELETEs triggered.
     self.container_deletes = 0
     #: Number of successful PUTs triggered.
     self.container_puts = 0
     #: Number of containers that didn't have sync turned on.
     self.container_skips = 0
     #: Number of containers that had a failure of some type.
     self.container_failures = 0
     #: Time of last stats report.
     self.reported = time()
     chase_dir = conf.get('chase_dir', '/etc/chase')
     #: chase.common.ring.Ring for locating containers.
     self.container_ring = container_ring or \
         Ring(os.path.join(chase_dir, 'container.ring.gz'))
     #: chase.common.ring.Ring for locating objects.
     self.object_ring = object_ring or \
         Ring(os.path.join(chase_dir, 'object.ring.gz'))
     self._myips = whataremyips()
     self._myport = int(conf.get('bind_port', 6001))
예제 #3
0
 def __init__(self, conf):
     """
     :param conf: configuration object obtained from ConfigParser
     :param logger: logging object
     """
     self.conf = conf
     self.logger = get_logger(conf, log_route='object-replicator')
     self.devices_dir = conf.get('devices', '/srv/node')
     self.mount_check = conf.get('mount_check', 'true').lower() in \
                           ('true', 't', '1', 'on', 'yes', 'y')
     self.vm_test_mode = conf.get('vm_test_mode',
                                  'no').lower() in ('yes', 'true', 'on',
                                                    '1')
     self.chase_dir = conf.get('chase_dir', '/etc/chase')
     self.port = int(conf.get('bind_port', 6000))
     self.concurrency = int(conf.get('concurrency', 1))
     self.stats_interval = int(conf.get('stats_interval', '300'))
     self.object_ring = Ring(join(self.chase_dir, 'object.ring.gz'))
     self.ring_check_interval = int(conf.get('ring_check_interval', 15))
     self.next_check = time.time() + self.ring_check_interval
     self.reclaim_age = int(conf.get('reclaim_age', 86400 * 7))
     self.partition_times = []
     self.run_pause = int(conf.get('run_pause', 30))
     self.rsync_timeout = int(conf.get('rsync_timeout', 900))
     self.rsync_io_timeout = conf.get('rsync_io_timeout', '30')
     self.http_timeout = int(conf.get('http_timeout', 60))
     self.lockup_timeout = int(conf.get('lockup_timeout', 1800))
     self.recon_enable = conf.get('recon_enable',
                                  'no').lower() in TRUE_VALUES
     self.recon_cache_path = conf.get('recon_cache_path',
                                      '/var/cache/chase')
     self.recon_object = os.path.join(self.recon_cache_path, "object.recon")
예제 #4
0
 def get_account_ring(self):
     """Get the account ring.  Load it if it hasn't been yet."""
     if not self.account_ring:
         self.logger.debug(
             _('Loading account ring from %s'), self.account_ring_path)
         self.account_ring = Ring(self.account_ring_path)
     return self.account_ring
예제 #5
0
 def get_object_ring(self):
     """ The object :class:`chase.common.ring.Ring` for the cluster. """
     if not self.object_ring:
         self.logger.debug(_('Loading object ring from %s'),
                           self.object_ring_path)
         self.object_ring = Ring(self.object_ring_path)
     return self.object_ring
예제 #6
0
 def get_container_ring(self):
     """ The container :class:`chase.common.ring.Ring` for the cluster. """
     if not self.container_ring:
         self.logger.debug(_('Loading container ring from %s'),
                           self.container_ring_path)
         self.container_ring = Ring(self.container_ring_path)
     return self.container_ring
예제 #7
0
 def get_container_ring(self):
     """Get the container ring.  Load it, if it hasn't been yet."""
     if not self.container_ring:
         self.logger.debug(_('Loading container ring from %s'),
                           self.container_ring_path)
         self.container_ring = Ring(self.container_ring_path)
     return self.container_ring