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


Java Server.getMetadata方法代码示例

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


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

示例1: createSnapshot

import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
public static String createSnapshot(String serverId , String name) throws Exception{
    OSClient os=Osp4jSession.getOspSession();
    serverId=CommonAPI.takeFromMemory(NovaKey.NOVA_SERVERID,serverId);
    Server server=os.compute().servers().get(serverId);
    String imageId = os.compute().servers().createSnapshot(serverId, name);
    waitUntilImageACTIVE(os,imageId); 
    Map<String,String> metadata=server.getMetadata();
    Boolean bootFromVolume=new Boolean(metadata.get("BOOT_FROM_VOLUME"));
    System.out.println(bootFromVolume);
    if(bootFromVolume){
        CinderAPI.getVolumeSnapshot(metadata.get("VOLUME_ID"));
    }
    
    return imageId;
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:16,代码来源:NovaAPI.java

示例2: 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);
}
 
开发者ID:vinodborole,项目名称:openstack4j-shell,代码行数:16,代码来源:NovaAPI.java

示例3: doRequest

import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
@Override
public Void doRequest(OSClient api) throws NotFoundException, ResponseException {
    ServerService serverApi = api.compute().servers();
    Server server = serverApi.get(this.serverId);
    if (server == null) {
        throw new NotFoundException(
                format("failed to update meta data on server '%s': " + "server not found", this.serverId));
    }
    // set tags
    Map<String, String> tags = new HashMap<>(server.getMetadata());
    tags.putAll(this.metadata);
    serverApi.updateMetadata(this.serverId, tags);
    return null;
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:15,代码来源:UpdateServerMetadataRequest.java

示例4: collect

import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
@Override
public List<CloudVmMetaDataStatus> collect(AuthenticatedContext authenticatedContext, List<CloudResource> resources, List<CloudInstance> vms) {
    CloudResource resource = utils.getHeatResource(resources);

    String stackName = utils.getStackName(authenticatedContext);
    String heatStackId = resource.getName();

    List<InstanceTemplate> templates = Lists.transform(vms, CloudInstance::getTemplate);

    Map<String, InstanceTemplate> templateMap = Maps.uniqueIndex(templates, from -> {
        return utils.getPrivateInstanceId(from.getGroupName(), Long.toString(from.getPrivateId()));
    });

    OSClient client = openStackClient.createOSClient(authenticatedContext);

    Stack heatStack = client.heat().stacks().getDetails(stackName, heatStackId);

    List<CloudVmMetaDataStatus> results = new ArrayList<>();


    List<Map<String, Object>> outputs = heatStack.getOutputs();
    for (Map<String, Object> map : outputs) {
        String instanceUUID = (String) map.get("output_value");
        if (!StringUtils.isEmpty(instanceUUID)) {
            Server server = client.compute().servers().get(instanceUUID);
            Map<String, String> metadata = server.getMetadata();
            String privateInstanceId = utils.getPrivateInstanceId(metadata);
            InstanceTemplate template = templateMap.get(privateInstanceId);
            if (template != null) {
                CloudInstanceMetaData md = cloudInstanceMetaDataExtractor.extractMetadata(client, server, instanceUUID);
                //TODO use here sshkey
                CloudInstance cloudInstance = new CloudInstance(instanceUUID, template, null);
                CloudVmInstanceStatus status = new CloudVmInstanceStatus(cloudInstance, InstanceStatus.CREATED);
                results.add(new CloudVmMetaDataStatus(status, md));
            }
        }
    }

    return results;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:41,代码来源:OpenStackMetadataCollector.java

示例5: collect

import org.openstack4j.model.compute.Server; //导入方法依赖的package包/类
@Override
public List<CloudVmMetaDataStatus> collect(AuthenticatedContext authenticatedContext, List<CloudResource> resources, List<CloudInstance> vms) {

    List<InstanceTemplate> templates = Lists.transform(vms, CloudInstance::getTemplate);

    Map<String, InstanceTemplate> templateMap = Maps.uniqueIndex(templates, from -> {
        return utils.getPrivateInstanceId(from.getGroupName(), Long.toString(from.getPrivateId()));
    });

    OSClient client = openStackClient.createOSClient(authenticatedContext);
    List<CloudVmMetaDataStatus> results = new ArrayList<>();

    for (CloudResource resource : resources) {
        if (resource.getType() == ResourceType.OPENSTACK_INSTANCE) {
            String instanceUUID = resource.getReference();
            Server server = client.compute().servers().get(instanceUUID);
            if (server != null) {
                Map<String, String> metadata = server.getMetadata();
                String privateInstanceId = utils.getPrivateInstanceId(metadata);
                InstanceTemplate template = templateMap.get(privateInstanceId);
                if (template != null) {
                    CloudInstanceMetaData md = cloudInstanceMetaDataExtractor.extractMetadata(client, server, instanceUUID);
                    //TODO use here sshkey
                    CloudInstance cloudInstance = new CloudInstance(instanceUUID, template, null);
                    CloudVmInstanceStatus status = new CloudVmInstanceStatus(cloudInstance, InstanceStatus.CREATED);
                    results.add(new CloudVmMetaDataStatus(status, md));
                }
            }
        }
    }
    return results;
}
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:33,代码来源:OpenStackNativeMetaDataCollector.java


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