Skip to content

Commit

Permalink
modify : kfeature-eval.py, function to get ip from vm
Browse files Browse the repository at this point in the history
also have to use after reboot, so make function to reuse
  • Loading branch information
wrlawodms committed Nov 12, 2016
1 parent 8455754 commit ac3e29c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
52 changes: 38 additions & 14 deletions core/scripts/kfeature-eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ def upload(self, frm, to):
return shell_command('scp -i {0} -P {1} "{2}" "{3}@{4}:{5}"'
.format(self._ssh_key, self._port, frm, self._user, self._addr, to))

def get_vm_ipvm(vm):
popen_guest_ip = Popen(['vmrun', 'getGuestIPAddress', vm], env=os.environ.copy() ,stdout=PIPE)

out, err = popen_guest_ip.communicate()

if popen_guest_ip.returncode:
print("Failed : Get gueste ip.", file=sys.stderr)
exit(1)
return out.decode('utf-8').strip()

parser = argparse.ArgumentParser(description='feature evaluation tools : make a kernel image and run a feature evaluation script')

#required arguments
Expand Down Expand Up @@ -97,18 +107,7 @@ def upload(self, frm, to):

shell_command('vmrun start "{0}"'.format(args.vm))

popen_guest_ip = Popen(['vmrun', 'getGuestIPAddress', args.vm], env=os.environ.copy() ,stdout=PIPE)

out, err = popen_guest_ip.communicate()

if popen_guest_ip.returncode:
print("Get gueste ip : "+err, file=sys.stderr)
exit(1)

guest_ip = out.decode('utf-8').strip()

print(os.getcwd())
print("Guest IP : {0}".format(guest_ip))
guest_ip = get_vm_ipvm(args.vm)

guest = Remote_ssh(guest_ip, args.ssh_key, user=args.guest_user)

Expand All @@ -129,13 +128,18 @@ def upload(self, frm, to):
guest.shell_command('cd {0};{1} {2}'.format(args.working_dir, compile_script, compile_script_args))

update_script = args.working_dir+'/kupdate.sh'
update_script_args = '{0}{1}+'.format(args.k_version, args.extraversion) #+ suffix is attached because of git change
k_version = args.k_version
if k_version.count('.') == 1 :
k_version = k_version+'.0'
update_script_args = '{0}{1}+'.format(k_version, args.extraversion) #+ suffix is attached because of git change
guest.shell_command('cd {0};{1} {2}'.format(args.working_dir, update_script, update_script_args))

print("reboot guest..")
shell_command('vmrun reset "{0}"'.format(args.vm))

log_dir = args.k_version+args.extraversion
guest_ip = get_vm_ipvm(args.vm)

log_dir = k_version+args.extraversion
guest.shell_command('mkdir -p {0}'.format(args.working_dir+'/'+log_dir))
shell_command('mkdir -p {0}'.format(script_dir()+'/../../logs/'+log_dir))

Expand All @@ -150,3 +154,23 @@ def upload(self, frm, to):

guest.shell_command('rm -rf '+args.working_dir)

b_report = input('Want to report result of feature evaluation to LKFES-report system?(Y/n)')

if b_report != 'n':
import requests
reporter = input('your name? ')
popen_uname = Popen(['uname', '-a'], stdout=PIPE)
out, err = popen_uname.communicate()
sw_specs = out.decode('utf-8').strip()
hw_specs = "hw spec"
url = '127.0.0.1:8000/post'
data = {'title' : '', 'reporter': reporter, 'hw_spec':hw_spec, 'sw_spec' : sw_specs }
files = {}
requests.post()







2 changes: 2 additions & 0 deletions feature-evals/uname/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
uname -a
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests>2.11

0 comments on commit ac3e29c

Please sign in to comment.