Revision 106659f1 ci/utils.py
b/ci/utils.py | ||
---|---|---|
22 | 22 |
import filelocker |
23 | 23 |
|
24 | 24 |
DEFAULT_CONFIG_FILE = "ci_wheezy.conf" |
25 |
# Is our terminal a colorful one? |
|
26 |
USE_COLORS = True |
|
25 | 27 |
# UUID of owner of system images |
26 | 28 |
DEFAULT_SYSTEM_IMAGES_UUID = [ |
27 | 29 |
"25ecced9-bf53-4145-91ee-cf47377e9fb2", # production (okeanos.grnet.gr) |
... | ... | |
47 | 49 |
|
48 | 50 |
def _red(msg): |
49 | 51 |
"""Red color""" |
50 |
#return "\x1b[31m" + str(msg) + "\x1b[0m"
|
|
51 |
return str(msg)
|
|
52 |
ret = "\x1b[31m" + str(msg) + "\x1b[0m" if USE_COLORS else str(msg)
|
|
53 |
return ret
|
|
52 | 54 |
|
53 | 55 |
|
54 | 56 |
def _yellow(msg): |
55 | 57 |
"""Yellow color""" |
56 |
#return "\x1b[33m" + str(msg) + "\x1b[0m"
|
|
57 |
return str(msg)
|
|
58 |
ret = "\x1b[33m" + str(msg) + "\x1b[0m" if USE_COLORS else str(msg)
|
|
59 |
return ret
|
|
58 | 60 |
|
59 | 61 |
|
60 | 62 |
def _green(msg): |
61 | 63 |
"""Green color""" |
62 |
#return "\x1b[32m" + str(msg) + "\x1b[0m"
|
|
63 |
return str(msg)
|
|
64 |
ret = "\x1b[32m" + str(msg) + "\x1b[0m" if USE_COLORS else str(msg)
|
|
65 |
return ret
|
|
64 | 66 |
|
65 | 67 |
|
66 | 68 |
def _check_fabric(fun): |
... | ... | |
359 | 361 |
# Check if we found one |
360 | 362 |
if list_flvs: |
361 | 363 |
self.logger.debug("Will use \"%s\" with id \"%s\"" |
362 |
% (list_flvs[0]['name'], list_flvs[0]['id'])) |
|
364 |
% (_green(list_flvs[0]['name']), |
|
365 |
_green(list_flvs[0]['id']))) |
|
363 | 366 |
return list_flvs[0]['id'] |
364 | 367 |
|
365 | 368 |
self.logger.error("No matching flavor found.. aborting") |
... | ... | |
406 | 409 |
# Check if we found one |
407 | 410 |
if list_imgs: |
408 | 411 |
self.logger.debug("Will use \"%s\" with id \"%s\"" |
409 |
% (list_imgs[0]['name'], list_imgs[0]['id'])) |
|
412 |
% (_green(list_imgs[0]['name']), |
|
413 |
_green(list_imgs[0]['id']))) |
|
410 | 414 |
return list_imgs[0]['id'] |
411 | 415 |
|
412 | 416 |
# We didn't found one |
... | ... | |
429 | 433 |
self.logger.debug("Server's IPv4 is %s" % _green(server_ip)) |
430 | 434 |
self.write_temp_config('server_port', server_port) |
431 | 435 |
self.logger.debug("Server's ssh port is %s" % _green(server_port)) |
432 |
self.logger.debug("Access server using \"ssh -p %s %s@%s\"" % |
|
433 |
(server_port, server['metadata']['users'], |
|
434 |
server_ip)) |
|
436 |
ssh_command = "ssh -p %s %s@%s" \ |
|
437 |
% (server_port, server['metadata']['users'], server_ip) |
|
438 |
self.logger.debug("Access server using \"%s\"" % |
|
439 |
(_green(ssh_command))) |
|
435 | 440 |
|
436 | 441 |
@_check_fabric |
437 | 442 |
def _copy_ssh_keys(self, ssh_keys): |
... | ... | |
442 | 447 |
|
443 | 448 |
if ssh_keys != "": |
444 | 449 |
ssh_keys = os.path.expanduser(ssh_keys) |
445 |
self.logger.debug("Will use %s authentication keys file" %
|
|
446 |
ssh_keys)
|
|
450 |
self.logger.debug("Will use \"%s\" authentication keys file" %
|
|
451 |
_green(ssh_keys))
|
|
447 | 452 |
keyfile = '/tmp/%s.pub' % fabric.env.user |
448 | 453 |
_run('mkdir -p ~/.ssh && chmod 700 ~/.ssh', False) |
449 | 454 |
if ssh_keys.startswith("http://") or \ |
... | ... | |
585 | 590 |
subprocess.Popen( |
586 | 591 |
["git", "rev-parse", "--short", "HEAD"], |
587 | 592 |
stdout=subprocess.PIPE).communicate()[0].strip() |
588 |
self.logger.info("Will use branch %s" % synnefo_branch)
|
|
593 |
self.logger.info("Will use branch \"%s\"" % _green(synnefo_branch))
|
|
589 | 594 |
|
590 | 595 |
if local_repo or synnefo_branch == "": |
591 | 596 |
# Use local_repo |
... | ... | |
714 | 719 |
self.logger.info("Deploy Synnefo..") |
715 | 720 |
if schema is None: |
716 | 721 |
schema = self.config.get('Global', 'schema') |
717 |
self.logger.debug("Will use \"%s\" schema" % schema)
|
|
722 |
self.logger.debug("Will use \"%s\" schema" % _green(schema))
|
|
718 | 723 |
|
719 | 724 |
schema_dir = os.path.join(self.ci_dir, "schemas/%s" % schema) |
720 | 725 |
if not (os.path.exists(schema_dir) and os.path.isdir(schema_dir)): |
Also available in: Unified diff