本文整理汇总了Python中mapper.Mapper.generate_validator方法的典型用法代码示例。如果您正苦于以下问题:Python Mapper.generate_validator方法的具体用法?Python Mapper.generate_validator怎么用?Python Mapper.generate_validator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapper.Mapper
的用法示例。
在下文中一共展示了Mapper.generate_validator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProviderManager
# 需要导入模块: from mapper import Mapper [as 别名]
# 或者: from mapper.Mapper import generate_validator [as 别名]
class ProviderManager(BaseProviderClass):
schema = PROVIDER_CONFIG_SCHEMA
CONFIG_NAMES_TO_MODIFY = (
('networking', 'agents_security_group'),
('networking', 'management_security_group'),
('compute', 'management_server', 'instance'),
('compute', 'management_server', 'management_keypair'),
('compute', 'agent_servers', 'agents_keypair'),
)
CONFIG_FILES_PATHS_TO_MODIFY = (
('compute', 'agent_servers', 'private_key_path'),
('compute', 'management_server', 'management_keypair',
'private_key_path'),
)
def __init__(self,
provider_config=None,
is_verbose_output=False):
super(ProviderManager, self).\
__init__(provider_config,
is_verbose_output)
provider_name = provider_config['connection']['cloud_provider_name']
provider_name = transfer_cloud_provider_name(provider_name)
from mapper import Mapper
self.mapper = Mapper(provider_name)
def validate(self):
connection_conf = self.provider_config['connection']
if not self.mapper.is_initialized():
raise RuntimeError(
'Error during trying to create context'
' for a cloud provider: {0}'
.format(connection_conf['cloud_provider_name'])
)
connector = LibcloudConnector(connection_conf)
validation_errors = {}
validator = self.mapper.generate_validator(
connector, self.provider_config, validation_errors, self.logger)
validator.validate()
self.logger.error('resource validation failed!') if validation_errors \
else self.logger.info('resources validated successfully')
return validation_errors
def provision(self):
driver = self.get_driver(self.provider_config)
public_ip, private_ip, ssh_key, ssh_user, provider_context = \
driver.create_topology()
driver.copy_files_to_manager(public_ip, ssh_key, ssh_user)
return public_ip, private_ip, ssh_key, ssh_user, provider_context
def teardown(self, provider_context, ignore_validation=False):
driver = self.get_driver(self.provider_config)
driver.delete_topology(ignore_validation,
provider_context['resources'])
def get_driver(self, provider_config, provider_context=None):
provider_context = provider_context if provider_context else {}
connector = LibcloudConnector(provider_config['connection'])
return self.mapper.generate_cosmo_driver(connector,
provider_context,
provider_config)