Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a63c8ac
Solve the problem of hostAggregates creation failure
Cherry522 Feb 13, 2017
98bd231
Add 'MTU' property to 'network'
Cherry522 Feb 14, 2017
be3b96c
Add 'vnicType' property to 'Port'.
Cherry522 Feb 14, 2017
0bdb30b
Add a feature to enable or disable DHCP when modify a subnet.
Cherry522 Feb 14, 2017
7b16fcd
Solve the problem:java.lang.NullPointerException:org.openstack4j.open…
Cherry522 Feb 14, 2017
227c5f7
Add 'distributed' property to 'Router'.
Cherry522 Feb 14, 2017
90596e3
Add 'state' and 'status' fields in 'ExtHypervisor'.
Cherry522 Feb 14, 2017
3af1c17
add a attaching volume funtion in Volumes
Cherry522 Feb 14, 2017
d23bf85
Evacuate Server (evacuate Action)
test-1pro Feb 9, 2017
bc6a389
Add evacuate server Testunit.
test-1pro Feb 10, 2017
395b9bf
Add the JSON contains the response as defined in OpenStacks API.
test-1pro Feb 13, 2017
805cda7
Update Test Code : assertNotNull -> assertEquals
test-1pro Feb 13, 2017
9daf525
add os-hosts and os-services interface
Cherry522 Feb 15, 2017
4847f43
add a method in os-interface:Creates a port interface and uses it to …
Cherry522 Feb 15, 2017
6da6cc6
update method name from 'getAvaiablityZone()' to 'getAvailablityZone(…
Cherry522 Feb 16, 2017
817cd90
add hostAggregates list test
Cherry522 Feb 17, 2017
a99045d
Merge branch 'master' of https://github.com/ContainX/openstack4j into…
Cherry522 Feb 17, 2017
f621b30
add hostAggregates list create
Cherry522 Feb 17, 2017
72e16e1
add list method with fields for security-groups and security-group-rules
Cherry522 Feb 17, 2017
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
@@ -0,0 +1,52 @@
package org.openstack4j.api.compute;

import static org.testng.Assert.assertEquals;

import java.util.List;

import org.openstack4j.api.AbstractTest;
import org.openstack4j.model.compute.HostAggregate;
import org.testng.annotations.Test;

