diff --git a/lib/vagrant-skytap/command/publish_url/create.rb b/lib/vagrant-skytap/command/publish_url/create.rb index db46152..e640213 100644 --- a/lib/vagrant-skytap/command/publish_url/create.rb +++ b/lib/vagrant-skytap/command/publish_url/create.rb @@ -36,6 +36,8 @@ def execute opts = OptionParser.new do |o| o.banner = "Usage: vagrant publish-url create [options]" o.separator "" + o.separator "Share an environment via the Skytap Cloud UI." + o.separator "" o.separator "Options:" o.separator "" @@ -44,7 +46,7 @@ def execute options[:password] = p end - o.on("-np", "--no-password", "Do not set a password") do |np| + o.on("-n", "--no-password", "Do not set a password") do |n| options[:no_password] = true end @@ -62,20 +64,25 @@ def execute end password ||= "" - ps = fetch_environment.create_publish_set( - name: "Vagrant publish set", - publish_set_type: "single_url", - vms: target_skytap_vms.collect do |vm| - { - vm_ref: vm.url, - access: "run_and_use", - } - end, - password: password - ) - @logger.debug("New publish set: #{ps.url}") + environment = fetch_environment + if (environment).nil? + @env.ui.info(I18n.t("vagrant_skytap.commands.publish_urls.fetch_environment_is_undefined")) + else + ps = environment.create_publish_set( + name: "Vagrant publish set", + publish_set_type: "single_url", + vms: target_skytap_vms.collect do |vm| + { + vm_ref: vm.url, + access: "run_and_use", + } + end, + password: password + ) + @logger.debug("New publish set: #{ps.url}") - @env.ui.info(I18n.t("vagrant_skytap.commands.publish_urls.created", url: ps.desktops_url)) + @env.ui.info(I18n.t("vagrant_skytap.commands.publish_urls.created", url: ps.desktops_url)) + end # Success, exit status 0 0 diff --git a/lib/vagrant-skytap/command/publish_url/delete.rb b/lib/vagrant-skytap/command/publish_url/delete.rb index 0d3d322..230fba6 100644 --- a/lib/vagrant-skytap/command/publish_url/delete.rb +++ b/lib/vagrant-skytap/command/publish_url/delete.rb @@ -35,8 +35,8 @@ def execute opts = OptionParser.new do |o| o.separator "" - o.separator "Deletes all published URLs for this project, including any" - o.separator "created through the Skytap UI." + o.separator "Delete the sharing portal. Users can no longer access" + o.separator "the environment through the URL." o.banner = "Usage: vagrant publish-url delete [options]" o.separator "" @@ -50,7 +50,10 @@ def execute return unless argv = parse_options(opts) - if publish_sets = fetch_environment.publish_sets.presence + environment = fetch_environment + if (environment).nil? + @env.ui.info(I18n.t("vagrant_skytap.commands.publish_urls.fetch_environment_is_undefined")) + elsif publish_sets = environment.publish_sets.presence unless options[:force] confirm = @env.ui.ask(I18n.t("vagrant_skytap.commands.publish_urls.confirm_delete")) return unless confirm.downcase == 'y' diff --git a/lib/vagrant-skytap/command/publish_url/root.rb b/lib/vagrant-skytap/command/publish_url/root.rb index ac5242e..1a12b94 100644 --- a/lib/vagrant-skytap/command/publish_url/root.rb +++ b/lib/vagrant-skytap/command/publish_url/root.rb @@ -74,6 +74,8 @@ def help opts = OptionParser.new do |opts| opts.banner = "Usage: vagrant publish-url []" opts.separator "" + opts.separator "Manages Skytap sharing portals." + opts.separator "" opts.separator "Available subcommands:" # Add the available subcommands as separators in order to print them diff --git a/lib/vagrant-skytap/command/publish_url/show.rb b/lib/vagrant-skytap/command/publish_url/show.rb index 9f2111b..56ea0d9 100644 --- a/lib/vagrant-skytap/command/publish_url/show.rb +++ b/lib/vagrant-skytap/command/publish_url/show.rb @@ -20,6 +20,7 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +require 'optparse' require 'vagrant-skytap/command/helpers' module VagrantPlugins @@ -30,7 +31,22 @@ class Show < Vagrant.plugin("2", :command) include Command::Helpers def execute - if publish_sets = fetch_environment.publish_sets.presence + options = {} + opts = OptionParser.new do |o| + o.banner = "Usage: vagrant publish-url show []" + o.separator "" + o.separator "Show the sharing portal, the VMs included, and whether" + o.separator "the URL is password-protected." + o.separator "" + o.separator "Available subcommands:" + end + + return unless argv = parse_options(opts) + + environment = fetch_environment + if (environment).nil? + @env.ui.info(I18n.t("vagrant_skytap.commands.publish_urls.fetch_environment_is_undefined")) + elsif publish_sets = environment.publish_sets.presence results = publish_sets.collect do |ps| "#{ps.desktops_url || 'n/a'}\n" \ " VMs: #{machine_names(ps.vm_ids).join(', ').presence || '(none)'}" \ diff --git a/locales/en.yml b/locales/en.yml index d43cb3a..3f1f698 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -227,6 +227,8 @@ en: created through the Skytap UI) have been deleted. Users cannot manage these VMs, or access them through SmartClient, unless they have a Skytap user account with appropriate permissions. + fetch_environment_is_undefined: |- + The command failed because the environment does not exist. Run `vagrant up` to create the environment. halt: not_allowed_if_suspended: |- Suspended machines cannot be halted gracefully. Run `vagrant up`