示例#1
0
 def get_rootdev_val(self):
     """
     Get root devices from board info
     :return: root devices list
     """
     (self.root_dev_val, num) = common.get_rootfs(self.board_info)
     return self.root_dev_val
示例#2
0
os.environ['COLOREDLOGS_LOG_FORMAT'] = \
        '[%(hostname)s] %(asctime)s - %(name)s[%(process)d] - ' \
        '%(filename)s[line:%(lineno)d] - %(levelname)-8s: %(message)s'
coloredlogs.install(level='DEBUG')
logger = logging.getLogger()

mailuser = os.environ.get('PST_MAIL_USER', None)
mailpasswd = os.environ.get('PST_MAIL_PASSWD', None)
smtpserver = os.environ.get('PST_MAIL_SMTP', None)
smtpport = os.environ.get('PST_MAIL_PORT', 465)
toaddrs = os.environ.get('PST_MAIL_TOADDRS', None)
subject = os.environ.get('PST_MAIL_SUBJECT', u"[PST][log]")

if mailuser and mailpasswd and smtpserver:
    hostname = common.get_hostname()
    rootfs = common.get_rootfs()
    commit = common.get_commit()
    if common.is_in_vm():
        tbox_type = 'vm'
    elif common.is_in_docker():
        tbox_type = 'docker'
    else:
        tbox_type = 'pm'
    subject_suffix = ' %s  %s  %s  %s' % (hostname, tbox_type, rootfs, commit)
    mail_handler = SSLSMTPHandler(mailhost=(smtpserver, int(smtpport)),
                                  fromaddr=mailuser,
                                  toaddrs=toaddrs,
                                  subject=subject+subject_suffix,
                                  credentials=(mailuser, mailpasswd))

    mail_handler.setLevel(logging.ERROR)