/**
* Host Aggregate Tests
* @author chenyan
*
*/
@Test(suiteName = "HostAggregate")
public class HostAggregateTests extends AbstractTest {

private static final String JSON_HOST_AGGREGATES = "/compute/aggregates.json";
private static final String JSON_HOST_AGGREGATE_CREATE = "/compute/aggregate_create.json";

@Test
public void serviceListingTest() throws Exception {
respondWith(JSON_HOST_AGGREGATES);

List<? extends HostAggregate> hostAggregateList = osv3().compute().hostAggregates().list();
assertEquals(hostAggregateList.size(),2);

HostAggregate aggregate = hostAggregateList.get(0);
assertEquals(aggregate.getAvailabilityZone(),"uec_zone_1");
assertEquals(aggregate.getId(),"8");
assertEquals(aggregate.getName(),"aggregate_zl_test");
}

@Test
public void createTest() throws Exception {
respondWith(JSON_HOST_AGGREGATE_CREATE);

String name = "testAggregate01";
String availabilityZone = "nova";
HostAggregate hostAggregate = osv3().compute().hostAggregates().create(name, availabilityZone);
assertEquals(null != hostAggregate, true);
assertEquals(hostAggregate.getName(),name);
assertEquals(hostAggregate.getAvailabilityZone(),availabilityZone);
}

@Override
protected Service service() {
return Service.COMPUTE;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.openstack4j.api.network;

import static org.testng.Assert.assertEquals;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.openstack4j.api.AbstractTest;
import org.openstack4j.model.network.SecurityGroupRule;
import org.testng.annotations.Test;

/**
* Security Group Rule Test
* @author chenyan
*
*/
public class SecurityGroupRuleTest extends AbstractTest {

private static final String JSON_SECURITY_GROUP_RULES = "/network/security_group_rulesv2.json";

@Test
public void serviceListingTest() throws Exception {
respondWith(JSON_SECURITY_GROUP_RULES);

Map<String, Object> params = new HashMap<String, Object>();
String security_group_id = "85cc3048-abc3-43cc-89b3-377341426ac5";
params.put("security_group_id", security_group_id);
List<? extends SecurityGroupRule> ruleList = osv3().networking().securityrule().list(params);
assertEquals(ruleList.size(),4);

SecurityGroupRule rule = ruleList.get(0);
assertEquals(rule.getSecurityGroupId(),security_group_id);
}

@Override
protected Service service() {
return Service.NETWORK;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.openstack4j.api.network;

import static org.testng.Assert.assertEquals;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.openstack4j.api.AbstractTest;
import org.openstack4j.model.network.SecurityGroup;
import org.testng.annotations.Test;

/**
* Security Group Test
* @author chenyan
*
*/
public class SecurityGroupTest extends AbstractTest {

private static final String JSON_SECURITY_GROUPS = "/network/security_groupsv2.json";

@Test
public void serviceListingTest() throws Exception {
respondWith(JSON_SECURITY_GROUPS);

Map<String, Object> params = new HashMap<String, Object>();
String projectId = "e4f50856753b4dc6afee5fa6b9b6c550";
params.put("tenant_id", projectId);
String tenantId = "e4f50856753b4dc6afee5fa6b9b6c550";
params.put("project_id", tenantId);
List<? extends SecurityGroup> securityGroupList = osv3().networking().securitygroup().list(params);
assertEquals(securityGroupList.size(),1);

SecurityGroup securityGroup = securityGroupList.get(0);
assertEquals(securityGroup.getTenantId(),tenantId);
}

@Override
protected Service service() {
return Service.NETWORK;
}

}
7 changes: 7 additions & 0 deletions core-test/src/main/resources/compute/aggregate_create.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"aggregate":
{
"name": "testAggregate01",
"availability_zone": "nova"
}
}
35 changes: 35 additions & 0 deletions core-test/src/main/resources/compute/aggregates.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"aggregates": [
{
"availability_zone": "uec_zone_1",
"create": 1485163578000,
"created_at": 1485163578000,
"deleted": false,
"hosts": [
"node-70.domain.tld",
"node-68.domain.tld",
"node-69.domain.tld"
],
"id": "8",
"metadata": {
"availability_zone": "uec_zone_1"
},
"name": "aggregate_zl_test"
},
{
"availability_zone": "uec_zone_1",
"create": 1486968614000,
"created_at": 1486968614000,
"deleted": false,
"hosts": [
"node-70.domain.tld",
"node-69.domain.tld"
],
"id": "9",
"metadata": {
"availability_zone": "uec_zone_1"
},
"name": "cyTest01"
}
]
}
60 changes: 60 additions & 0 deletions core-test/src/main/resources/network/security_group_rulesv2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"security_group_rules": [
{
"direction": "egress",
"ethertype": "IPv6",
"id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
"port_range_max": null,
"port_range_min": null,
"protocol": null,
"remote_group_id": null,
"remote_ip_prefix": null,
"security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"project_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"description": ""
},
{
"direction": "egress",
"ethertype": "IPv4",
"id": "93aa42e5-80db-4581-9391-3a608bd0e448",
"port_range_max": null,
"port_range_min": null,
"protocol": null,
"remote_group_id": null,
"remote_ip_prefix": null,
"security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"project_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"description": ""
},
{
"direction": "ingress",
"ethertype": "IPv6",
"id": "c0b09f00-1d49-4e64-a0a7-8a186d928138",
"port_range_max": null,
"port_range_min": null,
"protocol": null,
"remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"remote_ip_prefix": null,
"security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"project_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"description": ""
},
{
"direction": "ingress",
"ethertype": "IPv4",
"id": "f7d45c89-008e-4bab-88ad-d6811724c51c",
"port_range_max": null,
"port_range_min": null,
"protocol": null,
"remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"remote_ip_prefix": null,
"security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"project_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"description": ""
}
]
}
69 changes: 69 additions & 0 deletions core-test/src/main/resources/network/security_groupsv2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"security_groups": [
{
"description": "default",
"id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"name": "default",
"security_group_rules": [
{
"direction": "egress",
"ethertype": "IPv6",
"id": "3c0e45ff-adaf-4124-b083-bf390e5482ff",
"port_range_max": null,
"port_range_min": null,
"protocol": null,
"remote_group_id": null,
"remote_ip_prefix": null,
"security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"project_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"description": ""
},
{
"direction": "egress",
"ethertype": "IPv4",
"id": "93aa42e5-80db-4581-9391-3a608bd0e448",
"port_range_max": null,
"port_range_min": null,
"protocol": null,
"remote_group_id": null,
"remote_ip_prefix": null,
"security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"project_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"description": ""
},
{
"direction": "ingress",
"ethertype": "IPv6",
"id": "c0b09f00-1d49-4e64-a0a7-8a186d928138",
"port_range_max": null,
"port_range_min": null,
"protocol": null,
"remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"remote_ip_prefix": null,
"security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"project_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"description": ""
},
{
"direction": "ingress",
"ethertype": "IPv4",
"id": "f7d45c89-008e-4bab-88ad-d6811724c51c",
"port_range_max": null,
"port_range_min": null,
"protocol": null,
"remote_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"remote_ip_prefix": null,
"security_group_id": "85cc3048-abc3-43cc-89b3-377341426ac5",
"project_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"description": ""
}
],
"project_id": "e4f50856753b4dc6afee5fa6b9b6c550",
"tenant_id": "e4f50856753b4dc6afee5fa6b9b6c550"
}
]
}
18 changes: 18 additions & 0 deletions core/src/main/java/org/openstack4j/api/compute/HostService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.openstack4j.api.compute;

