Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
public class LbPoolV2Tests extends AbstractTest {
private static final String LBPOOLSV2_JSON = "/network/lbpoolsv2.json";
private static final String LBPOOLV2_JSON = "/network/lbpoolv2.json";
private static final String LBPOOLV2_WITHOUT_LISTENER_JSON = "/network/lbpoolv2_without_listener.json";
private static final String LBPOOLV2_UPDATE_JSON = "/network/lbpoolv2_update.json";

public void testListPoolV2() throws IOException {
Expand Down Expand Up @@ -71,6 +72,27 @@ public void testCreatePoolV2() throws IOException {
assertEquals(result.getProtocol(), protocol);
}

public void testCreatePoolV2_no_listener() throws IOException {
respondWith(LBPOOLV2_WITHOUT_LISTENER_JSON);
String name = "testlbpool_no_listener";
Protocol protocol = Protocol.HTTP;
String loadBalancerId = "fbc45db6-d3c2-4918-981e-c8ae8c9eccc0";
LbPoolV2 create = Builders.lbpoolV2()
.adminStateUp(true)
.description("im a swimming pool")
.lbMethod(LbMethod.LEAST_CONNECTIONS)
.name(name)
.tenantId("6f759d84e3ca496ab77f8c0ffaa0311e")
.protocol(protocol)
.loadBalancerId(loadBalancerId)
.build();
LbPoolV2 result = osv3().networking().lbaasV2().lbPool().create(create);
assertEquals(result.getName(), name);
assertEquals(result.getLbMethod(), LbMethod.LEAST_CONNECTIONS);
assertEquals(result.getProtocol(), protocol);
assertEquals(result.getLoadBalancerId(), loadBalancerId);
}

public void testUpdatePoolV2() throws IOException {
respondWith(LBPOOLV2_UPDATE_JSON);
String poolId = "b7f6a49f-ebd8-43c5-b792-5748366eff21";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"pool": {
"lb_algorithm": "LEAST_CONNECTIONS",
"protocol": "HTTP",
"description": "im a swimming pool",
"admin_state_up": true,
"tenant_id": "6f759d84e3ca496ab77f8c0ffaa0311e",
"session_persistence": null,
"healthmonitor_id": "350576d8-5015-4d4e-b73f-23df2397e4c4",
"listeners": [

],
"members": [

],
"id": "b7f6a49f-ebd8-43c5-b792-5748366eff21",
"name": "testlbpool_no_listener",
"loadbalancer_id": "fbc45db6-d3c2-4918-981e-c8ae8c9eccc0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public interface LbPoolV2 extends ModelEntity, Buildable<LbPoolV2Builder> {
*/
List<ListItem> getListeners();

/**
* @return The ID of the load balancer under which this pool will be created.
*/
String getLoadBalancerId();

/**
* @return List of members that belong to the pool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ public interface LbPoolV2Builder extends Buildable.Builder<LbPoolV2Builder, LbPo
* @return LbPoolV2Builder
*/
LbPoolV2Builder listenerId(String listenerId);

/**
* The ID of the load balancer under which this pool will be created.
* Each load balancer can have zero or more pools associated with it. These pools can be used for L7policies.
* Either listener_id or loadbalancer_id must be specified.
*
* @param loadBalancerId
* @return LbPoolV2Builder
*/
LbPoolV2Builder loadBalancerId(String loadBalancerId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public class NeutronLbPoolV2 implements LbPoolV2 {
@JsonProperty("listener_id")
private String listenerId;

@JsonProperty("loadbalancer_id")
private String loadBalancerId;

private List<ListItem> listeners;

private List<ListItem> members;
Expand Down Expand Up @@ -134,6 +137,14 @@ public List<ListItem> getListeners(){
return listeners;
}

/**
* {@inheritDoc}
*/
@Override
public String getLoadBalancerId(){
return loadBalancerId;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -163,6 +174,7 @@ public String toString(){
.add("adminStateUp", adminStateUp)
.add("listenerId", listenerId)
.add("listeners", listeners)
.add("loadBalancerId", loadBalancerId)
.add("members", members)
.add("healthMonitorId", healthMonitorId)
.toString();
Expand Down Expand Up @@ -262,6 +274,15 @@ public LbPoolV2Builder listenerId(String listenerId){
m.listenerId = listenerId;
return this;
}

/**
* {@inheritDoc}
*/
@Override
public LbPoolV2Builder loadBalancerId(String loadBalancerId) {
m.loadBalancerId = loadBalancerId;
return this;
}
}

public static class LbPoolsV2 extends ListResult<NeutronLbPoolV2> {
Expand Down