Rename "LOGGER" to "LOG"
Align with OpenStack projects Change-Id: Ie30b2819bce754650f3afa293935c2a0b551c217
This commit is contained in:
parent
228a6a45c5
commit
02b6284ec2
|
@ -10,7 +10,7 @@ from inception import __version__
|
||||||
from inception.orchestrator import Orchestrator
|
from inception.orchestrator import Orchestrator
|
||||||
from inception.utils import log
|
from inception.utils import log
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ def main():
|
||||||
try:
|
try:
|
||||||
CONF(args=sys.argv[1:], version="Inception: version %s" % __version__)
|
CONF(args=sys.argv[1:], version="Inception: version %s" % __version__)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOGGER.error(e)
|
LOG.error(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
# start orchestator
|
# start orchestator
|
||||||
log.setup('inception')
|
log.setup('inception')
|
||||||
|
|
|
@ -48,7 +48,7 @@ from oslo.config import cfg
|
||||||
from inception.utils import cmd
|
from inception.utils import cmd
|
||||||
from inception.utils import wrapper
|
from inception.utils import wrapper
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
orchestrator_opts = [
|
orchestrator_opts = [
|
||||||
cfg.StrOpt('prefix',
|
cfg.StrOpt('prefix',
|
||||||
|
@ -259,17 +259,16 @@ class Orchestrator(object):
|
||||||
self._deploy_dnsmasq()
|
self._deploy_dnsmasq()
|
||||||
self._setup_controller()
|
self._setup_controller()
|
||||||
self._setup_workers()
|
self._setup_workers()
|
||||||
LOGGER.info("Your inception cloud '%s' is ready!!!", self.prefix)
|
LOG.info("Your inception cloud '%s' is ready!!!", self.prefix)
|
||||||
LOGGER.info("Gateway IP is %s", self._gateway_floating_ip.ip)
|
LOG.info("Gateway IP is %s", self._gateway_floating_ip.ip)
|
||||||
LOGGER.info("Chef server WebUI is http://%s:4040",
|
LOG.info("Chef server WebUI is http://%s:4040",
|
||||||
self._chefserver_ip)
|
self._chefserver_ip)
|
||||||
LOGGER.info("OpenStack dashboard is https://%s",
|
LOG.info("OpenStack dashboard is https://%s", self._controller_ip)
|
||||||
self._controller_ip)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOGGER.exception("Error in launching inception cloud")
|
LOG.exception("Error in launching inception cloud")
|
||||||
if self.atomic:
|
if self.atomic:
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
LOGGER.info("Although there was error in creating your "
|
LOG.info("Although there was error in creating your "
|
||||||
"inception cloud '%s', resources have been "
|
"inception cloud '%s', resources have been "
|
||||||
"successfully cleaned up", self.prefix)
|
"successfully cleaned up", self.prefix)
|
||||||
if re_raise:
|
if re_raise:
|
||||||
|
@ -324,7 +323,7 @@ class Orchestrator(object):
|
||||||
security_groups=self.security_groups,
|
security_groups=self.security_groups,
|
||||||
userdata=self.userdata)
|
userdata=self.userdata)
|
||||||
self._gateway_id = gateway.id
|
self._gateway_id = gateway.id
|
||||||
LOGGER.info("Creating %s", gateway)
|
LOG.info("Creating %s", gateway)
|
||||||
|
|
||||||
# launch chefserver
|
# launch chefserver
|
||||||
chefserver = self.client.servers.create(
|
chefserver = self.client.servers.create(
|
||||||
|
@ -336,7 +335,7 @@ class Orchestrator(object):
|
||||||
userdata=self.userdata,
|
userdata=self.userdata,
|
||||||
files=self.chefserver_files)
|
files=self.chefserver_files)
|
||||||
self._chefserver_id = chefserver.id
|
self._chefserver_id = chefserver.id
|
||||||
LOGGER.info("Creating %s", chefserver)
|
LOG.info("Creating %s", chefserver)
|
||||||
|
|
||||||
# launch controller
|
# launch controller
|
||||||
controller = self.client.servers.create(
|
controller = self.client.servers.create(
|
||||||
|
@ -347,7 +346,7 @@ class Orchestrator(object):
|
||||||
security_groups=self.security_groups,
|
security_groups=self.security_groups,
|
||||||
userdata=self.userdata)
|
userdata=self.userdata)
|
||||||
self._controller_id = controller.id
|
self._controller_id = controller.id
|
||||||
LOGGER.info("Creating %s", controller)
|
LOG.info("Creating %s", controller)
|
||||||
|
|
||||||
# launch workers
|
# launch workers
|
||||||
for i in xrange(self.num_workers):
|
for i in xrange(self.num_workers):
|
||||||
|
@ -359,9 +358,9 @@ class Orchestrator(object):
|
||||||
security_groups=self.security_groups,
|
security_groups=self.security_groups,
|
||||||
userdata=self.userdata)
|
userdata=self.userdata)
|
||||||
self._worker_ids.append(worker.id)
|
self._worker_ids.append(worker.id)
|
||||||
LOGGER.info("Creating %s", worker)
|
LOG.info("Creating %s", worker)
|
||||||
|
|
||||||
LOGGER.info('wait at most %s seconds for servers to be ready'
|
LOG.info('wait at most %s seconds for servers to be ready'
|
||||||
' (ssh-able + userdata done)', self.timeout)
|
' (ssh-able + userdata done)', self.timeout)
|
||||||
servers_ready = False
|
servers_ready = False
|
||||||
begin_time = time.time()
|
begin_time = time.time()
|
||||||
|
@ -392,7 +391,7 @@ class Orchestrator(object):
|
||||||
servers_ready = True
|
servers_ready = True
|
||||||
break
|
break
|
||||||
except (UnboundLocalError, subprocess.CalledProcessError) as error:
|
except (UnboundLocalError, subprocess.CalledProcessError) as error:
|
||||||
LOGGER.info('servers are not all ready, error=%s,'
|
LOG.info('servers are not all ready, error=%s,'
|
||||||
' sleep %s seconds', error, self.poll_interval)
|
' sleep %s seconds', error, self.poll_interval)
|
||||||
time.sleep(self.poll_interval)
|
time.sleep(self.poll_interval)
|
||||||
continue
|
continue
|
||||||
|
@ -403,7 +402,7 @@ class Orchestrator(object):
|
||||||
floating_ip = self.client.floating_ips.create(pool=self.pool)
|
floating_ip = self.client.floating_ips.create(pool=self.pool)
|
||||||
self.client.servers.add_floating_ip(self._gateway_id, floating_ip)
|
self.client.servers.add_floating_ip(self._gateway_id, floating_ip)
|
||||||
self._gateway_floating_ip = floating_ip
|
self._gateway_floating_ip = floating_ip
|
||||||
LOGGER.info("Creating and associating %s", floating_ip)
|
LOG.info("Creating and associating %s", floating_ip)
|
||||||
|
|
||||||
def _get_server_info(self, _id):
|
def _get_server_info(self, _id):
|
||||||
"""
|
"""
|
||||||
|
@ -549,7 +548,7 @@ class Orchestrator(object):
|
||||||
got_exception = not exception_queue.empty()
|
got_exception = not exception_queue.empty()
|
||||||
while not exception_queue.empty():
|
while not exception_queue.empty():
|
||||||
thread_name, func_info, exc = exception_queue.get()
|
thread_name, func_info, exc = exception_queue.get()
|
||||||
LOGGER.error('%s %s %s', thread_name, func_info, exc)
|
LOG.error('%s %s %s', thread_name, func_info, exc)
|
||||||
if got_exception:
|
if got_exception:
|
||||||
raise RuntimeError("One or more subthreads got exception")
|
raise RuntimeError("One or more subthreads got exception")
|
||||||
|
|
||||||
|
@ -577,7 +576,7 @@ class Orchestrator(object):
|
||||||
@param re_raise: whether re-raise caught exception, for the purpose of
|
@param re_raise: whether re-raise caught exception, for the purpose of
|
||||||
notifying external caller. Default: False
|
notifying external caller. Default: False
|
||||||
"""
|
"""
|
||||||
LOGGER.info("Let's clean up inception cloud '%s'...", self.prefix)
|
LOG.info("Let's clean up inception cloud '%s'...", self.prefix)
|
||||||
## find out servers info
|
## find out servers info
|
||||||
servers = []
|
servers = []
|
||||||
gateway = None
|
gateway = None
|
||||||
|
@ -596,22 +595,22 @@ class Orchestrator(object):
|
||||||
try:
|
try:
|
||||||
for floating_ip in self.client.floating_ips.list():
|
for floating_ip in self.client.floating_ips.list():
|
||||||
if floating_ip.ip == gateway_ip:
|
if floating_ip.ip == gateway_ip:
|
||||||
LOGGER.info("Disassociating and releasing %s", floating_ip)
|
LOG.info("Disassociating and releasing %s", floating_ip)
|
||||||
self.client.servers.remove_floating_ip(gateway,
|
self.client.servers.remove_floating_ip(gateway,
|
||||||
floating_ip)
|
floating_ip)
|
||||||
self.client.floating_ips.delete(floating_ip)
|
self.client.floating_ips.delete(floating_ip)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOGGER.exception("Error in disassociating/releasing floating IP")
|
LOG.exception("Error in disassociating/releasing floating IP")
|
||||||
if re_raise:
|
if re_raise:
|
||||||
raise
|
raise
|
||||||
## try deleting each server
|
## try deleting each server
|
||||||
for server in servers:
|
for server in servers:
|
||||||
try:
|
try:
|
||||||
LOGGER.info('Deleting %s', server)
|
LOG.info('Deleting %s', server)
|
||||||
server.delete()
|
server.delete()
|
||||||
except Exception:
|
except Exception:
|
||||||
LOGGER.exception("Error in deleting server %s", server)
|
LOG.exception("Error in deleting server %s", server)
|
||||||
if re_raise:
|
if re_raise:
|
||||||
raise
|
raise
|
||||||
continue
|
continue
|
||||||
LOGGER.info("Inception cloud '%s' has been cleaned up.", self.prefix)
|
LOG.info("Inception cloud '%s' has been cleaned up.", self.prefix)
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def local(cmd, screen_output=False):
|
def local(cmd, screen_output=False):
|
||||||
|
@ -35,7 +35,7 @@ def local(cmd, screen_output=False):
|
||||||
@return: (output, error)
|
@return: (output, error)
|
||||||
if screen_output is True, return ("", "")
|
if screen_output is True, return ("", "")
|
||||||
"""
|
"""
|
||||||
LOGGER.info('executing command=%s', cmd)
|
LOG.info('executing command=%s', cmd)
|
||||||
stdout, stderr = ((None, None) if screen_output
|
stdout, stderr = ((None, None) if screen_output
|
||||||
else (subprocess.PIPE, subprocess.PIPE))
|
else (subprocess.PIPE, subprocess.PIPE))
|
||||||
proc = subprocess.Popen(cmd,
|
proc = subprocess.Popen(cmd,
|
||||||
|
@ -84,7 +84,7 @@ def ssh(uri, cmd, screen_output=False, silent=True, agent_forwarding=False):
|
||||||
if agent_forwarding:
|
if agent_forwarding:
|
||||||
flags.append('-A')
|
flags.append('-A')
|
||||||
cmd = 'ssh -p %s %s %s %s' % (port, ' '.join(flags), uri, cmd)
|
cmd = 'ssh -p %s %s %s %s' % (port, ' '.join(flags), uri, cmd)
|
||||||
LOGGER.info('executing command=%s', cmd)
|
LOG.info('executing command=%s', cmd)
|
||||||
stdout, stderr = ((None, None) if screen_output
|
stdout, stderr = ((None, None) if screen_output
|
||||||
else (subprocess.PIPE, subprocess.PIPE))
|
else (subprocess.PIPE, subprocess.PIPE))
|
||||||
proc = subprocess.Popen(cmd,
|
proc = subprocess.Popen(cmd,
|
||||||
|
|
|
@ -55,14 +55,14 @@ LOG_LEVELS = {
|
||||||
|
|
||||||
def setup(product_name):
|
def setup(product_name):
|
||||||
"""setup logger and its handlers"""
|
"""setup logger and its handlers"""
|
||||||
LOGGER = logging.getLogger(product_name)
|
LOG = logging.getLogger(product_name)
|
||||||
log_level = LOG_LEVELS[CONF.log_level]
|
log_level = LOG_LEVELS[CONF.log_level]
|
||||||
LOGGER.setLevel(log_level)
|
LOG.setLevel(log_level)
|
||||||
## console logging
|
## console logging
|
||||||
console_handler = logging.StreamHandler()
|
console_handler = logging.StreamHandler()
|
||||||
console_handler.setLevel(log_level)
|
console_handler.setLevel(log_level)
|
||||||
console_handler.setFormatter(CONF.log_formatter)
|
console_handler.setFormatter(CONF.log_formatter)
|
||||||
LOGGER.addHandler(console_handler)
|
LOG.addHandler(console_handler)
|
||||||
## file logging
|
## file logging
|
||||||
if CONF.log_dir is not None and CONF.log_file is not None:
|
if CONF.log_dir is not None and CONF.log_file is not None:
|
||||||
if not os.path.exists(CONF.log_dir):
|
if not os.path.exists(CONF.log_dir):
|
||||||
|
@ -71,4 +71,4 @@ def setup(product_name):
|
||||||
CONF.log_file))
|
CONF.log_file))
|
||||||
file_handler.setLevel(log_level)
|
file_handler.setLevel(log_level)
|
||||||
file_handler.setFormatter(CONF.log_formatter)
|
file_handler.setFormatter(CONF.log_formatter)
|
||||||
LOGGER.addHandler(file_handler)
|
LOG.addHandler(file_handler)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import logging
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FuncThread(threading.Thread):
|
class FuncThread(threading.Thread):
|
||||||
|
@ -46,5 +46,5 @@ class FuncThread(threading.Thread):
|
||||||
func_info = (str(self._func.func) + " " + str(self._func.args) +
|
func_info = (str(self._func.func) + " " + str(self._func.args) +
|
||||||
" " + str(self._func.keywords))
|
" " + str(self._func.keywords))
|
||||||
info = (self.name, func_info, traceback.format_exc())
|
info = (self.name, func_info, traceback.format_exc())
|
||||||
LOGGER.info(info)
|
LOG.info(info)
|
||||||
self._exception_queue.put(info)
|
self._exception_queue.put(info)
|
||||||
|
|
Loading…
Reference in New Issue