Class: OsCtl::Image::Operations::Builder::UseOrCreate

Inherits:
OsCtl::Image::Operations::Base show all
Defined in:
lib/osctl/image/operations/builder/use_or_create.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OsCtl::Image::Operations::Base

run

Constructor Details

#initialize(builder, base_dir) ⇒ UseOrCreate

Returns a new instance of UseOrCreate.



12
13
14
15
16
# File 'lib/osctl/image/operations/builder/use_or_create.rb', line 12

def initialize(builder, base_dir)
  super()
  @builder = builder
  @base_dir = base_dir
end

Instance Attribute Details

#base_dirString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/osctl/image/operations/builder/use_or_create.rb', line 10

def base_dir
  @base_dir
end

#builderBuilder (readonly)

Returns:



7
8
9
# File 'lib/osctl/image/operations/builder/use_or_create.rb', line 7

def builder
  @builder
end

Instance Method Details

#executeObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/osctl/image/operations/builder/use_or_create.rb', line 18

def execute
  client = OsCtldClient.new

  if client.find_container(builder.ctid)
    client.start_container(builder.ctid)
    builder.load_attrs(client)
    Operations::Builder::WaitForNetwork.run(builder)
  else
    Operations::Builder::Create.run(builder, base_dir)
  end
end