本文整理匯總了Python中amulet.raise_status方法的典型用法代碼示例。如果您正苦於以下問題:Python amulet.raise_status方法的具體用法?Python amulet.raise_status怎麽用?Python amulet.raise_status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類amulet
的用法示例。
在下文中一共展示了amulet.raise_status方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_ceph_pools
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def get_ceph_pools(self, sentry_unit):
"""Return a dict of ceph pools from a single ceph unit, with
pool name as keys, pool id as vals."""
pools = {}
cmd = 'sudo ceph osd lspools'
output, code = sentry_unit.run(cmd)
if code != 0:
msg = ('{} `{}` returned {} '
'{}'.format(sentry_unit.info['unit_name'],
cmd, code, output))
amulet.raise_status(amulet.FAIL, msg=msg)
# Example output: 0 data,1 metadata,2 rbd,3 cinder,4 glance,
for pool in str(output).split(','):
pool_id_name = pool.split(' ')
if len(pool_id_name) == 2:
pool_id = pool_id_name[0]
pool_name = pool_id_name[1]
pools[pool_name] = int(pool_id)
self.log.debug('Pools on {}: {}'.format(sentry_unit.info['unit_name'],
pools))
return pools
示例2: get_process_id_list
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def get_process_id_list(self, sentry_unit, process_name,
expect_success=True):
"""Get a list of process ID(s) from a single sentry juju unit
for a single process name.
:param sentry_unit: Amulet sentry instance (juju unit)
:param process_name: Process name
:param expect_success: If False, expect the PID to be missing,
raise if it is present.
:returns: List of process IDs
"""
cmd = 'pidof -x {}'.format(process_name)
if not expect_success:
cmd += " || exit 0 && exit 1"
output, code = sentry_unit.run(cmd)
if code != 0:
msg = ('{} `{}` returned {} '
'{}'.format(sentry_unit.info['unit_name'],
cmd, code, output))
amulet.raise_status(amulet.FAIL, msg=msg)
return str(output).split()
示例3: get_process_id_list
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def get_process_id_list(self, sentry_unit, process_name,
expect_success=True):
"""Get a list of process ID(s) from a single sentry juju unit
for a single process name.
:param sentry_unit: Amulet sentry instance (juju unit)
:param process_name: Process name
:param expect_success: If False, expect the PID to be missing,
raise if it is present.
:returns: List of process IDs
"""
cmd = 'pidof -x "{}"'.format(process_name)
if not expect_success:
cmd += " || exit 0 && exit 1"
output, code = sentry_unit.run(cmd)
if code != 0:
msg = ('{} `{}` returned {} '
'{}'.format(sentry_unit.info['unit_name'],
cmd, code, output))
amulet.raise_status(amulet.FAIL, msg=msg)
return str(output).split()
示例4: test_106_swift_object_store_endpoint
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def test_106_swift_object_store_endpoint(self):
"""Verify the swift object-store endpoint data."""
u.log.debug('Checking keystone endpoint for swift object store...')
endpoints = self.keystone.endpoints.list()
admin_port = internal_port = public_port = '8080'
expected = {'id': u.not_null,
'region': 'RegionOne',
'adminurl': u.valid_url,
'internalurl': u.valid_url,
'publicurl': u.valid_url,
'service_id': u.not_null}
ret = u.validate_endpoint_data(endpoints, admin_port, internal_port,
public_port, expected)
if ret:
message = 'object-store endpoint: {}'.format(ret)
amulet.raise_status(amulet.FAIL, msg=message)
示例5: test_200_swift_proxy_identity_service_relation
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def test_200_swift_proxy_identity_service_relation(self):
"""Verify the swift-proxy to keystone identity relation data."""
u.log.debug('Checking swift-proxy:keystone identity relation...')
unit = self.swift_proxy_sentry
relation = ['identity-service', 'keystone:identity-service']
expected = {
'swift_service': 'swift',
'swift_region': 'RegionOne',
'swift_public_url': u.valid_url,
'swift_internal_url': u.valid_url,
'swift_admin_url': u.valid_url,
's3_service': 's3',
's3_region': 'RegionOne',
's3_public_url': u.valid_url,
's3_internal_url': u.valid_url,
's3_admin_url': u.valid_url,
'private-address': u.valid_ip,
}
ret = u.validate_relation_data(unit, relation, expected)
if ret:
message = u.relation_error('swift-proxy identity-service', ret)
amulet.raise_status(amulet.FAIL, msg=message)
示例6: test_202_keystone_identity_service_relation
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def test_202_keystone_identity_service_relation(self):
"""Verify the keystone to swift-proxy identity relation data."""
u.log.debug('Checking keystone:swift-proxy identity relation...')
unit = self.keystone_sentry
relation = ['identity-service', 'swift-proxy:identity-service']
expected = {
'service_protocol': 'http',
'service_tenant': 'services',
'admin_token': 'ubuntutesting',
'service_password': u.not_null,
'service_port': '5000',
'auth_port': '35357',
'auth_protocol': 'http',
'private-address': u.valid_ip,
'auth_host': u.valid_ip,
'service_username': 's3_swift',
'service_tenant_id': u.not_null,
'service_host': u.valid_ip
}
ret = u.validate_relation_data(unit, relation, expected)
if ret:
message = u.relation_error('keystone identity-service', ret)
amulet.raise_status(amulet.FAIL, msg=message)
示例7: test_204_swift_storage_swift_storage_relation
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def test_204_swift_storage_swift_storage_relation(self):
"""Verify the swift-storage to swift-proxy swift-storage relation
data."""
u.log.debug('Checking swift:swift-proxy swift-storage relation...')
unit = self.swift_storage_sentry
relation = ['swift-storage', 'swift-proxy:swift-storage']
expected = {
'account_port': '6002',
'zone': '1',
'object_port': '6000',
'container_port': '6001',
'private-address': u.valid_ip,
'device': 'vdb'
}
ret = u.validate_relation_data(unit, relation, expected)
if ret:
message = u.relation_error('swift-storage swift-storage', ret)
amulet.raise_status(amulet.FAIL, msg=message)
示例8: test_206_swift_proxy_swift_storage_relation
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def test_206_swift_proxy_swift_storage_relation(self):
"""Verify the swift-proxy to swift-storage swift-storage relation
data."""
u.log.debug('Checking swift-proxy:swift swift-storage relation...')
unit = self.swift_proxy_sentry
relation = ['swift-storage', 'swift-storage:swift-storage']
expected = {
'private-address': u.valid_ip,
'trigger': u.not_null,
'rings_url': u.valid_url,
'swift_hash': u.not_null
}
ret = u.validate_relation_data(unit, relation, expected)
if ret:
message = u.relation_error('swift-proxy swift-storage', ret)
amulet.raise_status(amulet.FAIL, msg=message)
示例9: test_300_swift_config
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def test_300_swift_config(self):
"""Verify the data in the swift-hash section of the swift config
file."""
u.log.debug('Checking swift config...')
unit = self.swift_storage_sentry
conf = '/etc/swift/swift.conf'
swift_proxy_relation = self.swift_proxy_sentry.relation(
'swift-storage', 'swift-storage:swift-storage')
expected = {
'swift_hash_path_suffix': swift_proxy_relation['swift_hash']
}
ret = u.validate_config_data(unit, conf, 'swift-hash', expected)
if ret:
message = "swift config error: {}".format(ret)
amulet.raise_status(amulet.FAIL, msg=message)
示例10: _test_pause
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def _test_pause(self):
u.log.info("Testing pause action")
self._assert_services(should_run=True)
pause_action_id = u.run_action(self.swift_proxy_sentry, "pause")
assert u.wait_on_action(pause_action_id), "Pause action failed."
self._assert_services(should_run=False)
status, message = u.status_get(self.swift_proxy_sentry)
if status != "maintenance":
msg = ("Pause action failed to move unit to maintenance "
"status (got {} instead)".format(status))
amulet.raise_status(amulet.FAIL, msg=msg)
if message != "Paused. Use 'resume' action to resume normal service.":
msg = ("Pause action failed to set message"
" (got {} instead)".format(message))
amulet.raise_status(amulet.FAIL, msg=msg)
示例11: _test_resume
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def _test_resume(self):
u.log.info("Testing resume action")
# service is left paused by _test_pause
self._assert_services(should_run=False)
resume_action_id = u.run_action(self.swift_proxy_sentry, "resume")
assert u.wait_on_action(resume_action_id), "Resume action failed."
self._assert_services(should_run=True)
status, message = u.status_get(self.swift_proxy_sentry)
if status != "active":
msg = ("Resume action failed to move unit to active "
"status (got {} instead)".format(status))
amulet.raise_status(amulet.FAIL, msg=msg)
if message != "Unit is ready":
msg = ("Resume action failed to clear message"
" (got {} instead)".format(message))
amulet.raise_status(amulet.FAIL, msg=msg)
示例12: _image_create
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def _image_create(self):
"""Create an image to be used by the heat template, verify it exists"""
u.log.debug('Creating glance image ({})...'.format(IMAGE_NAME))
# Create a new image
image_new = u.create_cirros_image(self.glance, IMAGE_NAME)
# Confirm image is created and has status of 'active'
if not image_new:
message = 'glance image create failed'
amulet.raise_status(amulet.FAIL, msg=message)
# Verify new image name
images_list = list(self.glance.images.list())
if images_list[0].name != IMAGE_NAME:
message = ('glance image create failed or unexpected '
'image name {}'.format(images_list[0].name))
amulet.raise_status(amulet.FAIL, msg=message)
示例13: test_110_service_catalog
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def test_110_service_catalog(self):
"""Expect certain endpoints and endpoint data to be
present in the Keystone service catalog"""
u.log.debug('Checking service catalog endpoint data...')
ep_validate = {'adminURL': u.valid_url,
'region': 'RegionOne',
'publicURL': u.valid_url,
'internalURL': u.valid_url,
'id': u.not_null}
expected = {'compute': [ep_validate], 'orchestration': [ep_validate],
'image': [ep_validate], 'identity': [ep_validate]}
actual = self.keystone.service_catalog.get_endpoints()
ret = u.validate_svc_catalog_endpoint_data(expected, actual)
if ret:
amulet.raise_status(amulet.FAIL, msg=ret)
示例14: test_120_heat_endpoint
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def test_120_heat_endpoint(self):
"""Verify the heat api endpoint data."""
u.log.debug('Checking api endpoint data...')
endpoints = self.keystone.endpoints.list()
if self._get_openstack_release() < self.trusty_kilo:
# Before Kilo
admin_port = internal_port = public_port = '3333'
else:
# Kilo and later
admin_port = internal_port = public_port = '8004'
expected = {'id': u.not_null,
'region': 'RegionOne',
'adminurl': u.valid_url,
'internalurl': u.valid_url,
'publicurl': u.valid_url,
'service_id': u.not_null}
ret = u.validate_endpoint_data(endpoints, admin_port, internal_port,
public_port, expected)
if ret:
message = 'heat endpoint: {}'.format(ret)
amulet.raise_status(amulet.FAIL, msg=message)
示例15: test_200_heat_mysql_shared_db_relation
# 需要導入模塊: import amulet [as 別名]
# 或者: from amulet import raise_status [as 別名]
def test_200_heat_mysql_shared_db_relation(self):
"""Verify the heat:mysql shared-db relation data"""
u.log.debug('Checking heat:mysql shared-db relation data...')
unit = self.heat_sentry
relation = ['shared-db', 'percona-cluster:shared-db']
expected = {
'private-address': u.valid_ip,
'heat_database': 'heat',
'heat_username': 'heat',
'heat_hostname': u.valid_ip
}
ret = u.validate_relation_data(unit, relation, expected)
if ret:
message = u.relation_error('heat:mysql shared-db', ret)
amulet.raise_status(amulet.FAIL, msg=message)