vcloud: added error handling on tasks

This commit is contained in:
Adrian Cole 2010-03-15 15:30:48 -07:00
parent 1429edf69e
commit e8b8aced8e
4 changed files with 55 additions and 35 deletions

View File

@ -1,3 +1,21 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.compute.internal;
import static com.google.common.base.Preconditions.checkArgument;

View File

@ -56,24 +56,24 @@ public class BlueLockVCloudComputeServiceLiveTest extends VCloudComputeServiceLi
// TODO verify parsing works
}
// https://forums.bluelock.com/showthread.php?p=353#post353
@Override
@Test(enabled = false)
public void testCreate() throws Exception {
super.testCreate();
}
@Override
@Test(enabled = false)
public void testGet() throws Exception {
super.testGet();
}
@Override
@Test(enabled = false)
public void testReboot() throws Exception {
super.testReboot();
}
// // https://forums.bluelock.com/showthread.php?p=353#post353
// @Override
// @Test(enabled = false)
// public void testCreate() throws Exception {
// super.testCreate();
// }
//
// @Override
// @Test(enabled = false)
// public void testGet() throws Exception {
// super.testGet();
// }
//
// @Override
// @Test(enabled = false)
// public void testReboot() throws Exception {
// super.testReboot();
// }
@Test
public void testExample() throws Exception {

View File

@ -124,7 +124,7 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
@Named("NAMING_CONVENTION")
@Singleton
String provideNamingConvention() {
return "%s-%d";
return "%s%d";
}
@Singleton
@ -234,11 +234,11 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
while (node == null && i++ < 3) {
try {
node = getNodeMetadataByIdInVDC(vdc.getId(), resource.getId());
nodes.add(node);
} catch (NullPointerException e) {
logger.warn("vApp %s not yet present in vdc %s", resource.getId(), vdc.getId());
}
}
nodes.add(node);
}
}
@ -281,7 +281,7 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
protected NodeMetadata getNodeMetadataByIdInVDC(String vDCId, String id) {
VApp vApp = client.getVApp(id);
String tag = vApp.getName().replaceAll("-[0-9]+", "");
String tag = vApp.getName().replaceAll("[0-9]+", "");
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vDCId, vApp.getLocation(),
ImmutableMap.<String, String> of(), tag, vAppStatusToNodeState.get(vApp
.getStatus()), computeClient.getPublicAddresses(id), computeClient

View File

@ -52,8 +52,10 @@ public class TaskSuccess implements Predicate<String> {
logger.trace("looking for status on task %s", taskId);
Task task = client.getTask(taskId);
logger.trace("%s: looking for status %s: currently: %s", task,
TaskStatus.SUCCESS, task.getStatus());
logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task
.getStatus());
if (task.getStatus() == TaskStatus.ERROR)
throw new RuntimeException("error on task: " + task.getId() + " error: " + task.getError());
return task.getStatus() == TaskStatus.SUCCESS;
}