public function testListVirtualMachines()
{
$cloudstack = $this->getCloudStackMock('instance', $this->getResponseCallback(substr(__FUNCTION__, 4)));
$this->assertInstanceOf('Scalr\\Service\\CloudStack\\CloudStack', $cloudstack);
$vms = $cloudstack->instance->describe();
$this->assertInstanceOf('Scalr\\Service\\CloudStack\\DataType\\VirtualMachineInstancesList', $vms);
foreach ($vms as $vm) {
$this->assertEquals(60975, $vm->id);
$this->assertEquals("i-882-60975-VM", $vm->name);
$this->assertEquals("c5911bcc-c0fa-4a4e-8ee6-1a5f7811e077", $vm->displayname);
$this->assertEquals("Scalr-User1", $vm->account);
$this->assertEquals(1105, $vm->domainid);
$this->assertEquals("70000001100", $vm->domain);
$this->assertEquals(new DateTime("2014-05-13T22:14:14+0900", new DateTimeZone('UTC')), $vm->created);
$this->assertEquals("Stopped", $vm->state);
$this->assertEquals(false, $vm->haenable);
$this->assertEquals(5949, $vm->groupid);
$this->assertEquals("rabbitmq-ubuntu1204-devel", $vm->group);
$this->assertEquals(2, $vm->zoneid);
$this->assertEquals("jp-east-f2v", $vm->zonename);
$this->assertEquals(4668, $vm->templateid);
$this->assertEquals("mbeh1-ubuntu1204-devel-09102013", $vm->templatename);
$this->assertEquals("mbeh1-ubuntu1204-devel", $vm->templatedisplaytext);
$this->assertEquals(true, $vm->passwordenabled);
$this->assertEquals(30, $vm->serviceofferingid);
$this->assertEquals("S2", $vm->serviceofferingname);
$this->assertEquals(1, $vm->cpunumber);
$this->assertEquals(1600, $vm->cpuspeed);
$this->assertEquals(2048, $vm->memory);
$this->assertEquals(100, $vm->guestosid);
$this->assertEquals(0, $vm->rootdeviceid);
$this->assertEquals("Not created", $vm->rootdevicetype);
$this->assertEquals("VMware", $vm->hypervisor);
$this->assertInstanceOf('Scalr\\Service\\CloudStack\\DataType\\AffinityGroupList', $vm->affinitygroup);
foreach ($vm->affinitygroup as $affinitygroup) {
$this->assertEquals(1, $affinitygroup->id);
$this->assertEquals("Scalr", $affinitygroup->account);
$this->assertEquals("test", $affinitygroup->description);
$this->assertEquals("test.com", $affinitygroup->domain);
$this->assertEquals(42, $affinitygroup->domainid);
$this->assertEquals("testio", $affinitygroup->name);
$this->assertEquals("test", $affinitygroup->type);
$this->assertEquals("32", $affinitygroup->virtualmachineIds);
break;
}
$this->assertInstanceOf('Scalr\\Service\\CloudStack\\DataType\\SecurityGroupList', $vm->securitygroup);
foreach ($vm->securitygroup as $securitygroup) {
$this->assertEquals(1, $securitygroup->id);
$this->assertEquals("Scalr", $securitygroup->account);
$this->assertEquals("test", $securitygroup->description);
$this->assertEquals("test.com", $securitygroup->domain);
$this->assertEquals(42, $securitygroup->domainid);
$this->assertEquals("testio", $securitygroup->name);
$this->assertEquals("test", $securitygroup->project);
$this->assertEquals(32, $securitygroup->projectid);
$this->assertEquals(666, $securitygroup->jobid);
$this->assertEquals("pending", $securitygroup->jobstatus);
$this->assertInstanceOf('Scalr\\Service\\CloudStack\\DataType\\EgressruleList', $securitygroup->egressrule);
foreach ($securitygroup->egressrule as $egressrule) {
$this->assertEquals("testio", $egressrule->account);
$this->assertEquals("testio", $egressrule->cidr);
$this->assertEquals(80, $egressrule->endport);
$this->assertEquals(42, $egressrule->icmpcode);
$this->assertEquals("testing", $egressrule->icmptype);
$this->assertEquals("http", $egressrule->protocol);
$this->assertEquals(666, $egressrule->ruleid);
$this->assertEquals("testio", $egressrule->securitygroupname);
$this->assertEquals(81, $egressrule->startport);
break;
}
$this->assertInstanceOf('Scalr\\Service\\CloudStack\\DataType\\IngressruleList', $securitygroup->ingressrule);
foreach ($securitygroup->ingressrule as $ingressrule) {
$this->assertEquals("testio", $ingressrule->account);
$this->assertEquals("testio", $ingressrule->cidr);
$this->assertEquals(80, $ingressrule->endport);
$this->assertEquals(42, $ingressrule->icmpcode);
$this->assertEquals("testing", $ingressrule->icmptype);
$this->assertEquals("http", $ingressrule->protocol);
$this->assertEquals(666, $ingressrule->ruleid);
$this->assertEquals("testio", $ingressrule->securitygroupname);
$this->assertEquals(81, $ingressrule->startport);
break;
}
$this->assertInstanceOf('Scalr\\Service\\CloudStack\\DataType\\ResponseTagsList', $securitygroup->tags);
foreach ($securitygroup->tags as $tag) {
$this->assertEquals("testio", $tag->account);
$this->assertEquals("testio", $tag->customer);
$this->assertEquals("test.com", $tag->domain);
$this->assertEquals(42, $tag->domainid);
$this->assertEquals("key test", $tag->key);
$this->assertEquals("Project Test", $tag->project);
$this->assertEquals(666, $tag->projectid);
$this->assertEquals(11, $tag->resourceid);
$this->assertEquals("test", $tag->resourcetype);
$this->assertEquals("testvalue", $tag->value);
break;
}
unset($tag);
}
break;
}
$vmArray = $vms->toArray();
$this->assertArrayHasKey('nic', $vmArray[0]);
$this->assertArrayHasKey('securitygroup', $vmArray[0]);
$this->assertArrayHasKey('tags', $vmArray[0]);
$this->assertEmpty($vmArray[0]['tags']);
$this->assertArrayHasKey('affinitygroup', $vmArray[0]);
$fixtureArray = (include $this->getFixtureFilePath(substr(__FUNCTION__, 4) . '.php'));
$this->assertEquals($fixtureArray, $vmArray);
}