Class: Bosh::Deployer::Cli::Commands::Deployment

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh-deployer/cli/commands/deployment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, filepath = nil) ⇒ Deployment

Returns a new instance of Deployment.



7
8
9
10
# File 'lib/bosh-deployer/cli/commands/deployment.rb', line 7

def initialize(name, filepath=nil)
  @name = name
  @filepath = filepath
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/bosh-deployer/cli/commands/deployment.rb', line 5

def name
  @name
end

Instance Method Details

#addressObject



16
17
18
19
20
21
22
23
# File 'lib/bosh-deployer/cli/commands/deployment.rb', line 16

def address
  case name
  when 'microbosh'
    yml['address']['ip']
  when 'bosh'
    yml['meta']['networks']['manual']['static'][0].split('-')[0].strip
  end
end

#filepathObject



29
30
31
32
33
34
35
36
37
# File 'lib/bosh-deployer/cli/commands/deployment.rb', line 29

def filepath
  return @filepath if @filepath
  @filepath = case name
              when 'microbosh'
                '~/.microbosh/settings.yml'
              when 'bosh'
                '~/.deployer/stubs/bosh.yml'
              end
end

#targetObject



12
13
14
# File 'lib/bosh-deployer/cli/commands/deployment.rb', line 12

def target
  `bosh target #{address}`
end

#ymlObject



25
26
27
# File 'lib/bosh-deployer/cli/commands/deployment.rb', line 25

def yml
  YAML.load_file(filepath)
end