Skip to content

Instantly share code, notes, and snippets.

@yamanetoshi
Created April 18, 2014 08:55
Show Gist options
  • Save yamanetoshi/11032608 to your computer and use it in GitHub Desktop.
Save yamanetoshi/11032608 to your computer and use it in GitHub Desktop.
Mock of Fog::Compute[:cloudstack] | extract template requests
class Mock
def extract_template(options={})
Fog.credentials[:cloudstack_zone_id] = 1105
template_id = options['id']
template_mode = options['mode']
zoneid = self.data[:zones].keys[0]
zone = self.data[:zones][zoneid]
template = {}
template['id'] = template_id
template['name'] = "test template"
template['extractId'] = 1
template['accountid'] = 1
template['state'] = "DOWNLOAD_URL_CREATED"
template['zoneid'] = zoneid
template['zonename'] = self.data[:zones][zoneid]["name"]
template['extractMode'] = template_mode
template['url'] = "http:%2F%2Fexample.com"
job_id = 1
job = {
"jobid" => job_id,
"jobstatus" => 1,
"jobprocstatus" => 0,
"jobresultcode" => 0,
"jobresulttype" => "object",
"jobresult" => { "template" => template }
}
self.data[:jobs][job_id] = job
{
"extracttemplateresponse" => {
"jobid" => job_id
}
}
end
end # Mock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment