本文整理汇总了Python中modules.util.log.LogFactory.debug方法的典型用法代码示例。如果您正苦于以下问题:Python LogFactory.debug方法的具体用法?Python LogFactory.debug怎么用?Python LogFactory.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modules.util.log.LogFactory
的用法示例。
在下文中一共展示了LogFactory.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EventExecutor
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
class EventExecutor(threading.Thread):
"""
Polls the event queue and executes event handlers for each event
"""
def __init__(self, event_queue):
threading.Thread.__init__(self)
self.__event_queue = event_queue
# TODO: several handlers for one event
self.__event_handlers = {}
self.log = LogFactory().get_log(__name__)
def run(self):
while True:
event_msg = self.__event_queue.get()
event = event_msg.topic.rpartition('/')[2]
if event in self.__event_handlers:
handler = self.__event_handlers[event]
try:
self.log.debug("Executing handler for event %r" % event)
handler(event_msg)
except:
self.log.exception("Error processing %r event" % event)
else:
self.log.debug("Event handler not found for event : %r" % event)
def register_event_handler(self, event, handler):
self.__event_handlers[event] = handler
def terminate(self):
self.terminate()
示例2: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
log.info("Reading environment variables...")
clustering_enable= os.environ.get('CLUSTER')
log.info(clustering_enable)
if clustering_enable == 'true':
# start server
log.info("Starting Hadoop Namenode ...")
format_namenode_command = "exec ${HADOOP_HOME}/bin/hadoop namenode -format"
env_var = os.environ.copy()
p = subprocess.Popen(format_namenode_command, env=env_var, shell=True)
output, errors = p.communicate()
start_command = "exec ${HADOOP_HOME}/sbin/start-all.sh"
env_var = os.environ.copy()
p = subprocess.Popen(start_command, env=env_var, shell=True)
output, errors = p.communicate()
log.debug("Hadoop Namenode started successfully")
else:
# start server
log.info("Starting Hadoop Datanode ...")
start_command = "exec ${HADOOP_HOME}/sbin/hadoop-daemon.sh start datanode"
env_var = os.environ.copy()
p = subprocess.Popen(start_command, env=env_var, shell=True)
output, errors = p.communicate()
log.debug("Hadoop Datanode started successfully")
示例3: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
# php_start_command = "/usr/sbin/apache2ctl -D FOREGROUND"
php_start_command = "/etc/init.d/apache2 restart"
p = subprocess.Popen(php_start_command, shell=True)
output, errors = p.communicate()
log.debug("Apache server started: [command] %s, [output] %s" % (php_start_command, output))
示例4: DefaultHealthStatisticsReader
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
class DefaultHealthStatisticsReader(IHealthStatReaderPlugin):
"""
Default implementation for the health statistics reader
"""
def __init__(self):
super(DefaultHealthStatisticsReader, self).__init__()
self.log = LogFactory().get_log(__name__)
def stat_cartridge_health(self, ca_health_stat):
ca_health_stat.memory_usage = DefaultHealthStatisticsReader.__read_mem_usage()
ca_health_stat.load_avg = DefaultHealthStatisticsReader.__read_load_avg()
self.log.debug("Memory read: %r, CPU read: %r" % (ca_health_stat.memory_usage, ca_health_stat.load_avg))
return ca_health_stat
@staticmethod
def __read_mem_usage():
return psutil.virtual_memory().percent
@staticmethod
def __read_load_avg():
(one, five, fifteen) = os.getloadavg()
cores = multiprocessing.cpu_count()
return (one / cores) * 100
示例5: EventSubscriber
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
class EventSubscriber(threading.Thread):
"""
Provides functionality to subscribe to a given topic on the Stratos MB and
register event handlers for various events.
"""
def __init__(self, topic, ip, port):
threading.Thread.__init__(self)
self.__event_queue = Queue(maxsize=0)
self.__event_executor = EventExecutor(self.__event_queue)
self.log = LogFactory().get_log(__name__)
self.__mb_client = None
self.__topic = topic
self.__subscribed = False
self.__ip = ip
self.__port = port
def run(self):
# Start the event executor thread
self.__event_executor.start()
self.__mb_client = mqtt.Client()
self.__mb_client.on_connect = self.on_connect
self.__mb_client.on_message = self.on_message
self.log.debug("Connecting to the message broker with address %r:%r" % (self.__ip, self.__port))
self.__mb_client.connect(self.__ip, self.__port, 60)
self.__subscribed = True
self.__mb_client.loop_forever()
def register_handler(self, event, handler):
"""
Adds an event handler function mapped to the provided event.
:param str event: Name of the event to attach the provided handler
:param handler: The handler function
:return: void
:rtype: void
"""
self.__event_executor.register_event_handler(event, handler)
self.log.debug("Registered handler for event %r" % event)
def on_connect(self, client, userdata, flags, rc):
self.log.debug("Connected to message broker.")
self.__mb_client.subscribe(self.__topic)
self.log.debug("Subscribed to %r" % self.__topic)
def on_message(self, client, userdata, msg):
self.log.debug("Message received: %s:\n%s" % (msg.topic, msg.payload))
self.__event_queue.put(msg)
def is_subscribed(self):
"""
Checks if this event subscriber is successfully subscribed to the provided topic
:return: True if subscribed, False if otherwise
:rtype: bool
"""
return self.__subscribed
示例6: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
log.info("Reading port mappings...")
port_mappings_str = values["PORT_MAPPINGS"]
mgt_console_https_port = None
pt_http_port = None
pt_https_port = None
# port mappings format: """NAME:mgt-console|PROTOCOL:https|PORT:4500|PROXY_PORT:9443;
# NAME:pt-http|PROTOCOL:http|PORT:4501|PROXY_PORT:7280;
# NAME:pt-https|PROTOCOL:https|PORT:4502|PROXY_PORT:7243"""
log.info("Port mappings: %s" % port_mappings_str)
if port_mappings_str is not None:
port_mappings_array = port_mappings_str.split(";")
if port_mappings_array:
for port_mapping in port_mappings_array:
log.debug("port_mapping: %s" % port_mapping)
name_value_array = port_mapping.split("|")
name = name_value_array[0].split(":")[1]
protocol = name_value_array[1].split(":")[1]
port = name_value_array[2].split(":")[1]
if name == "mgt-console" and protocol == "https":
mgt_console_https_port = port
if name == "pt-http" and protocol == "http":
pt_http_port = port
if name == "pt-https" and protocol == "https":
pt_https_port = port
log.info("Kubernetes service management console https port: %s" % mgt_console_https_port)
log.info("Kubernetes service pass-through http port: %s" % pt_http_port)
log.info("Kubernetes service pass-through https port: %s" % pt_https_port)
# export environment variables
self.export_env_var('CONFIG_PARAM_HTTPS_PROXY_PORT', mgt_console_https_port)
self.export_env_var('CONFIG_PARAM_PT_HTTP_PROXY_PORT', pt_http_port)
self.export_env_var('CONFIG_PARAM_PT_HTTPS_PROXY_PORT', pt_https_port)
# configure server
log.info("Configuring WSO2 ESB...")
config_command = "python /opt/ppaas-configurator-4.1.0-SNAPSHOT/configurator.py"
env_var = os.environ.copy()
p = subprocess.Popen(config_command, env=env_var, shell=True)
output, errors = p.communicate()
log.info("WSO2 ESB configured successfully")
# start server
log.info("Starting WSO2 ESB...")
start_command = "exec ${CARBON_HOME}/bin/wso2server.sh start"
env_var = os.environ.copy()
p = subprocess.Popen(start_command, env=env_var, shell=True)
output, errors = p.communicate()
log.debug("WSO2 ESB started successfully")
示例7: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
# start tomcat
tomcat_start_command = "exec ${CATALINA_HOME}/bin/startup.sh"
log.info("Starting Tomcat server: [command] %s" % tomcat_start_command)
p = subprocess.Popen(tomcat_start_command, shell=True)
output, errors = p.communicate()
log.debug("Tomcat server started: [command] %s, [output] %s" % (p.args, output))
示例8: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
log.info("Reading port mappings...")
port_mappings_str = values["PORT_MAPPINGS"]
mgt_console_https_port = None
pt_http_port = None
pt_https_port = None
# port mappings format: """NAME:mgt-console|PROTOCOL:https|PORT:4500|PROXY_PORT:9443"""
log.info("Port mappings: %s" % port_mappings_str)
if port_mappings_str is not None:
port_mappings_array = port_mappings_str.split(";")
if port_mappings_array:
for port_mapping in port_mappings_array:
log.debug("port_mapping: %s" % port_mapping)
name_value_array = port_mapping.split("|")
name = name_value_array[0].split(":")[1]
protocol = name_value_array[1].split(":")[1]
port = name_value_array[2].split(":")[1]
if name == "mgt-console" and protocol == "https":
mgt_console_https_port = port
if name == "pt-http" and protocol == "http":
pt_http_port = port
if name == "pt-https" and protocol == "https":
pt_https_port = port
log.info("Kubernetes service management console https port: %s" % mgt_console_https_port)
if mgt_console_https_port is not None:
command = "sed -i \"s/^#CONFIG_PARAM_HTTPS_PROXY_PORT = .*/CONFIG_PARAM_HTTPS_PROXY_PORT = %s/g\" %s" % (mgt_console_https_port, "${CONFIGURATOR_HOME}/templates/wso2is-5.0.0/configs.ini")
p = subprocess.Popen(command, shell=True)
output, errors = p.communicate()
log.info("Successfully updated management console https proxy port: %s in IS template module" % mgt_console_https_port)
# configure server
log.info("Configuring WSO2 IS...")
config_command = "exec /opt/ppaas-configurator-4.1.0-SNAPSHOT/configurator.py"
env_var = os.environ.copy()
p = subprocess.Popen(config_command, env=env_var, shell=True)
output, errors = p.communicate()
log.info("WSO2 IS configured successfully")
# start server
log.info("Starting WSO2 IS...")
start_command = "exec ${CARBON_HOME}/bin/wso2server.sh start"
env_var = os.environ.copy()
p = subprocess.Popen(start_command, env=env_var, shell=True)
output, errors = p.communicate()
log.debug("WSO2 IS started successfully")
示例9: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
# start server
log.info("Starting APACHE STORM SUPERVISOR...")
start_command = "${CARBON_HOME}/bin/storm supervisor"
env_var = os.environ.copy()
p = subprocess.Popen(start_command, env=env_var, shell=True)
output, errors = p.communicate()
log.debug("APACHE STORM SUPERVISOR started successfully")
示例10: execute_script
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def execute_script(bash_file, extension_values):
""" Execute the given bash files in the <PCA_HOME>/extensions/bash folder
:param bash_file: name of the bash file to execute
:return: tuple of (output, errors)
"""
log = LogFactory().get_log(__name__)
working_dir = os.path.abspath(os.path.dirname(__file__))
command = working_dir[:-2] + "bash/" + bash_file
current_env_vars = os.environ.copy()
extension_values.update(current_env_vars)
log.debug("Execute bash script :: %s" % command)
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=extension_values)
output, errors = p.communicate()
return output, errors
示例11: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
# configure server
log.info("Configuring APACHE STORM UI...")
config_command = "exec /opt/ppaas-configurator-4.1.0-SNAPSHOT/configurator.py"
env_var = os.environ.copy()
p = subprocess.Popen(config_command, env=env_var, shell=True)
output, errors = p.communicate()
log.info("APACHE STORM UI configured successfully")
# start server
log.info("Starting APACHE STORM UI...")
start_command = "${CARBON_HOME}/bin/storm ui"
env_var = os.environ.copy()
p = subprocess.Popen(start_command, env=env_var, shell=True)
output, errors = p.communicate()
log.debug("APACHE STORM UI started successfully")
示例12: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
event_name = values["EVENT"]
log.debug("Running extension for %s" % event_name)
extension_values = {}
for key in values.keys():
extension_values["STRATOS_" + key] = values[key]
# log.debug("%s => %s" % ("STRATOS_" + key, extension_values["STRATOS_" + key]))
try:
output, errors = ExtensionExecutor.execute_script(event_name + ".sh")
except OSError:
raise RuntimeError("Could not find an extension file for event %s" % event_name)
if len(errors) > 0:
raise RuntimeError("Extension execution failed for script %s: %s" % (event_name, errors))
log.info("%s Extension executed. [output]: %s" % (event_name, output))
示例13: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
log.info("Starting tomcat metadata publisher...")
# publish callback and issuer id from tomcat for IS to pickup
publish_data = mdsclient.MDSPutRequest()
# hostname_entry = {"key": "TOMCAT_HOSTNAME", "values": member_hostname}
cluster_hostname = values["HOST_NAME"]
log.info("Reading port mappings...")
port_mappings_str = values["PORT_MAPPINGS"]
tomcat_http_port = None
# port mappings format: """NAME:mgt-console|PROTOCOL:https|PORT:4500|PROXY_PORT:8443;
# NAME:tomcat-http|PROTOCOL:http|PORT:4501|PROXY_PORT:7280;"""
log.info("Port mappings: %s" % port_mappings_str)
if port_mappings_str is not None:
port_mappings_array = port_mappings_str.split(";")
if port_mappings_array:
for port_mapping in port_mappings_array:
log.debug("port_mapping: %s" % port_mapping)
name_value_array = port_mapping.split("|")
name = name_value_array[0].split(":")[1]
protocol = name_value_array[1].split(":")[1]
port = name_value_array[2].split(":")[1]
if name == "tomcat-http" and protocol == "http":
tomcat_http_port = port
log.info("Kubernetes service port of tomcat http transport: %s" % tomcat_http_port)
callback_url = "http://%s:%s/travelocity.com/home.jsp" % (cluster_hostname, tomcat_http_port)
callback_url_property = {"key": "CALLBACK_URL", "values": [callback_url]}
mdsclient.put(callback_url_property, app=True)
log.info("Published property to metadata API: CALLBACK_URL: %s" % callback_url)
issuer_property = {"key": "SSO_ISSUER", "values": ["travelocity.com"]}
mdsclient.put(issuer_property, app=True)
log.info("Published property to metadata API: SSO_ISSUER: travelocity.com")
log.info("Tomcat metadata publisher completed")
示例14: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
log.info("Starting tomcat server starter plugin...")
# wait till SAML_ENDPOINT becomes available
mds_response = None
while mds_response is None:
log.debug("Waiting for SAML_ENDPOINT to be available from metadata service for app ID: %s" % values["APPLICATION_ID"])
time.sleep(5)
mds_response = mdsclient.get(app=True)
if mds_response is not None and mds_response.properties.get("SAML_ENDPOINT") is None:
mds_response = None
saml_endpoint = mds_response.properties["SAML_ENDPOINT"]
log.debug("SAML_ENDPOINT value read from Metadata service: %s" % saml_endpoint)
# start tomcat
tomcat_start_command = "exec /opt/tomcat/bin/startup.sh"
log.info("Starting Tomcat server: [command] %s, [STRATOS_SAML_ENDPOINT] %s" % (tomcat_start_command, saml_endpoint))
env_var = os.environ.copy()
env_var["STRATOS_SAML_ENDPOINT"] = saml_endpoint
env_var["STRATOS_HOST_NAME"] = values["HOST_NAME"]
log.info("Reading port mappings...")
port_mappings_str = values["PORT_MAPPINGS"]
tomcat_http_port = None
# port mappings format: """NAME:mgt-console|PROTOCOL:https|PORT:4500|PROXY_PORT:8443;
# NAME:tomcat-http|PROTOCOL:http|PORT:4501|PROXY_PORT:7280;"""
log.info("Port mappings: %s" % port_mappings_str)
if port_mappings_str is not None:
port_mappings_array = port_mappings_str.split(";")
if port_mappings_array:
for port_mapping in port_mappings_array:
log.debug("port_mapping: %s" % port_mapping)
name_value_array = port_mapping.split("|")
name = name_value_array[0].split(":")[1]
protocol = name_value_array[1].split(":")[1]
port = name_value_array[2].split(":")[1]
if name == "tomcat-http" and protocol == "http":
tomcat_http_port = port
log.info("Kubernetes service port of tomcat http transport: %s" % tomcat_http_port)
env_var["STRATOS_HOST_PORT"] = tomcat_http_port
p = subprocess.Popen(tomcat_start_command, env=env_var, shell=True)
output, errors = p.communicate()
log.debug("Tomcat server started")
log.info("Tomcat server starter plugin completed")
示例15: run_plugin
# 需要导入模块: from modules.util.log import LogFactory [as 别名]
# 或者: from modules.util.log.LogFactory import debug [as 别名]
def run_plugin(self, values):
log = LogFactory().get_log(__name__)
MYSQL_ROOT_PASSWORD = os.environ["MYSQL_ROOT_PASSWORD"];
TEMP_FILE_PATH="/tmp/temp.sql"
log.info("MYSQL_ROOT_PASSWORD : %s" % MYSQL_ROOT_PASSWORD)
f = open(TEMP_FILE_PATH, "w+")
f.write(
"USE mysql;\n"
"FLUSH PRIVILEGES;\n"
"GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;\n"
"UPDATE user SET password=PASSWORD('" + MYSQL_ROOT_PASSWORD + "') WHERE user='root';")
f.close()
log.info("Temp File created")
mysql_command = "/usr/sbin/mysqld --bootstrap --verbose=0 < "+TEMP_FILE_PATH
env_var = os.environ.copy()
p = subprocess.Popen(mysql_command, env=env_var, shell=True)
output, errors = p.communicate()
log.info("%s file executed" %TEMP_FILE_PATH)
mysql_start_command = "service mysql restart"
p = subprocess.Popen(mysql_start_command, env=env_var, shell=True)
output, errors = p.communicate()
log.debug("mysql started successfully")
# get local ip as to export to metadata
get_local_ip_cmd = "awk 'NR==1 {print $1}' /etc/hosts"
local_ip = subprocess.check_output(get_local_ip_cmd, shell=True)
if local_ip is not None:
local_ip = local_ip[0:-1]
log.info("local IP from /etc/hosts : %s " % local_ip)
# publishing to metadata service
mysql_host = {"key": "MYSQL_HOST", "values": local_ip}
mysql_password = {"key": "MYSQL_ROOT_PASSWORD", "values": MYSQL_ROOT_PASSWORD}
mysql_username = {"key": "MYSQL_ROOT_USERNAME", "values": "root"}
self.publish_metadata(mysql_host)
self.publish_metadata(mysql_username)
self.publish_metadata(mysql_password)