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),
PRIVATE_IP_ADDRESSES(5),
SECONDARY_STORAGE_USED_BYTES(6),
VLANS(7),
DIRECT_ATTACHED_PUBLIC_IP_ADDRESSES(8),
LOCAL_STORAGE_USED_BYTES(9),
UNRECOGNIZED(Integer.MAX_VALUE);
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
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
public CreateNetworkOptions domainId(long domainId) {

View File

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

View File

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

View File

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

View File

@ -99,7 +99,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
// Create a VM and stop it
Long templateId = (imageId != null && !"".equals(imageId)) ? new Long(imageId) : null;
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
Set<Volume> volumes = client.getVolumeClient().listVolumes(ListVolumesOptions.Builder.virtualMachineId(vmForCreation.getId()));
@ -109,7 +109,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
// Create a template
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);
assert jobComplete.apply(response.getJobId()) : vmForCreation;
assertTrue(jobComplete.apply(response.getJobId()), vmForCreation.toString());
createdTemplate = client.getTemplateClient().getTemplateInZone(response.getId(), vmForCreation.getZoneId());
// Assertions
@ -120,7 +120,7 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
public void testExtractTemplate() throws Exception {
// Initiate the extraction and wait for it to complete
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
AsyncJob<TemplateExtraction> asyncJob = client.getAsyncJobClient().getAsyncJob(response.getJobId());
@ -180,13 +180,13 @@ public class TemplateClientLiveTest extends BaseCloudStackClientLiveTest {
@AfterGroups(groups = "live")
protected void tearDown() {
if (vmForCreation != null) {
assert jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())) : vmForCreation;
assert jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForCreation.getId())) : vmForCreation;
assert virtualMachineDestroyed.apply(vmForCreation);
assertTrue(jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForCreation.getId())), vmForCreation.toString());
assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForCreation.getId())), vmForCreation.toString());
assertTrue(virtualMachineDestroyed.apply(vmForCreation));
}
if (vmForRegistration != null) {
assert jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForRegistration.getId())) : vmForRegistration;
assert jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForRegistration.getId())) : vmForRegistration;
assertTrue(jobComplete.apply(client.getVirtualMachineClient().stopVirtualMachine(vmForRegistration.getId())), vmForRegistration.toString());
assertTrue(jobComplete.apply(client.getVirtualMachineClient().destroyVirtualMachine(vmForRegistration.getId())), vmForRegistration.toString());
assert virtualMachineDestroyed.apply(vmForRegistration);
}
if (createdTemplate != null) {

View File

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