本文整理汇总了Python中nailgun.logger.logger.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: download_release_resp
def download_release_resp(cls, **kwargs):
logger.info("RPC method download_release_resp received: %s" % jsonutils.dumps(kwargs))
task_uuid = kwargs.get("task_uuid")
error_msg = kwargs.get("error")
status = kwargs.get("status")
progress = kwargs.get("progress")
task = objects.Task.get_by_uuid(task_uuid, fail_if_not_found=True)
release_info = task.cache["args"]["release_info"]
release_id = release_info["release_id"]
release = db().query(Release).get(release_id)
if not release:
logger.error("download_release_resp: Release" " with ID %s not found", release_id)
return
if error_msg:
status = "error"
error_msg = "{0} download and preparation " "has failed.".format(release.name)
cls._download_release_error(release_id, error_msg)
elif progress == 100 and status == "ready":
cls._download_release_completed(release_id)
result = {"release_info": {"release_id": release_id}}
data = {"status": status, "progress": progress, "message": error_msg, "result": result}
objects.Task.update(task, data)
示例2: create
def create(cls, data):
topic = data.get("topic")
node_id = data.get("node_id")
task_uuid = data.pop("task_uuid", None)
message = data.get("message")
if topic == 'discover' and node_id is None:
raise errors.CannotFindNodeIDForDiscovering(
"No node id in discover notification"
)
if "datetime" not in data:
data["datetime"] = datetime.now()
task = None
exist = None
if task_uuid:
task = Task.get_by_uuid(task_uuid)
if task and node_id:
exist = NotificationCollection.filter_by(
query=None,
node_id=node_id,
message=message,
task_id=task.id
).first()
if not exist:
super(Notification, cls).create(data)
logger.info(
u"Notification: topic: {0} message: {1}".format(
data.get("topic"),
data.get("message")
)
)
示例3: PUT
def PUT(self, cluster_id):
""":returns: JSONized Task object.
:http: * 202 (environment reset initiated)
* 400 (can't reset environment)
* 404 (environment not found in db)
"""
cluster = self.get_object_or_404(Cluster, cluster_id)
try:
logger.info(
u"Trying to reset environment '{0}'".format(
cluster_id
)
)
task_manager = ResetEnvironmentTaskManager(
cluster_id=cluster.id
)
task = task_manager.execute()
except Exception as exc:
logger.warn(u'Error during execution '
u'environment resetting '
u'task: {0}'.format(str(exc)))
raise web.badrequest(str(exc))
raise web.webapi.HTTPError(
status="202 Accepted",
data=TaskHandler.render(task)
)
示例4: assign_admin_ips
def assign_admin_ips(cls, node_id, num=1):
"""Method for assigning admin IP addresses to nodes.
:param node_id: Node database ID.
:type node_id: int
:param num: Number of IP addresses for node.
:type num: int
:returns: None
"""
admin_net_id = cls.get_admin_network_group_id()
node_admin_ips = db().query(IPAddr).filter_by(
node=node_id,
network=admin_net_id
).all()
if not node_admin_ips or len(node_admin_ips) < num:
admin_net = db().query(NetworkGroup).get(admin_net_id)
logger.debug(
u"Trying to assign admin ips: node=%s count=%s",
node_id,
num - len(node_admin_ips)
)
free_ips = cls.get_free_ips(
admin_net.id,
num=num - len(node_admin_ips)
)
logger.info(len(free_ips))
for ip in free_ips:
ip_db = IPAddr(
node=node_id,
ip_addr=ip,
network=admin_net_id
)
db().add(ip_db)
db().commit()
示例5: stats_user_resp
def stats_user_resp(cls, **kwargs):
logger.info("RPC method stats_user_resp received: %s",
jsonutils.dumps(kwargs))
task_uuid = kwargs.get('task_uuid')
nodes = kwargs.get('nodes', [])
status = kwargs.get('status')
error = kwargs.get('error')
message = kwargs.get('msg')
task = objects.Task.get_by_uuid(
task_uuid, fail_if_not_found=True, lock_for_update=True)
if status not in (consts.TASK_STATUSES.ready,
consts.TASK_STATUSES.error):
logger.debug("Task %s, id: %s in status: %s",
task.name, task.id, task.status)
return
data = {'status': status, 'progress': 100, 'message': message}
if status == consts.TASK_STATUSES.error:
logger.error("Task %s, id: %s failed: %s",
task.name, task.id, error)
data['message'] = error
objects.Task.update(task, data)
cls._update_action_log_entry(status, task.name, task_uuid, nodes)
logger.info("RPC method stats_user_resp processed")
示例6: set_proxy
def set_proxy(proxy):
"""Replace http_proxy environment variable for the scope
of context execution. After exit from context old proxy value
(if any) is restored
:param proxy: - proxy url
"""
variable_values = {
'http_proxy': os.environ.get('http_proxy'),
'https_proxy': os.environ.get('https_proxy')
}
for variable_name, variable_value in variable_values.items():
if variable_value:
logger.warning("{0} variable is already set with "
"value: {1}. Changing to {2}. Old value "
"will be restored after exit from script's "
"execution context"
.format(variable_name, variable_value, proxy))
os.environ[variable_name] = proxy
try:
yield
finally:
for variable_name, variable_value in variable_values.items():
if variable_value:
logger.info("Restoring old value for http_proxy")
os.environ[variable_name] = variable_value
else:
logger.info("Deleting set {0} environment variable"
.format(variable_name))
del os.environ[variable_name]
示例7: upload_fixtures
def upload_fixtures():
# TODO(akislitsky): Temporary workaround for preventing uploading
# fixtures on Fuel upgrade and container restart. We should remove
# this after DB data upload will be switched from fixtures loading
# to the the API calls.
if db().query(models.Release).count():
logger.info("Fixtures are already uploaded. Skipping")
return
fixtures_paths = get_all_fixtures_paths()
for orig_path in settings.FIXTURES_TO_UPLOAD:
if os.path.isabs(orig_path):
path = orig_path
else:
for fixtures_path in fixtures_paths:
path = os.path.abspath(
os.path.join(
fixtures_path,
orig_path
)
)
if os.access(path, os.R_OK):
break
if os.access(path, os.R_OK):
with open(path, "r") as fileobj:
upload_fixture(fileobj)
logger.info("Fixture has been uploaded from file: %s", path)
示例8: run
def run():
logger.info("Starting standalone stats sender...")
try:
while True:
StatsSender().send_stats_once()
except (KeyboardInterrupt, SystemExit):
logger.info("Stopping standalone stats sender...")
示例9: action_loadfakedeploymenttasks
def action_loadfakedeploymenttasks(params):
from nailgun.db.sqlalchemy import fixman
from nailgun.logger import logger
logger.info("Applying fake deployment tasks to all releases...")
fixman.load_fake_deployment_tasks()
logger.info("Done")
示例10: send_action_log
def send_action_log(self):
action_log = db().query(models.ActionLog).order_by(
models.ActionLog.id
).filter_by(
is_sent=False
).limit(settings.STATS_SEND_COUNT)
logger.info("Action log has %d unsent records", action_log.count())
uid = InstallationInfo().get_master_node_uid()
offset = 0
while True:
log_chunk = action_log.offset(offset)
records = []
ids = []
logger.info("Send records: %s", six.text_type(log_chunk.count()))
for log_record in log_chunk:
body = objects.ActionLog.to_dict(log_record)
record = {
'external_id': body['id'],
'master_node_uid': uid,
'body': body
}
records.append(record)
ids.append(log_record.id)
self.send_log_serialized(records, ids)
if log_chunk.count() < settings.STATS_SEND_COUNT:
break
offset += settings.STATS_SEND_COUNT
示例11: send_oswl_serialized
def send_oswl_serialized(self, rec_data, ids):
if rec_data:
resp = self.send_data_to_url(
url=self.build_collector_url("COLLECTOR_OSWL_INFO_URL"),
data={"oswl_stats": rec_data}
)
resp_dict = resp.json()
if self.is_status_acceptable(resp.status_code,
resp_dict["status"]):
records_resp = resp_dict["oswl_stats"]
status_failed = consts.LOG_RECORD_SEND_STATUS.failed
saved_ids = set(r["id"] for r in records_resp
if r["status"] != status_failed)
failed_ids = set(r["id"] for r in records_resp
if r["status"] == status_failed)
sent_saved_ids = set(saved_ids) & set(ids)
logger.info("OSWL info records saved: %s, failed: %s",
six.text_type(list(sent_saved_ids)),
six.text_type(list(failed_ids)))
if sent_saved_ids:
db().query(models.OpenStackWorkloadStats).filter(
models.OpenStackWorkloadStats.id.in_(sent_saved_ids)
).update(
{"is_sent": True}, synchronize_session=False
)
db().commit()
else:
logger.error("Unexpected collector answer: %s",
six.text_type(resp.text))
示例12: send_log_serialized
def send_log_serialized(self, records, ids):
if records:
logger.info("Send %d action logs records", len(records))
resp = self.send_data_to_url(
url=self.build_collector_url("COLLECTOR_ACTION_LOGS_URL"),
data={"action_logs": records}
)
resp_dict = resp.json()
if self.is_status_acceptable(resp.status_code,
resp_dict["status"]):
records_resp = resp_dict["action_logs"]
saved_ids = set()
failed_ids = set()
for record in records_resp:
if record["status"] == \
consts.LOG_RECORD_SEND_STATUS.failed:
failed_ids.add(record["external_id"])
else:
saved_ids.add(record["external_id"])
sent_saved_ids = set(saved_ids) & set(ids)
logger.info("Action logs records saved: %s, failed: %s",
six.text_type(list(sent_saved_ids)),
six.text_type(list(failed_ids)))
db().query(models.ActionLog).filter(
models.ActionLog.id.in_(sent_saved_ids)
).update(
{"is_sent": True}, synchronize_session=False
)
db().commit()
else:
logger.error("Unexpected collector answer: %s",
six.text_type(resp.text))
示例13: run
def run():
logger.info("Starting standalone stats sender...")
try:
StatsSender().run()
except (KeyboardInterrupt, SystemExit) as e:
logger.error("Stats sender exception: %s", six.text_type(e))
logger.info("Stopping standalone stats sender...")
示例14: _check_vmware_consistency
def _check_vmware_consistency(cls, task):
"""Checks vmware attributes consistency and proper values
"""
attributes = task.cluster.attributes.editable
vmware_attributes = task.cluster.vmware_attributes
# Old(< 6.1) clusters haven't vmware support
if vmware_attributes:
cinder_nodes = filter(
lambda node: 'cinder' in node.all_roles,
task.cluster.nodes)
if not cinder_nodes:
logger.info('There is no any node with "cinder" role provided')
models = {
'settings': attributes,
'default': vmware_attributes.editable,
'cluster': task.cluster,
'version': settings.VERSION,
'networking_parameters': task.cluster.network_config
}
errors_msg = VmwareAttributesRestriction.check_data(
models=models,
metadata=vmware_attributes.editable['metadata'],
data=vmware_attributes.editable['value'])
if errors_msg:
raise errors.CheckBeforeDeploymentError('\n'.join(errors_msg))
示例15: run
def run():
logger.info("Starting standalone RPC consumer...")
with Connection(rpc.conn_str) as conn:
try:
RPCConsumer(conn, NailgunReceiver).run()
except (KeyboardInterrupt, SystemExit):
logger.info("Stopping standalone RPC consumer...")