Class: Bosh::Bootstrap::Network

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh-bootstrap/network.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider_name, provider_client) ⇒ Network

Returns a new instance of Network.



9
10
11
12
# File 'lib/bosh-bootstrap/network.rb', line 9

def initialize(provider_name, provider_client)
  @provider_name = provider_name
  @provider_client = provider_client
end

Instance Attribute Details

#provider_clientObject (readonly)

Returns the value of attribute provider_client.



7
8
9
# File 'lib/bosh-bootstrap/network.rb', line 7

def provider_client
  @provider_client
end

#provider_nameObject (readonly)

Returns the value of attribute provider_name.



6
7
8
# File 'lib/bosh-bootstrap/network.rb', line 6

def provider_name
  @provider_name
end

Instance Method Details

#deployObject



14
15
16
# File 'lib/bosh-bootstrap/network.rb', line 14

def deploy
  network_provider.perform
end

#network_providerObject

Attempt to load and instantiate a NetworkProviders class Else return NetworkProviders::Dummy which does nothing



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bosh-bootstrap/network.rb', line 20

def network_provider
  @network_provider ||= begin
    begin
      require "bosh-bootstrap/network_providers/#{provider_name}"
      klass = Bosh::Bootstrap::NetworkProviders.provider_class(provider_name)
    rescue LoadError
      klass = Bosh::Bootstrap::NetworkProviders.provider_class("dummy")
    end
    klass.new(provider_client)
  end
end