Compare commits

...

2 Commits

Author SHA1 Message Date
46f3493be9 Add optional colored logging 2017-10-18 14:07:04 +02:00
709e79f835 Fix post-create ping 2017-10-18 14:03:37 +02:00
2 changed files with 13 additions and 2 deletions

View File

@ -5,3 +5,4 @@ libvirt-python>=1.3.1
ovh==0.4.7 ovh==0.4.7
termcolor==1.1.0 termcolor==1.1.0
terminaltables==3.1.0 terminaltables==3.1.0
coloredlogs==7.3

14
vm.py
View File

@ -16,7 +16,17 @@ __version__ = '0.1'
import logging import logging
logging.basicConfig(level=logging.DEBUG) logging.getLogger('ovh.vendor').setLevel(logging.WARNING)
logformat = '%(asctime)s %(name)s %(levelname)-7s %(message)s'
logdatefmt = '%Y-%m-%d %H:%M:%S'
loglevel = logging.INFO
try:
import coloredlogs
coloredlogs.install(level=loglevel, fmt=logformat, datefmt=logdatefmt)
except:
logging.basicConfig(level=loglevel, format=logformat, datefmt=logdatefmt)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
from docopt import docopt from docopt import docopt
@ -242,7 +252,7 @@ IP: {0.ip}
Username: {0.user} Username: {0.user}
Password: {0.password}'''.format(instance)) Password: {0.password}'''.format(instance))
subprocess.call(['ping', '-c', '1', '-W', '240', instance.ip]) subprocess.call(['ping', '-n', '-c', '1', '-w', '240', instance.ip])
def cmd_iplist(args): def cmd_iplist(args):