本文整理汇总了Java中org.openstack4j.model.compute.Server.getId方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getId方法的具体用法?Java Server.getId怎么用?Java Server.getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openstack4j.model.compute.Server
的用法示例。
在下文中一共展示了Server.getId方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startMachines
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
@Override
public List<Machine> startMachines(int count) throws StartMachinesException, CloudPoolDriverException {
checkState(isConfigured(), "attempt to use unconfigured driver");
List<Machine> startedMachines = new ArrayList<>();
try {
for (int i = 0; i < count; i++) {
// tag new server with cloud pool membership
Map<String, String> tags = ImmutableMap.of(Constants.CLOUD_POOL_TAG, getPoolName());
Server newServer = this.client.launchServer(uniqueServerName(), provisioningTemplate(), tags);
Machine machine = serverToMachine().apply(newServer);
startedMachines.add(machine);
if (provisioningTemplate().isAssignFloatingIp()) {
String serverId = newServer.getId();
String floatingIp = this.client.assignFloatingIp(serverId);
machine.getPublicIps().add(floatingIp);
}
}
} catch (Exception e) {
throw new StartMachinesException(count, startedMachines, e);
}
return startedMachines;
}
示例2: newVmInfo
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
private VmInfo newVmInfo(Server vm) {
VmInfo vmi = new VmInfo();
vmi.vmName = vm.getName();
vmi.vmId = vm.getId();
vmi.vmUuid = vm.getId();
// TODO: Future Maybe add comma seperated list of ip addresses
vmi.vmIpAddress = "";
vmi.hostName = vm.getHostId();
vmi.hostId = vm.getHostId();
return vmi;
}
示例3: find
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
public static OpenStackInstance find(OSClient os_client, String instanceId) throws InterruptedException, OS4JException {
Server server = os_client.compute().servers().get(instanceId);
if(server.getId() == null)
return null;
return new OpenStackInstance(server.getId(),
server.getCreated(),
server.getMetadata().get(Constants.GOSERVER_PROPERTIES_PREFIX + Constants.ENVIRONMENT_KEY),
os_client);
}
示例4: executeTransaction
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
@Override
public void executeTransaction(EntityManager em) throws Exception {
this.dai = DistributedApplianceInstanceEntityMgr.findById(em, this.dai.getId());
Endpoint osEndPoint = new Endpoint(this.dai.getDeploymentSpec());
try (Openstack4JNova nova = new Openstack4JNova(osEndPoint);
Openstack4JNeutron neutron = new Openstack4JNeutron(osEndPoint)) {
Server sva = null;
String serverId = this.dai.getExternalId();
if (serverId != null) {
sva = nova.getServer(this.region, this.dai.getExternalId());
}
if (sva == null) {
sva = nova.getServerByName(this.region, this.dai.getName());
}
if (sva != null) {
serverId = sva.getId();
}
this.activeRunner.getOsDeploymentSpecNotificationRunner()
.removeIdFromListener(this.dai.getDeploymentSpec().getId(), serverId);
this.log.info("Deleting Server " + serverId + " from region " + this.region);
boolean serverDeleted = serverId == null || nova.terminateInstance(this.region, serverId);
boolean ingressPortDeleted = true;
boolean egressPortDeleted = true;
String ingressPortId = this.dai.getInspectionOsIngressPortId();
String egressPortId = this.dai.getInspectionOsEgressPortId();
if (ingressPortId != null) {
this.log.info("Deleting Ingress port " + ingressPortId + " from region " + this.region);
ingressPortDeleted = neutron.deletePortById(this.region, ingressPortId);
}
if (!this.dai.isSingleNicInspection() && egressPortId != null) {
this.log.info("Deleting Egress port " + egressPortId + " from region " + this.region);
egressPortDeleted = neutron.deletePortById(this.region, egressPortId);
}
if (!serverDeleted) {
// Check if server still exists, if it does, fail!
if (nova.getServer(this.region, serverId) != null) {
throw new VmidcException("Server: " + serverId + " deletion failed!");
}
this.log.warn("Server: " + serverId + " deletion failed from region: " + this.region
+ ". Assume already deleted.");
}
if (!ingressPortDeleted || !egressPortDeleted) {
this.log.info("Deleting ports failed. Ingress port deleted: " + ingressPortDeleted + " Egress port deleted:"
+ egressPortDeleted);
throw new VmidcException("Server: " + serverId + " port deletion failed!");
}
}
this.dai.resetAllDiscoveredAttributes();
}
示例5: createInstance
import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
private Instance createInstance(Cloud cloud, String region, Server server) {
Instance instance = new Instance();
String realId = server.getId();
String instanceId = idGenerator.getInstanceId(cloud, realId);
instance.setId(instanceId);
instance.setRealId(realId);
instance.setName(server.getName());
instance.setState(stateFromStatus(server.getStatus()));
instance.setCloudId(cloud.getId());
instance.setCloudType(CloudType.OPENSTACK);
Keypair keypair = new Keypair();
keypair.setName(server.getKeyName());
instance.setKeypairs(Collections.singletonList(keypair));
ZonedDateTime created = ZonedDateTime.ofInstant(
server.getCreated().toInstant(),
ZoneId.systemDefault()
);
instance.setCreated(created);
ZonedDateTime timestamp = ZonedDateTime.ofInstant(
server.getUpdated().toInstant(),
ZoneId.systemDefault()
);
instance.setTimestamp(timestamp);
MetadataMap metadata = new MetadataMap();
metadata.put(MetadataKey.REGION, region);
instance.setMetadata(metadata);
String projectId = idGenerator.getProjectId(cloud, region);
Optional<Project> projectCandidate = getProject(projectId);
if (projectCandidate.isPresent()) {
instance.setProjectId(projectId);
Project project = projectCandidate.get();
List<Flavor> matchingFlavors = (server.getFlavor() != null) ?
project.getFlavors().stream()
.filter(f -> f.getId().equals(server.getFlavor().getId()))
.collect(Collectors.toList()) :
Collections.emptyList();
if (!matchingFlavors.isEmpty()) {
instance.setFlavor(matchingFlavors.get(0));
}
Map<String, List<? extends Address>> addresses = server.getAddresses().getAddresses();
List<Network> networks = new ArrayList<>();
addresses.keySet().forEach(networkName -> {
List<String> ipAddresses = addresses.get(networkName).stream()
.map(Address::getAddr).collect(Collectors.toList());
instance.setAddresses(ipAddresses);
Optional<Network> networkCandidate = project.getNetworks().stream()
.filter(n -> n.getName().equals(networkName))
.findFirst();
networkCandidate.ifPresent(networks::add);
});
instance.setNetworks(networks);
String fqdn = getFQDN(server.getName());
instance.setFqdn(fqdn);
}
if (server.getImage() != null) {
String imageId = idGenerator.getImageId(cloud, server.getImage().getId());
Optional<Image> imageCandidate = imagesAware.getImage(imageId);
imageCandidate.ifPresent(instance::setImage);
}
return instance;
}