From bed90d7a0b2a59bb92df75b846852e45fc70703e Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Wed, 31 Oct 2018 23:41:22 +0100 Subject: [PATCH] make destination optional in vmmc_bistro, make vm_name required in add_policy --- app/vmm_cli.ml | 10 +++++++++- app/vmmc_bistro.ml | 12 ++---------- app/vmmc_local.ml | 10 +--------- app/vmmp_request.ml | 10 +--------- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/app/vmm_cli.ml b/app/vmm_cli.ml index 5dd3796..f2926f3 100644 --- a/app/vmm_cli.ml +++ b/app/vmm_cli.ml @@ -99,7 +99,15 @@ let cpus = let vms = let doc = "Number of VMs to allow" in - Arg.(required & pos 0 (some int) None & info [] ~doc ~docv:"VMS") + Arg.(required & pos 1 (some int) None & info [] ~doc ~docv:"VMS") + +let image = + let doc = "File of virtual machine image." in + Arg.(required & pos 1 (some file) None & info [] ~doc ~docv:"IMAGE") + +let vm_name = + let doc = "Name virtual machine." in + Arg.(required & pos 0 (some vm_c) None & info [] ~doc ~docv:"VM") let block_size = let doc = "Block storage to allow in MB" in diff --git a/app/vmmc_bistro.ml b/app/vmmc_bistro.ml index 4a63a11..c436d95 100644 --- a/app/vmmc_bistro.ml +++ b/app/vmmc_bistro.ml @@ -129,15 +129,7 @@ let ca_key = let destination = let doc = "the destination hostname:port to connect to" in - Arg.(required & pos 0 (some host_port) None & info [] ~doc ~docv:"HOST:PORT") - -let image = - let doc = "File of virtual machine image." in - Arg.(required & pos 2 (some file) None & info [] ~doc ~docv:"IMAGE") - -let vm_name = - let doc = "Name virtual machine." in - Arg.(required & pos 1 (some vm_c) None & info [] ~doc ~docv:"VM") + Arg.(value & opt host_port ("localhost", 1025) & info [ "d" ; "destination" ] ~doc ~docv:"HOST:PORT") let destroy_cmd = let doc = "destroys a virtual machine" in @@ -181,7 +173,7 @@ let add_policy_cmd = [`S "DESCRIPTION"; `P "Adds a policy."] in - Term.(ret (const add_policy $ setup_log $ destination $ ca_cert $ ca_key $ server_ca $ opt_vm_name $ vms $ mem $ cpus $ block_size $ bridge)), + Term.(ret (const add_policy $ setup_log $ destination $ ca_cert $ ca_key $ server_ca $ vm_name $ vms $ mem $ cpus $ block_size $ bridge)), Term.info "add_policy" ~doc ~man let create_cmd = diff --git a/app/vmmc_local.ml b/app/vmmc_local.ml index c3be718..09d7632 100644 --- a/app/vmmc_local.ml +++ b/app/vmmc_local.ml @@ -97,14 +97,6 @@ let socket = let doc = "Socket to connect to" in Arg.(value & opt (some string) None & info [ "socket" ] ~doc) -let image = - let doc = "File of virtual machine image." in - Arg.(required & pos 1 (some file) None & info [] ~doc ~docv:"IMAGE") - -let vm_name = - let doc = "Name virtual machine." in - Arg.(required & pos 0 (some vm_c) None & info [] ~doc ~docv:"VM") - let destroy_cmd = let doc = "destroys a virtual machine" in let man = @@ -147,7 +139,7 @@ let add_policy_cmd = [`S "DESCRIPTION"; `P "Adds a policy."] in - Term.(ret (const add_policy $ setup_log $ socket $ opt_vm_name $ vms $ mem $ cpus $ block_size $ bridge)), + Term.(ret (const add_policy $ setup_log $ socket $ vm_name $ vms $ mem $ cpus $ block_size $ bridge)), Term.info "add_policy" ~doc ~man let create_cmd = diff --git a/app/vmmp_request.ml b/app/vmmp_request.ml index 7ee24eb..a339438 100644 --- a/app/vmmp_request.ml +++ b/app/vmmp_request.ml @@ -62,14 +62,6 @@ let help _ man_format cmds = function open Cmdliner open Vmm_cli -let image = - let doc = "File of virtual machine image." in - Arg.(required & pos 1 (some file) None & info [] ~doc ~docv:"IMAGE") - -let vm_name = - let doc = "Name virtual machine." in - Arg.(required & pos 0 (some vm_c) None & info [] ~doc ~docv:"VM") - let destroy_cmd = let doc = "destroys a virtual machine" in let man = @@ -112,7 +104,7 @@ let add_policy_cmd = [`S "DESCRIPTION"; `P "Adds a policy."] in - Term.(ret (const add_policy $ setup_log $ opt_vm_name $ vms $ mem $ cpus $ block_size $ bridge)), + Term.(ret (const add_policy $ setup_log $ vm_name $ vms $ mem $ cpus $ block_size $ bridge)), Term.info "add_policy" ~doc ~man let create_cmd =