本文整理汇总了Python中log.LOG.info方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.info方法的具体用法?Python LOG.info怎么用?Python LOG.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log.LOG
的用法示例。
在下文中一共展示了LOG.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __add_router_interface
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def __add_router_interface(self):
# and pick the first in the list - the list should be non empty and
# contain only 1 subnet since it is supposed to be a private network
# But first check that the router does not already have this subnet
# so retrieve the list of all ports, then check if there is one port
# - matches the subnet
# - and is attached to the router
# Assumed that both management networks are created together so checking for one of them
ports = self.neutron_client.list_ports()['ports']
for port in ports:
# Skip the check on stale ports
if port['fixed_ips']:
port_ip = port['fixed_ips'][0]
if (port['device_id'] == self.ext_router['id']) and \
(port_ip['subnet_id'] == self.vm_int_net[0]['subnets'][0]):
LOG.info('Ext router already associated to the internal network.')
return
for int_net in self.vm_int_net:
body = {
'subnet_id': int_net['subnets'][0]
}
self.neutron_client.add_interface_router(self.ext_router['id'], body)
LOG.debug('Ext router associated to ' + int_net['name'])
# If ipv6 is enabled than add second subnet
if self.ipv6_enabled:
body = {
'subnet_id': int_net['subnets'][1]
}
self.neutron_client.add_interface_router(self.ext_router['id'], body)
示例2: get_controller_info
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def get_controller_info(ssh_access, net, res_col, retry_count):
if not ssh_access:
return
LOG.info('Fetching OpenStack deployment details...')
sshcon = sshutils.SSH(ssh_access, connect_retry_count=retry_count)
if sshcon is None:
LOG.error('Cannot connect to the controller node')
return
res = {}
res['distro'] = sshcon.get_host_os_version()
res['openstack_version'] = sshcon.check_openstack_version()
res['cpu_info'] = sshcon.get_cpu_info()
if net:
l2type = res_col.get_result('l2agent_type')
encap = res_col.get_result('encapsulation')
if l2type:
if encap:
res['nic_name'] = sshcon.get_nic_name(l2type, encap,
net.internal_iface_dict)
res['l2agent_version'] = sshcon.get_l2agent_version(l2type)
# print results
CONLOG.info(res_col.ppr.pformat(res))
FILELOG.info(json.dumps(res, sort_keys=True))
res_col.add_properties(res)
示例3: run
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def run(self):
L.info("Command Send : %s" % self.command)
args = self.command.split(" ")
subproc_args = { 'stdin' : subprocess.PIPE,
'stdout' : subprocess.PIPE,
'stderr' : subprocess.STDOUT,
}
try:
proc = subprocess.Popen(args, **subproc_args)
except OSError:
L.info("Failed to execute command: %s" % args[0])
sys.exit(1)
(stdouterr, stdin) = (proc.stdout, proc.stdin)
Li = []
result = None
if stdouterr is None:
pass
else:
while True:
line = stdouterr.readline()
if not line:
break
Li.append(line.rstrip())
result = "".join(Li)
code = proc.wait()
time.sleep(2)
L.debug("Command Resturn Code: %d" % code)
self.queue.put(result)
示例4: measure_flow
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def measure_flow(self, label, target_ip):
label = self.add_location(label)
FlowPrinter.print_desc(label)
# results for this flow as a dict
perf_output = self.client.run_client(label, target_ip,
self.server,
bandwidth=self.config.vm_bandwidth,
az_to=self.server.az)
if self.config.keep_first_flow_and_exit:
CONLOG.info(self.rescol.ppr.pformat(perf_output))
FILELOG.info(json.dumps(perf_output, sort_keys=True))
LOG.info('Stopping execution after first flow, cleanup all VMs/networks manually')
sys.exit(0)
if self.config.stop_on_error:
# check if there is any error in the results
results_list = perf_output['results']
for res_dict in results_list:
if 'error' in res_dict:
LOG.error('Stopping execution on error, cleanup all VMs/networks manually')
CONLOG.info(self.rescol.ppr.pformat(perf_output))
FILELOG.info(json.dumps(perf_output, sort_keys=True))
sys.exit(2)
self.rescol.add_flow_result(perf_output)
CONLOG.info(self.rescol.ppr.pformat(perf_output))
FILELOG.info(json.dumps(perf_output, sort_keys=True))
示例5: receiveMsg_TCP
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def receiveMsg_TCP(self, datapacket = False):
if self.socket_tcp is None:
raise _error.ConnectionError("no tcp socket for receiving")
raw = ""
note = ""
data, readcounter = self.receive_bytes(self.socket_tcp, const.HEADER.size)
if readcounter > 1:
note += "HEADER SEGMENTED INTO %s SEGMENTS!" % readcounter
raw += data
size, command = networking.parsePacketHeader(data)
if not command in (const.PACKET_SERVER_FRAME, const.PACKET_SERVER_SYNC):
if command in const.packet_names:
LOG.debug("received size: %d, command: %s (%d)"% (size, const.packet_names[command], command))
else:
LOG.debug("received size: %d, command: %d"% (size, command))
size -= const.HEADER.size # remove size of the header ...
data, readcounter = self.receive_bytes(self.socket_tcp, size)
if readcounter > 1:
note += "DATA SEGMENTED INTO %s SEGMENTS!" % readcounter
raw += data
if not self.running:
return None
if len(note) > 0:
LOG.info(note)
content = data
if datapacket:
return DataPacket(size, command, content)
else:
return size, command, content
#content = struct.unpack(str(size) + 's', data)
#content = content[0]
示例6: sendToLog
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def sendToLog(self):
"""
Dispatcher to LOG
@rtype: boolean
@returns: True
"""
LOG.info("EVENT: %s" % (self.msg))
return True
示例7: delete_net
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def delete_net(self, network):
if network:
name = network['name']
# it may take some time for ports to be cleared so we need to retry
for _ in range(1, 5):
try:
self.neutron_client.delete_network(network['id'])
LOG.info('Network %s deleted.', name)
break
except NetworkInUseClient:
time.sleep(1)
示例8: save_to_db
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def save_to_db(self, cfg):
'''Save results to MongoDB database.'''
LOG.info("Saving results to MongoDB database...")
post_id = pns_mongo.\
pns_add_test_result_to_mongod(cfg.vmtp_mongod_ip,
cfg.vmtp_mongod_port,
cfg.vmtp_db,
cfg.vmtp_collection,
self.results)
if post_id is None:
LOG.error("Failed to add result to DB")
示例9: get_tags
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def get_tags(self):
LOG.info("Getting tags from openttd finger server")
LOG.debug("HTTP GET %s" % const.OPENTTD_FINGER_TAGS_URL)
self.request("GET", const.OPENTTD_FINGER_TAGS_URL)
r1 = self.getresponse()
LOG.debug("%d %s" % (r1.status, r1.reason))
if r1.status != 200:
raise Exception("Couldn't request tags list")
data1 = r1.read()
data2 = [i.strip().split() for i in data1.split('\n') if i]
data2 = [(int(i[0]), dateutil.parser.parse(i[1]).date(), i[2].strip()) for i in data2]
self.tags = data2
示例10: create_net
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def create_net(self, network_name, subnet_name, cidr, dns_nameservers,
subnet_name_ipv6=None, cidr_ipv6=None, ipv6_mode=None,
enable_dhcp=True):
for network in self.networks:
if network['name'] == network_name:
LOG.info('Found existing internal network: %s', network_name)
return network
body = {
'network': {
'name': network_name,
'admin_state_up': True
}
}
network = self.neutron_client.create_network(body)['network']
body = {
'subnet': {
'name': subnet_name,
'cidr': cidr,
'network_id': network['id'],
'enable_dhcp': True,
'ip_version': 4,
'dns_nameservers': dns_nameservers
}
}
if not enable_dhcp:
body['subnet']['enable_dhcp'] = False
subnet = self.neutron_client.create_subnet(body)['subnet']
# add subnet id to the network dict since it has just been added
network['subnets'] = [subnet['id']]
# If ipv6 is enabled than create and add ipv6 network
if ipv6_mode:
body = {
'subnet': {
'name': subnet_name_ipv6,
'cidr': cidr_ipv6,
'network_id': network['id'],
'enable_dhcp': True,
'ip_version': 6,
'ipv6_ra_mode': ipv6_mode,
'ipv6_address_mode': ipv6_mode
}
}
if not enable_dhcp:
body['subnet']['enable_dhcp'] = False
subnet = self.neutron_client.create_subnet(body)['subnet']
# add the subnet id to the network dict
network['subnets'].append(subnet['id'])
LOG.info('Created internal network: %s.', network_name)
return network
示例11: dispose
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def dispose(self):
# Delete the internal networks only of we did not reuse an existing
# network
if not self.config.reuse_network_name:
self.__remove_router_interface()
for int_net in self.vm_int_net:
self.delete_net(int_net)
# delete the router only if its name matches the pns router name
if self.ext_router_created:
try:
if self.ext_router['name'] == self.ext_router_name:
self.neutron_client.remove_gateway_router(
self.ext_router['id'])
self.neutron_client.delete_router(self.ext_router['id'])
LOG.info('External router %s deleted.', self.ext_router['name'])
except TypeError:
LOG.info("No external router set")
示例12: retry_if_http_error
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def retry_if_http_error(exception):
"""
Defines which type of exceptions allow for a retry of the request
:param exception: the raised exception
:return: True if retrying the request is possible
"""
error = False
if isinstance(exception, requests.HTTPError):
if exception.response.status_code == 503:
LOG.info('Requesting retry: response code: ' + str(exception.response.status_code))
LOG.error('Exception: ' + exception.__repr__())
error = True
elif isinstance(exception, requests.ConnectionError):
LOG.info('Requesting retry: ConnectionError')
LOG.error('Exception: ' + exception.__repr__())
error = True
return error
示例13: check_rpm_package_installed
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def check_rpm_package_installed(self, rpm_pkg):
'''
Given a host and a package name, check if it is installed on the
system.
'''
check_pkg_cmd = "rpm -qa | grep " + rpm_pkg
(status, cmd_output, _) = self.execute(check_pkg_cmd)
if status:
return None
pkg_pattern = ".*" + rpm_pkg + ".*"
rpm_pattern = re.compile(pkg_pattern, re.IGNORECASE)
for line in cmd_output.splitlines():
mobj = rpm_pattern.match(line)
if mobj:
return mobj.group(0)
LOG.info("%s pkg installed ", rpm_pkg)
return None
示例14: __exec_file
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def __exec_file(self, cmd, filename="tmp.txt", timeout=TIMEOUT):
filepath = os.path.join(define.APP_TMP, filename)
Li = []
proc = BantorraFileProcess(cmd, filepath)
proc.start()
proc.join(timeout)
if proc.is_alive():
proc.kill()
time.sleep(3)
L.debug("proc.terminate. %s" % proc.is_alive())
try:
with open(filepath, "r") as f:
while True:
line = f.readline()
if not line:
break
Li.append(line)
except:
L.info("No such file or directory")
result = "".join(Li); F.remove(filepath)
return result
示例15: teardown
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import info [as 别名]
def teardown(self):
'''
Clean up the floating ip and VMs
'''
LOG.info('Cleaning up...')
if self.server:
self.server.dispose()
if self.client:
self.client.dispose()
if not self.config.reuse_existing_vm and self.net:
self.net.dispose()
# Remove the public key
if self.comp:
self.comp.remove_public_key(self.config.public_key_name)
# Finally remove the security group
try:
if self.comp:
self.comp.security_group_delete(self.sec_group)
except ClientException:
# May throw novaclient.exceptions.BadRequest if in use
LOG.warning('Security group in use: not deleted')
if self.image_uploaded and self.config.delete_image_after_run:
self.comp.delete_image(self.glance_client, self.config.image_name)