Class: Veewee::Provider::Core::Provider
- Inherits:
-
Object
- Object
- Veewee::Provider::Core::Provider
- Includes:
- Helper::Shell
- Defined in:
- lib/veewee/provider/core/provider.rb
Direct Known Subclasses
Kvm::Provider, Parallels::Provider, Virtualbox::Provider, Vmfusion::Provider
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #gem_available?(gemname) ⇒ Boolean
- #gems_available?(names) ⇒ Boolean
- #get_box(name) ⇒ Object
-
#initialize(name, options, env) ⇒ Provider
constructor
A new instance of Provider.
- #ui ⇒ Object
Methods included from Helper::Shell
Constructor Details
#initialize(name, options, env) ⇒ Provider
Returns a new instance of Provider.
22 23 24 25 26 27 28 29 |
# File 'lib/veewee/provider/core/provider.rb', line 22 def initialize(name,,env) @env=env @name=name @options= @type=self.class.to_s.split("::")[-2] check_requirements end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
7 8 9 |
# File 'lib/veewee/provider/core/provider.rb', line 7 def env @env end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/veewee/provider/core/provider.rb', line 11 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/veewee/provider/core/provider.rb', line 8 def @options end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/veewee/provider/core/provider.rb', line 10 def type @type end |
Class Method Details
.available? ⇒ Boolean
49 50 51 52 53 54 55 56 |
# File 'lib/veewee/provider/core/provider.rb', line 49 def self.available? begin self.check_requirements return true rescue Error return false end end |
Instance Method Details
#gem_available?(gemname) ⇒ Boolean
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/veewee/provider/core/provider.rb', line 58 def gem_available?(gemname) env.logger.info "Checking for gem #{gemname}" available=false begin available=true unless Gem::Specification::find_by_name("#{gemname}").nil? rescue Gem::LoadError env.logger.info "Error loading gem #{gemname}" available=false rescue env.logger.info "Falling back to old syntax for #{gemname}" available=Gem.available?("#{gemname}") env.logger.info "Old syntax #{gemname}.available? #{available}" end return available end |
#gems_available?(names) ⇒ Boolean
74 75 76 77 78 79 |
# File 'lib/veewee/provider/core/provider.rb', line 74 def gems_available?(names) names.each do |gemname| return false if !gem_available?(gemname) end return true end |
#get_box(name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/veewee/provider/core/provider.rb', line 31 def get_box(name) begin require_path='veewee/provider/'+type.to_s.downcase+"/box.rb" require require_path # Get a real box object from the Provider box=Object.const_get("Veewee").const_get("Provider").const_get(type.to_s.capitalize).const_get("Box").new(name,env) # Attach the provider to the box box.provider = self return box rescue Error => ex ui.error "Could not instante the box #{name} with provider #{type} ,#{ex}" raise end end |
#ui ⇒ Object
15 16 17 18 19 20 |
# File 'lib/veewee/provider/core/provider.rb', line 15 def ui return @_ui if defined?(@_ui) @_ui = @env.ui.dup @_ui.resource = @name @_ui end |