"\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\","+
"\"ip_address\": \"10.0.0.2\" } ],"+
"\"id\": \"65c0ee9f-d634-4522-8954-51021b570b0d\","+
- "\"security_groups\": [ \"f0ac4394-7e4a-4409-9701-ba8be283dbc3\" ],"+
+ "\"security_groups\": [] ,"+
"\"device_id\": \"\" } }";
ITNeutronE2E.test_create(url, content,"Singleton Port Post Failed NB");
}
String content = "{\"port\": {\"status\": \"DOWN\", \"binding:host_id\": \"\", \"allowed_address_pairs\": [], \"device_owner\": \"network:router_gateway\", \"binding:profile\": {}, \"fixed_ips\": [{\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\", \"ip_address\": \"10.0.0.1\"}], \"id\": \"d8a4cc85-ad78-46ac-b5a1-8e04f16fa51e\", \"security_groups\": [], \"device_id\": \"8604a0de-7f6b-409a-a47c-a1cc7bc77b2e\", \"name\": \"\", \"admin_state_up\": true, \"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", \"tenant_id\": \"9bacb3c5d39d41a79512987f338cf177\", \"binding:vif_details\": {}, \"binding:vnic_type\": \"normal\", \"binding:vif_type\": \"unbound\", \"mac_address\": \"fa:16:3e:dc:1d:8d\"}}";
ITNeutronE2E.test_create(url, content, "Router Interface Port Post Failed NB");
}
+
+ public void bulk_port_create_test() {
+ String url = base + "/ports";
+ String content = "{ \"ports\": [ { "
+ + " \"status\": \"DOWN\", "
+ + " \"name\": \"sample_port_1\", "
+ + " \"allowed_address_pairs\": [], "
+ + " \"admin_state_up\": false, "
+ + " \"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", "
+ + " \"tenant_id\": \"d6700c0c9ffa4f1cb322cd4a1f3906fa\", "
+ + " \"device_owner\": \"\", "
+ + " \"mac_address\": \"fa:16:3e:48:b8:9f\", "
+ + " \"fixed_ips\": [ { "
+ + "\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\","
+ + " \"ip_address\": \"10.0.0.5\" } ], "
+ + " \"id\": \"94225baa-9d3f-4b93-bf12-b41e7ce49cdb\", "
+ + " \"security_groups\": [], "
+ + " \"device_id\": \"\" }, { "
+ + " \"status\": \"DOWN\", "
+ + " \"name\": \"sample_port_2\", "
+ + " \"allowed_address_pairs\": [], "
+ + " \"admin_state_up\": false, "
+ + " \"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", "
+ + " \"tenant_id\": \"d6700c0c9ffa4f1cb322cd4a1f3906fa\", "
+ + " \"device_owner\": \"\", "
+ + " \"mac_address\": \"fa:16:3e:f4:73:df\", "
+ + " \"fixed_ips\": [ { "
+ + "\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\","
+ + " \"ip_address\": \"10.0.0.6\" } ], "
+ + " \"id\": \"43c831e0-19ce-4a76-9a49-57b57e69428b\", "
+ + " \"security_groups\": [], "
+ + " \"device_id\": \"\" } ] } ";
+ ITNeutronE2E.test_create(url, content, "Bulk Subnet Post Failed");
+ }
+
+ public void port_update_test() {
+ String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
+ String content = " { \"port\": { "
+ + " \"status\": \"DOWN\", "
+ + " \"binding:host_id\": \"test_for_port_update_host\", "
+ + " \"allowed_address_pairs\": [], "
+ + " \"extra_dhcp_opts\": [], "
+ + " \"device_owner\": \"compute:nova\", "
+ + " \"binding:profile\": {}, "
+ + " \"fixed_ips\": [ { "
+ + "\"subnet_id\": \"3b80198d-4f7b-4f77-9ef5-774d54e17126\","
+ + " \"ip_address\": \"10.0.0.7\" } ], "
+ + " \"id\": \"43c831e0-19ce-4a76-9a49-57b57e69428b\", "
+ + " \"security_groups\": [], "
+ + " \"device_id\": \"\", "
+ + " \"name\": \"test-for-port-update\", "
+ + " \"admin_state_up\": true, "
+ + " \"network_id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\", "
+ + " \"tenant_id\": \"522eda8d23124b25bf03fe44f1986b74\", "
+ + " \"binding:vif_details\": {}, "
+ + " \"binding:vnic_type\": \"normal\", "
+ + " \"binding:vif_type\": \"binding_failed\", "
+ + " \"mac_address\": \"fa:16:3e:11:11:5e\" } } ";
+ ITNeutronE2E.test_modify(url, content,"Subnet Put Failed");
+ }
+
+ public void port_element_get_test() {
+ String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
+ ITNeutronE2E.test_fetch(url, true, "Subnet Element Get Failed");
+ }
+
+ public void port_delete_test() {
+ String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
+ ITNeutronE2E.test_delete(url, "Subnet Element Delete Failed");
+ }
+
+ public void port_element_negative_get_test() {
+ String url = base + "/ports/43c831e0-19ce-4a76-9a49-57b57e69428b";
+ ITNeutronE2E.test_fetch(url, false, "Subnet Element Get Failed");
+ }
}
) {
NeutronCRUDInterfaces interfaces = getNeutronInterfaces(false, true);
INeutronPortCRUD portInterface = interfaces.getPortInterface();
- INeutronSubnetCRUD subnetInterface = interfaces.getSubnetInterface();
-
// port has to exist and only a single delta is supported
if (!portInterface.portExists(portUUID)) {
throw new ResourceNotFoundException(UUID_NO_EXIST);
}
- NeutronPort target = portInterface.getPort(portUUID);
+ NeutronPort original = portInterface.getPort(portUUID);
if (!input.isSingleton()) {
throw new BadRequestException("only singleton edit suported");
}
- NeutronPort singleton = input.getSingleton();
- NeutronPort original = portInterface.getPort(portUUID);
- // deltas restricted by Neutron
- if (singleton.getID() != null || singleton.getTenantID() != null ||
- singleton.getStatus() != null) {
- throw new BadRequestException("attribute change blocked by Neutron");
- }
+ /*
+ * note: what we get appears to not be a delta, but rather a possibly
+ * complete updated object. So, that needs to be sent down to
+ * folks to check
+ */
+
+ NeutronPort updatedObject = input.getSingleton();
+ updatedObject.setID(portUUID);
Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
if (instances != null) {
if (instances.length > 0) {
for (Object instance : instances) {
INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canUpdatePort(singleton, original);
+ int status = service.canUpdatePort(updatedObject, original);
if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
return Response.status(status).build();
}
throw new ServiceUnavailableException(NO_PROVIDER_LIST);
}
- // Verify the new fixed ips are valid
- List<Neutron_IPs> fixedIPs = singleton.getFixedIPs();
- if (fixedIPs != null && fixedIPs.size() > 0) {
- Iterator<Neutron_IPs> fixedIPIterator = fixedIPs.iterator();
- while (fixedIPIterator.hasNext()) {
- Neutron_IPs ip = fixedIPIterator.next();
- if (ip.getSubnetUUID() == null) {
- throw new BadRequestException("subnet UUID must be specified");
- }
- if (!subnetInterface.subnetExists(ip.getSubnetUUID())) {
- throw new BadRequestException("subnet UUID doesn't exist.");
- }
- NeutronSubnet subnet = subnetInterface.getSubnet(ip.getSubnetUUID());
- if (!target.getNetworkUUID().equalsIgnoreCase(subnet.getNetworkUUID())) {
- throw new BadRequestException(NET_UUID_MATCH);
- }
- if (ip.getIpAddress() != null) {
- if (!subnet.isValidIP(ip.getIpAddress())) {
- throw new BadRequestException("invalid IP address");
- }
- if (subnet.isIPInUse(ip.getIpAddress())) {
- throw new ResourceConflictException("IP address in use");
- }
- }
- }
- }
-
// TODO: Support change of security groups
// update the port and return the modified object
- portInterface.updatePort(portUUID, singleton);
- NeutronPort updatedPort = portInterface.getPort(portUUID);
+ portInterface.updatePort(portUUID, updatedObject);
if (instances != null) {
for (Object instance : instances) {
INeutronPortAware service = (INeutronPortAware) instance;
- service.neutronPortUpdated(updatedPort);
+ service.neutronPortUpdated(updatedObject);
}
}
return Response.status(HttpURLConnection.HTTP_OK).entity(
- new NeutronPortRequest(updatedPort)).build();
+ new NeutronPortRequest(updatedObject)).build();
}