src/bosh_aws_cpi/lib/cloud/aws/stemcell_creator.rb
# This method tries to execute the helper script stemcell-copy
# as root using sudo, since it needs to write to the device_path.
# If stemcell-copy isn't available, it falls back to writing directly
# to the device, which is used in the micro bosh deployer.
# The stemcell-copy script must be in the PATH of the user running
# the director, and needs sudo privileges to execute without
# password.
#
This method tries to execute the helper script stemcell-copy
as root using sudo, since it needs to write to the device_path.
If stemcell-copy isn't available, it falls back to writing directly
to the device, which is used in the micro bosh deployer.
The stemcell-copy script must be in the PATH of the user running
the director, and needs sudo privileges to execute without
password.
This method tries to execute the helper script stemcell - copy as root using sudo since it needs to write to the device_path . If stemcell - copy isn ' t available it falls back to writing directly to the device which is used in the micro bosh deployer . The stemcell - copy script must be in the PATH of the user running the director and needs sudo privileges to execute without password .
def copy_root_image
      stemcell_copy = find_in_path('stemcell-copy')
      if stemcell_copy
        logger.debug('copying stemcell using stemcell-copy script')
        command = "sudo -n #{stemcell_copy} #{image_path} #{device_path} 2>&1"
      else
        logger.info('falling back to using included copy stemcell')
        included_stemcell_copy = File.expand_path('../../../../bin/stemcell-copy', __FILE__)
        command = "sudo -n #{included_stemcell_copy} #{image_path} #{device_path} 2>&1"
      end
      result = sh(command)
      logger.debug("stemcell copy output:\n#{result.output}")
    rescue Bosh::Exec::Error => e
      raise Bosh::Clouds::CloudError, "Unable to copy stemcell root image: #{e.message}\nScript output:\n#{e.output}"
    end
def copy_root_image stemcell_copy = find_in_path ( 'stemcell-copy' ) if stemcell_copy logger . debug ( 'copying stemcell using stemcell-copy script' ) command = "sudo -n #{stemcell_copy} #{image_path} #{device_path} 2>&1" else logger . info ( 'falling back to using included copy stemcell' ) included_stemcell_copy = File . expand_path ( '../../../../bin/stemcell-copy' , __FILE__ ) command = "sudo -n #{included_stemcell_copy} #{image_path} #{device_path} 2>&1" end result = sh ( command ) logger . debug ( "stemcell copy output:\n#{result.output}" ) rescue Bosh :: Exec :: Error => e raise Bosh :: Clouds :: CloudError , "Unable to copy stemcell root image: #{e.message}\nScript output:\n#{e.output}" end
This method tries to execute the helper script stemcell-copy
as root using sudo, since it needs to write to the device_path.
This method tries to execute the helper script stemcell - copy as root using sudo since it needs to write to the device_path .
# note that is is a potentially dangerous operation, but as the # stemcell-copy script sets PATH to a sane value this is safe