Class: ImageOptimize::ImageBundleBase

Inherits:
Object
  • Object
show all
Includes:
Command, Common
Defined in:
lib/image_bundle/image_bundle_base.rb

Direct Known Subclasses

ImageBundleEc2Base

Instance Method Summary collapse

Methods included from Command

#debug, #execute

Methods included from Common

#not_implemented

Constructor Details

#initialize(instance_api_client, full_api_client) ⇒ ImageBundleBase

Returns a new instance of ImageBundleBase.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/image_bundle/image_bundle_base.rb', line 28

def initialize(instance_api_client, full_api_client)

  @dry_run = false

  @log ||= Logger.new(STDOUT)
  @instance_client = instance_api_client
  unless @instance_client
    @log.error"ERROR: you must pass an instance_api_client parameter."
  end

  @api_client = full_api_client
  unless @api_client
    @log.error"ERROR: you must pass a full_api_client parameter."
  end
end

Instance Method Details

#add_image_to_next_instanceObject



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/image_bundle/image_bundle_base.rb', line 54

def add_image_to_next_instance
  # get next instance
  @log.info "Lookup next_instance for the server."
  next_instance = get_instance_parent.show.next_instance

  unless @dry_run
    raise "ERROR: image cannot be nil. Be sure to run register_image method first." unless @image
    # set next instance to use our cached image
    @log.info "Update next instance to launch with our new image."
    next_instance.update(:instance => {:image_href => @image.show.href})
  end
end

#log(logger) ⇒ Object



67
68
69
# File 'lib/image_bundle/image_bundle_base.rb', line 67

def log(logger)
  @log = logger
end

#register_image(name, description) ⇒ Object

Turn the VM “snapshot” into an launchable image



50
51
52
# File 'lib/image_bundle/image_bundle_base.rb', line 50

def register_image(name, description)
  not_implemented
end

#snapshot_instance(name, description) ⇒ Object

Captures a “snapshot” of the current VM configuration



45
46
47
# File 'lib/image_bundle/image_bundle_base.rb', line 45

def snapshot_instance(name, description)
  not_implemented
end