本文整理汇总了Python中scalarizr.util.wait_until函数的典型用法代码示例。如果您正苦于以下问题:Python wait_until函数的具体用法?Python wait_until怎么用?Python wait_until使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait_until函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: make_snapshot
def make_snapshot(self, volume):
prepared_image_path = os.path.join(self.destination, self.image_name)
LOG.debug('sgp_dd image into volume %s' % volume.device)
system2(('sgp_dd',
'if='+prepared_image_path,
'of='+volume.device,
'bs=8k',
'count=%s' % (self.image_size*1024*1024/8)))
# coreutils.dd(**{'if': prepared_image_path, 'of': volume.device, 'bs': '8M'})
volume.mount()
self.clean_snapshot(volume)
LOG.debug('detaching volume')
volume.detach()
LOG.debug('Making snapshot of volume %s' % volume.device)
snapshot = volume.snapshot()
util.wait_until(
lambda: snapshot.status() == 'completed',
logger=LOG,
error_text='EBS snapshot %s wasnt completed' % snapshot.id)
LOG.debug('Snapshot is made')
volume.ensure(mount=True)
return snapshot.id
开发者ID:chenleji,项目名称:scalarizr,代码行数:25,代码来源:ec2.py
示例2: _ensure_repos
def _ensure_repos(self, updatedb=True):
if "release-latest" in self.repo_url or "release-stable" in self.repo_url:
LOG.warn("Special branches release/latest and release/stable currently doesn't work")
self.repo_url = devel_repo_url_for_branch("master")
repo = pkgmgr.repository("scalr-{0}".format(self.repository), self.repo_url)
# Delete previous repository
for filename in glob.glob(os.path.dirname(repo.filename) + os.path.sep + "scalr*"):
if os.path.isfile(filename):
os.remove(filename)
if "buildbot.scalr-labs.com" in self.repo_url and not linux.os.windows:
self._configure_devel_repo(repo)
elif linux.os.debian_family:
self._apt_pin_release("scalr") # make downgrades possible
elif linux.os.redhat_family or linux.os.oracle_family:
self._yum_prioritize(repo)
# Ensure new repository
repo.ensure()
if updatedb:
LOG.info("Updating packages cache")
def do_updatedb():
try:
self.pkgmgr.updatedb()
return True
except:
LOG.warn("Package manager error", exc_info=sys.exc_info())
wait_until(do_updatedb, sleep=10, timeout=120)
开发者ID:chenleji,项目名称:scalarizr,代码行数:28,代码来源:api.py
示例3: _detach_volume
def _detach_volume(self):
volume_id = self.id
self._check_cinder_connection()
volume = self._cinder.volumes.get(volume_id)
LOG.debug('Detaching Cinder volume %s', volume_id)
if volume.status != 'available':
try:
# self._cinder.volumes.detach(volume_id)
self._check_nova_connection()
server_id = volume.attachments[0]['server_id']
self._nova.volumes.delete_server_volume(server_id, volume_id)
except BaseException, e:
LOG.error('Exception caught when detaching volume: %s', e)
LOG.debug('Checking that Cinder volume %s is detached '
'and available', volume_id)
def exit_condition():
vol = self._cinder.volumes.get(volume_id)
return vol.status == 'available'
msg = "Cinder volume %s is not in 'available' state. " \
"Timeout reached (%s seconds)" % \
(volume_id, self._global_timeout)
util.wait_until(
exit_condition,
logger=LOG,
timeout=self._global_timeout,
error_text=msg)
LOG.debug('Cinder volume %s is available', volume_id)
开发者ID:notbrain,项目名称:scalarizr,代码行数:34,代码来源:cinder.py
示例4: start
def start(cls):
if not cls.is_running():
cls._logger.info("Starting %s process" % MONGOS)
args = [
"sudo",
"-u",
DEFAULT_USER,
MONGOS,
"--fork",
"--logpath",
ROUTER_LOG_PATH,
"--configdb",
"mongo-0-0:%s" % CONFIG_SERVER_DEFAULT_PORT,
]
if cls.keyfile and os.path.exists(cls.keyfile):
chown_r(cls.keyfile, DEFAULT_USER)
args.append("--keyFile=%s" % cls.keyfile)
if cls.verbose and isinstance(cls.verbose, int) and 0 < cls.verbose < 6:
args.append("-" + "v" * cls.verbose)
if os.path.exists(ROUTER_LOG_PATH):
chown_r(ROUTER_LOG_PATH, DEFAULT_USER)
system2(args, close_fds=True, preexec_fn=mongo_preexec_fn)
wait_until(lambda: cls.is_running, timeout=MAX_START_TIMEOUT)
wait_until(lambda: cls.get_cli().has_connection, timeout=MAX_START_TIMEOUT)
cls._logger.debug("%s process has been started." % MONGOS)
开发者ID:rpallas,项目名称:scalarizr,代码行数:28,代码来源:mongodb.py
示例5: start
def start(self):
initdv2.ParametrizedInitScript.start(self)
wait_until(lambda: self._processes, timeout=10, sleep=1)
redis_conf = RedisConf.find()
password = redis_conf.requirepass
cli = RedisCLI(password)
wait_until(lambda: cli.test_connection(), timeout=10, sleep=1)
开发者ID:AnyBucket,项目名称:scalarizr,代码行数:7,代码来源:redis.py
示例6: _attach_volume
def _attach_volume(self, volume):
ebs = self._ebs_volume(volume)
with self.attach_lock:
device_name = get_free_name()
taken_before = base.taken_devices()
volume_id = ebs.id
LOG.debug('Attaching EBS volume %s (name: %s)', volume_id, device_name)
ebs.attach(self._instance_id(), device_name)
LOG.debug('Checking that EBS volume %s is attached', volume_id)
msg = "EBS volume %s wasn't attached. Timeout reached (%s seconds)" % (
ebs.id, self._global_timeout)
util.wait_until(
lambda: ebs.update() and ebs.attachment_state() == 'attached',
logger=LOG, timeout=self._global_timeout,
error_text=msg
)
LOG.debug('EBS volume %s attached', volume_id)
if not linux.os.windows:
util.wait_until(lambda: base.taken_devices() > taken_before,
start_text='Checking that volume %s is available in OS' % volume_id,
timeout=30,
sleep=1,
error_text='Volume %s attached but not available in OS' % volume_id)
devices = list(base.taken_devices() - taken_before)
if len(devices) > 1:
msg = "While polling for attached device, got multiple new devices: {0}. " \
"Don't know which one to select".format(devices)
raise Exception(msg)
return devices[0], device_name
else:
return device_name, device_name
开发者ID:chenleji,项目名称:scalarizr,代码行数:35,代码来源:ebs.py
示例7: start
def start(self):
try:
if not self.running:
#TODO: think about moving this code elsewhere
if self.port == DEFAULT_PORT:
base_dir = self.redis_conf.dir
snap_src = os.path.join(base_dir, DB_FILENAME)
snap_dst = os.path.join(base_dir, get_snap_db_filename(DEFAULT_PORT))
if os.path.exists(snap_src) and not os.path.exists(snap_dst):
shutil.move(snap_src, snap_dst)
self.redis_conf.dbfilename = snap_dst
aof_src = os.path.join(base_dir, AOF_FILENAME)
aof_dst = os.path.join(base_dir, get_aof_db_filename(DEFAULT_PORT))
if os.path.exists(aof_src) and not os.path.exists(aof_dst):
shutil.move(aof_src, aof_dst)
self.redis_conf.appendfilename = aof_dst
LOG.debug('Starting %s on port %s' % (BIN_PATH, self.port))
system2('%s %s -s %s -c "%s %s"'%(SU_EXEC, DEFAULT_USER, BASH, BIN_PATH, self.config_path), shell=True, close_fds=True, preexec_fn=os.setsid)
wait_until(lambda: self.running, timeout=MAX_START_TIMEOUT)
wait_until(lambda: self.cli.test_connection(), timeout=MAX_START_TIMEOUT)
LOG.debug('%s process has been started.' % SERVICE_NAME)
except PopenError, e:
LOG.error('Unable to start redis process: %s' % e)
raise initdv2.InitdError(e)
开发者ID:notbrain,项目名称:scalarizr,代码行数:28,代码来源:redis.py
示例8: destroy
def destroy(self, vol, force=False, **kwargs):
super(LoopVolumeProvider, self).destroy(vol, force, **kwargs)
wait_until(self._rmloop, (vol.devname, ),
sleep=1, timeout=60, error_text='Cannot detach loop device %s' % vol.devname)
if force:
os.remove(vol.file)
vol.device = None
开发者ID:AnyBucket,项目名称:scalarizr,代码行数:7,代码来源:loop.py
示例9: _create_volume
def _create_volume(self, zone=None, size=None, snapshot=None,
volume_type=None, iops=None, tags=None, encrypted=False):
LOG.debug('Creating EBS volume (zone: %s size: %s snapshot: %s '
'volume_type: %s iops: %s encrypted: %s)', zone, size, snapshot,
volume_type, iops, encrypted)
if snapshot:
self._wait_snapshot(snapshot)
ebs = self._conn.create_volume(size, zone, snapshot, volume_type, iops,
encrypted)
LOG.debug('EBS volume %s created', ebs.id)
LOG.debug('Checking that EBS volume %s is available', ebs.id)
msg = "EBS volume %s is not in 'available' state. " \
"Timeout reached (%s seconds)" % (
ebs.id, self._global_timeout)
util.wait_until(
lambda: ebs.update() == "available",
logger=LOG, timeout=self._global_timeout,
error_text=msg
)
LOG.debug('EBS volume %s available', ebs.id)
if tags:
self._create_tags_async(ebs.id, tags)
return ebs
开发者ID:chenleji,项目名称:scalarizr,代码行数:25,代码来源:ebs.py
示例10: _run
def _run(self):
self.volume = storage2.volume(self.volume)
LOG.debug("Volume obj: %s", self.volume)
LOG.debug("Volume config: %s", dict(self.volume))
state = {}
self.fire("freeze", self.volume, state)
try:
snap = self.volume.snapshot(self.description, tags=self.tags)
finally:
self.fire("unfreeze", self.volume, state)
try:
util.wait_until(
lambda: snap.status() in (snap.COMPLETED, snap.FAILED),
start_text="Polling snapshot status (%s)" % snap.id,
logger=LOG,
)
except:
if "Request limit exceeded" in str(sys.exc_info()[1]):
pass
else:
raise
if snap.status() == snap.FAILED:
msg = "Backup failed because snapshot %s failed" % snap.id
raise Error(msg)
return restore(type=self.type, snapshot=snap, **state)
开发者ID:chenleji,项目名称:scalarizr,代码行数:25,代码来源:backup.py
示例11: rebundle
def rebundle(self):
image_name = self._role_name + "-" + time.strftime("%Y%m%d%H%M%S")
nova = __node__['openstack']['new_nova_connection']
nova.connect()
server_id = __node__['openstack']['server_id']
system2("sync", shell=True)
LOG.info('Creating server image (server_id: %s)', server_id)
image_id = nova.servers.create_image(server_id, image_name)
LOG.info('Server image %s created', image_id)
result = [None]
def image_completed():
try:
result[0] = nova.images.get(image_id)
return result[0].status in ('ACTIVE', 'FAILED')
except:
e = sys.exc_info()[1]
if 'Unhandled exception occurred during processing' in str(e):
return
raise
wait_until(image_completed, start_text='Polling image status', sleep=30)
image_id = result[0].id
if result[0].status == 'FAILED':
raise handlers.HandlerError('Image %s becomes FAILED', image_id)
LOG.info('Image %s completed and available for use!', image_id)
return image_id
开发者ID:AnyBucket,项目名称:scalarizr,代码行数:28,代码来源:rebundle.py
示例12: execute
def execute(self, query, silent=False):
if not self.password:
full_query = query
else:
full_query = 'AUTH %s\n%s' % (self.password, query)
execute_query = lambda: system2([self.path, '-p', self.port], stdin=full_query,silent=True, warn_stderr=False)
try:
out = execute_query()[0]
#fix for redis 2.4 AUTH
if 'Client sent AUTH, but no password is set' in out:
execute_query = lambda: system2([self.path], stdin=query, silent=True)
out = execute_query()[0]
if "Redis is loading the dataset in memory" in out:
#[SCALARIZR-1604]
#test until service becomes available:
wait_until(lambda: "LOADING" not in system2([self.path], stdin='ping', silent=True)[0])
#run query again:
out = execute_query()[0]
elif out.startswith('ERR'):
raise PopenError(out)
elif out.startswith('OK\n'):
out = out[3:]
if out.endswith('\n'):
out = out[:-1]
return out
except PopenError, e:
if not silent:
LOG.error('Unable to execute query %s with redis-cli: %s' % (query, e))
raise
开发者ID:chenleji,项目名称:scalarizr,代码行数:34,代码来源:redis.py
示例13: _check_attachement
def _check_attachement(self):
self._native_vol = self._conn.listVolumes(id=self.id)[0]
if self._attached():
if self._native_vol.virtualmachineid == __cloudstack__['instance_id']:
LOG.debug('Volume %s is attached to this instance', self.id)
return
self.device = None # Volume will have a new device name
LOG.warning('Volume %s is not available. '
'It is attached to different instance %s. '
'Now scalarizr will detach it',
self.id, self._native_vol.virtualmachineid)
# We should wait for state chage
if self._native_vol.vmstate == 'Stopping':
def vm_state_changed():
self._native_vol = self._conn.listVolumes(id=self._native_vol.id)[0]
return not hasattr(self._native_vol, 'virtualmachineid') or \
self._native_vol.vmstate != 'Stopping'
util.wait_until(vm_state_changed)
# If stil attached, detaching
if hasattr(self._native_vol, 'virtualmachineid'):
self._detach()
LOG.debug('Volume %s detached', self.id)
return self._attach(__cloudstack__['instance_id'])
开发者ID:AnyBucket,项目名称:scalarizr,代码行数:26,代码来源:csvol.py
示例14: _attach
def _attach(self, instance_id):
self._check_connection()
volume_id = self.id or self._native_vol.id
with self.attach_lock:
LOG.debug('Attaching CloudStack volume %s', volume_id)
taken_before = base.taken_devices()
self._conn.attachVolume(volume_id, instance_id)
def device_plugged():
# Rescan SCSI bus
scsi_host = '/sys/class/scsi_host'
for name in os.listdir(scsi_host):
with open(scsi_host + '/' + name + '/scan', 'w') as fp:
fp.write('- - -')
return base.taken_devices() > taken_before
util.wait_until(device_plugged,
start_text='Checking that volume %s is available in OS' % volume_id,
timeout=30,
sleep=1,
error_text='Volume %s attached but not available in OS' % volume_id)
devices = list(base.taken_devices() - taken_before)
if len(devices) > 1:
msg = "While polling for attached device, got multiple new devices: %s. " \
"Don't know which one to select".format(devices)
raise Exception(msg)
return devices[0]
LOG.debug('Checking that volume %s is attached', volume_id)
开发者ID:AnyBucket,项目名称:scalarizr,代码行数:31,代码来源:csvol.py
示例15: _attach_volume
def _attach_volume(self, volume, device_name=None):
ebs = self._ebs_volume(volume)
LOG.debug('Attaching EBS volume %s (device: %s)', ebs.id, device_name)
ebs.attach(self._instance_id(), device_name)
LOG.debug('Checking that EBS volume %s is attached', ebs.id)
msg = "EBS volume %s wasn't attached. Timeout reached (%s seconds)" % (
ebs.id, self._global_timeout)
util.wait_until(
lambda: ebs.update() and ebs.attachment_state() == 'attached',
logger=LOG, timeout=self._global_timeout,
error_text=msg
)
LOG.debug('EBS volume %s attached', ebs.id)
device = name2device(device_name)
LOG.debug('EBS device name %s is mapped to %s in operation system',
device_name, device)
LOG.debug('Checking that device %s is available', device)
msg = 'Device %s is not available in operation system. ' \
'Timeout reached (%s seconds)' % (
device, self._global_timeout)
util.wait_until(
lambda: os.access(device, os.F_OK | os.R_OK),
sleep=1, logger=LOG, timeout=self._global_timeout,
error_text=msg
)
LOG.debug('Device %s is available', device)
开发者ID:yoyama,项目名称:scalarizr,代码行数:28,代码来源:ebs.py
示例16: on_host_init_response
def on_host_init_response(self, hir):
LOG.info('Configuring block device mountpoints')
with bus.initialization_op as op:
with op.phase(self._phase_plug_volume):
wait_until(self._plug_all_volumes, sleep=10, timeout=600,
error_text='Cannot attach and mount disks in a reasonable time')
volumes = hir.body.get('volumes') or []
if volumes:
LOG.debug('HIR volumes: %s', volumes)
for i in range(0, len(volumes)):
vol = volumes[i]
template = vol.pop('template', None)
from_template_if_missing = vol.pop('from_template_if_missing', None)
vol = storage2.volume(**vol)
LOG.info('Ensuring %s volume %s', vol.type, dict(vol))
try:
vol.ensure(mount=bool(vol.mpoint), mkfs=True)
except storage2.VolumeNotExistsError, e:
if template and from_template_if_missing == '1':
vol = storage2.volume(**template)
LOG.warn('Volume %s not exists, re-creating %s volume from config: %s',
str(e), vol.type, dict(vol))
vol.ensure(mount=bool(vol.mpoint), mkfs=True)
else:
raise
self._volumes.append(dict(vol))
开发者ID:notbrain,项目名称:scalarizr,代码行数:28,代码来源:block_device.py
示例17: on_BeforeHostTerminate
def on_BeforeHostTerminate(self, *args):
cassandra.start_service()
err = system2('nodetool -h localhost decommission', shell=True)[2]
if err:
raise HandlerError('Cannot decommission node: %s' % err)
wait_until(self._is_decommissioned, timeout=300, error_text="Node wasn't decommissioned in a reasonable time")
cassandra.stop_service()
开发者ID:golovast,项目名称:scalarizr,代码行数:7,代码来源:cassandra.py
示例18: _create_volume
def _create_volume(self, zone=None, size=None, snapshot=None,
volume_type=None, iops=None, tags=None):
LOG.debug('Creating EBS volume (zone: %s size: %s snapshot: %s '
'volume_type: %s iops: %s)', zone, size, snapshot,
volume_type, iops)
if snapshot:
self._wait_snapshot(snapshot)
ebs = self._conn.create_volume(size, zone, snapshot, volume_type, iops)
LOG.debug('EBS volume %s created', ebs.id)
LOG.debug('Checking that EBS volume %s is available', ebs.id)
msg = "EBS volume %s is not in 'available' state. " \
"Timeout reached (%s seconds)" % (
ebs.id, self._global_timeout)
util.wait_until(
lambda: ebs.update() == "available",
logger=LOG, timeout=self._global_timeout,
error_text=msg
)
LOG.debug('EBS volume %s available', ebs.id)
if tags:
try:
LOG.debug('Applying tags to EBS volume %s (tags: %s)', ebs.id, tags)
self._conn.create_tags([ebs.id], tags)
except:
LOG.warn('Cannot apply tags to EBS volume %s. Error: %s',
ebs.id, sys.exc_info()[1])
return ebs
开发者ID:golovast,项目名称:scalarizr,代码行数:29,代码来源:ebs.py
示例19: on_host_init_response
def on_host_init_response(self, hir):
bus.init_op.logger.info('Configuring storage volumes')
# volumes from QueryEnv.list_ebs_mountpoints()
wait_until(self._plug_old_style_volumes, sleep=10)
# volumes assigned to this role on Farm Designer
volumes = hir.body.get('volumes', []) or []
self._plug_new_style_volumes(volumes)
开发者ID:AnyBucket,项目名称:scalarizr,代码行数:7,代码来源:block_device.py
示例20: _wait_snapshot
def _wait_snapshot(self, snapshot_id):
LOG.debug('Checking that Cinder snapshot %s is completed', snapshot_id)
msg = "Cinder snapshot %s wasn't completed. " \
"Timeout reached (%s seconds)" % (
snapshot_id, self._global_timeout)
snap = [None]
def exit_condition():
snap[0] = self._cinder.volume_snapshots.get(snapshot_id)
return snap[0].status != 'creating'
util.wait_until(
exit_condition,
logger=LOG,
timeout=self._global_timeout,
error_text=msg
)
if snap[0].status == 'error':
msg = 'Cinder snapshot %s creation failed.' \
'AWS status is "error"' % snapshot_id
raise storage2.StorageError(msg)
elif snap[0].status == 'available':
LOG.debug('Snapshot %s completed', snapshot_id)
开发者ID:AnyBucket,项目名称:scalarizr,代码行数:25,代码来源:cinder.py
注:本文中的scalarizr.util.wait_until函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论