This patch is a cadidate for cherry picking to stable/lithium.
However, it changes the semantics of the canNetworkBeUpdated
part of the INetworkAware interface and so before we change
that, we need to communicate with other projects.
Change-Id: Ie9c3774fb98ebdb044d9523477bc0fb3112beaba
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
network_tester.network_collection_get_test();
network_tester.singleton_network_create_test();
network_tester.external_network_create_test(); //needed for router test
+ network_tester.bulk_network_create_test();
+ network_tester.network_update_test();
+ network_tester.network_element_get_test();
+ network_tester.network_delete_test();
+ network_tester.network_element_negative_get_test();
NeutronSubnetTests subnet_tester = new NeutronSubnetTests(base);
subnet_tester.subnet_collection_get_test();
}
}
+ static void test_fetch(String url_s, boolean positiveTest, String context) {
+ try {
+ URL url = new URL(url_s);
+ HttpURLConnection httpConn = HttpURLConnectionFactoryGet(url);
+ if (positiveTest) {
+ Assert.assertEquals(context, 200, httpConn.getResponseCode());
+ } else {
+ Assert.assertEquals(context, 404, httpConn.getResponseCode());
+ }
+ } catch (Exception e) {
+ e.printStackTrace(); // temporary, remove me
+ Assert.assertFalse("E2E Tests Failed", true);
+ }
+ }
+
static void test_delete(String url_s, String context) {
try {
URL url = new URL(url_s);
" \"id\": \"8ca37218-28ff-41cb-9b10-039601ea7e6b\" } } ";
ITNeutronE2E.test_create(url, content,"External Network Post Failed NB");
}
+
+ //TODO handle SB check
+ public void bulk_network_create_test() {
+ String url = base + "/networks";
+ String content = "{ \"networks\": [ { "
+ + "\"status\": \"ACTIVE\", \"subnets\": [], "
+ + "\"name\": \"sample_network3\", "
+ + "\"provider:physical_network\": null, "
+ + "\"admin_state_up\": true, "
+ + "\"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\", "
+ + "\"provider:network_type\": \"local\", "
+ + "\"shared\": false, "
+ + "\"id\": \"bc1a76cb-8767-4c3a-bb95-018b822f2130\", "
+ + "\"provider:segmentation_id\": null }, { "
+ + "\"status\": \"ACTIVE\", "
+ + "\"subnets\": [], "
+ + "\"name\": \"sample_network4\", "
+ + "\"provider:physical_network\": null, "
+ + "\"admin_state_up\": true, "
+ + "\"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\", "
+ + "\"provider:network_type\": \"local\", "
+ + "\"shared\": false, "
+ + "\"id\": \"af374017-c9ae-4a1d-b799-ab73111476e2\", "
+ + "\"provider:segmentation_id\": null } ] } ";
+ ITNeutronE2E.test_create(url, content,"Bulk Network Post Failed");
+ }
+
+ //TODO handle SB check
+ public void network_update_test() {
+ String url = base + "/networks/bc1a76cb-8767-4c3a-bb95-018b822f2130";
+ String content = " { \"network\": { "
+ +"\"status\": \"ACTIVE\", "
+ +"\"subnets\": [], "
+ +"\"name\": \"sample_network_5_updated\", "
+ +"\"provider:physical_network\": null, "
+ +"\"admin_state_up\": true, "
+ +"\"tenant_id\": \"4fd44f30292945e481c7b8a0c8908869\", "
+ +"\"provider:network_type\": \"local\", "
+ +"\"router:external\": false, "
+ +"\"shared\": false, "
+ +"\"provider:segmentation_id\": null } } ";
+ ITNeutronE2E.test_modify(url, content,"Network Put Failed");
+ }
+
+ public void network_element_get_test() {
+ String url = base + "/networks/bc1a76cb-8767-4c3a-bb95-018b822f2130";
+ ITNeutronE2E.test_fetch(url, true ,"Network Element Get Failed");
+ }
+
+ public void network_element_negative_get_test() {
+ String url = base + "/networks/bc1a76cb-8767-4c3a-bb95-018b822f2130";
+ ITNeutronE2E.test_fetch(url, false ,"Network Element Negative Get Failed");
+ }
+
+ public void network_delete_test() {
+ String url = base + "/networks/bc1a76cb-8767-4c3a-bb95-018b822f2130";
+ ITNeutronE2E.test_delete(url, "Network Element Delete Failed");
+ }
}
INeutronNetworkCRUD networkInterface = getNeutronInterfaces().getNetworkInterface();
/*
- * network has to exist and only a single delta is supported
+ * network has to exist and only a single object is supported
*/
if (!networkInterface.networkExists(netUUID)) {
throw new ResourceNotFoundException(UUID_NO_EXIST);
if (!input.isSingleton()) {
throw new BadRequestException("only singleton edits supported");
}
- NeutronNetwork delta = input.getSingleton();
+ NeutronNetwork updatedObject = input.getSingleton();
/*
- * transitions forbidden by Neutron
+ * note: what we get appears to not be a delta but
+ * rather an incomplete updated object. So we need to set
+ * the ID to complete the object and then send that down
+ * for folks to check
*/
- if (delta.getID() != null || delta.getTenantID() != null ||
- delta.getStatus() != null) {
- throw new BadRequestException("attribute edit blocked by Neutron");
- }
+ updatedObject.setID(netUUID);
Object[] instances = NeutronUtil.getInstances(INeutronNetworkAware.class, this);
if (instances != null) {
if (instances.length > 0) {
for (Object instance : instances) {
INeutronNetworkAware service = (INeutronNetworkAware) instance;
NeutronNetwork original = networkInterface.getNetwork(netUUID);
- int status = service.canUpdateNetwork(delta, original);
+ int status = service.canUpdateNetwork(updatedObject, original);
if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
return Response.status(status).build();
}
throw new ServiceUnavailableException(NO_PROVIDER_LIST);
}
- // update network object and return the modified object
- networkInterface.updateNetwork(netUUID, delta);
- NeutronNetwork updatedSingleton = networkInterface.getNetwork(netUUID);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronNetworkAware service = (INeutronNetworkAware) instance;
- service.neutronNetworkUpdated(updatedSingleton);
- }
- }
- return Response.status(HttpURLConnection.HTTP_OK).entity(
- new NeutronNetworkRequest(networkInterface.getNetwork(netUUID))).build();
+ // update network object
+ networkInterface.updateNetwork(netUUID, updatedObject);
+ if (instances != null) {
+ for (Object instance : instances) {
+ INeutronNetworkAware service = (INeutronNetworkAware) instance;
+ service.neutronNetworkUpdated(updatedObject);
+ }
+ }
+ return Response.status(HttpURLConnection.HTTP_OK).entity(
+ new NeutronNetworkRequest(networkInterface.getNetwork(netUUID))).build();
}
/**
if (!networkExists(uuid)) {
return false;
}
- NeutronNetwork target = networkDB.get(uuid);
- boolean rc = overwrite(target, delta);
- if (rc) {
- updateMd(networkDB.get(uuid));
- }
- return rc;
+/* note: because what we get is *not* a delta but (at this point) the updated
+ * object, this is much simpler - just replace the value and update the mdsal
+ * with it */
+ networkDB.replace(uuid, delta);
+ updateMd(delta);
+ return true;
}
@Override