本文整理汇总了Python中cfgm_common.zkclient.ZookeeperClient.delete_node方法的典型用法代码示例。如果您正苦于以下问题:Python ZookeeperClient.delete_node方法的具体用法?Python ZookeeperClient.delete_node怎么用?Python ZookeeperClient.delete_node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cfgm_common.zkclient.ZookeeperClient
的用法示例。
在下文中一共展示了ZookeeperClient.delete_node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from cfgm_common.zkclient import ZookeeperClient [as 别名]
# 或者: from cfgm_common.zkclient.ZookeeperClient import delete_node [as 别名]
def main():
#removing config_db_uuid,useragent keyspaces
config = None
server_list = []
config = ConfigParser.SafeConfigParser({'admin_token': None})
config.read('/etc/contrail/contrail-api.conf')
server_list_str=config.get('DEFAULTS','cassandra_server_list')
server_list=server_list_str.split()
server_idx = 0
num_dbnodes = len(server_list)
connected = False
cass_server = None
while not connected:
try:
cass_server = server_list[server_idx]
sys_mgr = SystemManager(cass_server)
connected = True
except Exception as e:
server_idx = (server_idx + 1) % num_dbnodes
time.sleep(3)
uuid_keyspace_name = 'config_db_uuid'
agent_keyspace_name = 'useragent'
try:
print "deleting config_db_uuid keyspace"
sys_mgr.drop_keyspace(uuid_keyspace_name)
except pycassa.cassandra.ttypes.InvalidRequestException as e:
print "Warning! " + str(e)
try:
print "deleting useragent keyspace"
sys_mgr.drop_keyspace(agent_keyspace_name)
except pycassa.cassandra.ttypes.InvalidRequestException as e:
print "Warning! " + str(e)
#deleting znodes
_SUBNET_PATH = "/api-server/subnets"
_FQ_NAME_TO_UUID_PATH = "/fq-name-to-uuid"
_zk_client = None
while True:
try:
_zk_client = ZookeeperClient("api-" + '0', '127.0.0.1:2181')
break
except gevent.event.Timeout as e:
pass
print "deleting nodes at ",_SUBNET_PATH
_zk_client.delete_node(_SUBNET_PATH, True);
print "deleting nodes at ",_FQ_NAME_TO_UUID_PATH
_zk_client.delete_node(_FQ_NAME_TO_UUID_PATH, True);
示例2: ContrailZKIssu
# 需要导入模块: from cfgm_common.zkclient import ZookeeperClient [as 别名]
# 或者: from cfgm_common.zkclient.ZookeeperClient import delete_node [as 别名]
class ContrailZKIssu():
def __init__(self, Old_Version_Address, New_Version_Address,
Old_Prefix, New_Prefix, Znode_Issu_List, logger):
self._Old_ZK_Version_Address = Old_Version_Address
self._New_ZK_Version_Address = New_Version_Address
self._Old_Prefix = '/' + Old_Prefix
self._New_Prefix = '/' + New_Prefix
self._Znode_Issu_List = list(Znode_Issu_List)
self._logger = logger
self._logger(
"Issu contrail zookeeper initialized...",
level=SandeshLevel.SYS_INFO,
)
# end __init__
# Create new path recursively
def _zk_copy(self, old_v_path, new_v_path):
children = self._zk_old.get_children(old_v_path)
value = self._zk_old.read_node(old_v_path)
self._logger(
"Issu contrail zookeeper, _zk_copy, old version path"
+ str(old_v_path), level=SandeshLevel.SYS_DEBUG,
)
self._logger(
"Issu contrail zookeeper, _zk_copy, new version path"
+ str(new_v_path), level=SandeshLevel.SYS_DEBUG,
)
self._zk_new.create_node(new_v_path, value)
value = self._zk_new.read_node(new_v_path)
self._logger(
"Issu contrail zookeeper ,_zk_copy, new value"
+ str(value), level=SandeshLevel.SYS_DEBUG,
)
for _path in children:
new_path = str(new_v_path) + '/' + str(_path)
old_path = str(old_v_path) + '/' + str(_path)
self._zk_copy(old_path, new_path)
# end _zk_copy
def issu_compare(self, new_prefix, old_prefix):
for _path in self._Znode_Issu_List:
new_path = new_prefix + str(_path)
old_path = old_prefix + str(_path)
_new_children = self._zk_new.get_children(new_path)
_old_children = self._zk_old.get_children(old_path)
_new_children.sort()
_old_children.sort()
_result = cmp(_new_children, _old_children)
if (_result == 0):
continue
else:
self._logger(
"Issu contrail zookeeper failed...",
level=SandeshLevel.SYS_DEBUG,
)
break
self._logger(
"Issu contrail zookeeper passed...",
level=SandeshLevel.SYS_INFO,
)
# end issu_compare
def issu_zk_start(self):
# Connect to old and new ZK servers
self._zk_old = ZookeeperClient("zk issu client older version",
self._Old_ZK_Version_Address)
self._zk_old.set_lost_cb(self.issu_restart)
self._zk_old.set_suspend_cb(self.issu_restart)
self._zk_new = ZookeeperClient("zk issu client newer version",
self._New_ZK_Version_Address)
self._zk_new.set_lost_cb(self.issu_restart)
self._zk_new.set_suspend_cb(self.issu_restart)
old_prefix = self._Old_Prefix + "/"
new_prefix = self._New_Prefix + "/"
# Delete all state in new ZK if any
if self._zk_new.exists(new_prefix):
children = self._zk_new.get_children(new_prefix)
for _path in children:
if _path == "zookeeper":
continue
self._logger(
"Issu contrail zookeeper ,issu_zk_start, deleted paths"
+ str((new_prefix + str(_path))),
level=SandeshLevel.SYS_INFO,
)
self._zk_new.delete_node((new_prefix + str(_path)), True)
else:
self._zk_new.create_node(new_prefix, "")
if self._zk_old.exists(old_prefix):
children = self._zk_old.get_children(old_prefix)
elif self._zk_old.exists(self._Old_Prefix):
children = self._zk_old.get_children(self._Old_Prefix)
#.........这里部分代码省略.........