progress on deltacloud

This commit is contained in:
Adrian Cole 2011-03-29 16:59:04 -07:00
parent 15d8aecdac
commit 7a7ab9ecf2
6 changed files with 34 additions and 12 deletions

View File

@ -33,6 +33,7 @@ To run a local deltacloud server, do the following:
# export SSL_CERT_DIR=$HOME/certs # export SSL_CERT_DIR=$HOME/certs
# export SSL_CERT_FILE=$HOME/certs/cacert.pem # export SSL_CERT_FILE=$HOME/certs/cacert.pem
# jruby -S deltacloudd -i mock # jruby -S deltacloudd -i mock
* or if you are running from a src tree: jruby -S ./server/bin/deltacloudd -i <driver>
Here are some notes about specific cloud providers Here are some notes about specific cloud providers
* terremark * terremark

View File

@ -53,7 +53,7 @@
<!-- when instances are hung, open a ticket and add here --> <!-- when instances are hung, open a ticket and add here -->
<jclouds.compute.blacklist-nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist-nodes> <jclouds.compute.blacklist-nodes>trmkrun-ccc,test.trmk-924</jclouds.compute.blacklist-nodes>
<test.deltacloud.endpoint>http://localhost:3001/api</test.deltacloud.endpoint> <test.deltacloud.endpoint>http://localhost:3001/api</test.deltacloud.endpoint>
<test.deltacloud.apiversion>0.1.0</test.deltacloud.apiversion> <test.deltacloud.apiversion>0.1.2</test.deltacloud.apiversion>
<test.deltacloud.identity>mockuser</test.deltacloud.identity> <test.deltacloud.identity>mockuser</test.deltacloud.identity>
<test.deltacloud.credential>mockpassword</test.deltacloud.credential> <test.deltacloud.credential>mockpassword</test.deltacloud.credential>
</properties> </properties>

View File

@ -34,7 +34,7 @@ public class DeltacloudPropertiesBuilder extends PropertiesBuilder {
@Override @Override
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.defaultProperties(); Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_API_VERSION, "0.1.0"); properties.setProperty(PROPERTY_API_VERSION, "0.1.2");
return properties; return properties;
} }

View File

@ -48,7 +48,7 @@ import org.jclouds.http.annotation.ServerError;
import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.config.RestClientModule;
import org.jclouds.rest.suppliers.RetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
@ -86,7 +86,7 @@ public class DeltacloudRestClientModule extends RestClientModule<DeltacloudClien
@Singleton @Singleton
protected Supplier<Set<? extends DeltacloudCollection>> provideCollections( protected Supplier<Set<? extends DeltacloudCollection>> provideCollections(
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final DeltacloudClient client) { @Named(PROPERTY_SESSION_INTERVAL) long seconds, final DeltacloudClient client) {
return new RetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Set<? extends DeltacloudCollection>>( return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<Set<? extends DeltacloudCollection>>(
authException, seconds, new Supplier<Set<? extends DeltacloudCollection>>() { authException, seconds, new Supplier<Set<? extends DeltacloudCollection>>() {
@Override @Override
public Set<? extends DeltacloudCollection> get() { public Set<? extends DeltacloudCollection> get() {

View File

@ -45,6 +45,10 @@ public enum InstanceState {
* the instance is stopped * the instance is stopped
*/ */
STOPPED, STOPPED,
/**
* the instance is shutting down
*/
SHUTTING_DOWN,
/** /**
* the instance is terminated * the instance is terminated
*/ */
@ -56,7 +60,7 @@ public enum InstanceState {
public static InstanceState fromValue(String state) { public static InstanceState fromValue(String state) {
try { try {
return valueOf(checkNotNull(state, "state")); return valueOf(checkNotNull(state, "state").toUpperCase());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return UNRECOGNIZED; return UNRECOGNIZED;
} }

View File

@ -21,12 +21,15 @@ package org.jclouds.deltacloud.xml;
import java.util.Map; import java.util.Map;
import javax.annotation.Resource;
import org.jclouds.deltacloud.domain.InstanceAction; import org.jclouds.deltacloud.domain.InstanceAction;
import org.jclouds.deltacloud.domain.InstanceState; import org.jclouds.deltacloud.domain.InstanceState;
import org.jclouds.deltacloud.domain.Transition; import org.jclouds.deltacloud.domain.Transition;
import org.jclouds.deltacloud.domain.TransitionAutomatically; import org.jclouds.deltacloud.domain.TransitionAutomatically;
import org.jclouds.deltacloud.domain.TransitionOnAction; import org.jclouds.deltacloud.domain.TransitionOnAction;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.Logger;
import org.jclouds.util.SaxUtils; import org.jclouds.util.SaxUtils;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -39,6 +42,9 @@ import com.google.common.collect.Multimap;
*/ */
public class InstanceStatesHandler extends ParseSax.HandlerWithResult<Multimap<InstanceState, ? extends Transition>> { public class InstanceStatesHandler extends ParseSax.HandlerWithResult<Multimap<InstanceState, ? extends Transition>> {
@Resource
protected Logger logger = Logger.NULL;
private Multimap<InstanceState, Transition> states = LinkedHashMultimap.create(); private Multimap<InstanceState, Transition> states = LinkedHashMultimap.create();
private InstanceState state; private InstanceState state;
@ -50,17 +56,28 @@ public class InstanceStatesHandler extends ParseSax.HandlerWithResult<Multimap<I
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs);
if (qName.equals("state")) { if (qName.equals("state")) {
state = InstanceState.valueOf(attributes.get("name").toUpperCase()); state = instanceStateWarningOnUnrecognized(attributes.get("name"));
} else if (qName.equals("transition")) { } else if (qName.equals("transition")) {
if (attributes.containsKey("auto")) if (attributes.containsKey("auto"))
states.put(state, new TransitionAutomatically(InstanceState.valueOf(attributes.get("to").toUpperCase()))); states.put(state, new TransitionAutomatically(instanceStateWarningOnUnrecognized(attributes.get("to"))));
else else
states.put( states.put(state, new TransitionOnAction(instanceActionWarningOnUnrecognized(attributes.get("action")),
state, instanceStateWarningOnUnrecognized(attributes.get("to"))));
new TransitionOnAction(InstanceAction.fromValue(attributes.get("action")), InstanceState
.valueOf(attributes.get("to").toUpperCase())));
} }
} }
InstanceState instanceStateWarningOnUnrecognized(String input) {
InstanceState state = InstanceState.fromValue(input);
if (state == InstanceState.UNRECOGNIZED)
logger.warn("unrecognized state: %s", input);
return state;
}
InstanceAction instanceActionWarningOnUnrecognized(String input) {
InstanceAction action = InstanceAction.fromValue(input);
if (action == InstanceAction.UNRECOGNIZED)
logger.warn("unrecognized action: %s", input);
return action;
}
} }