def create_vms(opts)
raise ArgumentError, "Fog::Compute::Softlayer#create_vms expects argument of type Array" unless opts.kind_of?(Array)
response = Excon::Response.new
required = %w{hostname domain startCpus maxMemory hourlyBillingFlag localDiskFlag}
begin
opts.each {|vm| Fog::Softlayer.valid_request?(required, vm) or raise MissingRequiredParameter}
response.status = 200
response.body = []
fields = {
'accountId' => Fog::Softlayer.mock_account_id,
'createDate' => Time.now.iso8601,
'datacenter' => nil,
'dedicatedAccountHostOnlyFlag' => false,
'domain' => nil,
'fullyQualifiedDomainName' => nil,
'hostname' => nil,
'id' => Fog::Softlayer.mock_vm_id,
'lastPowerStateId' => nil,
'lastVerifiedDate' => nil,
'maxCpu' => nil,
'maxCpuUnits' => "CORE",
'maxMemory' => nil,
'metricPollDate' => nil,
'modifyDate' => nil,
'startCpus' => nil,
'statusId' => 1001,
'globalIdentifier' => Fog::Softlayer.mock_global_identifier,
'operatingSystem' => {},
'primaryIpAddress' => Fog::Mock.random_ip,
'tagReferences' => []
}
response.body = opts.map do |vm|
fields.deep_merge(Fog::Softlayer.stringify_keys(opts.first))
end
rescue MissingRequiredParameter
response.status = 500
response.body = {
"code" => "SoftLayer_Exception_MissingCreationProperty",
"error" => "Properties #{required.join(', ')} ALL must be set to create an instance of 'SoftLayer_Virtual_Guest'."
}
end
@virtual_guests.push(response.body).flatten!
response
end