Skip to content

Commit 8993722

Browse files
author
Kashyap Jha
committed
Added Trunk API
1 parent 6454542 commit 8993722

35 files changed

+2157
-669
lines changed

CHANGELOG.md

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,116 @@
11
# Change Log
22

3-
### 3.0.0 (Latest / Stable)
3+
### 3.2.0 (Latest / Stable)
4+
5+
- Implement listCachedImages() for Glance V2 Images #1226
6+
- Make all keystone v3 services (ProjectService, RoleService,..) work #1222
7+
- Add support for “tags” of project which introduced in KeyStone v3.9 #1219
8+
- Solves the issue #1198: "Identity service not working with OS4j". #1199
9+
- neutron attach and detach network to agent dhcp #1082
10+
- aodh-gnocchi alarm support #1130
11+
- Fix for issue #979: Disable Gateway problem #1149
12+
- Fix for issue #1124:openstack4j mistaken heat-cfn service as heat ser… #1142
13+
- Heat service, adding support for stack abandon and adopt #1136
14+
- Alarm test case fix #1209
15+
- aodh-gnocchi alarm support #1134
16+
- Consider the SSLContext of an HttpRequest's Config object when using the Resteasy connector #1162
17+
- Fix issue #1165. #1166
18+
- Make sure the number of okhttp CLOSE_WAIT connections is always manageable #1151
19+
- add loadbalancer_id to LbPoolV2Builder #1143
20+
- Added SFC Service, all calls. #1141
21+
- Better format used in toString method #1135
22+
- Fix JSON deserialize bug cause by 'sessionPersistence' is abstract type #1127
23+
- Add octavia error msg to ActionResponse #1140
24+
- add vip_network_id and vip_port_id for lb post #1133
25+
- Heat, add support for stack abandon and adopt #1135
26+
- pull master #14
27+
- aodh gnocchi driver support #13
28+
- merge #12
29+
- Fix parsing error when Glance V2 image contains optional locations #1096
30+
- Add cascade delete load balancer, it will delete all child objects of… #1120
31+
- Adding device_owner and device_id support for Port #1119
32+
- add detach method to blockstorage api #1106
33+
- merge #11
34+
- Fix octavia pool update session_persistence with value "null" #1099
35+
- Update volume bootable status #1098
36+
- [issue 1094] Fix NPEs caused by okhttp HttpExecutorServiceImpl #1095
37+
- add rescue server status #1100
38+
- fix(secret): fix wrong representation of Secret values & add payload #1088
39+
- Switch to standalone snakeyaml #1092
40+
- Support Availability zones API in Neutron. #1086
41+
42+
### 3.1.0
43+
44+
- Issue : #[1070](https://github.com/ContainX/openstack4j/issues/1070) #1072
45+
- fix Firewall policy param cannot be updated #1074
46+
- Added API for Octavia #1081
47+
- Feature/barbican secret #1080
48+
- Support multiattach property in volume #1079
49+
- Wrong return type of disable/enable service actions #1076
50+
- Fix in ServiceTypeEnum #1078
51+
- Allow identity V3 to lookup service by name #1077
52+
- Update javadoc for BlockDeviceMappingBuilder #1075
53+
- Allow value to be object type in ServiceConfig #1061
54+
- fix unscoped token authentication #1066
55+
- Fix ETag header to match documented name: 'Etag' #1062
56+
- Added a new method createSnapshot() to invoke create image action API with metadata properties #1056
57+
- Adding limit to SampleCriteria for Ceilometer APIs #1052
58+
- Update builder to set old deprecated fields to support volume creation (preserving name and description) for cinder API V1 #1058
59+
- Mistral: add workflow environment and cron trigger endpoint #1055
60+
- 928 ceilometer statistics date parsing #1049
61+
- Renamed CinderVolume properties to be compatible with block storage API v2, fixed broken VolumeTests #1046
62+
- Mistral: add task and action execution endpoints #1048
63+
- Mistral: adding workflow executions endpoint #1043
64+
- Mistral: implement endpoints for action definitions and workbook definitions #1039
65+
- Mistral client: workflow definitions #1009
66+
- Added missing fields in Magnum bay #1034
67+
- Fix cpu info in hypervisor #1028
68+
- Fix cinder volume snapshot #1031
69+
- Add additional properties of the availability zone hint for the network. #1030
70+
- merge #10
71+
- Fix NeutronExtraDhcpOptCreate #1029
72+
- Fix UntrustedSSL SSLVerificationDisabled may cause NullPointerException #1026
73+
- merge #8
74+
- Add http headers for supporting keystone tokenless #1002
75+
- Api for glance image cache, list cached #1020
76+
- update guava version to 20.0 #1021
77+
- Override equal and hashcode method of some Neutron classes #1015
78+
- cherry-picking #932 #1017
79+
- 3.0.4 release #999
80+
- designate v2 service #1011
81+
- SenlinNodeService: details about physical object that backs the node #1001
82+
- Add additional properties of block device mapping api v2 #989
83+
- Allow Port Creation in Bulk #988
84+
- Allow passing additional properties for Glance V2 #986
85+
- Fix for correcting return result type in Magnum Container APIs #984
86+
- add security group and rules filterable list method #981
87+
- Implement Security Group Update API & Support Enable DHCP #978
88+
- support ipv6 properties in subnet again #976
89+
- support Blockstorage Service List #968
90+
- Allow set ID when creating image #972
91+
- Change date-time format in Sahara API to ISO 8601 #961
92+
- Extended OS4J to support OpenStack Magnum Service APIs #969
93+
- Adding neutron port binding data support. #967
94+
- support ipv6 properties in subnet #964
95+
- Fixing port name list option. #965
96+
- add public host property getter #962
97+
- issue 957: run as non-root user in docker #959
98+
- Issue 944: etag support in os.objectStorage().objects().get() #958
99+
- Fix get console output not working with Resteasy connector (#795) #949
100+
- add missed 'os-vol-host-attr:host' property on CinderVolume #952
101+
- fix domain null pointer exception #947
102+
- added unit test readme #945
103+
- OS4J client for Openstack Glare #926
104+
- add Evacuate Server (evacuate Action) #931
105+
- use Long insead of Integer in class GlanceImage #876
106+
- Bug #913: add SSLContext and HostnameVerifier to hashCode and equals #923
107+
- Issue 903 remove last route #917
108+
- Add api for nova service list #914
109+
- Trove Update #910
110+
- Openstack telemetry aodh support #900
111+
- Kept the portsecurityenabled property as undefined #904
112+
113+
### 3.0.0
4114

5115
This is a major milestone release which was driven and lead by @auhlig and @dhague. Special thanks for their major contributions and making this release possible.
6116

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This software is licensed under the Apache 2 license, quoted below.
22

3-
Copyright 2015 Jeremy Unruh and OpenStack4j
3+
Copyright 2019 Jeremy Unruh and OpenStack4j
44

55
Licensed under the Apache License, Version 2.0 (the "License"); you may not
66
use this file except in compliance with the License. You may obtain a copy of

README.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ OpenStack4j is a fluent OpenStack client that allows provisioning and control of
2121

2222
## Requirements
2323

24+
* OpenStack4j 3.2.X - Java 8+
2425
* OpenStack4j 3.0.X - Java 7 (JDK 8 preferred)
2526
* OpenStack4j 2.0.X - Java 7
2627

@@ -38,7 +39,7 @@ OpenStack4j version 2.0.0+ is now modular. One of the benefits to this is the a
3839
<dependency>
3940
<groupId>org.pacesys</groupId>
4041
<artifactId>openstack4j</artifactId>
41-
<version>3.1.0</version>
42+
<version>3.2.0</version>
4243
</dependency>
4344
```
4445

@@ -54,7 +55,7 @@ See notes above about connectors (same rules apply) to development branches.
5455
<dependency>
5556
<groupId>org.pacesys</groupId>
5657
<artifactId>openstack4j</artifactId>
57-
<version>3.1.1-SNAPSHOT</version>
58+
<version>3.2.1-SNAPSHOT</version>
5859
</dependency>
5960
```
6061

@@ -79,25 +80,23 @@ Contributing
7980
------------
8081
If you would like to contribute please see our contributing [guidelines](https://github.com/ContainX/openstack4j/blob/master/CONTRIBUTING.md)
8182

82-
#### Top 15 Contributors
83-
84-
| Rank | Login | Contributions |
85-
| :--- | :---- | :------------ |
86-
| 1 | @gondor | 527 |
87-
| 2 | @auhlig | 57 |
88-
| 3 | @octupszhang | 26 |
89-
| 4 | @gonzolino | 18 |
90-
| 5 | @ekasitk | 17 |
91-
| 6 | @magixyu | 17 |
92-
| 7 | @maxrome | 12 |
93-
| 8 | @isartcanyameres | 9 |
94-
| 9 | @iviireczech | 8 |
95-
| 10 | @n-r-anderson | 7 |
96-
| 11 | @krishnabrucelee | 6 |
97-
| 12 | @peter-nordquist | 4 |
98-
| 13 | @RibeiroAna | 4 |
99-
| 14 | @symcssn | 4 |
100-
| 15 | @olivergondza | 5 |
83+
#### Thank you contributors
84+
85+
- @gondor
86+
- @auhlig
87+
- @octupszhang
88+
- @gonzolino
89+
- @ekasitk
90+
- @magixyu
91+
- @maxrome
92+
- @isartcanyameres
93+
- @iviireczech
94+
- @n-r-anderson
95+
- @krishnabrucelee
96+
- @peter-nordquist
97+
- @RibeiroAna
98+
- @symcssn
99+
- @olivergondza
101100

102101
#### Throughput
103102

@@ -398,7 +397,7 @@ License
398397
```
399398
This software is licensed under the Apache 2 license, quoted below.
400399

401-
Copyright 2016 ContainX and OpenStack4j
400+
Copyright 2019 ContainX and OpenStack4j
402401

403402
Licensed under the Apache License, Version 2.0 (the "License"); you may not
404403
use this file except in compliance with the License. You may obtain a copy of
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package org.openstack4j.api.network;
2+
3+
import static org.testng.Assert.assertEquals;
4+
import static org.testng.Assert.assertNotNull;
5+
import static org.testng.Assert.assertTrue;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
10+
import org.openstack4j.api.AbstractTest;
11+
import org.openstack4j.api.Builders;
12+
import org.openstack4j.model.common.ActionResponse;
13+
import org.openstack4j.model.network.Port;
14+
import org.openstack4j.model.network.SubPort;
15+
import org.openstack4j.model.network.Trunk;
16+
import org.openstack4j.openstack.networking.domain.NeutronSubPort;
17+
import org.testng.annotations.Test;
18+
19+
/**
20+
* Rewrote the entire API and so had to re-write tests
21+
*
22+
* @author Kashyap Jha
23+
*/
24+
@Test(suiteName = "Network")
25+
public class TrunkTests extends AbstractTest {
26+
27+
private static final String JSON_CREATE_TRUNK_RESPONSE = "/network/createTrunkResponse.json";
28+
private static final String JSON_ADD_SUBPORT_RESPONSE = "/network/addSubPortResponse.json";
29+
private static final String JSON_REMOVE_SUBPORT_RESPONSE = "/network/removeSubPortResponse.json";
30+
private static final String JSON_GET_TRUNK_RESPONSE = "/network/getTrunkResponse.json";
31+
private static final String JSON_UPDATE_TRUNK_RESPONSE = "/network/updateTrunkResponse.json";
32+
private static final String JSON_LIST_SUBPORTS_RESPONSE = "/network/listSubPortsResponse.json";
33+
private static final String JSON_LIST_TRUNKS_RESPONSE = "/network/listTrunksResponse.json";
34+
private static final String JSON_PORT_CREATE_RESPONSE = "/network/portCreateResponse.json";
35+
36+
@Override
37+
protected Service service() {
38+
return Service.NETWORK;
39+
}
40+
41+
@Test(enabled = true)
42+
public void createTrunk() throws Exception {
43+
respondWith(JSON_PORT_CREATE_RESPONSE);
44+
45+
String network1Id = "466e612-73a3-45df-96b6-4c084dfe1fc7";
46+
String port1Name = "port1";
47+
String trunk1Name = "trunk1";
48+
49+
Port toBuild = Builders.port().networkId(network1Id).name(port1Name).build();
50+
Port builtPort = osv3().networking().port().create(toBuild);
51+
52+
respondWith(JSON_CREATE_TRUNK_RESPONSE);
53+
Trunk builtTrunk = osv3.networking().trunk()
54+
.createTrunk(Builders.trunk().name(trunk1Name).parentPort(builtPort.getId()).build());
55+
56+
assertNotNull(builtTrunk);
57+
assertEquals(builtTrunk.getParentPort(), builtPort.getId());
58+
assertEquals(builtTrunk.getName(), trunk1Name);
59+
}
60+
61+
@Test(enabled = true)
62+
public void deleteTrunk() throws Exception {
63+
respondWith(204);
64+
String trunkId = "8a2ea42d-06b5-42c2-a54d-97105420f2bb";
65+
ActionResponse delete = osv3().networking().trunk().deleteTrunk(trunkId);
66+
assertTrue(delete.isSuccess());
67+
}
68+
69+
@Test(enabled = true)
70+
public void listTrunks() throws Exception {
71+
respondWith(JSON_LIST_TRUNKS_RESPONSE);
72+
73+
String trunk1Id = "cf15956d-4391-4ebf-a9cb-0f7e27b24073";
74+
String trunk2Id = "f98559e9-8e92-4100-96ac-a805e0340abd";
75+
List<String> trunkIds = new ArrayList<>();
76+
assertNotNull(trunkIds);
77+
for (Trunk t : osv3().networking().trunk().list()) {
78+
assertNotNull(t);
79+
trunkIds.add(t.getId());
80+
}
81+
assertTrue(trunkIds.contains(trunk1Id));
82+
assertTrue(trunkIds.contains(trunk2Id));
83+
}
84+
85+
@Test(enabled = true)
86+
public void updateTrunk() throws Exception {
87+
respondWith(JSON_UPDATE_TRUNK_RESPONSE);
88+
89+
String trunkId = "f98559e9-8e92-4100-96ac-a805e0340abd";
90+
String updatedName = "changedName";
91+
Trunk updatedTrunk = osv3().networking().trunk().updateTrunk(Builders.trunk().name(updatedName).build(),
92+
trunkId);
93+
assertNotNull(updatedTrunk);
94+
assertEquals(updatedTrunk.getName(), updatedName);
95+
assertEquals(updatedTrunk.getId(), trunkId);
96+
}
97+
98+
@Test(enabled = true)
99+
public void addSubPort() throws Exception {
100+
respondWith(JSON_ADD_SUBPORT_RESPONSE);
101+
102+
String trunkId = "f98559e9-8e92-4100-96ac-a805e0340abd";
103+
String subPortId = "9d30c4d8-3bb6-4b59-99ab-5eaa22e55037";
104+
int segmentationId = 101;
105+
String segmentationType = "vlan";
106+
SubPort subPort = NeutronSubPort.builder().portId(subPortId).segmentationId(segmentationId)
107+
.segmentationType("vlan").build();
108+
Trunk withSubPort = osv3().networking().trunk().addSubPort(trunkId, subPort);
109+
assertNotNull(withSubPort);
110+
assertEquals(subPortId, withSubPort.getSubPorts().get(0).getPortId());
111+
assertEquals(segmentationId, withSubPort.getSubPorts().get(0).getSegmentationId());
112+
assertEquals(segmentationType, withSubPort.getSubPorts().get(0).getSegmentationType());
113+
}
114+
115+
@Test(enabled = true)
116+
public void removeSubPort() throws Exception {
117+
respondWith(JSON_REMOVE_SUBPORT_RESPONSE);
118+
119+
String trunkId = "f98559e9-8e92-4100-96ac-a805e0340abd";
120+
String subPortId = "9d30c4d8-3bb6-4b59-99ab-5eaa22e55037";
121+
Trunk withoutSubport = osv3().networking().trunk().removeSubPort(trunkId, subPortId);
122+
assertNotNull(withoutSubport);
123+
assertTrue(withoutSubport.getSubPorts().isEmpty());
124+
}
125+
126+
@Test(enabled = true)
127+
public void listSubPorts() throws Exception {
128+
respondWith(JSON_LIST_SUBPORTS_RESPONSE);
129+
130+
String trunkId = "f98559e9-8e92-4100-96ac-a805e0340abd";
131+
List<String> ids = new ArrayList<>();
132+
List<NeutronSubPort> subPorts = osv3().networking().trunk().listSubPorts(trunkId);
133+
assertNotNull(subPorts);
134+
for (SubPort subPort : subPorts) {
135+
assertNotNull(subPort);
136+
ids.add(subPort.getId());
137+
}
138+
assertEquals(ids.size(), 2);
139+
}
140+
141+
@Test(enabled = true)
142+
public void getTrunk() throws Exception {
143+
respondWith(JSON_GET_TRUNK_RESPONSE);
144+
145+
String trunkId = "cf15956d-4391-4ebf-a9cb-0f7e27b24073";
146+
String portId = "e2d70799-b1e3-4737-9298-23cfb5c94416";
147+
Trunk trunk = osv3().networking().trunk().get(trunkId);
148+
assertNotNull(trunk);
149+
assertEquals(trunkId, trunk.getId());
150+
assertEquals(portId, trunk.getParentPort());
151+
}
152+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"status": "DOWN",
3+
"sub_ports": [{
4+
"segmentation_type": "vlan",
5+
"port_id": "9d30c4d8-3bb6-4b59-99ab-5eaa22e55037",
6+
"segmentation_id": 101
7+
}],
8+
"name": "changedName",
9+
"admin_state_up": true,
10+
"tenant_id": "1b9ef7f7ec0c41ac83e3ea0df5257f60",
11+
"created_at": "2019-03-28T10:16:40Z",
12+
"tags": [],
13+
"updated_at": "2019-03-28T10:34:18Z",
14+
"revision_number": 2,
15+
"project_id": "1b9ef7f7ec0c41ac83e3ea0df5257f60",
16+
"port_id": "e88917ca-039d-4758-ad0c-5e0e03dc75ae",
17+
"id": "f98559e9-8e92-4100-96ac-a805e0340abd",
18+
"description": ""
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"trunk":{
3+
"status":"DOWN",
4+
"sub_ports":[],
5+
"name":"trunk1",
6+
"admin_state_up":true,
7+
"tenant_id":"1b9ef7f7ec0c41ac83e3ea0df5257f60",
8+
"created_at":"2019-03-28T05:41:32Z",
9+
"tags":[],
10+
"updated_at":"2019-03-28T05:41:32Z",
11+
"revision_number":0,
12+
"project_id":"1b9ef7f7ec0c41ac83e3ea0df5257f60",
13+
"port_id":"0908f280-d0e8-45c6-acec-85714181ddb1",
14+
"id":"8fc625a7-d9a9-415f-83b3-87e9926990fd",
15+
"description":""
16+
}
17+
}

0 commit comments

Comments
 (0)