本文整理汇总了Java中org.openstack4j.model.compute.Server.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getStatus方法的具体用法?Java Server.getStatus怎么用?Java Server.getStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openstack4j.model.compute.Server
的用法示例。
在下文中一共展示了Server.getStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitUntilServerDeleted
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
private static void waitUntilServerDeleted(OSClient os, String serverId) throws Exception{
while(true){
Server server=os.compute().servers().get(serverId);
Server.Status status=Status.DELETED;
if(server!=null)
status=server.getStatus();
System.out.println("current status: "+status.toString());
if(status.equals(Status.DELETED)){
break;
}else{
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
}
}
}
示例2: handleForkedNodes
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
private List<Server> handleForkedNodes(List<Server> forkedNodes, List<String> leftNodes) {
List<Server> activeNodes = new ArrayList<>();
List<Server> failedNodes = new ArrayList<>();
int unnamedVms = 0;
for (Server s : forkedNodes ) {
logger.info(String.format("Checking node %s", s.getId()));
Server updated_s = this.novaContext.getCompute().servers().get(s.getId());
String nodeName = updated_s.getName();
leftNodes.remove(nodeName);
if (updated_s.getStatus() == Server.Status.ACTIVE) {
activeNodes.add(updated_s);
} else if (updated_s.getCreated() != null &&
updated_s.getCreated().getTime() + (10*60*1000) < new Date().getTime()) {
logger.info(String.format("Server %s(%s) createdi at %s now is %s did not start in time",
nodeName, s.getId(), updated_s.getCreated().getTime(), new Date().getTime()));
logger.info(String.format("Server %s(%s) did not start in time lets try again", nodeName, s.getId()));
this.novaContext.getCompute().servers().delete(s.getId());
// Readd so we restart it
leftNodes.add(nodeName);
failedNodes.add(s);
}
}
// removed failed
forkedNodes.removeAll(failedNodes);
return activeNodes;
}
示例3: getStatus
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
private Status getStatus(AuthenticatedContext auth, String serverId) {
OSClient osClient = createOSClient(auth);
Server server = osClient.compute().servers().get(serverId);
Status status = null;
if (server != null) {
status = server.getStatus();
}
return status;
}
示例4: ensureVmActive
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
/**
* Waits until the VM state becomes active. If the VM enters a terminal state, throws a VmidcException
*/
public static void ensureVmActive(VirtualizationConnector vc, String project, String region, String vmId)
throws Exception {
try (Openstack4JNova nova = new Openstack4JNova(new Endpoint(vc, project))) {
Server server = null;
int i = MAX_DISCOVERY_RETRIES;
while (i > 0) {
server = nova.getServer(region, vmId);
if (server == null) {
throw new VmidcException("VM with id: '" + vmId + "' does not exist");
}
if (server.getStatus() == Server.Status.ACTIVE) {
break;
} else if (isVmStatusTerminal(server.getStatus())) {
throw new VmidcException("VM is in bad state (" + server.getStatus() + ")");
}
LOG.info("Retry VM discovery (" + i + "/" + MAX_DISCOVERY_RETRIES + ") of VM '" + vmId + "' Status: "
+ server.getStatus());
Thread.sleep(SLEEP_DISCOVERY_RETRIES);
i--;
}
if (server.getStatus() != Server.Status.ACTIVE) {
throw new VmidcException("VM with id: '" + vmId + "' is not in ready state (" + server.getStatus()
+ ")");
}
i = MAX_DISCOVERY_RETRIES;
int activePorts = 0;
while (i > 0) {
List<? extends InterfaceAttachment> interfaces = nova.getVmAttachedNetworks(region, vmId);
activePorts = 0;
for (InterfaceAttachment infs : interfaces) {
if (infs.getPortState().equals(PortState.ACTIVE) && infs.getFixedIps() != null) {
activePorts += infs.getFixedIps().size();
}
}
if (activePorts >= 2) {
LOG.info("VM network discovery (interfaces: " + interfaces + ")");
break;
}
LOG.info("Retry VM network discovery (" + i + "/" + MAX_DISCOVERY_RETRIES + ") of VM '"
+ server.getName() + "' (interfaces: " + interfaces + ")");
Thread.sleep(SLEEP_DISCOVERY_RETRIES);
i--;
}
if (activePorts < 2) {
throw new VmidcException("VM '" + server.getName() + "' network is not ready.");
}
}
}