Class/Module Index [+]

Quicksearch

Deltacloud::Drivers::Condor::CondorDriver

Constants

CONDOR_MAPPER_DIR

Public Instance Methods

create_instance(credentials, image_id, opts={}) click to toggle source
# File lib/deltacloud/drivers/condor/condor_driver.rb, line 125
def create_instance(credentials, image_id, opts={})
  # User data should contain this Base64 encoded configuration:
  #
  # $config_server_ip:[$uuid]
  #
  # $config_server - IP address of Configuration Server to use (eg. 192.168.1.1)
  # $uuid          - UUID to use for instance (will be used for ConfServer <-> DC
  #                  API communication)
  # $otp           - One-time-password
  #
  user_data = opts[:user_data] ? Base64.decode64(opts[:user_data]) : nil
  if user_data
    config_server_address, vm_uuid, vm_otp = opts[:user_data].strip.split(';')
    if vm_uuid.nil? and vm_otp.nil?
      vm_uuid = config_server_address
      config_server_address = nil
    end
  end
  vm_uuid ||= UUIDTools::UUID.random_create.to_s
  vm_otp ||= vm_uuid[0..7]
  new_client(credentials) do |condor|
    config_server_address ||= condor.ip_agent.address
    image = images(credentials, :id => image_id).first
    hardware_profile = hardware_profiles(credentials, :id => opts[:hwp_id] || 'small').first
    instance = condor.launch_instance(image, hardware_profile, {
      :name => opts[:name] || "i-#{Time.now.to_i}",
      :config_server_address => config_server_address,
      :uuid => vm_uuid,
      :otp => vm_otp,
    }).first
    store(:uuid, vm_uuid, instance.id)
    raise "Error: VM not launched" unless instance
    instance(credentials, { :id => instance.id, :password => vm_otp })
  end
end
destroy_instance(credentials, instance_id) click to toggle source
# File lib/deltacloud/drivers/condor/condor_driver.rb, line 161
def destroy_instance(credentials, instance_id)
  old_instance = instance(credentials, :id => instance_id)
  new_client(credentials) do |condor|
    condor.destroy_instance(instance_id)
    remove_key(:uuid, instance_id)
    remove_key(:mac, instance_id)
  end
  old_instance.state = 'PENDING'
  old_instance.actions = instance_actions_for(old_instance.state),
  old_instance
end
hardware_profiles(credentials, opts={}) click to toggle source
# File lib/deltacloud/drivers/condor/condor_driver.rb, line 53
def hardware_profiles(credentials, opts={})
  results = []
  new_client(credentials) do |condor|
    results = condor.hardware_profiles.collect do |hwp|
      HardwareProfile::new(hwp[:name]) do
        architecture 'x86_64'
        memory  hwp[:memory]
        cpu     hwp[:cpus]
        storage 100
      end
    end
  end
  filter_hardware_profiles(results, opts)
end
images(credentials, opts={}) click to toggle source
# File lib/deltacloud/drivers/condor/condor_driver.rb, line 79
def images(credentials, opts={})
  results = []
  new_client(credentials) do |condor|
    results = condor.images.collect do |image|
      Image::new(
        :id => Digest::SHA1.hexdigest(image.name).to_s,
        :name => image.name.split(':').first,
        :state => image.state || 'AVAILABLE',
        :architecture => 'x86_64',
        :owner_id => image.owner_id || 'unknown',
        :description => image.description
      )
    end
  end
  filter_on( results, :id, opts )
end
instances(credentials, opts={}) click to toggle source
# File lib/deltacloud/drivers/condor/condor_driver.rb, line 96
def instances(credentials, opts={})
  results = []
  new_client(credentials) do |condor|
    results = condor.instances.collect do |instance|
      vm_uuid = get_value(:uuid, instance.id)
      ip_address = condor.ip_agent.find_ip_by_mac(vm_uuid)
      Instance::new(
        :id => instance.id,
        :name => instance.name,
        :realm_id => 'default',
        :instance_profile => InstanceProfile::new(instance.instance_profile.name),
        :image_id => instance.image_id,
        :public_addresses => [ InstanceAddress.new(ip_address) ],
        :private_addresses => [],
        :owner_id => instance.owner_id,
        :description => instance.name,
        :architecture => 'x86_64',
        :actions => instance_actions_for(instance.state),
        :launch_time => instance.launch_time,
        :username => 'root',
        :password => opts[:password],
        :state => instance.state
      )
    end
  end
  results = filter_on( results, :state, opts )
  filter_on( results, :id, opts )
end
realms(credentials, opts={}) click to toggle source
# File lib/deltacloud/drivers/condor/condor_driver.rb, line 68
def realms(credentials, opts={})
  [
    Realm::new(
      :id => 'default',
      :name => 'Default Condor Realm',
      :limit => :unlimited,
      :state => 'AVAILABLE'
    )
  ]
end
supported_collections() click to toggle source
# File lib/deltacloud/drivers/condor/condor_driver.rb, line 47
def supported_collections
  DEFAULT_COLLECTIONS - [ :storage_volumes, :storage_snapshots ]
end
valid_credentials?(credentials) click to toggle source
# File lib/deltacloud/drivers/condor/condor_driver.rb, line 182
def valid_credentials?(credentials)
  if ( credentials.user != @config[:username] ) or ( credentials.password != @config[:password] )
    return false
  end
  return true
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.