import java.util.List;
import java.util.Map;

import org.openstack4j.common.RestService;
import org.openstack4j.model.compute.HostResource;
Expand All @@ -20,5 +21,22 @@ public interface HostService extends RestService {
* @return the Resource of the Host specified
*/
public List<? extends HostResource> hostDescribe(String hostName);

/**
* List all host that the current tenant has access to
*
* @return list of all hosts
* @author Wang Ting/王婷
*/
List<? extends HostResource> list();

/**
* Returns list of hosts filtered by parameters.
*
* @param filteringParams map (name, value) of filtering parameters
* @return
* @author Wang Ting/王婷
*/
List<? extends HostResource> list(Map<String, String> filteringParams);

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,12 @@ public interface HypervisorService extends RestService {
* @return the hypervisor statistics
*/
HypervisorStatistics statistics();


/**
* Get the specified Hypervisor by ID
* Author:Wang Ting
* @param hypervisorId the hypervisor identifier
* @return the Hypervisor or null if not found
*/
Hypervisor get(String hypervisorId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public interface InterfaceService extends RestService {
* @return the attached interface
*/
InterfaceAttachment create(String serverId, String portId);

/**
* Creates a port interface and uses it to attach a port to a server.
* @param serverId:instance id
* @param portId: The ID of the port for which you want to create an interface. The net_id and port_id parameters are mutually exclusive. If you do not specify the port_id parameter, the OpenStack Networking API v2.0 allocates a port and creates an interface for it on the network.
* @param netId:The ID of the network for which you want to create a port interface. The net_id and port_id parameters are mutually exclusive. If you do not specify the net_id parameter, the OpenStack Networking API v2.0 uses the network information cache that is associated with the instance.
* @return
*/
InterfaceAttachment create(String serverId, String portId, String netId);

/**
* List the port interfaces for the specified {@code serverId}
Expand Down
Loading