本文整理汇总了Python中aquilon.aqdb.model.Personality.validate_env_in_name方法的典型用法代码示例。如果您正苦于以下问题:Python Personality.validate_env_in_name方法的具体用法?Python Personality.validate_env_in_name怎么用?Python Personality.validate_env_in_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aquilon.aqdb.model.Personality
的用法示例。
在下文中一共展示了Personality.validate_env_in_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ArgumentError
# 需要导入模块: from aquilon.aqdb.model import Personality [as 别名]
# 或者: from aquilon.aqdb.model.Personality import validate_env_in_name [as 别名]
dbpersona.cluster_required != cluster_required):
if dbpersona.is_cluster:
q = session.query(Cluster)
else:
q = session.query(Host)
q = q.filter_by(personality=dbpersona)
# XXX: Ideally, filter based on hosts that are/arenot in cluster
if q.count() > 0:
raise ArgumentError("The personality {0} is in use and cannot "
"be modified".format(str(dbpersona)))
dbpersona.cluster_required = cluster_required
if host_environment is not None:
if dbpersona.host_environment.name == 'legacy':
dbhost_env = HostEnvironment.get_instance(session, host_environment)
Personality.validate_env_in_name(personality, dbhost_env.name)
dbpersona.host_environment = dbhost_env
else:
raise ArgumentError("The personality '{0!s}' already has env set to '{1!s}'"
" and cannot be updated"
.format(dbpersona, dbpersona.host_environment))
plenaries = PlenaryCollection(logger=logger)
if grn or eon_id:
dbgrn = lookup_grn(session, grn, eon_id, logger=logger,
config=self.config)
old_grn = dbpersona.owner_grn
dbpersona.owner_grn = dbgrn
if not leave_existing:
示例2: render
# 需要导入模块: from aquilon.aqdb.model import Personality [as 别名]
# 或者: from aquilon.aqdb.model.Personality import validate_env_in_name [as 别名]
def render(self, session, logger, personality, archetype,
grn, eon_id, host_environment, comments,
cluster_required, copy_from, config_override, **arguments):
if not VALID_PERSONALITY_RE.match(personality):
raise ArgumentError("Personality name '%s' is not valid." %
personality)
if not (grn or eon_id):
raise ArgumentError("GRN or EON ID is required for adding a "
"personality.")
dbarchetype = Archetype.get_unique(session, archetype, compel=True)
if not host_environment:
try:
host_environment = self.config.get("archetype_" + archetype,
"default_environment")
except (NoSectionError, NoOptionError):
raise ArgumentError("Default environment is not configured "
"for {0:l}, please specify "
"--host_environment.".format(dbarchetype))
HostEnvironment.polymorphic_subclass(host_environment,
"Unknown environment name")
Personality.validate_env_in_name(personality, host_environment)
host_env = HostEnvironment.get_unique(session, host_environment, compel=True)
Personality.get_unique(session, archetype=dbarchetype, name=personality,
preclude=True)
dbgrn = lookup_grn(session, grn, eon_id, logger=logger,
config=self.config)
dbpersona = Personality(name=personality, archetype=dbarchetype,
cluster_required=bool(cluster_required),
host_environment=host_env, owner_grn=dbgrn,
comments=comments,
config_override=config_override)
session.add(dbpersona)
if self.config.has_option("archetype_" + archetype, "default_grn_target"):
dbpersona.grns.append((dbpersona, dbgrn,
self.config.get("archetype_" + archetype,
"default_grn_target")))
if copy_from:
## copy config data
dbfrom_persona = Personality.get_unique(session,
archetype=dbarchetype,
name=copy_from,
compel=True)
src_parameters = get_parameters(session,
personality=dbfrom_persona)
db_param_holder = PersonalityParameter(personality=dbpersona)
for param in src_parameters:
dbparameter = Parameter(value=param.value,
comments=param.comments,
holder=db_param_holder)
session.add(dbparameter)
for link in dbfrom_persona.features:
params = {}
params["personality"] = dbpersona
if link.model:
params["model"] = link.model
if link.interface_name:
params["interface_name"] = link.interface_name
add_link(session, logger, link.feature, params)
## service maps
q = session.query(PersonalityServiceMap).filter_by(personality=dbfrom_persona)
for sm in q.all() :
dbmap = PersonalityServiceMap(service_instance=sm.service_instance,
location=sm.location,
network=sm.network,
personality=dbpersona)
session.add(dbmap)
## required services
dbpersona.services.extend(dbfrom_persona.services)
session.flush()
plenary = PlenaryPersonality(dbpersona, logger=logger)
plenary.write()
return
示例3: ArgumentError
# 需要导入模块: from aquilon.aqdb.model import Personality [as 别名]
# 或者: from aquilon.aqdb.model.Personality import validate_env_in_name [as 别名]
q = session.query(Cluster)
else:
q = session.query(Host)
q = q.filter_by(personality=dbpersona)
# XXX: Ideally, filter based on hosts that are/arenot in cluster
if q.count() > 0:
raise ArgumentError("The personality {0} is in use and cannot "
"be modified".format(str(dbpersona)))
dbpersona.cluster_required = cluster_required
if host_environment is not None:
legacy_env = HostEnvironment.get_unique(session, 'legacy', compel=True)
if dbpersona.host_environment == legacy_env:
HostEnvironment.polymorphic_subclass(host_environment,
"Unknown environment name")
Personality.validate_env_in_name(personality, host_environment)
dbpersona.host_environment = HostEnvironment.get_unique(session,
host_environment,
compel=True)
else:
raise ArgumentError("The personality '{0}' already has env set to '{1}'"
" and cannot be updated".format(str(dbpersona), host_environment))
plenaries = PlenaryCollection(logger=logger)
if grn or eon_id:
dbgrn = lookup_grn(session, grn, eon_id, logger=logger,
config=self.config)
old_grn = dbpersona.owner_grn
dbpersona.owner_grn = dbgrn