class VolBundler
Public Instance Methods
bundle_vol(p)
click to toggle source
# File lib/ec2/amitools/bundlevol.rb, line 108 def bundle_vol(p) name = p.prefix image_file = File::join( p.destination, name ) volume = File::join( p.volume, "" ) # Add a trailing "/" if not present. # # We can't bundle unless we're root. # raise "You need to be root to run #{$0}" unless SysChecks::root_user? # # Extra parameter verification. # raise "the specified size #{p.size}MB is too large" unless p.size <= MAX_SIZE_MB raise "the specified image file #{image_file} already exists" if File::exist?( image_file ) # # Create a list of files to be included in the image. This list will override any # files that are excluded by the security filtered files list. Files are only added if # they are under the volume root. # includes = [] p.includes.each do |file| includes << file end # # Create list of directories to exclude from the image. Always exclude special # directories, directories specified by the user and the image file itself. # exclude = [] unless p.all # # Exclude mounted non-local filesystems if they are under the volume root. # EC2::Platform::Current::Mtab.load.entries.values.each do |entry| unless EC2::Platform::Current::LOCAL_FS_TYPES.include? entry.fstype exclude << entry.mpoint if entry.mpoint.index(volume) == 0 end end end EC2::Platform::Current::Image::EXCLUDES.each { |dir| exclude << dir } # # Exclude user specified excluded directories if they are under the volume root. # p.exclude.each do |dir| exclude << dir end # # Exclude the image file if it is under the volume root. # if image_file.index( volume ) == 0 exclude << image_file end # If we are inheriting instance data but can't access it we want to fail early if p.inherit && !EC2::InstanceData.new.instance_data_accessible raise EC2FatalError.new(12, "Can't access instance metadata. If you are not bundling on an EC2 instance use --no-inherit.") end # # Create image from volume. # image = EC2::Platform::Current::Image.new(volume, image_file, p.size, exclude, includes, p.filter, p.fstab, p.part_type, p.arch, p.script, @debug, p.grub_config) image.make $stdout.puts 'Image file created: %s' % [image_file] $stdout.puts 'Volume cloning done.' if p.clone_only $stdout.puts 'Not bundling image file since "--clone-only" flag was specified.' else # # Bundle the created image file. # $stdout.puts 'Bundling image file...' optional_args = { :kernel_id => p.kernel_id, :ramdisk_id => p.ramdisk_id, :product_codes => p.product_codes, :ancestor_ami_ids => p.ancestor_ami_ids, :block_device_mapping => p.block_device_mapping } Bundle.bundle_image(image_file, p.user, p.arch, Bundle::ImageType::VOLUME, p.destination, p.user_pk_path, p.user_cert_path, p.ec2_cert_path, nil, # prefix optional_args, @debug, p.inherit) end $stdout.puts("#{BUNDLE_VOL_NAME} complete.") end
get_manual()
click to toggle source
# File lib/ec2/amitools/bundlevol.rb, line 222 def get_manual() BUNDLE_VOL_MANUAL end
get_name()
click to toggle source
# File lib/ec2/amitools/bundlevol.rb, line 226 def get_name() BUNDLE_VOL_NAME end
main(p)
click to toggle source
# File lib/ec2/amitools/bundlevol.rb, line 230 def main(p) bundle_vol(p) end