mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 19:51:35 +01:00
args -> kwargs
This commit is contained in:
32
run-docker
32
run-docker
@@ -11,28 +11,28 @@ image_name = common.repo_short_id
|
||||
target_dir = '/root/{}'.format(common.repo_short_id)
|
||||
docker = ['sudo', 'docker']
|
||||
def create(args):
|
||||
self.sh.run_cmd(docker + ['build', '-t', image_name, '.', common.Newline])
|
||||
self.sh.run_cmd(docker + ['build', '-t', image_name, '.', LF])
|
||||
# --privileged for KVM:
|
||||
# https://stackoverflow.com/questions/48422001/launching-qemu-kvm-from-inside-docker-container
|
||||
self.sh.run_cmd(
|
||||
docker +
|
||||
[
|
||||
'create', common.Newline,
|
||||
'--hostname', container_hostname, common.Newline,
|
||||
'-i', common.Newline,
|
||||
'--name', container_name, common.Newline,
|
||||
'--net', 'host', common.Newline,
|
||||
'--privileged', common.Newline,
|
||||
'-t', common.Newline,
|
||||
'-w', target_dir, common.Newline,
|
||||
'-v', '{}:{}'.format(os.getcwd(), target_dir), common.Newline,
|
||||
'create', LF,
|
||||
'--hostname', container_hostname, LF,
|
||||
'-i', LF,
|
||||
'--name', container_name, LF,
|
||||
'--net', 'host', LF,
|
||||
'--privileged', LF,
|
||||
'-t', LF,
|
||||
'-w', target_dir, LF,
|
||||
'-v', '{}:{}'.format(os.getcwd(), target_dir), LF,
|
||||
image_name,
|
||||
]
|
||||
)
|
||||
def destroy(args):
|
||||
stop(args)
|
||||
self.sh.run_cmd(docker + ['rm', container_name, common.Newline])
|
||||
self.sh.run_cmd(docker + ['rmi', image_name, common.Newline])
|
||||
self.sh.run_cmd(docker + ['rm', container_name, LF])
|
||||
self.sh.run_cmd(docker + ['rmi', image_name, LF])
|
||||
def sh(args):
|
||||
start(args)
|
||||
if args:
|
||||
@@ -42,12 +42,12 @@ def sh(args):
|
||||
self.sh.run_cmd(
|
||||
docker + ['exec', '-i', '-t', container_name] +
|
||||
sh_args +
|
||||
[common.Newline],
|
||||
[LF],
|
||||
)
|
||||
def start(args):
|
||||
self.sh.run_cmd(docker + ['start', container_name, common.Newline])
|
||||
self.sh.run_cmd(docker + ['start', container_name, LF])
|
||||
def stop(args):
|
||||
self.sh.run_cmd(docker + ['stop', container_name, common.Newline])
|
||||
self.sh.run_cmd(docker + ['stop', container_name, LF])
|
||||
cmd_action_map = {
|
||||
'create': lambda args: create(args),
|
||||
'DESTROY': lambda args: destroy(args),
|
||||
@@ -61,4 +61,4 @@ parser.add_argument('args', nargs='*')
|
||||
common.add_dry_run_argument(parser)
|
||||
args = parser.parse_args()
|
||||
common.setup_dry_run_arguments(args)
|
||||
cmd_action_map[args.cmd](args.args)
|
||||
cmd_action_map[kwargs['cmd']](kwargs['args'])
|
||||
|
||||
Reference in New Issue
Block a user