Skip to content

Commit

Permalink
reset command must not call OpenStack
Browse files Browse the repository at this point in the history
Fix #195
  • Loading branch information
ggiamarchi committed Jan 17, 2015
1 parent 9d90a8f commit 055e75d
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def execute(name)
env[:ui] = @env.ui
end

VagrantPlugins::Openstack::Action::ConnectOpenstack.new(nil, env).call(env)
before_cmd(name, @argv, env)

cmd(name, @argv, env)
@env.ui.info('')
Expand All @@ -38,6 +38,9 @@ def normalize_args(args)
args
end

def before_cmd(_name, _argv, _env)
end

def cmd(_name, _argv, _env)
fail 'Command not implemented. \'cmd\' method must be overridden in all subclasses'
end
Expand Down
8 changes: 3 additions & 5 deletions source/lib/vagrant-openstack-provider/command/flavor_list.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
require 'vagrant-openstack-provider/command/utils'
require 'vagrant-openstack-provider/command/abstract_command'
require 'vagrant-openstack-provider/command/openstack_command'

module VagrantPlugins
module Openstack
module Command
class FlavorList < AbstractCommand
include VagrantPlugins::Openstack::Command::Utils

class FlavorList < OpenstackCommand
def self.synopsis
I18n.t('vagrant_openstack.command.flavor_list_synopsis')
end

def cmd(name, argv, env)
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
flavors = env[:openstack_client].nova.get_all_flavors(env)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
require 'vagrant-openstack-provider/command/utils'
require 'vagrant-openstack-provider/command/abstract_command'
require 'vagrant-openstack-provider/command/openstack_command'

module VagrantPlugins
module Openstack
module Command
class FloatingIpList < AbstractCommand
include VagrantPlugins::Openstack::Command::Utils

class FloatingIpList < OpenstackCommand
def self.synopsis
I18n.t('vagrant_openstack.command.flaotingip_list_synopsis')
end

def cmd(name, argv, env)
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0

Expand Down
8 changes: 3 additions & 5 deletions source/lib/vagrant-openstack-provider/command/image_list.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
require 'vagrant-openstack-provider/command/utils'
require 'vagrant-openstack-provider/command/abstract_command'
require 'vagrant-openstack-provider/command/openstack_command'

module VagrantPlugins
module Openstack
module Command
class ImageList < AbstractCommand
include VagrantPlugins::Openstack::Command::Utils

class ImageList < OpenstackCommand
def self.synopsis
I18n.t('vagrant_openstack.command.image_list_synopsis')
end

def cmd(name, argv, env)
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
rows = []
Expand Down
8 changes: 3 additions & 5 deletions source/lib/vagrant-openstack-provider/command/network_list.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
require 'vagrant-openstack-provider/command/utils'
require 'vagrant-openstack-provider/command/abstract_command'
require 'vagrant-openstack-provider/command/openstack_command'

module VagrantPlugins
module Openstack
module Command
class NetworkList < AbstractCommand
include VagrantPlugins::Openstack::Command::Utils

class NetworkList < OpenstackCommand
def self.synopsis
I18n.t('vagrant_openstack.command.network_list_synopsis')
end

def cmd(name, argv, env)
fail Errors::UnrecognizedArgForCommand, cmd: name, arg: argv[1] if argv.size > 1
if argv.size == 0
Expand Down
20 changes: 20 additions & 0 deletions source/lib/vagrant-openstack-provider/command/openstack_command.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'vagrant-openstack-provider/command/utils'
require 'vagrant-openstack-provider/command/abstract_command'

module VagrantPlugins
module Openstack
module Command
class OpenstackCommand < AbstractCommand
include VagrantPlugins::Openstack::Command::Utils

def initialize(argv, env)
super(argv, env)
end

def before_cmd(_name, _argv, env)
VagrantPlugins::Openstack::Action::ConnectOpenstack.new(nil, env).call(env)
end
end
end
end
end
3 changes: 1 addition & 2 deletions source/lib/vagrant-openstack-provider/command/reset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ module VagrantPlugins
module Openstack
module Command
class Reset < AbstractCommand
include VagrantPlugins::Openstack::Command::Utils

def self.synopsis
I18n.t('vagrant_openstack.command.reset')
end

def cmd(name, argv, env)
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
FileUtils.remove_dir("#{env[:machine].data_dir}")
Expand Down
7 changes: 2 additions & 5 deletions source/lib/vagrant-openstack-provider/command/subnet_list.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
require 'vagrant-openstack-provider/command/utils'
require 'vagrant-openstack-provider/command/abstract_command'
require 'vagrant-openstack-provider/command/openstack_command'

module VagrantPlugins
module Openstack
module Command
class SubnetList < AbstractCommand
include VagrantPlugins::Openstack::Command::Utils

class SubnetList < OpenstackCommand
def self.synopsis
I18n.t('vagrant_openstack.command.subnet_list_synopsis')
end
Expand Down
8 changes: 3 additions & 5 deletions source/lib/vagrant-openstack-provider/command/volume_list.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
require 'vagrant-openstack-provider/command/utils'
require 'vagrant-openstack-provider/command/abstract_command'
require 'vagrant-openstack-provider/command/openstack_command'

module VagrantPlugins
module Openstack
module Command
class VolumeList < AbstractCommand
include VagrantPlugins::Openstack::Command::Utils

class VolumeList < OpenstackCommand
def self.synopsis
I18n.t('vagrant_openstack.command.volume_list_synopsis')
end

def cmd(name, argv, env)
fail Errors::NoArgRequiredForCommand, cmd: name unless argv.size == 0
volumes = env[:openstack_client].cinder.get_all_volumes(env)
Expand Down

0 comments on commit 055e75d

Please sign in to comment.