Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Bug Fixes and New Features
--------------------------

Before starting to write code, look for existing [tickets]
(https://github.com/gondor/openstack4j/issues?state=open) or [create one]
(https://github.com/gondor/openstack4j/issues/new)
(https://github.com/ContainX/openstack4j/issues?state=open) or [create one]
(https://github.com/ContainX/openstack4j/issues/new)
for your bug, issue, or feature request. This helps the community
avoid working on something that might not be of interest or which
has already been addressed.
Expand All @@ -31,7 +31,7 @@ Chat With Me
------------

If you want to work on something or have questions / complaints please reach
out to me by creating a Question issue at https://github.com/gondor/openstack4j/issues/new or better yet join our group at http://groups.google.com/group/openstack4j
out to me by creating a Question issue at https://github.com/ContainX/openstack4j/issues/new or better yet join our group at http://groups.google.com/group/openstack4j

Thank you for your support!

Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ OpenStack4j
===========

[![Build Status](https://travis-ci.org/ContainX/openstack4j.svg?branch=master)](https://travis-ci.org/ContainX/openstack4j) [![License](https://img.shields.io/badge/license-Apache%202-blue.svg)]()
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gondor/openstack4j?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

OpenStack4j is a fluent OpenStack client that allows provisioning and control of an OpenStack deployment. This includes support for Identity, Compute, Image, Network, Block Storage, Telemetry, Data Processing as well as many extensions (LBaaS, FWaaS, Quota-Sets, etc)

Expand All @@ -12,9 +11,9 @@ OpenStack4j is a fluent OpenStack client that allows provisioning and control of
* Documentation/Tutorials: [OpenStack4j.com/learn/](http://www.openstack4j.com/learn/)
* Questions - Use Google Groups: [groups.google.com/group/openstack4j](http://groups.google.com/group/openstack4j)
* Questions - [Stackoverflow](http://stackoverflow.com/search?q=openstack4j)
* Chat on Slack: [containx.slack.com](https://containx.slack.com)
* Twitter: [@openstack4j](https://twitter.com/openstack4j)
* Facebook: [facebook.com/openstack4j](http://www.facebook.com/openstack4j)
* Changelog: [Changelog](https://github.com/gondor/openstack4j/blob/master/CHANGELOG.md)
* Changelog: [Changelog](https://github.com/ContainX/openstack4j/blob/master/CHANGELOG.md)

## Bug Reports

Expand Down Expand Up @@ -45,7 +44,7 @@ OpenStack4j version 2.0.0+ is now modular. One of the benefits to this is the a

**Using OpenStack4j with one of our connector modules**

To configure OpenStack4j to use one of our supported connectors (Jersey 2, Resteasy, Apache HttpClient, OKHttp) [see the usage guide](https://github.com/gondor/openstack4j/tree/master/connectors)
To configure OpenStack4j to use one of our supported connectors (Jersey 2, Resteasy, Apache HttpClient, OKHttp) [see the usage guide](https://github.com/ContainX/openstack4j/tree/master/connectors)

#### Current (Master Branch)

Expand Down Expand Up @@ -78,7 +77,7 @@ Example POM based repository declaration to grab snapshots:

Contributing
------------
If you would like to contribute please see our contributing [guidelines](https://github.com/gondor/openstack4j/blob/master/CONTRIBUTING.md)
If you would like to contribute please see our contributing [guidelines](https://github.com/ContainX/openstack4j/blob/master/CONTRIBUTING.md)

#### Top 15 Contributors

Expand All @@ -102,7 +101,7 @@ If you would like to contribute please see our contributing [guidelines](https:/

#### Throughput

[![Throughput Graph](https://graphs.waffle.io/gondor/openstack4j/throughput.svg)](https://waffle.io/gondor/openstack4j/metrics)
[![Throughput Graph](https://graphs.waffle.io/ContainX/openstack4j/throughput.svg)](https://waffle.io/ContainX/openstack4j/metrics)

Quick Usage Guide
-----------------
Expand Down
4 changes: 2 additions & 2 deletions connectors/httpclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>openstack4j-httpclient</artifactId>
<name>OpenStack4j HttpComponents-HttpClient Connector</name>
<url>http://github.com/gondor/openstack4j/</url>
<url>http://github.com/ContainX/openstack4j/</url>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -58,4 +58,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import java.util.HashMap;
import java.util.Map;

import static com.google.common.base.Preconditions.checkNotNull;

public class HttpResponseImpl implements HttpResponse {

private static final Logger LOG = LoggerFactory.getLogger(HttpResponseImpl.class);
Expand Down Expand Up @@ -123,8 +125,13 @@ public Map<String, String> headers() {
@Override
public <T> T readEntity(Class<T> typeToReadAs) {
HttpEntity entity = response.getEntity();
if (entity == null) {
// Normal case if the response has no content, e.g. for a HEAD request
return null;
}
try {
return ObjectMapperSingleton.getContext(typeToReadAs).reader(typeToReadAs).readValue(entity.getContent());
InputStream content = checkNotNull(entity.getContent(), "Entity content should not be null.");
return ObjectMapperSingleton.getContext(typeToReadAs).readerFor(typeToReadAs).readValue(content);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
throw new ClientResponseException(e.getMessage(), 0, e);
Expand Down
2 changes: 1 addition & 1 deletion connectors/jersey2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>openstack4j-jersey2</artifactId>
<name>OpenStack4j Jersey2 Connector</name>
<url>http://github.com/gondor/openstack4j/</url>
<url>http://github.com/ContainX/openstack4j/</url>
<packaging>jar</packaging>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions connectors/okhttp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>openstack4j-okhttp</artifactId>
<name>OpenStack4j OKHttp Connector</name>
<url>http://github.com/gondor/openstack4j/</url>
<url>http://github.com/ContainX/openstack4j/</url>
<packaging>jar</packaging>

<properties>
Expand Down Expand Up @@ -56,4 +56,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
2 changes: 1 addition & 1 deletion connectors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<artifactId>openstack4j-connectors</artifactId>
<name>OpenStack4j Connectors</name>
<description>OpenStack Java API Connectors</description>
<url>http://github.com/gondor/openstack4j/</url>
<url>http://github.com/ContainX/openstack4j/</url>
<packaging>pom</packaging>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion connectors/resteasy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>openstack4j-resteasy</artifactId>
<name>OpenStack4j RestEasy Connector</name>
<url>http://github.com/gondor/openstack4j/</url>
<url>http://github.com/ContainX/openstack4j/</url>
<packaging>jar</packaging>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions core-integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>openstack4j-core-integration-test</artifactId>
<name>OpenStack4j Integrationtest Cases</name>
<url>http://github.com/gondor/openstack4j/</url>
<name>OpenStack4j Integration test Cases</name>
<url>http://github.com/ContainX/openstack4j/</url>
<packaging>pom</packaging>
<properties>
<skipTests>false</skipTests>
Expand Down
4 changes: 2 additions & 2 deletions core-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>openstack4j-core-test</artifactId>
<name>OpenStack4j Test Cases</name>
<url>http://github.com/gondor/openstack4j/</url>
<url>http://github.com/ContainX/openstack4j/</url>
<packaging>jar</packaging>
<properties>
<skipTests>true</skipTests>
Expand Down Expand Up @@ -44,4 +44,4 @@
</dependency>
</dependencies>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ protected enum Service {
DATABASE(8779),
TACKER(9890),
IMAGE(9292),
CLUSTERING(8778);
CLUSTERING(8778),
APP_CATALOG(8082);

private final int port;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.openstack4j.api.murano.v1;

import org.openstack4j.api.AbstractTest;
import org.openstack4j.api.Builders;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.murano.v1.domain.Environment;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.List;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

/**
* @author nmakhotkin
*/
@Test(suiteName="Murano/AppCatalog", enabled = true)
public class EnvironmentTests extends AbstractTest {
private static final String ENVIRONMENTS_JSON = "/murano/v1/environments.json";
private static final String ENVIRONMENT_JSON = "/murano/v1/environment.json";
private static final String ENVIRONMENT_RENAME_JSON = "/murano/v1/environment-rename.json";

public void testListEnvironments() throws IOException {
respondWith(ENVIRONMENTS_JSON);
List<? extends Environment> list = osv3().murano().environments().list();
assertEquals(list.size(), 2);
assertEquals(list.get(0).getId(), "e1c1b5a0b3284f188c5d91ab18bf0451");
assertEquals(list.get(0).getName(), "some_env");
}

public void testGetEnvironment() throws IOException {
respondWith(ENVIRONMENT_JSON);
String id = "721f76f9a9d64ebcacc76189cb8978a9";
Environment env = osv3().murano().environments().get(id);
assertNotNull(env);
assertNotNull(env.getId());
assertEquals(env.getId(), id);
}

public void testCreateEnvironment() throws IOException {
respondWith(ENVIRONMENT_JSON);
String id = "721f76f9a9d64ebcacc76189cb8978a9";
String name = "test";
Environment env = Builders.environment().name(name).build();
env = osv3().murano().environments().create(env);
assertNotNull(env);
assertEquals(env.getId(), id);
assertEquals(env.getName(), name);
}

public void testDeleteEnvironment() throws IOException {
respondWith(204);
ActionResponse delete = osv3().murano().environments().delete("721f76f9a9d64ebcacc76189cb8978a9");
assertTrue(delete.isSuccess());
}

public void testRenameEnvironment() throws IOException {
respondWith(ENVIRONMENT_RENAME_JSON);
String name = "renamed-test";
String envId = "721f76f9a9d64ebcacc76189cb8978a9";
Environment env = osv3().murano().environments().rename(envId, name);
assertEquals(env.getName(), name);
assertEquals(env.getId(), envId);
}

@Override
protected Service service() {
return Service.APP_CATALOG;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package org.openstack4j.api.murano.v1;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.ByteStreams;
import org.openstack4j.api.AbstractTest;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.murano.v1.domain.Application;
import org.testng.annotations.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Map;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;

/**
* @author nmakhotkin
*/
@Test(suiteName="Murano/AppCatalog", enabled = true)
public class ServicesTests extends AbstractTest {
private static final String SERVICE_JSON = "/murano/v1/service.json";
private static final String SERVICES_JSON = "/murano/v1/services.json";
private static final String envId = "e1c1b5a0b3284f188c5d91ab18bf0451";
private static final String sessionId = "c2e2b5a0b3284f188c5d91ab18bf8754";

private String getResourceAsString(String path) throws IOException {
InputStream is = getClass().getResourceAsStream(path);
return new String(ByteStreams.toByteArray(is));
}

public void testListServices() throws IOException {
respondWith(SERVICES_JSON);
List<? extends Application> apps = osv3().murano().services().list(envId, sessionId);
assertNotNull(apps);
assertEquals(apps.size(), 2);
}

public void testListServicesWithoutSession() throws IOException {
respondWith(SERVICE_JSON);
List<? extends Application> apps = osv3().murano().services().list(envId);
assertNotNull(apps);
assertEquals(apps.size(), 1);
}

public void testGetServicesListResponse() throws IOException {
respondWith(SERVICES_JSON);
List<? extends Application> apps = osv3().murano().services().get(envId, sessionId);
assertNotNull(apps);
assertEquals(apps.size(), 2);
}

public void testGetServicesEmptySession() throws IOException {
respondWith(200, "[]");
List<? extends Application> apps = osv3().murano().services().get(envId, sessionId);
assertNotNull(apps);
assertEquals(apps.size(), 0);
}

public void testCreateOneService() throws IOException {
respondWith(SERVICE_JSON);
String json = this.getResourceAsString(SERVICE_JSON);
List<? extends Application> apps = osv3().murano().services().create(envId, sessionId, json);
assertNotNull(apps);
assertEquals(apps.size(), 1);
}

public void testCreateOneServiceFromMap() throws IOException {
respondWith(SERVICE_JSON);
String json = this.getResourceAsString(SERVICE_JSON);

ObjectMapper mapper = new ObjectMapper();
Map<String, Object> serviceMap = mapper.readValue(json, Map.class);

Application app = osv3().murano().services().create(envId, sessionId, serviceMap);
assertNotNull(app);
assertEquals(app.getData(), serviceMap);
}

public void testCreateManyServices() throws IOException {
respondWith(SERVICES_JSON);
String json = this.getResourceAsString(SERVICES_JSON);
List<? extends Application> apps = osv3().murano().services().create(envId, sessionId, json);
assertNotNull(apps);
assertEquals(apps.size(), 2);
}

public void testUpdateOneService() throws IOException {
respondWith(SERVICE_JSON);
String json = this.getResourceAsString(SERVICE_JSON);
List<? extends Application> apps = osv3().murano().services().update(envId, sessionId, json);
assertNotNull(apps);
assertEquals(apps.size(), 1);
}

public void testUpdateOneServiceFromMap() throws IOException {
respondWith(SERVICE_JSON);
String json = this.getResourceAsString(SERVICE_JSON);

ObjectMapper mapper = new ObjectMapper();
Map<String, Object> serviceMap = mapper.readValue(json, Map.class);

Application app = osv3().murano().services().update(envId, sessionId, serviceMap);
assertNotNull(app);
assertEquals(app.getData(), serviceMap);
}

public void testUpdateManyServices() throws IOException {
respondWith(SERVICES_JSON);
String json = this.getResourceAsString(SERVICES_JSON);
List<? extends Application> apps = osv3().murano().services().update(envId, sessionId, json);
assertNotNull(apps);
assertEquals(apps.size(), 2);
}

public void testDeleteService() throws IOException {
respondWith(200);
ActionResponse delete = osv3().murano().services().delete(envId, "/", sessionId);
assertTrue(delete.isSuccess());
}

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