if (instancePb.getNetworkInterfaces() != null) { this.networkInterfaces = Lists.transform(instancePb.getNetworkInterfaces(), NetworkInterface.FROM_PB_FUNCTION);
static String getInstanceIp(AccountDeploymentDetails<GoogleAccount> details, String instanceName) { Compute compute = getCompute(details); Instance instance = null; try { instance = compute.instances().get(details.getAccount().getProject(), "us-central1-f", instanceName).execute(); } catch (IOException e) { throw new HalException(FATAL, "Unable to get instance " + instanceName); } return instance.getNetworkInterfaces() .stream() .map(i -> i.getAccessConfigs().stream() .map(AccessConfig::getNatIP) .filter(ip -> !StringUtils.isEmpty(ip)) .findFirst() ).filter(Optional::isPresent) .map(Optional::get) .findFirst() .orElseThrow(() -> new HalException(FATAL, "No public IP associated with" + instanceName)); }
static String getInstanceIp(AccountDeploymentDetails<GoogleAccount> details, String instanceName) { Compute compute = getCompute(details); Instance instance = null; try { instance = compute.instances().get(details.getAccount().getProject(), "us-central1-f", instanceName).execute(); } catch (IOException e) { throw new HalException(FATAL, "Unable to get instance " + instanceName); } return instance.getNetworkInterfaces() .stream() .map(i -> i.getAccessConfigs().stream() .map(AccessConfig::getNatIP) .filter(ip -> !StringUtils.isEmpty(ip)) .findFirst() ).filter(Optional::isPresent) .map(Optional::get) .findFirst() .orElseThrow(() -> new HalException(FATAL, "No public IP associated with" + instanceName)); }
for (NetworkInterface networkInterface : instance.getNetworkInterfaces()) { Path path = Paths.get(networkInterface.getNetwork()); String networkName = path.getFileName().toString();
/** * For the given zone and client type, we add the instances created to the clients array, for the * base controller. */ private void addInstanceGroupInfo(String zone, ClientParams params) throws IOException { InstanceGroupManagersListManagedInstancesResponse response; do { response = compute.instanceGroupManagers(). listManagedInstances(projectName, zone, "cps-loadtest-" + params.getClientType() + "-" + cores).execute(); // If we are not instantiating any instances of this type, just return. if (response.getManagedInstances() == null) { return; } } while (!response.getManagedInstances().stream() .allMatch(i -> i.getCurrentAction().equals("NONE"))); for (ManagedInstance managedInstance : response.getManagedInstances()) { String instanceName = managedInstance.getInstance() .substring(managedInstance.getInstance().lastIndexOf('/') + 1); Instance instance = compute.instances().get(projectName, zone, instanceName).execute(); synchronized (this) { clients.add(new Client( params.getClientType(), instance.getNetworkInterfaces().get(0).getAccessConfigs().get(0).getNatIP(), projectName, params.subscription, executor)); } } }
if (instancePb.getNetworkInterfaces() != null) { this.networkInterfaces = Lists.transform(instancePb.getNetworkInterfaces(), NetworkInterface.FROM_PB_FUNCTION);
List<NetworkInterface> networkInterfaces = instance.getNetworkInterfaces(); if (networkInterfaces != null && !networkInterfaces.isEmpty()) { NetworkInterface networkInterface = networkInterfaces.get(0);