当前位置: 首页>>代码示例>>Java>>正文


Java Server.getHypervisorHostname方法代码示例

本文整理汇总了Java中org.openstack4j.model.compute.Server.getHypervisorHostname方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getHypervisorHostname方法的具体用法?Java Server.getHypervisorHostname怎么用?Java Server.getHypervisorHostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openstack4j.model.compute.Server的用法示例。


在下文中一共展示了Server.getHypervisorHostname方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: discoverVmForPort

import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
/**
 * @param em     Hibernate session object
 * @param region Region this entity belongs to
 * @param sg     Security Group in context
 * @param osPort Open stack port
 * @param vmPort VM port
 * @throws IOException
 */
public static void discoverVmForPort(EntityManager em, String region, SecurityGroup sg, Port osPort, VMPort vmPort)
        throws IOException, EncryptionException {

    try (Openstack4JNova nova = new Openstack4JNova(new Endpoint(sg.getVirtualizationConnector(), sg.getProjectName()))) {
        Server osVm = nova.getServer(region, osPort.getDeviceId());
        if (null == osVm) {
            OSCEntityManager.delete(em, vmPort, StaticRegistry.transactionalBroadcastUtil());
            //TODO sridhar handle stale VM delete ?
            return;

        }
        VM vm = VMEntityManager.findByOpenstackId(em, osPort.getDeviceId());
        if (vm == null) {
            vm = new VM(region, osPort.getDeviceId(), osVm.getName());
            OSCEntityManager.create(em, vm, StaticRegistry.transactionalBroadcastUtil());
        }
        vmPort.setVm(vm);
        // Update vm host if needed
        String hypervisorHostname = osVm.getHypervisorHostname();
        if (hypervisorHostname != null && !hypervisorHostname.equals(vm.getHost())) {
            vm.setHost(hypervisorHostname);
            OSCEntityManager.update(em, vm, StaticRegistry.transactionalBroadcastUtil());
        }
    }
    OSCEntityManager.update(em, vmPort, StaticRegistry.transactionalBroadcastUtil());
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:35,代码来源:OpenstackUtil.java

示例2: getHypervisor

import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
public String getHypervisor(Server server) {
    LOGGER.info("Hypervisor info for instance: {}. HypervisorHostname: {}, Host: {}", server.getInstanceName(), server.getHypervisorHostname(), server
            .getHost());
    String hypervisor = server.getHypervisorHostname();
    LOGGER.info("Hypervisor for instance: {} is: {} on {}", server.getInstanceName(), server.getHypervisorHostname(), server.getHost());
    if (hypervisor == null) {
        hypervisor = server.getHost();
    }
    LOGGER.info("Used hypervisor for instance: {}. hypervisor: {}", server.getInstanceName(), hypervisor);
    return hypervisor;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:12,代码来源:HypervisorExtractor.java

示例3: discover

import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
public VmInfo discover(String region, String vmId) throws Exception {
    if (vmId == null) {
        return null;
    }
    VmInfo vmInfo = this.vmIdToVmMap.get(vmId);
    if (vmInfo != null) {
        return vmInfo;
    }

    vmInfo = new VmInfo();
    vmInfo.vmId = vmId;

    try {
        Server vm = this.novaApi.getServer(region, vmId);
        if (vm == null) {
            return null;
        }

        vmInfo.projectId = vm.getTenantId();
        vmInfo.name = vm.getName();
        vmInfo.host = vm.getHypervisorHostname();
        List<? extends InterfaceAttachment> interfaces = this.novaApi.getVmAttachedNetworks(region, vmId);
        for (InterfaceAttachment infs : interfaces) {
            if (infs.getMacAddr() == null) {
                continue;
            }

            PortInfo portInfo = new PortInfo();
            portInfo.vm = vmInfo;
            portInfo.macAddress = infs.getMacAddr();
            portInfo.osNetworkId = infs.getNetId();
            portInfo.osPortId = infs.getPortId();

            // add IP addresses for give port
            infs.getFixedIps().forEach(ip -> portInfo.portIPs.add(ip.getIpAddress()));

            vmInfo.macAddressToPortMap.put(infs.getMacAddr(), portInfo);

            this.osPortIdToPortMap.put(portInfo.osPortId, portInfo);
            this.macAddressToPortMap.put(portInfo.macAddress, portInfo);
        }
        this.vmIdToVmMap.put(vmId, vmInfo);
    } finally {
        this.novaApi.close();
    }

    return vmInfo;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:49,代码来源:VmDiscoveryCache.java


注:本文中的org.openstack4j.model.compute.Server.getHypervisorHostname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。