Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
13df2ba
attach and detach network to agent dhcp based on neutron spec https:/…
Aug 31, 2017
b602740
imports re-arranged
Sep 11, 2017
e31a14b
attachNetworkToDhcpAgent test removed
Sep 11, 2017
97e7353
Merge pull request #12 from ContainX/master
zizhongwei Dec 5, 2017
83772d2
Merge pull request #13 from inspur-iop/aodh_gnocchi_support
zizhongwei Dec 5, 2017
f5d597e
Heat, add support for stack abandon and adopt (#1135)
akemr Dec 19, 2017
525f77e
Fix for issue #1124:openstack4j mistaken heat-cfn service as heat ser…
Jan 21, 2018
203e215
Better format used in toString method (#1135)
akemr Jan 23, 2018
6ab339c
"gateway_ip" property is not included in request json.
ewhseo Feb 8, 2018
4b84f30
fix import JsonInclude
ewhseo Feb 8, 2018
e185f4f
Add files via upload
jyothisaroja Jun 12, 2018
72609cd
Update BaseIdentityServices.java
jyothisaroja Jul 23, 2018
6f2e0c2
Update access.json to fix Travis CI build failure
jyothisaroja Jul 24, 2018
368589c
Update authv3_project.json
jyothisaroja Jul 24, 2018
24ff7e8
Update alarm.json to fix Travis CI build failed
jyothisaroja Jul 24, 2018
d6b5f29
Alarm test case fix
Aug 10, 2018
ac21c7a
Merge pull request #1209 from Anshuraj17/master_openstack4j_fix
vinodborole Oct 10, 2018
eb33ccb
Merge pull request #1136 from akemr/heat-abandon
vinodborole Oct 10, 2018
86cc59f
Merge pull request #1142 from newinone/master
vinodborole Oct 10, 2018
c52e1f8
Merge pull request #1149 from ewhseo/develop
vinodborole Oct 10, 2018
dd6452f
Merge pull request #1130 from inspur-iop/master
vinodborole Oct 10, 2018
9f0eeb3
Merge pull request #1082 from rafael-bertoli/dhcp-clients
vinodborole Oct 10, 2018
681a2d8
Merge branch 'master' into jyothisaroja-patch-1
jyothisaroja Oct 12, 2018
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,51 @@
package org.openstack4j.api.heat;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.HashMap;
import java.util.Map;
import org.openstack4j.api.AbstractTest;
import org.openstack4j.model.heat.AdoptStackData;
import org.openstack4j.model.heat.Stack;
import org.openstack4j.openstack.heat.domain.HeatAdoptStackData;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;

/**
* Test cases for Heat Stack Services function
*
* @author Ales Kemr
*/
@Test(suiteName="heat/stacks", enabled = true)
public class StackServiceTests extends AbstractTest {

private static final String JSON_ABANDON = "/heat/abandon.json";
private static final String JSON_ADOPT = "/heat/adopt.json";

public void testAbandonStack() throws Exception {
respondWith(JSON_ABANDON);

AdoptStackData adoptStackData = osv3().heat().stacks().abandon("stack_123", "416c09e9-2022-4d43-854b-0292ddff3f5d");
takeRequest();

assertEquals(adoptStackData.getName(), "stack_123");
assertEquals(adoptStackData.getStatus(), "COMPLETE");
final Map<String, Object> portResource = adoptStackData.getResources().get("network_port");
assertEquals(portResource.get("type"), "OS::Neutron::Port");
}

public void testAdoptStack() throws Exception {
respondWith(JSON_ADOPT);

AdoptStackData adoptStackData = new ObjectMapper().readValue(getResource(JSON_ABANDON), HeatAdoptStackData.class);
Stack adoptedStack = osv3().heat().stacks().adopt(adoptStackData, new HashMap<String, String>(), false, 30L, null);
takeRequest();

assertEquals(adoptedStack.getId(), "79370050-6038-4ea2-baaa-3e4706d59e0e");
}

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

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

import static org.junit.Assert.assertFalse;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
Expand All @@ -14,11 +13,10 @@
import org.openstack4j.api.Builders;
import org.openstack4j.model.network.Agent;
import org.openstack4j.model.network.Agent.Type;
import org.openstack4j.model.storage.block.VolumeBackup;
import org.openstack4j.model.network.Network;
import org.openstack4j.model.network.NetworkType;
import org.openstack4j.model.network.State;
import org.testng.Reporter;
import org.openstack4j.model.common.ActionResponse;
import org.testng.annotations.Test;

import okhttp3.mockwebserver.RecordedRequest;
Expand Down Expand Up @@ -90,6 +88,14 @@ public void agentList() throws Exception {
assertEquals(agent.getAgentType(), Type.DHCP);
}

@Test
public void detachNetworkToDhcpAgent() throws Exception {
respondWith(204);
ActionResponse result = osv3().networking().agent().detachNetworkToDhcpAgent("190ecbc2-77e0-4e4f-a96b-aa849edb357b", "4e8e5957-649f-477b-9e5b-f1f75b21c03c");
server.takeRequest();
assertTrue(result.isSuccess());
}

@Override
protected Service service() {
return Service.NETWORK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public class ServiceTypeTest {

private Map<ServiceType, Collection<String>> types;

private Map<ServiceType, Collection<String>> unknownTypes;

@BeforeSuite
public void setup() {
types = new HashMap<>();
Expand All @@ -37,6 +39,10 @@ public void setup() {
types.put(ServiceType.MAGNUM, Arrays.asList("container","ContainerV3","containerv1"));
types.put(ServiceType.DNS, Arrays.asList("dns","dnsv2","dnsV3"));
types.put(ServiceType.WORKFLOW, Arrays.asList("workflow","workflowv3","workflowv2"));

unknownTypes = new HashMap();
unknownTypes.put(ServiceType.ORCHESTRATION, Arrays.asList("heat-cfg","heatother","heatvm","heat-cfg4"));

}

@Test
Expand All @@ -47,4 +53,13 @@ public void testNameResolveByType() {
}
}
}

@Test
public void testNameNotResolved() {
for (Map.Entry<ServiceType, Collection<String>> entry : unknownTypes.entrySet()) {
for(String type : entry.getValue()){
assertEquals(ServiceType.UNKNOWN, ServiceType.forName(type));
}
}
}
}
55 changes: 55 additions & 0 deletions core-test/src/main/resources/heat/abandon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"files":{

},
"status":"COMPLETE",
"name":"stack_123",
"tags":null,
"stack_user_project_id":"44ed5c0be2384092b8e8b6444812db5d",
"environment":{
"event_sinks":[

],
"parameter_defaults":{

},
"parameters":{

},
"resource_registry":{
"resources":{

}
}
},
"template":{
"heat_template_version":"2016-04-08",
"description":"A heat test template",
"resources":{
"network_port":{
"type":"OS::Neutron::Port",
"properties":{
"network_id":"network123"
}
}
}
},
"action":"CREATE",
"project_id":"0dbd25a2a75347cf88a0a52638b8fff3",
"id":"416c09e9-2022-4d43-854b-0292ddff3f5d",
"resources":{
"network_port":{
"status":"COMPLETE",
"name":"network_port",
"resource_data":{

},
"resource_id":"1d0dccbb-0c99-48cd-b41b-abeca3ac6a42",
"action":"CREATE",
"type":"OS::Neutron::Port",
"metadata":{

}
}
}
}
11 changes: 11 additions & 0 deletions core-test/src/main/resources/heat/adopt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"stack":{
"id":"79370050-6038-4ea2-baaa-3e4706d59e0e",
"links":[
{
"href":"http://any.os.com:8004/v1/0dbd25a2a75347cf88a0a52638b8fff3/stacks/stack_123/79370050-6038-4ea2-baaa-3e4706d59e0e",
"rel":"self"
}
]
}
}
19 changes: 19 additions & 0 deletions core-test/src/main/resources/identity/v2/access.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@
"endpoints_links": [],
"type": "identity",
"name": "keystone"
}, {
"endpoints": [
{
"adminURL": "http:\/\/127.0.0.1:8087\/v2.0",
"region": "RegionOne",
"internalURL": "http:\/\/127.0.0.1:8087\/v2.0",
"id": "9c66xrg3gruv2a3hj8aatd7smmas23fy",
"publicURL": "http:\/\/127.0.0.1:8087\/v2.0"
}, {
"adminURL": "http:\/\/127.0.0.1:8087\/v2.0",
"region": "RegionTwo",
"internalURL": "http:\/\/127.0.0.1:8087\/v2.0",
"id": "9c66xrgerruv2a3hj8batd7smmas23fy",
"publicURL": "http:\/\/127.0.0.1:8087\/v2.0"
}
],
"endpoints_links": [],
"type": "aodh",
"name": "alarming"
}, {
"endpoints": [
{
Expand Down
60 changes: 58 additions & 2 deletions core-test/src/main/resources/identity/v3/authv3_project.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,65 @@
"id": "123450a4597040849c03bc1358854321"
}
],
"type": "telemetry",
"type": "alarming",
"id": "1236500210a24c38a3702b6825e12345",
"name": "ceilometeter"
"name": "aodh"
},
{
"endpoints": [
{
"region_id": "RegionOne",
"url": "http://127.0.0.1:8087",
"region": "RegionOne",
"interface": "public",
"id": "123458912d3f40a09df51035681d5678"
},
{
"region_id": "RegionOne",
"url": "http://127.0.0.1:8087",
"region": "RegionOne",
"interface": "admin",
"id": "12345321ae80458abc3728fa1e6f1234"
},
{
"region_id": "RegionOne",
"url": "http://127.0.0.1:8087",
"region": "RegionOne",
"interface": "internal",
"id": "123450a4597040859c03bc1358854321"
}
],
"type": "metering",
"id": "1236500210a24c38a3702b6835e12345",
"name": "ceilometer"
},
{
"endpoints": [
{
"region_id": "RegionOne",
"url": "http://127.0.0.1:8087",
"region": "RegionOne",
"interface": "public",
"id": "123458912d3f49a09df51035681d59a8"
},
{
"region_id": "RegionOne",
"url": "http://127.0.0.1:8087",
"region": "RegionOne",
"interface": "admin",
"id": "123453dd1ae80457abc3728fa1e6f123"
},
{
"region_id": "RegionOne",
"url": "http://127.0.0.1:8087",
"region": "RegionOne",
"interface": "internal",
"id": "123451a45a7040849c03bc1358854321"
}
],
"type": "aodh",
"id": "1236500210a24c38a1702e6825e12345",
"name": "alarming"
},
{
"endpoints": [
Expand Down
3 changes: 1 addition & 2 deletions core-test/src/main/resources/telemetry/alarm.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[{
{
"alarm_id" : "03757eede9c540338e732d1a7fb07966",
"enabled": false,
"name": "name_post",
Expand Down Expand Up @@ -27,4 +27,3 @@
"granularity": 180
}
}
]
24 changes: 23 additions & 1 deletion core/src/main/java/org/openstack4j/api/heat/StackService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Map;

import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.heat.AdoptStackData;
import org.openstack4j.model.heat.Stack;
import org.openstack4j.model.heat.StackCreate;
import org.openstack4j.model.heat.StackUpdate;
Expand Down Expand Up @@ -100,5 +101,26 @@ Stack create(String name, String template, Map<String, String> parameters,
*/
ActionResponse delete(String stackName, String stackId);


/**
* Deletes a stack but leaves its resources intact, and returns data that describes the stack and its resources.
*
* @param stackName Name of {@link Stack}
* @param stackId Id of {@link Stack}
*
* @return <code>adopt_stack_data</code> element representing by {@link AdoptStackData}
*/
AdoptStackData abandon(String stackName, String stackId);

/**
* Creates a stack from existing resources.
*
* @param adoptStackData Structure {@link AdoptStackData}, representing existing resources
* @param parameters Map of parameters
* @param disableRollback Enable or disable rollback
* @param timeOutMins Timeout in minutes
* @param template Template in Json-Format or YAML format. It is optional, used just in case there will be new resources (not included in adoptStackData)
* @return
*/
Stack adopt(AdoptStackData adoptStackData, Map<String, String> parameters,
boolean disableRollback, Long timeOutMins, String template);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.openstack4j.api.networking.ext;

import java.util.List;

import org.openstack4j.common.RestService;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.network.Agent;

/**
Expand Down Expand Up @@ -35,5 +35,21 @@ public interface AgentService extends RestService {
* @return a new reference to the updated agent
*/
Agent setAdminStateUp(String agentId, boolean state);

/**
* Schedules the network to that the specified DHCP agent.
* @param agentId the id of agent with type DHCP
* @param networkId the id of network
* @return the action response
*/
ActionResponse attachNetworkToDhcpAgent(String agentId, String networkId);

/**
* Removes the network from that the specified DHCP agent.
* @param agentId the id of agent with type DHCP
* @param networkId the id of network
* @return the action response
*/
ActionResponse detachNetworkToDhcpAgent(String agentId, String networkId);

}
Loading