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


Java Instance.getPublicDnsName方法代码示例

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


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

示例1: run

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
public void run() throws IOException, JSchException, SftpException, InterruptedException {
    List<String> commands = context.params(Param.EXECUTE_COMMAND);
    String script = context.param(Param.EXECUTE_SCRIPT);

    Asserts.isTrue(commands != null || script != null, "{} or {} is required", Param.EXECUTE_COMMAND.key, Param.EXECUTE_SCRIPT.key);

    String index = context.param(Param.INSTANCE_INDEX);

    for (int i = 0; i < remoteInstances.size(); i++) {
        Instance remoteInstance = remoteInstances.get(i);
        if (InstanceState.RUNNING.equalsTo(remoteInstance.getState()) && indexMatches(index, i)) {
            try (SSH ssh = new SSH(remoteInstance.getPublicDnsName(), "ubuntu", KeyPair.keyFile(remoteInstance.getKeyName(), env))) {
                if (commands != null) {
                    ssh.executeCommands(commands.toArray(new String[commands.size()]));
                } else {
                    executeScript(ssh, env.envDir.resolve(script));
                }
            }
        }
    }
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:22,代码来源:LinuxCommandRunner.java

示例2: getPreferredHostName

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
private String getPreferredHostName(Instance instance) {
    if (preferPrivateIpHostnames) {
        return instance.getPrivateIpAddress();
    }

    return instance.getPublicDnsName();
}
 
开发者ID:electronicarts,项目名称:gatling-aws-maven-plugin,代码行数:8,代码来源:GatlingAwsMojo.java

示例3: getEC2HostAddress

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
private String getEC2HostAddress(EC2Computer computer, Instance inst) {
    if (computer.getNode().usePrivateDnsName) {
        return inst.getPrivateDnsName();
    } else {
        String host = inst.getPublicDnsName();
        // If we fail to get a public DNS name, use the private IP.
        if (host == null || host.equals("")) {
            host = inst.getPrivateIpAddress();
        }
        return host;
    }
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:13,代码来源:EC2UnixLauncher.java

示例4: upload

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
public void upload() throws IOException, JSchException, SftpException, InterruptedException {
    String packageDir = context.requiredParam(Param.PACKAGE_DIR);

    String index = context.param(Param.INSTANCE_INDEX);

    for (int i = 0; i < remoteInstances.size(); i++) {
        Instance remoteInstance = remoteInstances.get(i);
        if (InstanceState.RUNNING.equalsTo(remoteInstance.getState()) && indexMatches(index, i)) {
            try (SSH ssh = new SSH(remoteInstance.getPublicDnsName(), "ubuntu", KeyPair.keyFile(remoteInstance.getKeyName(), env))) {
                ssh.uploadDir(Paths.get(packageDir), "/opt/packages");
            }
        }
    }
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:15,代码来源:LinuxUploader.java

示例5: getPropertyValue

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
@Override
protected String getPropertyValue(Instance instance) {
  return instance.getPublicDnsName();
}
 
开发者ID:cloudera,项目名称:director-aws-plugin,代码行数:5,代码来源:EC2Instance.java

示例6: connectToWinRM

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
private WinConnection connectToWinRM(EC2Computer computer, PrintStream logger) throws AmazonClientException,
InterruptedException {
    final long timeout = computer.getNode().getLaunchTimeoutInMillis();
    final long startTime = System.currentTimeMillis();
    
    logger.println(computer.getNode().getDisplayName() + " booted at " + computer.getNode().getCreatedTime());
    boolean alreadyBooted = (startTime - computer.getNode().getCreatedTime()) > TimeUnit.MINUTES.toMillis(3);
    while (true) {
        try {
            long waitTime = System.currentTimeMillis() - startTime;
            if (waitTime > timeout) {
                throw new AmazonClientException("Timed out after " + (waitTime / 1000)
                        + " seconds of waiting for winrm to be connected");
            }
            Instance instance = computer.updateInstanceDescription();
            String vpc_id = instance.getVpcId();
            String ip, host;

            if (computer.getNode().usePrivateDnsName) {
                host = instance.getPrivateDnsName();
                ip = instance.getPrivateIpAddress(); // SmbFile doesn't quite work with hostnames
            } else {
                host = instance.getPublicDnsName();
                if (host == null || host.equals("")) {
                    host = instance.getPrivateDnsName();
                    ip = instance.getPrivateIpAddress(); // SmbFile doesn't quite work with hostnames
                }
                else {
                    host = instance.getPublicDnsName();
                    ip = instance.getPublicIpAddress(); // SmbFile doesn't quite work with hostnames
                }
            }

            if ("0.0.0.0".equals(host)) {
                logger.println("Invalid host 0.0.0.0, your host is most likely waiting for an ip address.");
                throw new IOException("goto sleep");
            }

            logger.println("Connecting to " + host + "(" + ip + ") with WinRM as " + computer.getNode().remoteAdmin);

            WinConnection connection = new WinConnection(ip, computer.getNode().remoteAdmin, computer.getNode().getAdminPassword());
            connection.setUseHTTPS(computer.getNode().isUseHTTPS());
            if (!connection.ping()) {
                logger.println("Waiting for WinRM to come up. Sleeping 10s.");
                Thread.sleep(sleepBetweenAttemps);
                continue;
            }
            
            if (!alreadyBooted || computer.getNode().stopOnTerminate) {
                logger.println("WinRM service responded. Waiting for WinRM service to stabilize on " + computer.getNode().getDisplayName());
                Thread.sleep(computer.getNode().getBootDelay());
                alreadyBooted = true;
                logger.println("WinRM should now be ok on " + computer.getNode().getDisplayName());
                if (!connection.ping()) {
                    logger.println("WinRM not yet up. Sleeping 10s.");
                    Thread.sleep(sleepBetweenAttemps);
                    continue;
                }
            }

            logger.println("Connected with WinRM.");
            return connection; // successfully connected
        } catch (IOException e) {
            logger.println("Waiting for WinRM to come up. Sleeping 10s.");
            Thread.sleep(sleepBetweenAttemps);
        }
    }
}
 
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:69,代码来源:EC2WindowsLauncher.java

示例7: hostName

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
private String hostName(Instance remoteInstance) {
    String publicDNS = remoteInstance.getPublicDnsName();
    return publicDNS != null ? publicDNS : remoteInstance.getPrivateDnsName();
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:5,代码来源:SSHRunner.java

示例8: hostName

import com.amazonaws.services.ec2.model.Instance; //导入方法依赖的package包/类
private String hostName(Instance instance) {
    String publicDNS = instance.getPublicDnsName();
    return Strings.notEmpty(publicDNS) ? publicDNS : instance.getPrivateIpAddress();
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:5,代码来源:AnsibleProvisioner.java


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