mirror of https://github.com/apache/jclouds.git
vcloud: added error handling on tasks
This commit is contained in:
parent
1429edf69e
commit
e8b8aced8e
|
@ -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;
|
package org.jclouds.compute.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
|
@ -56,24 +56,24 @@ public class BlueLockVCloudComputeServiceLiveTest extends VCloudComputeServiceLi
|
||||||
// TODO verify parsing works
|
// TODO verify parsing works
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://forums.bluelock.com/showthread.php?p=353#post353
|
// // https://forums.bluelock.com/showthread.php?p=353#post353
|
||||||
@Override
|
// @Override
|
||||||
@Test(enabled = false)
|
// @Test(enabled = false)
|
||||||
public void testCreate() throws Exception {
|
// public void testCreate() throws Exception {
|
||||||
super.testCreate();
|
// super.testCreate();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
@Test(enabled = false)
|
// @Test(enabled = false)
|
||||||
public void testGet() throws Exception {
|
// public void testGet() throws Exception {
|
||||||
super.testGet();
|
// super.testGet();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
@Test(enabled = false)
|
// @Test(enabled = false)
|
||||||
public void testReboot() throws Exception {
|
// public void testReboot() throws Exception {
|
||||||
super.testReboot();
|
// super.testReboot();
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExample() throws Exception {
|
public void testExample() throws Exception {
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
@Named("NAMING_CONVENTION")
|
@Named("NAMING_CONVENTION")
|
||||||
@Singleton
|
@Singleton
|
||||||
String provideNamingConvention() {
|
String provideNamingConvention() {
|
||||||
return "%s-%d";
|
return "%s%d";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
|
@ -234,11 +234,11 @@ public class VCloudComputeServiceContextModule extends VCloudContextModule {
|
||||||
while (node == null && i++ < 3) {
|
while (node == null && i++ < 3) {
|
||||||
try {
|
try {
|
||||||
node = getNodeMetadataByIdInVDC(vdc.getId(), resource.getId());
|
node = getNodeMetadataByIdInVDC(vdc.getId(), resource.getId());
|
||||||
|
nodes.add(node);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
logger.warn("vApp %s not yet present in vdc %s", resource.getId(), vdc.getId());
|
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) {
|
protected NodeMetadata getNodeMetadataByIdInVDC(String vDCId, String id) {
|
||||||
VApp vApp = client.getVApp(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(),
|
return new NodeMetadataImpl(vApp.getId(), vApp.getName(), vDCId, vApp.getLocation(),
|
||||||
ImmutableMap.<String, String> of(), tag, vAppStatusToNodeState.get(vApp
|
ImmutableMap.<String, String> of(), tag, vAppStatusToNodeState.get(vApp
|
||||||
.getStatus()), computeClient.getPublicAddresses(id), computeClient
|
.getStatus()), computeClient.getPublicAddresses(id), computeClient
|
||||||
|
|
|
@ -52,8 +52,10 @@ public class TaskSuccess implements Predicate<String> {
|
||||||
logger.trace("looking for status on task %s", taskId);
|
logger.trace("looking for status on task %s", taskId);
|
||||||
|
|
||||||
Task task = client.getTask(taskId);
|
Task task = client.getTask(taskId);
|
||||||
logger.trace("%s: looking for status %s: currently: %s", task,
|
logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task
|
||||||
TaskStatus.SUCCESS, task.getStatus());
|
.getStatus());
|
||||||
|
if (task.getStatus() == TaskStatus.ERROR)
|
||||||
|
throw new RuntimeException("error on task: " + task.getId() + " error: " + task.getError());
|
||||||
return task.getStatus() == TaskStatus.SUCCESS;
|
return task.getStatus() == TaskStatus.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue