def create_instance(credentials, image_id, opts={})
sbc_client = new_client(credentials)
body = opts.dup
body.delete('image_id')
body.delete('hwp_id')
body.delete('realm_id')
if @last_image.nil? || @last_image['id'] != opts[:image_id]
@last_image = sbc_client.list_images(image_id).map[0]
end
body['imageID'] = opts[:image_id]
body['location'] = opts[:realm_id] || @last_image['location']
body['instanceType'] = opts[:hwp_id].gsub('-', '/') || @last_image['supportedInstanceTypes'][0]['id']
convert_instance(sbc_client.create_instance(body).map[0])
end