def add_cartridge(cart, options={})
debug "Adding cartridge #{name}"
clear_attribute :cartridges
cart =
if cart.is_a? String
{:name => cart}
elsif cart.respond_to? :[]
cart
else
c = cart.url ? {:url => cart.url} : {:name => cart.name}
if cart.respond_to?(:environment_variables) && cart.environment_variables.present?
c[:environment_variables] = cart.environment_variables
end
if cart.respond_to?(:gear_size) && cart.gear_size.present?
c[:gear_size] = cart.gear_size
end
cart = c
end
if cart.respond_to?(:[]) and cart[:url] and !has_param?('ADD_CARTRIDGE', 'url')
raise RHC::Rest::DownloadingCartridgesNotSupported, "The server does not support downloading cartridges."
end
rest_method(
"ADD_CARTRIDGE",
cart,
options
)
end