本文整理汇总了Python中host.Host.set_master方法的典型用法代码示例。如果您正苦于以下问题:Python Host.set_master方法的具体用法?Python Host.set_master怎么用?Python Host.set_master使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类host.Host
的用法示例。
在下文中一共展示了Host.set_master方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: log
# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import set_master [as 别名]
if down:
log('down: find a new master!', 'info')
try:
master = r.info()['master_host']
log("master: {0}".format(master), 'info')
if cluster.exists(master):
grandmaster = cluster.get_master(master)
log("{0} = cluster.get_master({1})".format(grandmaster, master), 'info')
# and make sure the master doesn't participate anymore
cluster.incarcerate_node(master)
log("cluster.incarcerate_node({0})".format(master), 'info')
else:
grandmaster = cluster.get_master(node)
log("{0} = cluster.get_master({1})".format(grandmaster, node), 'info')
except:
log('we never were a slave', 'info')
grandmaster = None
if grandmaster == None:
r53_zone.update_record(cluster.name(), endpoint)
log("r53_zone.update_record({0}, {1})".format(cluster.name(), endpoint), 'info')
host.set_master()
log("host.set_master()", 'info')
else:
host.set_master(grandmaster)
log("host.set_master({0})".format(grandmaster), 'info')
else:
log("master is up (and running)", 'info')
示例2: log
# 需要导入模块: from host import Host [as 别名]
# 或者: from host.Host import set_master [as 别名]
def log(message, logging='info'):
events.log(node, component, message, logging)
if __name__ == '__main__':
log('joining the cluster', 'info')
log('adding the node to the cluster', 'info')
# now we are ready to be (added to) the cluster
cluster.add_node(node, endpoint)
log('creating a Route53 records', 'info')
r53_zone.create_record(node, endpoint)
log('setting the tag', 'info')
ec2.set_tag(node)
log('getting the master of the node', 'info')
master = cluster.get_master(node)
# if we don't have a master, we ARE the master
if master == None:
log('setting the main Route53 record for the cluster', 'info')
r53_zone.update_record(cluster.name(), endpoint)
# and make sure we 'run' correctly (no-slave, well-monitored)
log('set the host to run as master', 'info')
host.set_master()
else:
# attach to the master (and start watching its availability)
log('set the host to run as slave of {0}'.format(master), 'info')
host.set_master(master)
log('joined the cluster', 'info')