本文整理汇总了Java中org.openstack4j.model.compute.Server.getAddresses方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getAddresses方法的具体用法?Java Server.getAddresses怎么用?Java Server.getAddresses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openstack4j.model.compute.Server
的用法示例。
在下文中一共展示了Server.getAddresses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addServerRow
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
private static void addServerRow(TableBuilder tb,Server server){
String metadata="";
String imageName="";
String addresses="";
Map<String,String> metadataMap=server.getMetadata();
if(metadataMap!=null && !metadataMap.isEmpty())
metadata=metadataMap.toString();
Image image=server.getImage();
if(image!=null)
imageName=image.getName();
Addresses addressesobj= server.getAddresses();
if(addresses!=null)
addresses=addressesobj.toString();
tb.addRow(server.getId(),server.getName(),imageName,server.getFlavor().getName(),server.getStatus().toString(),server.getPowerState(),server.getAccessIPv4(),server.getAccessIPv6(),addresses,metadata);
}
示例2: asMachine
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
/**
* Converts a {@link Server} from the OpenStack API to its {@link Machine}
* representation.
*/
private Machine asMachine(Server server) {
Builder builder = Machine.builder();
builder.id(server.getId());
builder.cloudProvider(this.cloudProvider);
builder.region(this.region);
builder.machineSize(server.getFlavor().getName());
builder.machineState(new StatusToMachineState().apply(server.getStatus()));
builder.requestTime(new DateTime(server.getCreated(), DateTimeZone.UTC));
builder.launchTime(new DateTime(server.getLaunchedAt(), DateTimeZone.UTC));
Addresses serverAddresses = server.getAddresses();
if (serverAddresses != null) {
collectIps(builder, server.getAddresses());
}
// extract membership status if tag has been set on server
MembershipStatus membershipStatus = MembershipStatus.defaultStatus();
if (server.getMetadata().containsKey(Constants.MEMBERSHIP_STATUS_TAG)) {
membershipStatus = JsonUtils.toObject(
JsonUtils.parseJsonString(server.getMetadata().get(Constants.MEMBERSHIP_STATUS_TAG)),
MembershipStatus.class);
}
builder.membershipStatus(membershipStatus);
// extract service state if tag has been set on server
ServiceState serviceState = ServiceState.UNKNOWN;
if (server.getMetadata().containsKey(Constants.SERVICE_STATE_TAG)) {
serviceState = ServiceState.valueOf(server.getMetadata().get(Constants.SERVICE_STATE_TAG));
}
builder.serviceState(serviceState);
builder.metadata(JsonUtils.toJson(server).getAsJsonObject());
return builder.build();
}