Class: Hawser::BakingCommand

Inherits:
Mattock::Rake::RemoteCommandTask
  • Object
show all
Defined in:
lib/hawser/baking-command.rb

Instance Method Summary collapse

Instance Method Details

#commandObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/hawser/baking-command.rb', line 57

def command
  cmd("(ec2-bundle-vol --version | grep \"#{ec2_version_pattern}\")") &
    (cmd("rm") {|rm|
    rm.options = ["-f", File::join(ephemeral_dir.abspath, prefix || "no-such-file") ]
  }) &
    (cmd("ec2-bundle-vol") { |bundle|
    bundle.options += ["-k", private_key.abspath ]
    bundle.options += ["-c", certificate_file.abspath ]
    bundle.options += ["--user",  ]
    bundle.options += ["--block-device-mapping", block_mappings.map do |name, dev|
      "#{name}=#{dev}"
    end.join(",")
    ]

    bundle.options += ["--destination", ephemeral_dir.abspath ]
    bundle.options += ["--prefix", prefix ]
    bundle.options += ["--arch", arch ]
    bundle.options += %w{-i /etc/ec2/amitools/cert-ec2.pem}
    bundle.options += ["-i", '$(ls /etc/ssl/certs/*.pem | tr \\\\n ,)']
    bundle.options += %w{--ec2cert /etc/ec2/amitools/cert-ec2.pem}
    bundle.options += ["-e", keyfile_dir.abspath]
  }) &
    (cmd("ec2-upload-bundle") {|upload|
    upload.options += ["-b", bucket ]
    upload.options += ["-m", manifest_path]
    upload.options += ["-a", access_key ]
    upload.options += ["-s", secret_key ]
    upload.options += ["--location", region ]
    upload.options += ["--retry"]
  }) &
    (cmd("ec2-register") {|register|
    register.options << "#{bucket}/#{manifest_name}"
    register.options += ["-n", image_name]
    register.options += ["--region", region]
    register.options += ["--aws-access-key", access_key]
    register.options += ["--aws-secret-key", secret_key]
  }) &
  (cmd("rm") {|rm|
    rm.options = ["-rf", keyfile_dir.abspath]
  }) &
  (cmd("rm") {|rm|
    rm.options = ["-f", File::join(ephemeral_dir.abspath, prefix || "no-such-file"), File::join(ephemeral_dir.abspath, prefix || "no-such-file") + ".part.*" ]
  })
end

#resolve_configurationObject



35
36
37
38
39
# File 'lib/hawser/baking-command.rb', line 35

def resolve_configuration
  super

  resolve_paths
end

#resolve_runtime_configurationObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/hawser/baking-command.rb', line 41

def resolve_runtime_configuration
  if field_unset?(:prefix)
    self.prefix = image_name
  end

  if field_unset?(:manifest_name)
    self.manifest_name = "#{prefix}.manifest.xml"
  end

  if field_unset?(:manifest_path)
    self.manifest_path = File::join(ephemeral_dir.abspath, manifest_name)
  end

  super
end