mirror of https://github.com/apache/jclouds.git
Issue 388: added adminPassword to Image and NodeMetadata, and corrected runScript process to use them
This commit is contained in:
parent
a9fe466614
commit
b4ad8fed1f
|
@ -31,8 +31,8 @@ import org.jclouds.scriptbuilder.domain.OsFamily;
|
|||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
import org.jclouds.ssh.ExecResponse;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.util.Utils;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
|
@ -77,8 +77,9 @@ public class InitAndStartScriptOnNode implements SshCallable<ExecResponse> {
|
|||
|
||||
protected ExecResponse runCommand(String command) {
|
||||
ExecResponse returnVal;
|
||||
logger.debug(">> running [%s] as %s@%s", command.replace(node.getCredentials().credential, "XXXXX"), node
|
||||
.getCredentials().identity, Iterables.get(node.getPublicAddresses(), 0));
|
||||
logger.debug(">> running [%s] as %s@%s", command.replace(node.getAdminPassword() != null ? node
|
||||
.getAdminPassword() : "XXXXX", "XXXXX"), node.getCredentials().identity, Iterables.get(node
|
||||
.getPublicAddresses(), 0));
|
||||
returnVal = ssh.exec(command);
|
||||
return returnVal;
|
||||
}
|
||||
|
@ -89,15 +90,15 @@ public class InitAndStartScriptOnNode implements SshCallable<ExecResponse> {
|
|||
this.ssh = checkNotNull(ssh, "ssh");
|
||||
}
|
||||
|
||||
protected String execScriptAsRoot(String action) {
|
||||
@VisibleForTesting
|
||||
public String execScriptAsRoot(String action) {
|
||||
String command;
|
||||
if (node.getCredentials().identity.equals("root")) {
|
||||
command = "./" + init.getInstanceName() + " " + action;
|
||||
} else if (Utils.isPrivateKeyCredential(node.getCredentials())) {
|
||||
command = "sudo ./" + init.getInstanceName() + " " + action;
|
||||
} else if (node.getAdminPassword() != null) {
|
||||
command = String.format("echo '%s'|sudo -S ./%s %s", node.getAdminPassword(), init.getInstanceName(), action);
|
||||
} else {
|
||||
command = String.format("echo '%s'|sudo -S ./%s %s", node.getCredentials().credential, init.getInstanceName(),
|
||||
action);
|
||||
command = "sudo ./" + init.getInstanceName() + " " + action;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
|
||||
package org.jclouds.compute.domain;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.compute.domain.internal.ImageImpl;
|
||||
import org.jclouds.domain.Credentials;
|
||||
|
||||
|
@ -48,6 +50,17 @@ public interface Image extends ComputeMetadata {
|
|||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* secures access to root with a password. This password is required to access either the console
|
||||
* or run sudo as root.
|
||||
* <p/>
|
||||
* ex. {@code echo 'password' |sudo -S command}
|
||||
*
|
||||
* @return root or console password, if configured, or null.
|
||||
*/
|
||||
@Nullable
|
||||
String getAdminPassword();
|
||||
|
||||
/**
|
||||
* Default credentials for the current image
|
||||
*/
|
||||
|
|
|
@ -37,6 +37,8 @@ public class ImageBuilder extends ComputeMetadataBuilder {
|
|||
private OperatingSystem operatingSystem;
|
||||
private String version;
|
||||
private String description;
|
||||
@Nullable
|
||||
private String adminPassword;
|
||||
private Credentials defaultCredentials;
|
||||
|
||||
public ImageBuilder() {
|
||||
|
@ -58,6 +60,11 @@ public class ImageBuilder extends ComputeMetadataBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ImageBuilder adminPassword(@Nullable String adminPassword) {
|
||||
this.adminPassword = adminPassword;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ImageBuilder defaultCredentials(@Nullable Credentials defaultCredentials) {
|
||||
this.defaultCredentials = defaultCredentials;
|
||||
return this;
|
||||
|
@ -101,7 +108,14 @@ public class ImageBuilder extends ComputeMetadataBuilder {
|
|||
@Override
|
||||
public Image build() {
|
||||
return new ImageImpl(providerId, name, id, location, uri, userMetadata, operatingSystem, description, version,
|
||||
defaultCredentials);
|
||||
adminPassword, defaultCredentials);
|
||||
}
|
||||
|
||||
public static ImageBuilder fromImage(Image image) {
|
||||
return new ImageBuilder().providerId(image.getProviderId()).name(image.getName()).id(image.getId()).location(
|
||||
image.getLocation()).uri(image.getUri()).userMetadata(image.getUserMetadata()).version(
|
||||
image.getVersion()).description(image.getDescription()).operatingSystem(image.getOperatingSystem())
|
||||
.adminPassword(image.getAdminPassword()).defaultCredentials(image.getDefaultCredentials());
|
||||
}
|
||||
|
||||
}
|
|
@ -75,6 +75,17 @@ public interface NodeMetadata extends ComputeMetadata {
|
|||
*/
|
||||
int getLoginPort();
|
||||
|
||||
/**
|
||||
* secures access to root with a password. This password is required to access either the console
|
||||
* or run sudo as root.
|
||||
* <p/>
|
||||
* ex. {@code echo 'password' |sudo -S command}
|
||||
*
|
||||
* @return root or console password, if configured, or null.
|
||||
*/
|
||||
@Nullable
|
||||
String getAdminPassword();
|
||||
|
||||
/**
|
||||
* If possible, these are returned upon all detail requests. However, it is often the case that
|
||||
* credentials are only available at "run" time.
|
||||
|
|
|
@ -42,6 +42,8 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
|||
private Set<String> publicAddresses = Sets.newLinkedHashSet();
|
||||
private Set<String> privateAddresses = Sets.newLinkedHashSet();
|
||||
@Nullable
|
||||
private String adminPassword;
|
||||
@Nullable
|
||||
private Credentials credentials;
|
||||
@Nullable
|
||||
private String tag;
|
||||
|
@ -82,6 +84,11 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public NodeMetadataBuilder adminPassword(@Nullable String adminPassword) {
|
||||
this.adminPassword = adminPassword;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NodeMetadataBuilder tag(@Nullable String tag) {
|
||||
this.tag = tag;
|
||||
return this;
|
||||
|
@ -140,15 +147,16 @@ public class NodeMetadataBuilder extends ComputeMetadataBuilder {
|
|||
@Override
|
||||
public NodeMetadata build() {
|
||||
return new NodeMetadataImpl(providerId, name, id, location, uri, userMetadata, tag, hardware, imageId, os, state,
|
||||
loginPort, publicAddresses, privateAddresses, credentials);
|
||||
loginPort, publicAddresses, privateAddresses, adminPassword, credentials);
|
||||
}
|
||||
|
||||
public static NodeMetadataBuilder fromNodeMetadata(NodeMetadata node) {
|
||||
return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId())
|
||||
.location(node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tag(node.getTag())
|
||||
.hardware(node.getHardware()).imageId(node.getImageId()).operatingSystem(node.getOperatingSystem())
|
||||
.state(node.getState()).loginPort(node.getLoginPort()).publicAddresses(node.getPublicAddresses())
|
||||
.privateAddresses(node.getPrivateAddresses()).credentials(node.getCredentials());
|
||||
return new NodeMetadataBuilder().providerId(node.getProviderId()).name(node.getName()).id(node.getId()).location(
|
||||
node.getLocation()).uri(node.getUri()).userMetadata(node.getUserMetadata()).tag(node.getTag()).hardware(
|
||||
node.getHardware()).imageId(node.getImageId()).operatingSystem(node.getOperatingSystem()).state(
|
||||
node.getState()).loginPort(node.getLoginPort()).publicAddresses(node.getPublicAddresses())
|
||||
.privateAddresses(node.getPrivateAddresses()).adminPassword(node.getAdminPassword()).credentials(
|
||||
node.getCredentials());
|
||||
}
|
||||
|
||||
}
|
|
@ -43,15 +43,18 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
|||
private final OperatingSystem operatingSystem;
|
||||
private final String version;
|
||||
private final String description;
|
||||
@Nullable
|
||||
private final String adminPassword;
|
||||
private final Credentials defaultCredentials;
|
||||
|
||||
public ImageImpl(String providerId, String name, String id, Location location, URI uri,
|
||||
Map<String, String> userMetadata, OperatingSystem operatingSystem, String description,
|
||||
@Nullable String version, @Nullable Credentials defaultCredentials) {
|
||||
Map<String, String> userMetadata, OperatingSystem operatingSystem, String description,
|
||||
@Nullable String version, @Nullable String adminPassword, @Nullable Credentials defaultCredentials) {
|
||||
super(ComputeType.IMAGE, providerId, name, id, location, uri, userMetadata);
|
||||
this.operatingSystem = checkNotNull(operatingSystem, "operatingSystem");
|
||||
this.version = version;
|
||||
this.description = checkNotNull(description, "description");
|
||||
this.adminPassword = adminPassword;
|
||||
this.defaultCredentials = defaultCredentials;
|
||||
}
|
||||
|
||||
|
@ -87,18 +90,27 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
|||
return defaultCredentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getAdminPassword() {
|
||||
return adminPassword;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + getId() + ", name=" + getName() + ", operatingSystem=" + operatingSystem + ", description="
|
||||
+ description + ", version=" + version + ", location=" + getLocation() + ", loginUser="
|
||||
+ ((defaultCredentials != null) ? defaultCredentials.identity : null) + ", userMetadata="
|
||||
+ getUserMetadata() + "]";
|
||||
+ description + ", version=" + version + ", location=" + getLocation() + ", loginUser="
|
||||
+ ((defaultCredentials != null) ? defaultCredentials.identity : null) + ", userMetadata="
|
||||
+ getUserMetadata() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((adminPassword == null) ? 0 : adminPassword.hashCode());
|
||||
result = prime * result + ((defaultCredentials == null) ? 0 : defaultCredentials.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((operatingSystem == null) ? 0 : operatingSystem.hashCode());
|
||||
|
@ -115,6 +127,11 @@ public class ImageImpl extends ComputeMetadataImpl implements Image {
|
|||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ImageImpl other = (ImageImpl) obj;
|
||||
if (adminPassword == null) {
|
||||
if (other.adminPassword != null)
|
||||
return false;
|
||||
} else if (!adminPassword.equals(other.adminPassword))
|
||||
return false;
|
||||
if (defaultCredentials == null) {
|
||||
if (other.defaultCredentials != null)
|
||||
return false;
|
||||
|
|
|
@ -51,6 +51,8 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
private final Set<String> publicAddresses;
|
||||
private final Set<String> privateAddresses;
|
||||
@Nullable
|
||||
private final String adminPassword;
|
||||
@Nullable
|
||||
private final Credentials credentials;
|
||||
@Nullable
|
||||
private final String tag;
|
||||
|
@ -62,9 +64,10 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
private final OperatingSystem os;
|
||||
|
||||
public NodeMetadataImpl(String providerId, String name, String id, Location location, URI uri,
|
||||
Map<String, String> userMetadata, @Nullable String tag, @Nullable Hardware hardware, @Nullable String imageId,
|
||||
@Nullable OperatingSystem os, NodeState state, int loginPort, Iterable<String> publicAddresses,
|
||||
Iterable<String> privateAddresses, @Nullable Credentials credentials) {
|
||||
Map<String, String> userMetadata, @Nullable String tag, @Nullable Hardware hardware,
|
||||
@Nullable String imageId, @Nullable OperatingSystem os, NodeState state, int loginPort,
|
||||
Iterable<String> publicAddresses, Iterable<String> privateAddresses, @Nullable String adminPassword,
|
||||
@Nullable Credentials credentials) {
|
||||
super(ComputeType.NODE, providerId, name, id, location, uri, userMetadata);
|
||||
this.tag = tag;
|
||||
this.hardware = hardware;
|
||||
|
@ -74,6 +77,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
this.loginPort = loginPort;
|
||||
this.publicAddresses = ImmutableSet.copyOf(checkNotNull(publicAddresses, "publicAddresses"));
|
||||
this.privateAddresses = ImmutableSet.copyOf(checkNotNull(privateAddresses, "privateAddresses"));
|
||||
this.adminPassword = adminPassword;
|
||||
this.credentials = credentials;
|
||||
}
|
||||
|
||||
|
@ -93,6 +97,14 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
return hardware;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getAdminPassword() {
|
||||
return adminPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -152,11 +164,11 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
@Override
|
||||
public String toString() {
|
||||
return "[id=" + getId() + ", providerId=" + getProviderId() + ", tag=" + getTag() + ", name=" + getName()
|
||||
+ ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os="
|
||||
+ getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort() + ", privateAddresses="
|
||||
+ privateAddresses + ", publicAddresses=" + publicAddresses + ", hardware=" + getHardware()
|
||||
+ ", loginUser=" + ((credentials != null) ? credentials.identity : null) + ", userMetadata="
|
||||
+ getUserMetadata() + "]";
|
||||
+ ", location=" + getLocation() + ", uri=" + getUri() + ", imageId=" + getImageId() + ", os="
|
||||
+ getOperatingSystem() + ", state=" + getState() + ", loginPort=" + getLoginPort()
|
||||
+ ", privateAddresses=" + privateAddresses + ", publicAddresses=" + publicAddresses + ", hardware="
|
||||
+ getHardware() + ", loginUser=" + ((credentials != null) ? credentials.identity : null)
|
||||
+ ", userMetadata=" + getUserMetadata() + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -170,6 +182,7 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
result = prime * result + ((imageId == null) ? 0 : imageId.hashCode());
|
||||
result = prime * result + ((hardware == null) ? 0 : hardware.hashCode());
|
||||
result = prime * result + ((os == null) ? 0 : os.hashCode());
|
||||
result = prime * result + ((adminPassword == null) ? 0 : adminPassword.hashCode());
|
||||
result = prime * result + ((credentials == null) ? 0 : credentials.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
@ -215,6 +228,11 @@ public class NodeMetadataImpl extends ComputeMetadataImpl implements NodeMetadat
|
|||
return false;
|
||||
} else if (!os.equals(other.os))
|
||||
return false;
|
||||
if (adminPassword == null) {
|
||||
if (other.adminPassword != null)
|
||||
return false;
|
||||
} else if (!adminPassword.equals(other.adminPassword))
|
||||
return false;
|
||||
if (credentials == null) {
|
||||
if (other.credentials != null)
|
||||
return false;
|
||||
|
|
|
@ -158,8 +158,8 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
if (context != null)
|
||||
context.close();
|
||||
Properties props = setupProperties();
|
||||
context = new ComputeServiceContextFactory().createContext(provider,
|
||||
ImmutableSet.of(new Log4JLoggingModule(), getSshModule()), props);
|
||||
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.of(new Log4JLoggingModule(),
|
||||
getSshModule()), props);
|
||||
client = context.getComputeService();
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,8 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
public void testCorrectAuthException() throws Exception {
|
||||
ComputeServiceContext context = null;
|
||||
try {
|
||||
context = new ComputeServiceContextFactory().createContext(provider, "MOMMA", "MIA",
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule()));
|
||||
context = new ComputeServiceContextFactory().createContext(provider, "MOMMA", "MIA", ImmutableSet
|
||||
.<Module> of(new Log4JLoggingModule()));
|
||||
context.getComputeService().listNodes();
|
||||
} catch (AuthorizationException e) {
|
||||
throw e;
|
||||
|
@ -214,7 +214,7 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
OperatingSystem os = get(nodes, 0).getOperatingSystem();
|
||||
try {
|
||||
Map<? extends NodeMetadata, ExecResponse> responses = runScriptWithCreds(tag, os, new Credentials(
|
||||
good.identity, "romeo"));
|
||||
good.identity, "romeo"));
|
||||
assert false : "shouldn't pass with a bad password\n" + responses;
|
||||
} catch (RunScriptOnNodesException e) {
|
||||
assert getRootCause(e).getMessage().contains("Auth fail") : e;
|
||||
|
@ -247,11 +247,11 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
}
|
||||
|
||||
template = client.templateBuilder().options(blockOnComplete(false).blockOnPort(8080, 600).inboundPorts(22, 8080))
|
||||
.build();
|
||||
.build();
|
||||
// note this is a dependency on the template resolution
|
||||
template.getOptions().runScript(
|
||||
RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage()
|
||||
.getOperatingSystem()));
|
||||
RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage()
|
||||
.getOperatingSystem()));
|
||||
try {
|
||||
NodeMetadata node = getOnlyElement(client.runNodesWithTag(tag, 1, template));
|
||||
|
||||
|
@ -299,7 +299,7 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
template = buildTemplate(client.templateBuilder());
|
||||
|
||||
template.getOptions().installPrivateKey(keyPair.get("private")).authorizePublicKey(keyPair.get("public"))
|
||||
.runScript(newStringPayload(buildScript(template.getImage().getOperatingSystem())));
|
||||
.runScript(newStringPayload(buildScript(template.getImage().getOperatingSystem())));
|
||||
}
|
||||
|
||||
protected void checkImageIdMatchesTemplate(NodeMetadata node) {
|
||||
|
@ -310,8 +310,8 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
protected void checkOsMatchesTemplate(NodeMetadata node) {
|
||||
if (node.getOperatingSystem() != null)
|
||||
assert node.getOperatingSystem().getFamily().equals(template.getImage().getOperatingSystem().getFamily()) : String
|
||||
.format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(),
|
||||
node.getOperatingSystem());
|
||||
.format("expecting family %s but got %s", template.getImage().getOperatingSystem().getFamily(), node
|
||||
.getOperatingSystem());
|
||||
}
|
||||
|
||||
void assertLocationSameOrChild(Location test, Location expected) {
|
||||
|
@ -343,10 +343,10 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
}
|
||||
|
||||
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String tag, OperatingSystem os,
|
||||
Credentials creds) throws RunScriptOnNodesException {
|
||||
Credentials creds) throws RunScriptOnNodesException {
|
||||
try {
|
||||
return client.runScriptOnNodesMatching(runningWithTag(tag), newStringPayload(buildScript(os)),
|
||||
overrideCredentialsWith(creds).nameTask("runScriptWithCreds"));
|
||||
overrideCredentialsWith(creds).nameTask("runScriptWithCreds"));
|
||||
} catch (SshException e) {
|
||||
throw e;
|
||||
}
|
||||
|
@ -358,7 +358,8 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
assertNotNull(node.getTag());
|
||||
assertEquals(node.getTag(), tag);
|
||||
assertEquals(node.getState(), NodeState.RUNNING);
|
||||
assertEquals(context.getCredentialStore().get(node.getId()), node.getCredentials());
|
||||
Credentials fromStore = context.getCredentialStore().get(node.getId());
|
||||
assertEquals(fromStore, node.getCredentials());
|
||||
assert node.getPublicAddresses().size() >= 1 || node.getPrivateAddresses().size() >= 1 : "no ips in" + node;
|
||||
assertNotNull(node.getCredentials());
|
||||
if (node.getCredentials().identity != null) {
|
||||
|
@ -375,16 +376,16 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
|
||||
@Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired")
|
||||
public void testGet() throws Exception {
|
||||
Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(
|
||||
filter(client.listNodesDetailsMatching(all()), and(withTag(tag), not(TERMINATED))),
|
||||
new Function<NodeMetadata, String>() {
|
||||
Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(filter(client
|
||||
.listNodesDetailsMatching(all()), and(withTag(tag), not(TERMINATED))),
|
||||
new Function<NodeMetadata, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(NodeMetadata from) {
|
||||
return from.getId();
|
||||
}
|
||||
@Override
|
||||
public String apply(NodeMetadata from) {
|
||||
return from.getId();
|
||||
}
|
||||
|
||||
}));
|
||||
}));
|
||||
for (NodeMetadata node : nodes) {
|
||||
metadataMap.remove(node.getId());
|
||||
NodeMetadata metadata = client.getNodeMetadata(node.getId());
|
||||
|
@ -402,7 +403,7 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
|
||||
protected void assertNodeZero(Collection<? extends NodeMetadata> metadataSet) {
|
||||
assert metadataSet.size() == 0 : String.format("nodes left in set: [%s] which didn't match set: [%s]",
|
||||
metadataSet, nodes);
|
||||
metadataSet, nodes);
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "testGet")
|
||||
|
@ -463,26 +464,26 @@ public abstract class BaseComputeServiceLiveTest {
|
|||
assert location != location.getParent() : location;
|
||||
assert location.getScope() != null : location;
|
||||
switch (location.getScope()) {
|
||||
case PROVIDER:
|
||||
assertProvider(location);
|
||||
break;
|
||||
case REGION:
|
||||
assertProvider(location.getParent());
|
||||
break;
|
||||
case ZONE:
|
||||
Location provider = location.getParent().getParent();
|
||||
// zone can be a direct descendant of provider
|
||||
if (provider == null)
|
||||
provider = location.getParent();
|
||||
assertProvider(provider);
|
||||
break;
|
||||
case HOST:
|
||||
Location provider2 = location.getParent().getParent().getParent();
|
||||
// zone can be a direct descendant of provider
|
||||
if (provider2 == null)
|
||||
provider2 = location.getParent().getParent();
|
||||
assertProvider(provider2);
|
||||
break;
|
||||
case PROVIDER:
|
||||
assertProvider(location);
|
||||
break;
|
||||
case REGION:
|
||||
assertProvider(location.getParent());
|
||||
break;
|
||||
case ZONE:
|
||||
Location provider = location.getParent().getParent();
|
||||
// zone can be a direct descendant of provider
|
||||
if (provider == null)
|
||||
provider = location.getParent();
|
||||
assertProvider(provider);
|
||||
break;
|
||||
case HOST:
|
||||
Location provider2 = location.getParent().getParent().getParent();
|
||||
// zone can be a direct descendant of provider
|
||||
if (provider2 == null)
|
||||
provider2 = location.getParent().getParent();
|
||||
assertProvider(provider2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue