本文整理匯總了Python中charms_openstack.charm.default方法的典型用法代碼示例。如果您正苦於以下問題:Python charm.default方法的具體用法?Python charm.default怎麽用?Python charm.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類charms_openstack.charm
的用法示例。
在下文中一共展示了charm.default方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: custom_assess_status_check
# 需要導入模塊: from charms_openstack import charm [as 別名]
# 或者: from charms_openstack.charm import default [as 別名]
def custom_assess_status_check(self):
"""Verify that the configuration provided is valid and thus the service
is ready to go. This will return blocked if the configuraiton is not
valid for the service.
:returns (status: string, message: string): the status, and message if
there is a problem. Or (None, None) if there are no issues.
"""
options = self.options # tiny optimisation for less typing.
backends = options.computed_share_backends
if not backends:
return 'blocked', 'No share backends configured'
default_share_backend = options.default_share_backend
if not default_share_backend:
return 'blocked', "'default-share-backend' is not set"
if default_share_backend not in backends:
return ('blocked',
"'default-share-backend:{}' is not a configured backend"
.format(default_share_backend))
return None, None
示例2: get_database_setup
# 需要導入模塊: from charms_openstack import charm [as 別名]
# 或者: from charms_openstack.charm import default [as 別名]
def get_database_setup(self):
"""Provide the default database credentials as a list of 3-tuples
returns a structure of:
[
{'database': <database>,
'username': <username>,
'hostname': <hostname of this unit>
'prefix': <the optional prefix for the database>, },
]
:returns [{'database': ...}, ...]: credentials for multiple databases
"""
return [
dict(
database=self.options.database,
username=self.options.database_user, )
]
示例3: get_database_setup
# 需要導入模塊: from charms_openstack import charm [as 別名]
# 或者: from charms_openstack.charm import default [as 別名]
def get_database_setup(self):
"""Provide the default database credentials as a list of 3-tuples
returns a structure of:
[
{'database': <database>,
'username': <username>,
'hostname': <hostname of this unit>
'prefix': <the optional prefix for the database>, },
]
:returns [{'database': ...}, ...]: credentials for multiple databases
"""
return [
dict(
database=self.config['database'],
username=self.config['database-user'], )
]
示例4: states_to_check
# 需要導入模塊: from charms_openstack import charm [as 別名]
# 或者: from charms_openstack.charm import default [as 別名]
def states_to_check(self, required_relations=None):
"""Override the default states_to_check() for the assess_status
functionality so that, if we have to have an HSM relation, then enforce
it on the assess_status() call.
If param required_relations is not None then it overrides the
instance/class variable self.required_relations.
:param required_relations: [list of state names]
:returns: [states{} as per parent method]
"""
if required_relations is None:
required_relations = self.required_relations
if hookenv.config('require-hsm-plugin'):
required_relations.append('hsm')
return super(BarbicanCharm, self).states_to_check(
required_relations=required_relations)
示例5: computed_share_protocols
# 需要導入模塊: from charms_openstack import charm [as 別名]
# 或者: from charms_openstack.charm import default [as 別名]
def computed_share_protocols(config):
"""Return a list of protocols as a comma (no space) separated list.
The default protocols are CIFS,NFS.
:param config: the config option on which to look up config options
:returns: string
"""
return strip_join(config.share_protocols, ',').upper()
示例6: get_amqp_credentials
# 需要導入模塊: from charms_openstack import charm [as 別名]
# 或者: from charms_openstack.charm import default [as 別名]
def get_amqp_credentials(self):
"""Provide the default amqp username and vhost as a tuple.
:returns (username, host): two strings to send to the amqp provider.
"""
return (self.options.rabbit_user, self.options.rabbit_vhost)
示例7: get_amqp_credentials
# 需要導入模塊: from charms_openstack import charm [as 別名]
# 或者: from charms_openstack.charm import default [as 別名]
def get_amqp_credentials(self):
"""Provide the default amqp username and vhost as a tuple.
:returns (username, host): two strings to send to the amqp provider.
"""
return (self.config['rabbit-user'], self.config['rabbit-vhost'])