本文整理汇总了Python中aquilon.worker.templates.Plenary类的典型用法代码示例。如果您正苦于以下问题:Python Plenary类的具体用法?Python Plenary怎么用?Python Plenary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plenary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: del_cluster
def del_cluster(session, logger, dbcluster, config):
check_no_provided_service(dbcluster)
if hasattr(dbcluster, 'members') and dbcluster.members:
raise ArgumentError("%s is still in use by clusters: %s." %
(format(dbcluster),
", ".join([c.name for c in dbcluster.members])))
elif dbcluster.hosts:
hosts = ", ".join([h.fqdn for h in dbcluster.hosts])
raise ArgumentError("%s is still in use by hosts: %s." %
(format(dbcluster), hosts))
plenaries = PlenaryCollection(logger=logger)
plenaries.append(Plenary.get_plenary(dbcluster))
if dbcluster.resholder:
for res in dbcluster.resholder.resources:
plenaries.append(Plenary.get_plenary(res))
session.delete(dbcluster)
session.flush()
plenaries.remove(remove_profile=True)
trigger_notifications(config, logger, CLIENT_INFO)
return
示例2: add_resource
def add_resource(session, logger, holder, dbresource, dsdb_callback=None,
**arguments):
if dbresource not in holder.resources:
holder.resources.append(dbresource)
holder_plenary = Plenary.get_plenary(holder.holder_object, logger=logger)
res_plenary = Plenary.get_plenary(dbresource, logger=logger)
domain = holder.holder_object.branch.name
session.flush()
key = CompileKey.merge([res_plenary.get_write_key(),
holder_plenary.get_write_key()])
try:
lock_queue.acquire(key)
res_plenary.write(locked=True)
try:
holder_plenary.write(locked=True)
except IncompleteError:
holder_plenary.cleanup(domain, locked=True)
if dsdb_callback:
dsdb_callback(session, logger, dbresource, **arguments)
except:
res_plenary.restore_stash()
holder_plenary.restore_stash()
raise
finally:
lock_queue.release(key)
return
示例3: stash_services
def stash_services(self):
changed_servers = set()
for instance in self.instances_bound.union(self.instances_unbound):
if not instance.service.need_client_list:
continue
for srv in instance.servers:
if srv.host:
changed_servers.add(srv.host)
if srv.cluster:
changed_servers.add(srv.cluster)
plenary = PlenaryServiceInstanceServer.get_plenary(instance)
self.plenaries.append(plenary)
for dbobj in changed_servers:
# Skip servers that do not have a profile
if not dbobj.personality.archetype.is_compileable:
continue
# Skip servers that are in a different domain/sandbox
if (dbobj.branch != self.dbobj.branch or
dbobj.sandbox_author_id != self.dbobj.sandbox_author_id):
continue
self.plenaries.append(Plenary.get_plenary(dbobj))
if isinstance(dbobj, Cluster):
for dbhost in dbobj.hosts:
self.plenaries.append(Plenary.get_plenary(dbhost))
示例4: render
def render(self, session, logger, cluster, buildstatus, **arguments):
dbcluster = Cluster.get_unique(session, cluster, compel=True)
dbstatus = ClusterLifecycle.get_instance(session, buildstatus)
if not dbcluster.status.transition(dbcluster, dbstatus):
return
if not dbcluster.personality.archetype.is_compileable:
return
session.flush()
plenaries = PlenaryCollection(logger=logger)
plenaries.append(Plenary.get_plenary(dbcluster))
for dbhost in dbcluster.hosts:
plenaries.append(Plenary.get_plenary(dbhost))
td = TemplateDomain(dbcluster.branch, dbcluster.sandbox_author,
logger=logger)
# Force a host lock as pan might overwrite the profile...
with plenaries.get_key():
plenaries.stash()
try:
plenaries.write(locked=True)
td.compile(session, only=plenaries.object_templates,
locked=True)
except:
plenaries.restore_stash()
raise
return
示例5: render
def render(self, session, logger, domain, sandbox,
pancinclude, pancexclude, pancdebug, cleandeps,
**arguments):
(dbdomain, dbauthor) = get_branch_and_author(session, logger,
domain=domain,
sandbox=sandbox,
compel=True)
# Grab a shared lock on personalities and services used by the domain.
# Object templates (hosts, clusters) are protected by the domain lock.
plenaries = PlenaryCollection(logger=logger)
q1 = session.query(Personality)
q1 = q1.join(Host)
q1 = q1.filter(and_(Host.branch == dbdomain,
Host.sandbox_author == dbauthor))
q1 = q1.reset_joinpoint()
q1 = q1.options(joinedload('paramholder'),
subqueryload('paramholder.parameters'))
q2 = session.query(Personality)
q2 = q2.join(Cluster)
q2 = q2.filter(and_(Cluster.branch == dbdomain,
Cluster.sandbox_author == dbauthor))
q2 = q2.reset_joinpoint()
q2 = q2.options(joinedload('paramholder'),
subqueryload('paramholder.parameters'))
for dbpers in q1.union(q2):
plenaries.append(Plenary.get_plenary(dbpers))
q1 = session.query(ServiceInstance)
q1 = q1.join(ServiceInstance.clients)
q1 = q1.filter(and_(Host.branch == dbdomain,
Host.sandbox_author == dbauthor))
q2 = session.query(ServiceInstance)
q2 = q2.join(ServiceInstance.cluster_clients)
q2 = q2.filter(and_(Cluster.branch == dbdomain,
Cluster.sandbox_author == dbauthor))
for si in q1.union(q2):
plenaries.append(Plenary.get_plenary(si))
if pancdebug:
pancinclude = r'.*'
pancexclude = r'components/spma/functions'
dom = TemplateDomain(dbdomain, dbauthor, logger=logger)
with CompileKey.merge([CompileKey(domain=dbdomain.name, logger=logger),
plenaries.get_key(exclusive=False)]):
dom.compile(session,
panc_debug_include=pancinclude,
panc_debug_exclude=pancexclude,
cleandeps=cleandeps,
locked=True)
return
示例6: prestash_primary
def prestash_primary(self):
self.plenaries.append(Plenary.get_plenary(self.dbobj))
# This may be too much action at a distance... however, if
# we are potentially re-writing a host plenary, it seems like
# a good idea to also verify and refresh known dependencies.
self.plenaries.append(Plenary.get_plenary(self.dbobj.hardware_entity))
if self.dbobj.resholder:
for dbres in self.dbobj.resholder.resources:
self.plenaries.append(Plenary.get_plenary(dbres))
示例7: add_cluster_dependencies
def add_cluster_dependencies(cluster):
self.plenaries.append(Plenary.get_plenary(cluster))
for dbhost in cluster.hosts:
self.plenaries.append(Plenary.get_plenary(dbhost))
if cluster.resholder:
for dbres in cluster.resholder.resources:
self.plenaries.append(Plenary.get_plenary(dbres))
if isinstance(cluster, EsxCluster) and cluster.network_device:
self.plenaries.append(Plenary.get_plenary(cluster.network_device))
示例8: render
def render(self, session, logger, share, latency_threshold,
comments, **arguments):
validate_nlist_key("share", share)
q = session.query(Share).filter_by(name=share)
if q.count() == 0:
raise ArgumentError("Share %s is not used on any resource and "
"cannot be modified" % share)
plenaries = PlenaryCollection(logger=logger)
for dbshare in q.all():
if latency_threshold:
dbshare.latency_threshold = latency_threshold
if comments:
dbshare.comments = comments
plenaries.append(Plenary.get_plenary(dbshare))
session.flush()
plenaries.write()
return
示例9: render
def render(self, session, logger, hostname, **arguments):
dbhost = hostname_to_host(session, hostname)
if dbhost.status.name == 'ready':
raise ArgumentError("{0:l} is in ready status, "
"advertised status can be reset only "
"when host is in non ready state."
.format(dbhost))
dbhost.advertise_status = False
session.flush()
td = TemplateDomain(dbhost.branch, dbhost.sandbox_author, logger=logger)
plenary = Plenary.get_plenary(dbhost, logger=logger)
# Force a host lock as pan might overwrite the profile...
with plenary.get_key():
try:
plenary.write(locked=True)
td.compile(session, only=plenary.object_templates, locked=True)
except IncompleteError:
raise ArgumentError("Run aq make for host %s first." %
dbhost.fqdn)
except:
plenary.restore_stash()
raise
return
示例10: add_cluster_data
def add_cluster_data(cluster, logger):
for dbhost in cluster.hosts:
host_plenary = Plenary.get_plenary(dbhost, logger=self.logger)
host_plenary.stash()
self.plenaries.append(host_plenary)
if cluster.resholder:
for dbres in cluster.resholder.resources:
resource_plenary = Plenary.get_plenary(dbres, logger=self.logger)
resource_plenary.stash()
self.plenaries.append(resource_plenary)
if isinstance(cluster, EsxCluster) and cluster.switch:
sw_plenary = Plenary.get_plenary(cluster.switch, logger=self.logger)
sw_plenary.stash()
self.plenaries.append(sw_plenary)
示例11: render
def render(
self,
session,
logger,
archetype,
personality,
feature,
model,
interface,
path,
value=None,
comments=None,
**arguments
):
param_holder = get_parameter_holder(session, archetype, personality, auto_include=True)
if (
isinstance(param_holder.holder_object, Personality)
and not param_holder.holder_object.archetype.is_compileable
):
raise ArgumentError("{0} is not compileable.".format(param_holder.holder_object.archetype))
dbparameter = self.process_parameter(session, param_holder, feature, model, interface, path, value, comments)
session.add(dbparameter)
session.flush()
plenary = Plenary.get_plenary(param_holder.personality)
plenary.write()
示例12: prestash_primary
def prestash_primary(self):
plenary_host = Plenary.get_plenary(self.dbhost, logger=self.logger)
plenary_host.stash()
self.plenaries.append(plenary_host)
# This may be too much action at a distance... however, if
# we are potentially re-writing a host plenary, it seems like
# a good idea to also verify known dependencies.
plenary_machine = Plenary.get_plenary(self.dbhost.machine,
logger=self.logger)
plenary_machine.stash()
self.plenaries.append(plenary_machine)
if self.dbhost.resholder:
for dbres in self.dbhost.resholder.resources:
resource_plenary = Plenary.get_plenary(dbres, logger=self.logger)
resource_plenary.stash()
self.plenaries.append(resource_plenary)
示例13: render
def render(self, session, logger, city, country, fullname, comments,
timezone, campus,
**arguments):
if country:
dbparent = Country.get_unique(session, country, compel=True)
else:
dbparent = Campus.get_unique(session, campus, compel=True)
dbcity = add_location(session, City, city, dbparent, fullname=fullname,
comments=comments, timezone=timezone)
session.flush()
plenary = Plenary.get_plenary(dbcity, logger=logger)
with plenary.get_key():
try:
plenary.write(locked=True)
dsdb_runner = DSDBRunner(logger=logger)
dsdb_runner.add_city(city, dbcity.country.name, fullname)
dsdb_runner.commit_or_rollback()
except:
plenary.restore_stash()
raise
return
示例14: render
def render(self, session, logger, service, **arguments):
dbservice = Service.get_unique(session, service, compel=True)
if dbservice.archetypes:
msg = ", ".join([archetype.name for archetype in
dbservice.archetypes])
raise ArgumentError("Service %s is still required by the following "
"archetypes: %s." % (dbservice.name, msg))
if dbservice.personalities:
msg = ", ".join(["%s (%s)" % (personality.name,
personality.archetype.name)
for personality in dbservice.personalities])
raise ArgumentError("Service %s is still required by the following "
"personalities: %s." % (dbservice.name, msg))
if dbservice.instances:
raise ArgumentError("Service %s still has instances defined and "
"cannot be deleted." % dbservice.name)
session.delete(dbservice)
session.flush()
plenary_info = Plenary.get_plenary(dbservice, logger=logger)
plenary_info.remove()
return
示例15: render
def render(self, generate, session, logger, network_device, **kwargs):
dbnetdev = NetworkDevice.get_unique(session, network_device, compel=True)
plenary_info = Plenary.get_plenary(dbnetdev, logger=logger)
if generate:
return plenary_info._generate_content()
else:
return plenary_info.read()