except IOError:
return -1
+def get_timeout_cmd():
+ timeout_cmd = ''
+ if os.getenv('JOB_TIMEOUT_IN_MILLISECONDS'):
+ #TODO: Save 5 minutes gard time.
+ timeout_val = int(os.getenv('JOB_TIMEOUT_IN_MILLISECONDS'))/1000 - 300
+ if timeout_val <= 300:
+ timeout_val = 300
+ timeout_cmd = 'timeout %s ' % str(timeout_val)
+ return timeout_cmd
+
def run_inside_sign_vm(vm_image, vm_memory, vm_cpus, basedir):
"""
Run mic inside VM
user = "net=%s,host=%s,dhcpstart=%s" %(os.getenv('SIGN_VM_USER_NET'), \
os.getenv('SIGN_VM_USER_HOST'), \
os.getenv('SIGN_VM_USER_DHCPSTART'))
- cmd = 'qemu-system-x86_64 -machine accel=kvm:xen:tcg -name '\
+ cmd = '%s qemu-system-x86_64 -machine accel=kvm:xen:tcg -name '\
'opensuse -M pc -m %d -smp %d -vga none -drive file=%s,'\
'snapshot=on -nographic -virtfs local,id=test_dev,'\
'path=%s,security_model=mapped,mount_tag=share '\
+ '-virtfs local,id=test_sign,path=/var/lib/jenkins/.sign/,'\
+ 'security_model=mapped,mount_tag=sign '\
'-net nic,macaddr=%s -net user,%s' % \
- (vm_memory, vm_cpus, vm_image, basedir, mac_address, user)
+ (get_timeout_cmd(), vm_memory, vm_cpus, vm_image, basedir, mac_address, user)
print "cmd=%s" %(cmd)
sys.stdout.flush()
subprocess.call(cmd, stdout=sys.stdout,
def main():
"""The main body"""
+
buildmonitor_enabled = os.getenv("BUILDMONITOR_ENABLED", "0") != "0"
- print 'buildmonitor_enabled(%s)\n' % (buildmonitor_enabled)
if buildmonitor_enabled:
bm_start_datetime = datetime.datetime.now()
if os.getenv('MIC_WORK_DIR') and os.getenv('MIC_CONF_FILE'):
mic_conf_file = os.getenv('MIC_CONF_FILE')
print 'Set mic conf file: %s' % mic_conf_file
- mic_cmd = "sudo /usr/bin/mic cr auto -c %s %s --release %s -o %s -k %s "\
- '--logfile=%s' % (mic_conf_file, ksf, build_id, outdir, cache, log)
+ mic_cmd = "sudo %s /usr/bin/mic cr auto -c %s %s --release %s -o %s -k %s "\
+ '--logfile=%s' % (get_timeout_cmd(), mic_conf_file, ksf, build_id, outdir, cache, log)
else:
- mic_cmd = "sudo /usr/bin/mic cr auto %s --release %s -o %s -k %s "\
- '--logfile=%s' % (ksf, build_id, outdir, cache, log)
+ mic_cmd = "sudo %s /usr/bin/mic cr auto %s --release %s -o %s -k %s "\
+ '--logfile=%s' % (get_timeout_cmd(), ksf, build_id, outdir, cache, log)
sys.stdout.flush()
print 'starting mic to create image: %s' % mic_cmd
if __name__ == "__main__":
sys.exit(main())
+