Merge branch 'master' of https://github.com/jclouds/jclouds into sync-domain-objects

This commit is contained in:
vijaykiran 2011-12-07 15:01:51 +01:00
commit ead59590f8
7 changed files with 57 additions and 35 deletions

View File

@ -102,6 +102,9 @@ public class Capacity implements Comparable<Capacity> {
PUBLIC_IP_ADDRESSES(4), PUBLIC_IP_ADDRESSES(4),
PRIVATE_IP_ADDRESSES(5), PRIVATE_IP_ADDRESSES(5),
SECONDARY_STORAGE_USED_BYTES(6), SECONDARY_STORAGE_USED_BYTES(6),
VLANS(7),
DIRECT_ATTACHED_PUBLIC_IP_ADDRESSES(8),
LOCAL_STORAGE_USED_BYTES(9),
UNRECOGNIZED(Integer.MAX_VALUE); UNRECOGNIZED(Integer.MAX_VALUE);
private int code; private int code;

View File

@ -187,7 +187,16 @@ public class CreateNetworkOptions extends AccountInDomainOptions {
} }
/** /**
* {@inheritDoc} * Specify the account that will own the network. This can be run by a privileged user to be
* able to set advanced network properties, such as the VLAN tag, and then to immediately pass
* ownership of the network to an unprivileged user.
*
* Note that the unprivileged user will be able to delete the network later, since they are it's owner.
*
* @param account
* account name
* @param domain
* domain ID
*/ */
@Override @Override
public CreateNetworkOptions accountInDomain(String account, long domain) { public CreateNetworkOptions accountInDomain(String account, long domain) {
@ -195,7 +204,16 @@ public class CreateNetworkOptions extends AccountInDomainOptions {
} }
/** /**
* {@inheritDoc} * Specify the domain that will own the network. Any user in the domain can then use this
* network.
*
* CloudStack requires that when using this option, you also specify isShared(true).
*
* Changes or deletions to this network must be done by a domain admin in the same domain, or a
* global admin.
*
* @param domainId
* domain ID
*/ */
@Override @Override
public CreateNetworkOptions domainId(long domainId) { public CreateNetworkOptions domainId(long domainId) {

View File

@ -76,7 +76,7 @@ public class FirewallClientLiveTest extends BaseCloudStackClientLiveTest {
try { try {
AsyncCreateResponse job = client.getFirewallClient().createPortForwardingRuleForVirtualMachine(vm.getId(), AsyncCreateResponse job = client.getFirewallClient().createPortForwardingRuleForVirtualMachine(vm.getId(),
ip.getId(), "tcp", 22, 22); ip.getId(), "tcp", 22, 22);
assert jobComplete.apply(job.getJobId()); assertTrue(jobComplete.apply(job.getJobId()));
rule = findRuleWithId(job.getId()); rule = findRuleWithId(job.getId());
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// very likely an ip conflict, so retry; // very likely an ip conflict, so retry;

View File

@ -105,10 +105,10 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
public void testAssignToLoadBalancerRule() throws Exception { public void testAssignToLoadBalancerRule() throws Exception {
if (networksDisabled) if (networksDisabled)
return; return;
assert jobComplete.apply(client.getLoadBalancerClient().assignVirtualMachinesToLoadBalancerRule(rule.getId(), assertTrue(jobComplete.apply(client.getLoadBalancerClient().assignVirtualMachinesToLoadBalancerRule(rule.getId(),
vm.getId())); vm.getId())));
assertEquals(client.getLoadBalancerClient().listVirtualMachinesAssignedToLoadBalancerRule(rule.getId()).size(), 1); assertEquals(client.getLoadBalancerClient().listVirtualMachinesAssignedToLoadBalancerRule(rule.getId()).size(), 1);
assert loadBalancerRuleActive.apply(rule) : rule; assertTrue(loadBalancerRuleActive.apply(rule), rule.toString());
loopAndCheckSSH(); loopAndCheckSSH();
} }
@ -134,8 +134,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
public void testRemoveFromLoadBalancerRule() throws Exception { public void testRemoveFromLoadBalancerRule() throws Exception {
if (networksDisabled) if (networksDisabled)
throw new SshException(); throw new SshException();
assert jobComplete.apply(client.getLoadBalancerClient().removeVirtualMachinesFromLoadBalancerRule(rule.getId(), assertTrue(jobComplete.apply(client.getLoadBalancerClient().removeVirtualMachinesFromLoadBalancerRule(rule.getId(),
vm.getId())); vm.getId())));
assertEquals(client.getLoadBalancerClient().listVirtualMachinesAssignedToLoadBalancerRule(rule.getId()).size(), 0); assertEquals(client.getLoadBalancerClient().listVirtualMachinesAssignedToLoadBalancerRule(rule.getId()).size(), 0);
assertEquals(rule.getState(), State.ADD); assertEquals(rule.getState(), State.ADD);
checkSSH(new IPSocket(ip.getIPAddress(), 22)); checkSSH(new IPSocket(ip.getIPAddress(), 22));
@ -144,10 +144,10 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { protected void tearDown() {
if (rule != null) { if (rule != null) {
assert jobComplete.apply(client.getLoadBalancerClient().deleteLoadBalancerRule(rule.getId())); assertTrue(jobComplete.apply(client.getLoadBalancerClient().deleteLoadBalancerRule(rule.getId())));
} }
if (vm != null) { if (vm != null) {
assert jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId())); assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId())));
} }
if (ip != null) { if (ip != null) {
client.getAddressClient().disassociateIPAddress(ip.getId()); client.getAddressClient().disassociateIPAddress(ip.getId());

View File

@ -19,6 +19,7 @@
package org.jclouds.cloudstack.features; package org.jclouds.cloudstack.features;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@ -71,7 +72,7 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
for (SecurityGroup securityGroup : client.getSecurityGroupClient().listSecurityGroups( for (SecurityGroup securityGroup : client.getSecurityGroupClient().listSecurityGroups(
ListSecurityGroupsOptions.Builder.named(prefix))) { ListSecurityGroupsOptions.Builder.named(prefix))) {
for (IngressRule rule : securityGroup.getIngressRules()) for (IngressRule rule : securityGroup.getIngressRules())
assert this.jobComplete.apply(client.getSecurityGroupClient().revokeIngressRule(rule.getId())) : rule; assertTrue(jobComplete.apply(client.getSecurityGroupClient().revokeIngressRule(rule.getId())), rule.toString());
client.getSecurityGroupClient().deleteSecurityGroup(securityGroup.getId()); client.getSecurityGroupClient().deleteSecurityGroup(securityGroup.getId());
} }
group = client.getSecurityGroupClient().createSecurityGroup(prefix); group = client.getSecurityGroupClient().createSecurityGroup(prefix);
@ -101,9 +102,9 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
return; return;
String cidr = getCurrentCIDR(); String cidr = getCurrentCIDR();
ImmutableSet<String> cidrs = ImmutableSet.of(cidr); ImmutableSet<String> cidrs = ImmutableSet.of(cidr);
assert jobComplete.apply(client.getSecurityGroupClient().authorizeIngressICMPToCIDRs(group.getId(), 0, 8, cidrs)) : group; assertTrue(jobComplete.apply(client.getSecurityGroupClient().authorizeIngressICMPToCIDRs(group.getId(), 0, 8, cidrs)), group.toString());
assert jobComplete.apply(client.getSecurityGroupClient().authorizeIngressPortsToCIDRs(group.getId(), "TCP", 22, assertTrue(jobComplete.apply(client.getSecurityGroupClient().authorizeIngressPortsToCIDRs(group.getId(), "TCP", 22,
22, cidrs)) : group; 22, cidrs)), group.toString());
AccountInDomainOptions.Builder.accountInDomain(group.getAccount(), group.getDomainId()); AccountInDomainOptions.Builder.accountInDomain(group.getAccount(), group.getDomainId());
@ -197,11 +198,11 @@ public class SecurityGroupClientLiveTest extends BaseCloudStackClientLiveTest {
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { protected void tearDown() {
if (vm != null) { if (vm != null) {
assert jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId())); assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vm.getId())));
} }
if (group != null) { if (group != null) {
for (IngressRule rule : group.getIngressRules()) for (IngressRule rule : group.getIngressRules())
assert this.jobComplete.apply(client.getSecurityGroupClient().revokeIngressRule(rule.getId())) : rule; assertTrue(jobComplete.apply(client.getSecurityGroupClient().revokeIngressRule(rule.getId())), rule.toString());
client.getSecurityGroupClient().deleteSecurityGroup(group.getId()); client.getSecurityGroupClient().deleteSecurityGroup(group.getId());
assertEquals(client.getSecurityGroupClient().getSecurityGroup(group.getId()), null); assertEquals(client.getSecurityGroupClient().getSecurityGroup(group.getId()), null);
} }

View File

@ -99,7 +99,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
// Create a VM and stop it // Create a VM and stop it
Long templateId = (imageId != null && !"".equals(imageId)) ? new Long(imageId) : null; Long templateId = (imageId != null && !"".equals(imageId)) ? new Long(imageId) : null;
vmForCreation = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, templateId, client, jobComplete, virtualMachineRunning); vmForCreation = VirtualMachineClientLiveTest.createVirtualMachineInNetwork(network, templateId, client, jobComplete, virtualMachineRunning);
assert jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())) : vmForCreation; assertTrue(jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())), vmForCreation.toString());
// Work out the VM's volume // Work out the VM's volume
Set<Volume> volumes = client.getVolumeClient().listVolumes(ListVolumesOptions.Builder.virtualMachineId(vmForCreation.getId())); Set<Volume> volumes = client.getVolumeClient().listVolumes(ListVolumesOptions.Builder.virtualMachineId(vmForCreation.getId()));
@ -109,7 +109,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
// Create a template // Create a template
CreateTemplateOptions options = CreateTemplateOptions.Builder.volumeId(volume.getId()); CreateTemplateOptions options = CreateTemplateOptions.Builder.volumeId(volume.getId());
AsyncCreateResponse response = client.getTemplateClient().createTemplate(TemplateMetadata.builder().name(prefix+"-createTemplate").osTypeId(vmForCreation.getGuestOSId()).displayText("jclouds live testCreateTemplate").build(), options); AsyncCreateResponse response = client.getTemplateClient().createTemplate(TemplateMetadata.builder().name(prefix+"-createTemplate").osTypeId(vmForCreation.getGuestOSId()).displayText("jclouds live testCreateTemplate").build(), options);
assert jobComplete.apply(response.getJobId()) : vmForCreation; assertTrue(jobComplete.apply(response.getJobId()), vmForCreation.toString());
createdTemplate = client.getTemplateClient().getTemplateInZone(response.getId(), vmForCreation.getZoneId()); createdTemplate = client.getTemplateClient().getTemplateInZone(response.getId(), vmForCreation.getZoneId());
// Assertions // Assertions
@ -120,7 +120,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
public void testExtractTemplate() throws Exception { public void testExtractTemplate() throws Exception {
// Initiate the extraction and wait for it to complete // Initiate the extraction and wait for it to complete
AsyncCreateResponse response = client.getTemplateClient().extractTemplate(registeredTemplate.getId(), ExtractMode.HTTP_DOWNLOAD, registeredTemplate.getZoneId()); AsyncCreateResponse response = client.getTemplateClient().extractTemplate(registeredTemplate.getId(), ExtractMode.HTTP_DOWNLOAD, registeredTemplate.getZoneId());
assert jobComplete.apply(response.getJobId()) : registeredTemplate; assertTrue(jobComplete.apply(response.getJobId()), registeredTemplate.toString());
// Get the result // Get the result
AsyncJob<TemplateExtraction> asyncJob = client.getAsyncJobClient().getAsyncJob(response.getJobId()); AsyncJob<TemplateExtraction> asyncJob = client.getAsyncJobClient().getAsyncJob(response.getJobId());
@ -180,13 +180,13 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
@AfterGroups(groups = "live") @AfterGroups(groups = "live")
protected void tearDown() { protected void tearDown() {
if (vmForCreation != null) { if (vmForCreation != null) {
assert jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())) : vmForCreation; assertTrue(jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())), vmForCreation.toString());
assert jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForCreation.getId())) : vmForCreation; assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForCreation.getId())), vmForCreation.toString());
assert virtualMachineDestroyed.apply(vmForCreation); assertTrue(virtualMachineDestroyed.apply(vmForCreation));
} }
if (vmForRegistration != null) { if (vmForRegistration != null) {
assert jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForRegistration.getId())) : vmForRegistration; assertTrue(jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForRegistration.getId())), vmForRegistration.toString());
assert jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForRegistration.getId())) : vmForRegistration; assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForRegistration.getId())), vmForRegistration.toString());
assert virtualMachineDestroyed.apply(vmForRegistration); assert virtualMachineDestroyed.apply(vmForRegistration);
} }
if (createdTemplate != null) { if (createdTemplate != null) {

View File

@ -155,7 +155,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
zoneId, options); zoneId, options);
AsyncCreateResponse job = client.getVirtualMachineClient().deployVirtualMachineInZone(zoneId, serviceOfferingId, AsyncCreateResponse job = client.getVirtualMachineClient().deployVirtualMachineInZone(zoneId, serviceOfferingId,
templateId, options); templateId, options);
assert jobComplete.apply(job.getJobId()); assertTrue(jobComplete.apply(job.getJobId()));
AsyncJob<VirtualMachine> jobWithResult = client.getAsyncJobClient().<VirtualMachine> getAsyncJob(job.getJobId()); AsyncJob<VirtualMachine> jobWithResult = client.getAsyncJobClient().<VirtualMachine> getAsyncJob(job.getJobId());
if (jobWithResult.getError() != null) if (jobWithResult.getError() != null)
Throwables.propagate(new ExecutionException(String.format("job %s failed with exception %s", job.getId(), Throwables.propagate(new ExecutionException(String.format("job %s failed with exception %s", job.getId(),
@ -166,7 +166,7 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
if (vm.isPasswordEnabled()) { if (vm.isPasswordEnabled()) {
assert vm.getPassword() != null : vm; assert vm.getPassword() != null : vm;
} }
assert virtualMachineRunning.apply(vm); assertTrue(virtualMachineRunning.apply(vm));
assertEquals(vm.getServiceOfferingId(), serviceOfferingId); assertEquals(vm.getServiceOfferingId(), serviceOfferingId);
assertEquals(vm.getTemplateId(), templateId); assertEquals(vm.getTemplateId(), templateId);
assertEquals(vm.getZoneId(), zoneId); assertEquals(vm.getZoneId(), zoneId);
@ -209,8 +209,8 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
} }
} }
assert adminJobComplete.apply( assertTrue(adminJobComplete.apply(
adminClient.getNetworkClient().deleteNetwork(net.getId())) : net; adminClient.getNetworkClient().deleteNetwork(net.getId())), net.toString());
} }
} }
@ -272,9 +272,9 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
} }
private void destroyMachine(VirtualMachine virtualMachine) { private void destroyMachine(VirtualMachine virtualMachine) {
assert adminJobComplete.apply( assertTrue(adminJobComplete.apply(
adminClient.getVirtualMachineClient().destroyVirtualMachine(virtualMachine.getId())) : virtualMachine; adminClient.getVirtualMachineClient().destroyVirtualMachine(virtualMachine.getId())), virtualMachine.toString());
assert adminVirtualMachineDestroyed.apply(virtualMachine); assertTrue(adminVirtualMachineDestroyed.apply(virtualMachine));
} }
private void conditionallyCheckSSH() { private void conditionallyCheckSSH() {
@ -294,13 +294,13 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
@Test(dependsOnMethods = "testCreateVirtualMachine") @Test(dependsOnMethods = "testCreateVirtualMachine")
public void testLifeCycle() throws Exception { public void testLifeCycle() throws Exception {
Long job = client.getVirtualMachineClient().stopVirtualMachine(vm.getId()); Long job = client.getVirtualMachineClient().stopVirtualMachine(vm.getId());
assert jobComplete.apply(job); assertTrue(jobComplete.apply(job));
vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId()); vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
assertEquals(vm.getState(), VirtualMachine.State.STOPPED); assertEquals(vm.getState(), VirtualMachine.State.STOPPED);
if (vm.isPasswordEnabled()) { if (vm.isPasswordEnabled()) {
job = client.getVirtualMachineClient().resetPasswordForVirtualMachine(vm.getId()); job = client.getVirtualMachineClient().resetPasswordForVirtualMachine(vm.getId());
assert jobComplete.apply(job); assertTrue(jobComplete.apply(job));
vm = client.getAsyncJobClient().<VirtualMachine> getAsyncJob(job).getResult(); vm = client.getAsyncJobClient().<VirtualMachine> getAsyncJob(job).getResult();
if (vm.getPassword() != null) { if (vm.getPassword() != null) {
conditionallyCheckSSH(); conditionallyCheckSSH();
@ -308,12 +308,12 @@ public class VirtualMachineClientLiveTest extends BaseCloudStackClientLiveTest {
} }
job = client.getVirtualMachineClient().startVirtualMachine(vm.getId()); job = client.getVirtualMachineClient().startVirtualMachine(vm.getId());
assert jobComplete.apply(job); assertTrue(jobComplete.apply(job));
vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId()); vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
assertEquals(vm.getState(), VirtualMachine.State.RUNNING); assertEquals(vm.getState(), VirtualMachine.State.RUNNING);
job = client.getVirtualMachineClient().rebootVirtualMachine(vm.getId()); job = client.getVirtualMachineClient().rebootVirtualMachine(vm.getId());
assert jobComplete.apply(job); assertTrue(jobComplete.apply(job));
vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId()); vm = client.getVirtualMachineClient().getVirtualMachine(vm.getId());
assertEquals(vm.getState(), VirtualMachine.State.RUNNING); assertEquals(vm.getState(), VirtualMachine.State.RUNNING);
} }