static AccessConfig fromPb(com.google.api.services.compute.model.AccessConfig configPb) { Builder builder = newBuilder(); builder.setName(configPb.getName()); if (configPb.getNatIP() != null) { builder.setNatIp(configPb.getNatIP()); } if (configPb.getType() != null) { builder.setType(Type.valueOf(configPb.getType())); } return builder.build(); } }
static AccessConfig fromPb(com.google.api.services.compute.model.AccessConfig configPb) { Builder builder = newBuilder(); builder.setName(configPb.getName()); if (configPb.getNatIP() != null) { builder.setNatIp(configPb.getNatIP()); } if (configPb.getType() != null) { builder.setType(Type.valueOf(configPb.getType())); } return builder.build(); } }
/** * 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)); } } }
String publicIp = accessConfigs.get(0).getNatIP(); if (publicIp != null) { builder.publicIp(publicIp);