Class: Wakame::Service::VmSpec::EC2

Inherits:
Template
  • Object
show all
Defined in:
lib/wakame/service.rb

Constant Summary collapse

AWS_VERSION =
''

Instance Method Summary collapse

Methods inherited from Template

inherited

Instance Method Details

#merge(vm_attr, diff) ⇒ Object



1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
# File 'lib/wakame/service.rb', line 1026

def merge(vm_attr, diff)
  self.class.vm_attr_defs.each_key { |k|
    raise "Passed VM attribute hash is incomplete data set: #{vm_attr}" unless vm_attr.has_key? k
  }

  merged = vm_attr.merge(diff){ |k,v1,v2|
    case k
    when :security_groups
      if v1.is_a?(Array)
        (v1.dup << v2).flatten.uniq
      else
        v2
      end
    else
      v2.nil? ? v1 : v2
    end
  }

  merged
end

#satisfy?(vm_attr, diff) ⇒ Boolean

Returns:

  • (Boolean)


1020
1021
1022
1023
1024
# File 'lib/wakame/service.rb', line 1020

def satisfy?(vm_attr, diff)
  # Compare critical variables which will return false if they are not same.
  return false unless [:availability_zone, :instance_type, :image_id].all? { |k| diff[k].nil? ? true : diff[k] == vm_attr[self.class.vm_attr_defs[k][:right_aws_key]] }
  true
end