コード例 #1
0
ファイル: zkOpers.py プロジェクト: xuhengpw/nginx-manager
 def retrieveNginxCnf(self):
     clusterUUID = getClusterUUID()
     resultValue = {}
     path = self.rootPath + "/" + clusterUUID + "/nginxcnf"
     if self.zk.exists(path):
         resultValue = self.DEFAULT_RETRY_POLICY(self.zk.get, path)
     return resultValue
コード例 #2
0
ファイル: nodeOpers.py プロジェクト: xuhengpw/nginx-manager
    def create(self, params):
        if params == {} or params is None:
            raise UserVisiableException("please set the componentNode info!")

        dataNodeInternalPort = params.get('dataNodeInternalPort')
        if dataNodeInternalPort is not None:
            raise UserVisiableException(
                "no need to set the dataNodeInternalPort param!")

        zkOper = Common_ZkOpers()

        local_uuid = getClusterUUID()
        existCluster = zkOper.existCluster(local_uuid)
        if not existCluster:
            raise UserVisiableException(
                "sync componentCluster info error! please check if sync uuid is right!"
            )

        params.setdefault("dataNodeInternalPort", options.port)
        dataNodeExternalPort = params.get('dataNodeExternalPort')
        if dataNodeExternalPort is None or '' == dataNodeExternalPort:
            params.setdefault("dataNodeExternalPort", options.port)

        self.confOpers.setValue(options.data_node_property, params)
        dataNodeProprs = self.confOpers.getValue(options.data_node_property)
        zkOper.writeDataNodeInfo(local_uuid, dataNodeProprs)

        result = {}
        result.setdefault(
            "message",
            "Configuration on this componentNode has been done successfully")
        return result
コード例 #3
0
 def existCluster(self, uuid=None):
     self.zk.ensure_path(self.rootPath)
     cluster_uuids = self.zk.get_children(self.rootPath)
     
     if uuid is None:
         local_uuid = getClusterUUID()
     else:
         local_uuid = uuid
     
     if local_uuid in cluster_uuids:
         return True
     
     return False
コード例 #4
0
ファイル: zkOpers.py プロジェクト: xuhengpw/nginx-manager
 def __lock_base_action(self, lock_name):
     clusterUUID = getClusterUUID()
     path = "%s/%s/lock/%s" % (self.rootPath, clusterUUID, lock_name)
     lock = self.zk.Lock(path, threading.current_thread())
     isLock = lock.acquire(True, 1)
     return (isLock, lock)
コード例 #5
0
ファイル: zkOpers.py プロジェクト: xuhengpw/nginx-manager
 def writeNginxCnf(self, NginxCnfPropsFullText):
     clusterUUID = getClusterUUID()
     path = self.rootPath + "/" + clusterUUID + "/nginxcnf"
     self.zk.ensure_path(path)
     self.DEFAULT_RETRY_POLICY(
         self.zk.set, path, NginxCnfPropsFullText)  #version need to write
コード例 #6
0
ファイル: zkOpers.py プロジェクト: xuhengpw/nginx-manager
 def retrieve_started_nodes(self):
     clusterUUID = getClusterUUID()
     path = self.rootPath + "/" + clusterUUID + "/monitor_status/node/started"
     started_nodes = self.__return_children_to_list(path)
     return started_nodes
コード例 #7
0
ファイル: zkOpers.py プロジェクト: xuhengpw/nginx-manager
 def remove_started_node(self, container_node_name):
     clusterUUID = getClusterUUID()
     path = self.rootPath + "/" + clusterUUID + "/monitor_status/node/started/" + container_node_name
     if self.zk.exists(path):
         self.DEFAULT_RETRY_POLICY(self.zk.delete, path)
コード例 #8
0
ファイル: zkOpers.py プロジェクト: xuhengpw/nginx-manager
 def write_started_node(self, container_node_name):
     clusterUUID = getClusterUUID()
     path = self.rootPath + "/" + clusterUUID + "/monitor_status/node/started/" + container_node_name
     self.zk.ensure_path(path)
コード例 #9
0
ファイル: zkOpers.py プロジェクト: xuhengpw/nginx-manager
 def retrieve_nginx_node_info(self, container_node_name):
     clusterUUID = getClusterUUID()
     path = self.rootPath + "/" + clusterUUID + "/dataNode/" + container_node_name
     ip_dict = self.__retrieve_special_path_prop(path)
     return ip_dict
コード例 #10
0
ファイル: zkOpers.py プロジェクト: xuhengpw/nginx-manager
 def retrieve_nginx_node_list(self):
     clusterUUID = getClusterUUID()
     path = self.rootPath + "/" + clusterUUID + "/dataNode"
     container_node_name_list = self.__return_children_to_list(path)
     return container_node_name_list
コード例 #11
0
 def _get_base_path(self):
     return self.root_path + '/' + get_cluster_name(
     ) + '/' + getClusterUUID()