summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openstack-client-connectors/jersey-connector/pom.xml29
-rw-r--r--openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java119
-rw-r--r--openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyLoggingFilter.java225
-rw-r--r--openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyResponse.java82
-rw-r--r--openstack-client-connectors/jersey-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector1
-rw-r--r--openstack-client-connectors/jersey-connector/src/test/java/com/woorea/openstack/connector/JerseyLoggingFilterTest.java267
-rw-r--r--openstack-client-connectors/jersey2-connector/pom.xml35
-rw-r--r--openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Connector.java81
-rw-r--r--openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Response.java77
-rw-r--r--openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/OpenStack.java129
-rw-r--r--openstack-client-connectors/jersey2-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector1
-rw-r--r--openstack-client-connectors/pom.xml29
-rw-r--r--openstack-client-connectors/resteasy-connector/pom.xml36
-rw-r--r--openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java145
-rw-r--r--openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java53
-rw-r--r--openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java75
-rw-r--r--openstack-client-connectors/resteasy-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector1
-rw-r--r--openstack-client/src/main/java/com/woorea/openstack/common/client/AbstractOpenStackClient.java141
-rw-r--r--openstack-console/pom.xml78
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/Command.java37
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/CommandLineHelper.java87
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/Commands.java47
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/Console.java127
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/Environment.java46
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/Main.java43
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneCommand.java40
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneEnvironment.java79
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleCreate.java85
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleDelete.java41
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleList.java64
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneServiceList.java64
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantCreate.java85
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantDelete.java41
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantList.java64
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserCreate.java91
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserDelete.java41
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserList.java66
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserShow.java69
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaCommand.java41
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaEnvironment.java81
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaServerList.java60
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/utils/Column.java81
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/utils/ConsoleUtils.java63
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/utils/Table.java97
-rw-r--r--openstack-console/src/main/java/com/woorea/openstack/console/utils/TableModel.java41
-rw-r--r--openstack-console/src/main/resources/console.properties6
-rw-r--r--openstack-examples/pom.xml84
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/ExamplesConfiguration.java50
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaCreateServer.java106
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListFlavors.java67
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListImages.java68
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListServers.java54
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java56
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/glance/GlanceListImages.java99
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/heat/HeatListStacks.java92
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/Keystone3Authentication.java50
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/KeystoneAuthentication.java45
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/keystone/KeystoneCreateTenant.java52
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/keystone/KeystoneCreateUser.java54
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/metering/v2/TestAll.java78
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumListNetworks.java63
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumNetworkCreate.java124
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumQueryNetworks.java75
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/objectstore/SwiftExample.java106
-rw-r--r--openstack-examples/src/main/java/com/woorea/openstack/examples/simple/OpenStackSimpleClient.java31
-rw-r--r--openstack-java-sdk-master/.travis.yml3
66 files changed, 0 insertions, 4648 deletions
diff --git a/openstack-client-connectors/jersey-connector/pom.xml b/openstack-client-connectors/jersey-connector/pom.xml
deleted file mode 100644
index e942e8d..0000000
--- a/openstack-client-connectors/jersey-connector/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
- <artifactId>client-connectors</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- </parent>
- <groupId>org.onap.so.libs.openstack-java-sdk.client-connectors</groupId>
- <artifactId>jersey-connector</artifactId>
- <name>OpenStack Jersey Connector</name>
- <description>OpenStack Jersey Connector</description>
- <dependencies>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- <version>1.17.1</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java b/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java
deleted file mode 100644
index 770b4d8..0000000
--- a/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.ContextResolver;
-import javax.ws.rs.ext.Provider;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.client.impl.ClientRequestImpl;
-import com.sun.jersey.core.header.OutBoundHeaders;
-import com.woorea.openstack.base.client.OpenStackClientConnector;
-import com.woorea.openstack.base.client.OpenStackRequest;
-import com.woorea.openstack.base.client.OpenStackResponse;
-import com.woorea.openstack.base.client.OpenStackResponseException;
-
-public class JerseyConnector implements OpenStackClientConnector {
-
- protected Client client = null;
- protected boolean logPassword;
- private JerseyLoggingFilter logger = new JerseyLoggingFilter(Logger.getLogger("os"));
-
- public JerseyConnector() {
- ClientConfig clientConfig = new DefaultClientConfig();
- clientConfig.getClasses().add(JacksonJaxbJsonProvider.class);
- clientConfig.getClasses().add(OpenStackObjectMapper.class);
- client = Client.create(clientConfig);
- }
-
- @Override
- public <T> OpenStackResponse request(OpenStackRequest<T> request) {
- WebResource target = client.resource(request.endpoint()).path(request.path());
- for(Map.Entry<String, List<Object> > entry : request.queryParams().entrySet()) {
- for (Object o : entry.getValue()) {
- target = target.queryParam(entry.getKey(), String.valueOf(o));
- }
- }
- target.addFilter(logger);
- MultivaluedMap<String, Object> headers = new OutBoundHeaders();
- for(Map.Entry<String, List<Object>> h : request.headers().entrySet()) {
- for(Object v : h.getValue()) {
- headers.add(h.getKey(), v);
- }
- }
- if(request.entity() != null && request.entity().getContentType() != null) {
- headers.add("Content-Type", request.entity().getContentType());
- } else {
- headers.add("Content-Type", "application/json");
- }
- try {
- ClientResponse response;
- if (request.entity() != null && request.entity().getEntity() != null) {
- response = target.getHeadHandler().handle(new ClientRequestImpl(target.getURI(), request.method().name(), request.entity().getEntity(), headers));
- } else {
- response = target.getHeadHandler().handle(new ClientRequestImpl(target.getURI(), request.method().name(), null, headers));
- }
- return new JerseyResponse(response);
- } catch (UniformInterfaceException e) {
- throw new OpenStackResponseException(e.getResponse().getClientResponseStatus().getReasonPhrase(), e.getResponse().getStatus());
- }
- }
-
- @Provider
- public static class OpenStackObjectMapper implements ContextResolver<ObjectMapper> {
- static ObjectMapper DEFAULT_MAPPER;
- static ObjectMapper WRAPPED_MAPPER;
- static {
- DEFAULT_MAPPER = new ObjectMapper();
- DEFAULT_MAPPER.setSerializationInclusion(Include.NON_NULL);
- DEFAULT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
- DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- DEFAULT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
-
- WRAPPED_MAPPER = new ObjectMapper();
- WRAPPED_MAPPER.setSerializationInclusion(Include.NON_NULL);
- WRAPPED_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
- WRAPPED_MAPPER.enable(SerializationFeature.WRAP_ROOT_VALUE);
- WRAPPED_MAPPER.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
- WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- WRAPPED_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
- }
-
- @Override
- public ObjectMapper getContext(Class<?> type) {
- return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER;
- }
- }
-}
diff --git a/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyLoggingFilter.java b/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyLoggingFilter.java
deleted file mode 100644
index ffdeb83..0000000
--- a/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyLoggingFilter.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package com.woorea.openstack.connector;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Logger;
-
-import com.sun.jersey.api.client.AbstractClientRequestAdapter;
-import com.sun.jersey.api.client.ClientHandlerException;
-import com.sun.jersey.api.client.ClientRequest;
-import com.sun.jersey.api.client.ClientRequestAdapter;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.filter.ClientFilter;
-import com.sun.jersey.core.util.ReaderWriter;
-
-/**
- * A Jersey client filter that writes the request and response to a specified logger.
- */
-public class JerseyLoggingFilter extends ClientFilter {
-
- private final AtomicLong counter = new AtomicLong(0);
- private final Logger logger;
-
- /**
- * Constructor
- * @param logger the logger to which the request and response are written.
- */
- public JerseyLoggingFilter(Logger logger) {
- this.logger = logger;
- }
-
- @Override
- public ClientResponse handle(ClientRequest request) throws ClientHandlerException {
- long id = counter.incrementAndGet();
- logRequest(id, request);
- ClientResponse response = getNext().handle(request);
- logResponse(id, response);
- return response;
- }
-
- /**
- * Logs a request.
- * @param id the request id (counter)
- * @param request the request
- */
- private void logRequest(long id, ClientRequest request) {
- StringBuilder builder = new StringBuilder();
-
- builder.append(String.valueOf(id));
- builder.append(" * Client out-bound request\n");
-
- builder.append(String.valueOf(id));
- builder.append(" > ");
- builder.append(request.getMethod());
- builder.append(" ");
- builder.append(request.getURI().toASCIIString());
- builder.append("\n");
-
- // Request headers
-
- for (Map.Entry<String, List<Object>> entry : request.getHeaders().entrySet()) {
- String header = entry.getKey();
- List<Object> values = entry.getValue();
-
- if (values.size() == 1) {
- builder.append(String.valueOf(id));
- builder.append(" > ");
- builder.append(header);
- builder.append(": ");
- builder.append(ClientRequest.getHeaderValue(values.get(0)));
- builder.append("\n");
- } else {
- StringBuilder buf = new StringBuilder();
- boolean first = true;
-
- for(Object value : values) {
- if (first) {
- first = false;
- } else {
- buf.append(",");
- }
-
- buf.append(ClientRequest.getHeaderValue(value));
- }
-
- builder.append(String.valueOf(id));
- builder.append(" > ");
- builder.append(header);
- builder.append(": ");
- builder.append(buf.toString());
- builder.append("\n");
- }
- }
-
- // Request body
-
- if (request.getEntity() != null) {
- request.setAdapter(new JerseyLoggingAdapter(request.getAdapter(), builder));
- } else {
- logger.info(builder.toString());
- }
- }
-
- /**
- * Logs a response.
- * @param id the request id (counter)
- * @param response the response
- */
- private void logResponse(long id, ClientResponse response) {
- StringBuilder builder = new StringBuilder();
-
- builder.append(String.valueOf(id));
- builder.append(" * Client in-bound response\n");
-
- builder.append(String.valueOf(id));
- builder.append(" < ");
- builder.append(String.valueOf(response.getStatus()));
- builder.append("\n");
-
- // Response headers
-
- for (Map.Entry<String, List<String>> entry : response.getHeaders().entrySet()) {
- String header = entry.getKey();
- for (String value : entry.getValue()) {
- builder.append(String.valueOf(id));
- builder.append(" < ");
- builder.append(header);
- builder.append(": ");
- builder.append(value).append("\n");
- }
- }
-
- // Response body
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- InputStream in = response.getEntityInputStream();
- try {
- ReaderWriter.writeTo(in, out);
-
- byte[] requestEntity = out.toByteArray();
- appendToBuffer(builder, requestEntity);
- response.setEntityInputStream(new ByteArrayInputStream(requestEntity));
- } catch (IOException ex) {
- throw new ClientHandlerException(ex);
- }
-
- logger.info(builder.toString());
- }
-
- /**
- * Appends bytes to the builder. If the bytes contain the password pattern,
- * the password is obliterated.
- * @param builder the builder
- * @param bytes the bytes to append
- */
- private void appendToBuffer(StringBuilder builder, byte[] bytes) {
- if (bytes.length != 0) {
- String s = new String(bytes);
- builder.append(s.replaceAll("\"password\".*:.*\"(.*)\"", "\"password\" : \"******\""));
- builder.append("\n");
- }
- }
-
- private class JerseyLoggingAdapter extends AbstractClientRequestAdapter {
- private final StringBuilder builder;
-
- JerseyLoggingAdapter(ClientRequestAdapter adapter, StringBuilder builder) {
- super(adapter);
- this.builder = builder;
- }
-
- @Override
- public OutputStream adapt(ClientRequest request, OutputStream out) throws IOException {
- return new JerseyLoggingOutputStream(getAdapter().adapt(request, out), builder);
- }
- }
-
- private class JerseyLoggingOutputStream extends OutputStream {
- private final OutputStream stream;
- private final StringBuilder builder;
- private final ByteArrayOutputStream logStream = new ByteArrayOutputStream();
-
- JerseyLoggingOutputStream(OutputStream stream, StringBuilder builder) {
- this.stream = stream;
- this.builder = builder;
- }
-
- @Override
- public void write(int value) throws IOException {
- logStream.write(value);
- stream.write(value);
- }
-
- @Override
- public void close() throws IOException {
- appendToBuffer(builder, logStream.toByteArray());
- logger.info(builder.toString());
- stream.close();
- }
- }
-} \ No newline at end of file
diff --git a/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyResponse.java b/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyResponse.java
deleted file mode 100644
index 5b01660..0000000
--- a/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyResponse.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-/*
- * Modifications copyright (c) 2017 AT&T Intellectual Property
- */
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.sun.jersey.api.client.ClientResponse;
-import com.woorea.openstack.base.client.OpenStackResponse;
-import com.woorea.openstack.base.client.OpenStackResponseException;
-
-public class JerseyResponse implements OpenStackResponse {
-
- private ClientResponse response;
-
- public JerseyResponse(ClientResponse response) {
- this.response = response;
- }
-
- @Override
- public <T> T getEntity(Class<T> returnType) {
- if(response.getStatus() >= 400) {
- throw new OpenStackResponseException(response.getClientResponseStatus().getReasonPhrase(),
- response.getStatus(), this);
- }
- if(response.hasEntity() && returnType != null && Void.class != returnType) {
- return response.getEntity(returnType);
- } else {
- return null;
- }
- }
-
- @Override
- public <T> T getErrorEntity(Class<T> returnType) {
- if(response.getStatus() >= 400 && response.hasEntity()) {
- return response.getEntity(returnType);
- }
- return null;
- }
-
- @Override
- public InputStream getInputStream() {
- if(response.hasEntity()) {
- return response.getEntityInputStream();
- } else {
- return null;
- }
- }
-
- @Override
- public String header(String name) {
- return response.getHeaders().getFirst(name);
- }
-
- @Override
- public Map<String, String> headers() {
- Map<String, String> headers = new HashMap<>();
- for(String k : response.getHeaders().keySet()) {
- headers.put(k, response.getHeaders().getFirst(k));
- }
- return headers;
- }
-}
diff --git a/openstack-client-connectors/jersey-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/openstack-client-connectors/jersey-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
deleted file mode 100644
index 5b9a158..0000000
--- a/openstack-client-connectors/jersey-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
+++ /dev/null
@@ -1 +0,0 @@
-com.woorea.openstack.connector.JerseyConnector \ No newline at end of file
diff --git a/openstack-client-connectors/jersey-connector/src/test/java/com/woorea/openstack/connector/JerseyLoggingFilterTest.java b/openstack-client-connectors/jersey-connector/src/test/java/com/woorea/openstack/connector/JerseyLoggingFilterTest.java
deleted file mode 100644
index 3ebad7c..0000000
--- a/openstack-client-connectors/jersey-connector/src/test/java/com/woorea/openstack/connector/JerseyLoggingFilterTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doCallRealMethod;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.reflect.Method;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-import java.util.logging.SimpleFormatter;
-
-import javax.ws.rs.core.MultivaluedMap;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-import com.sun.jersey.api.client.ClientHandler;
-import com.sun.jersey.api.client.ClientRequest;
-import com.sun.jersey.api.client.ClientRequestAdapter;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.filter.ClientFilter;
-
-public class JerseyLoggingFilterTest {
-
- private static Logger logger;
- private static LogFormatter logFormatter;
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- logger = Logger.getLogger(JerseyLoggingFilterTest.class.getSimpleName());
- logger.setLevel(Level.ALL);
- logger.setUseParentHandlers(false);
-
- ConsoleHandler handler = new ConsoleHandler();
- logFormatter = new LogFormatter();
- handler.setFormatter(logFormatter);
- handler.setLevel(Level.ALL);
- logger.addHandler(handler);
- }
-
- @Before
- public void setUpTest() {
- logFormatter.clearLog();
- }
-
- /**
- * Tests a scenario with no request content (GET).
- * @throws Exception for unexpected errors
- */
- @Test
- public void testGET() throws Exception {
- String responseContent = "<response>Hello, I am Eliza.</response>";
- execute("GET", "http://www.onap.org/eliza", null, responseContent);
- }
-
- /**
- * Tests a scenario with request content (POST).
- * @throws Exception for unexpected errors
- */
- @Test
- public void testPOST() throws Exception {
- String requestContent = "<request>I feel sad.</request>";
- String responseContent = "<response>Do you often feel sad?</response>";
- execute("POST", "http://www.onap.org/eliza", requestContent, responseContent);
- }
-
- /**
- * Runs a single test.
- * @param httpMethod any HTTP method (POST, GET, ...)
- * @param url any URL
- * @param requestContent mock request content, possibly null
- * @param responseContent mock response content, never null
- * @throws Exception for unexpected errors
- */
- private void execute(String httpMethod, String url, String requestContent, String responseContent)
- throws Exception {
- JerseyLoggingFilter loggingFilter = new JerseyLoggingFilter(logger);
-
- // Mock multi-valued and single valued request headers
-
- HashMap<String, List<Object>> requestHeaderMap = new HashMap<>();
- requestHeaderMap.put("Accept", Arrays.asList(new Object[]{"application/xml","application/json"}));
-
- if (requestContent != null) {
- requestHeaderMap.put("Content-Type", Arrays.asList(new Object[]{"application/xml"}));
- requestHeaderMap.put("Content-Length", Arrays.asList(new Object[]{String.valueOf(requestContent.length())}));
- }
-
- @SuppressWarnings("unchecked")
- MultivaluedMap<String, Object> requestHeaders = mock(MultivaluedMap.class);
- when(requestHeaders.entrySet()).thenReturn(requestHeaderMap.entrySet());
-
- // Mock the request object
-
- ClientRequest request = mock(TestClientRequest.class);
- when(request.getURI()).thenReturn(new URI(url));
- when(request.getMethod()).thenReturn(httpMethod);
- when(request.getHeaders()).thenReturn(requestHeaders);
-
- if (requestContent != null) {
- when(request.getEntity()).thenReturn(requestContent.getBytes("UTF-8"));
- }
-
- doCallRealMethod().when(request).setAdapter(any(ClientRequestAdapter.class));
- when(request.getAdapter()).thenCallRealMethod();
- request.setAdapter(new DefaultClientRequestAdapter());
-
- // Mock multi-valued and single valued response headers
-
- HashMap<String, List<String>> responseHeaderMap = new HashMap<>();
- responseHeaderMap.put("Cache-Control", Arrays.asList(new String[]{"no-cache","no-store"}));
- responseHeaderMap.put("Content-Type", Arrays.asList(new String[]{"application/xml"}));
- responseHeaderMap.put("Content-Length", Arrays.asList(new String[]{String.valueOf(responseContent.length())}));
- @SuppressWarnings("unchecked")
- MultivaluedMap<String, String> responseHeaders = mock(MultivaluedMap.class);
- when(responseHeaders.entrySet()).thenReturn(responseHeaderMap.entrySet());
-
- // Mock the response object
-
- ClientResponse response = mock(ClientResponse.class);
- when(response.getStatus()).thenReturn(200);
- when(response.getHeaders()).thenReturn(responseHeaders);
- when(response.getEntityInputStream()).thenReturn(
- new ByteArrayInputStream(responseContent.getBytes("UTF-8")));
-
- // Mock a handler that returns the response object and set
- // it to be the next filter after the logging filter.
-
- ClientFilter handler = mock(ClientFilter.class);
- when(handler.handle(request)).then(produceResponse(response));
- Method setNext = ClientFilter.class.getDeclaredMethod("setNext", new Class<?>[]{ClientHandler.class});
- setNext.setAccessible(true);
- setNext.invoke(loggingFilter, new Object[]{handler});
-
- // Run the request into the logging filter
-
- loggingFilter.handle(request);
-
- // Validate resulting the log content
-
- String log = logFormatter.getLog();
-
- assertContains(log, "* Client out-bound request");
- assertContains(log, "> " + httpMethod + " " + url);
-
- for (String header : requestHeaderMap.keySet()) {
- assertContains(log, "> " + header + ": ");
- }
-
- if (requestContent != null) {
- assertContains(log, requestContent);
- }
-
- assertContains(log, "* Client in-bound response");
- assertContains(log, "< 200");
-
- for (String header : responseHeaderMap.keySet()) {
- assertContains(log, "< " + header + ": ");
- }
-
- assertContains(log, responseContent);
- }
-
- private void assertContains(String log, String expect) {
- assertTrue("Log does not contain '" + expect + "'", log.contains(expect));
- }
-
- private class DefaultClientRequestAdapter implements ClientRequestAdapter {
- @Override
- public OutputStream adapt(ClientRequest request, OutputStream out) throws IOException {
- return out;
- }
- }
-
- private abstract class TestClientRequest extends ClientRequest {
- private ClientRequestAdapter adapter;
-
- @Override
- public ClientRequestAdapter getAdapter() {
- return adapter;
- }
-
- @Override
- public void setAdapter(ClientRequestAdapter adapter) {
- this.adapter = adapter;
- }
- }
-
- private Answer<ClientResponse> produceResponse(final ClientResponse response) {
- return new Answer<ClientResponse>() {
- public ClientResponse answer(InvocationOnMock invocation) throws IOException {
- ClientRequest request = (ClientRequest) invocation.getArguments()[0];
- byte[] entity = (byte[]) request.getEntity();
-
- if (entity != null) {
- ClientRequestAdapter adapter = request.getAdapter();
-
- OutputStream nullOutputStream = new OutputStream() {
- @Override
- public void write(int b) {
- // Discard
- }
- };
-
- OutputStream outputStream = adapter.adapt(request, nullOutputStream);
- outputStream.write(entity);
- outputStream.close();
- }
-
- return response;
- }
- };
- }
-
- private static class LogFormatter extends SimpleFormatter {
- StringBuilder buffer = new StringBuilder();
-
- public synchronized String getLog() {
- return buffer.toString();
- }
-
- public synchronized void clearLog() {
- buffer.setLength(0);
- }
-
- @Override
- public synchronized String format(LogRecord record) {
- String logData = super.format(record);
- buffer.append(logData);
- return logData;
- }
- }
-} \ No newline at end of file
diff --git a/openstack-client-connectors/jersey2-connector/pom.xml b/openstack-client-connectors/jersey2-connector/pom.xml
deleted file mode 100644
index 396867d..0000000
--- a/openstack-client-connectors/jersey2-connector/pom.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
- <artifactId>client-connectors</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- </parent>
- <groupId>org.onap.so.libs.openstack-java-sdk.client-connectors</groupId>
- <artifactId>jersey2-connector</artifactId>
- <name>OpenStack Jersey2 Connector</name>
- <description>OpenStack Jersey2 Connector</description>
- <url>http://maven.apache.org</url>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.glassfish.jersey.core</groupId>
- <artifactId>jersey-client</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish.jersey.media</groupId>
- <artifactId>jersey-media-json-jackson</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
- <artifactId>openstack-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Connector.java b/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Connector.java
deleted file mode 100644
index b1b528f..0000000
--- a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Connector.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import javax.ws.rs.ClientErrorException;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.client.Invocation;
-import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.MediaType;
-
-import org.glassfish.jersey.filter.LoggingFilter;
-
-import com.woorea.openstack.base.client.HttpMethod;
-import com.woorea.openstack.base.client.OpenStackClientConnector;
-import com.woorea.openstack.base.client.OpenStackRequest;
-import com.woorea.openstack.base.client.OpenStackResponse;
-import com.woorea.openstack.base.client.OpenStackResponseException;
-
-public class JaxRs20Connector implements OpenStackClientConnector {
-
- protected Client client = OpenStack.CLIENT;
- private LoggingFilter logger = new LoggingFilter(Logger.getLogger("os"), 10000);
-
- @Override
- public <T> OpenStackResponse request(OpenStackRequest<T> request) {
- WebTarget target = client.target(request.endpoint()).path(request.path());
-
- for(Map.Entry<String, List<Object> > entry : request.queryParams().entrySet()) {
- for (Object o : entry.getValue()) {
- target = target.queryParam(entry.getKey(), o);
- }
- }
- target.register(logger);
- Invocation.Builder invocation = target.request();
-
- for(Map.Entry<String, List<Object>> h : request.headers().entrySet()) {
- StringBuilder sb = new StringBuilder();
- for(Object v : h.getValue()) {
- sb.append(String.valueOf(v));
- }
- invocation.header(h.getKey(), sb);
- }
-
- Entity<?> entity = (request.entity() == null) ? null :
- Entity.entity(request.entity().getEntity(), request.entity().getContentType());
-
- try {
- if (entity != null) {
- return new JaxRs20Response(invocation.method(request.method().name(), entity));
- } else {
- if(HttpMethod.PUT == request.method()) {
- return new JaxRs20Response(invocation.method(request.method().name(), Entity.entity("", MediaType.APPLICATION_JSON)));
- } else {
- return new JaxRs20Response(invocation.method(request.method().name()));
- }
- }
- } catch (ClientErrorException e) {
- throw new OpenStackResponseException(e.getResponse()
- .getStatusInfo().toString(), e.getResponse().getStatus());
- }
- }
-}
diff --git a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Response.java b/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Response.java
deleted file mode 100644
index 2b1820e..0000000
--- a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Response.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-/*
- * Modifications copyright (c) 2017 AT&T Intellectual Property
- */
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-
-import com.woorea.openstack.base.client.OpenStackResponse;
-import com.woorea.openstack.base.client.OpenStackResponseException;
-
-public class JaxRs20Response implements OpenStackResponse {
-
- private Response response;
-
- public JaxRs20Response(Response response) {
- this.response = response;
- }
-
- @Override
- public <T> T getEntity(Class<T> returnType) {
- if(response.getStatus() >= 400) {
- throw new OpenStackResponseException(response.getStatusInfo().getReasonPhrase(),
- response.getStatusInfo().getStatusCode(), this);
- }
- return response.readEntity(returnType);
- }
-
- @Override
- public <T> T getErrorEntity(Class<T> returnType) {
- if(response.getStatus() >= 400 && response.hasEntity()) {
- return response.readEntity(returnType);
- }
- return null;
- }
-
-
- @Override
- public InputStream getInputStream() {
- return (InputStream) response.getEntity();
- }
-
- @Override
- public String header(String name) {
- return response.getHeaderString(name);
- }
-
- @Override
- public Map<String, String> headers() {
- Map<String, String> headers = new HashMap<>();
- for(String k : response.getHeaders().keySet()) {
- headers.put(k, response.getHeaderString(k));
- }
- return headers;
- }
-
-}
diff --git a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/OpenStack.java b/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/OpenStack.java
deleted file mode 100644
index eeedfd0..0000000
--- a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/OpenStack.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-import java.io.IOException;
-
-import javax.net.ssl.SSLContext;
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.ClientRequestContext;
-import javax.ws.rs.client.ClientRequestFilter;
-import javax.ws.rs.ext.ContextResolver;
-
-import org.glassfish.jersey.SslConfigurator;
-import org.glassfish.jersey.jackson.JacksonFeature;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
-public class OpenStack {
-
- public static Client CLIENT;
-
- public static ObjectMapper DEFAULT_MAPPER;
-
- public static ObjectMapper WRAPPED_MAPPER;
-
- static {
- initialize();
- }
-
- private static void initialize() {
-
- /*
- //class MyX509TrustManager implements X509TrustManager
- TrustManager mytm[] = null;
- KeyManager mykm[] = null;
-
- try {
- mytm = new TrustManager[]{new MyX509TrustManager("./truststore_client", "asdfgh".toCharArray())};
- mykm = new KeyManager[]{new MyX509KeyManager("./keystore_client", "asdfgh".toCharArray())};
- } catch (Exception ex) {
-
- }
-
- SSLContext context = null;
- context = SSLContext.getInstance("SSL");
- context.init(mykm, mytm, null);
-
- */
-
- try {
-
- SSLContext context;
- context = SSLContext.getInstance("SSL");
- context.init(null, null, null);
-
- SslConfigurator sslConfig = SslConfigurator.newInstance();
- /*
- .trustStoreFile("./truststore_client")
- .trustStorePassword("asdfgh")
-
- .keyStoreFile("./keystore_client")
- .keyPassword("asdfgh");
- */
- //old: CLIENT.property(ClientProperties.SSL_CONFIG, new SslConfig(context));
-
- CLIENT = ClientBuilder.newBuilder().sslContext(sslConfig.createSSLContext()).build();
-
- DEFAULT_MAPPER = new ObjectMapper();
-
- DEFAULT_MAPPER.setSerializationInclusion(Include.NON_NULL);
- DEFAULT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
- DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- DEFAULT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
-
- WRAPPED_MAPPER = new ObjectMapper();
-
- WRAPPED_MAPPER.setSerializationInclusion(Include.NON_NULL);
- WRAPPED_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
- WRAPPED_MAPPER.enable(SerializationFeature.WRAP_ROOT_VALUE);
- WRAPPED_MAPPER.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
- WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- WRAPPED_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
-
- CLIENT.register(new JacksonFeature()).register(new ContextResolver<ObjectMapper>() {
-
- @Override
- public ObjectMapper getContext(Class<?> type) {
- return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER;
- }
-
- });
-
- CLIENT.register(new ClientRequestFilter() {
-
- @Override
- public void filter(ClientRequestContext requestContext) throws IOException {
- requestContext.getHeaders().remove("Content-Language");
- requestContext.getHeaders().remove("Content-Encoding");
- }
- });
-
- } catch(Exception e) {
- throw new RuntimeException(e.getMessage(), e);
- }
-
- }
-
-}
diff --git a/openstack-client-connectors/jersey2-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/openstack-client-connectors/jersey2-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
deleted file mode 100644
index fc24457..0000000
--- a/openstack-client-connectors/jersey2-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
+++ /dev/null
@@ -1 +0,0 @@
-com.woorea.openstack.connector.JaxRs20Connector \ No newline at end of file
diff --git a/openstack-client-connectors/pom.xml b/openstack-client-connectors/pom.xml
index 3654d39..51ff6e4 100644
--- a/openstack-client-connectors/pom.xml
+++ b/openstack-client-connectors/pom.xml
@@ -12,33 +12,6 @@
<packaging>pom</packaging>
<profiles>
<profile>
- <id>jersey</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>jersey-connector</module>
- </modules>
- </profile>
- <profile>
- <id>jersey2</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>jersey2-connector</module>
- </modules>
- </profile>
- <profile>
- <id>resteasy</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <modules>
- <module>resteasy-connector</module>
- </modules>
- </profile>
- <profile>
<id>http</id>
<activation>
<activeByDefault>true</activeByDefault>
@@ -47,7 +20,6 @@
<module>http-connector</module>
</modules>
</profile>
-
</profiles>
<dependencies>
<dependency>
@@ -56,5 +28,4 @@
<version>${project.version}</version>
</dependency>
</dependencies>
-
</project>
diff --git a/openstack-client-connectors/resteasy-connector/pom.xml b/openstack-client-connectors/resteasy-connector/pom.xml
deleted file mode 100644
index 8bfe105..0000000
--- a/openstack-client-connectors/resteasy-connector/pom.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
- <artifactId>client-connectors</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- </parent>
- <groupId>org.onap.so.libs.openstack-java-sdk.client-connectors</groupId>
- <artifactId>resteasy-connector</artifactId>
- <name>OpenStack RESTEasy Connector</name>
- <description>OpenStack RESTEasy Connector</description>
- <dependencies>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <!-- replaced with 3.5.0.Final <version>2.3.2.Final</version> -->
- <version>3.5.1.Final</version><!-- 3.5.0 changed to 3.5.1 for the CLM policy threat issue resolution -->
- </dependency>
- <!-- replaced with httpclient and httpcore
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
- </dependency>
- -->
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java
deleted file mode 100644
index b804e69..0000000
--- a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.ws.rs.core.UriBuilder;
-import javax.ws.rs.ext.ContextResolver;
-
-// bwj: changed the HttpStatus package
-//import org.apache.commons.httpclient.HttpStatus;
-import org.apache.http.HttpStatus;
-import org.jboss.resteasy.client.ClientRequest;
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.plugins.providers.InputStreamProvider;
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
-
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
-import com.woorea.openstack.base.client.OpenStackClientConnector;
-import com.woorea.openstack.base.client.OpenStackRequest;
-import com.woorea.openstack.base.client.OpenStackResponse;
-import com.woorea.openstack.base.client.OpenStackResponseException;
-
-public class RESTEasyConnector implements OpenStackClientConnector {
-
- public static ObjectMapper DEFAULT_MAPPER;
-
- public static ObjectMapper WRAPPED_MAPPER;
-
- static class OpenStackProviderFactory extends ResteasyProviderFactory {
-
- private JacksonJsonProvider jsonProvider;
- private InputStreamProvider streamProvider;
-
- public OpenStackProviderFactory() {
- super();
-
- addContextResolver(new ContextResolver<ObjectMapper>() {
- @Override
- public ObjectMapper getContext(Class<?> type) {
- return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER;
- }
- });
-
- jsonProvider = new JacksonJsonProvider();
- addMessageBodyReader(jsonProvider);
- addMessageBodyWriter(jsonProvider);
-
- streamProvider = new InputStreamProvider();
- addMessageBodyReader(streamProvider);
- addMessageBodyWriter(streamProvider);
- }
-
- }
-
- private static OpenStackProviderFactory providerFactory;
-
- static {
- DEFAULT_MAPPER = new ObjectMapper();
-
- DEFAULT_MAPPER.setSerializationInclusion(Include.NON_NULL);
- DEFAULT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
- DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- DEFAULT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
-
- WRAPPED_MAPPER = new ObjectMapper();
-
- WRAPPED_MAPPER.setSerializationInclusion(Include.NON_NULL);
- WRAPPED_MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
- WRAPPED_MAPPER.enable(SerializationFeature.WRAP_ROOT_VALUE);
- WRAPPED_MAPPER.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
- WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- WRAPPED_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
-
- providerFactory = new OpenStackProviderFactory();
- }
-
- @Override
- public <T> OpenStackResponse request(OpenStackRequest<T> request) {
- ClientRequest client = new ClientRequest(UriBuilder.fromUri(request.endpoint() + "/" + request.path()),
- ClientRequest.getDefaultExecutor(), providerFactory);
-
- for(Map.Entry<String, List<Object> > entry : request.queryParams().entrySet()) {
- for (Object o : entry.getValue()) {
- client = client.queryParameter(entry.getKey(), String.valueOf(o));
- }
- }
-
- for (Entry<String, List<Object>> h : request.headers().entrySet()) {
- StringBuilder sb = new StringBuilder();
- for (Object v : h.getValue()) {
- sb.append(String.valueOf(v));
- }
- client.header(h.getKey(), sb);
- }
-
- if (request.entity() != null) {
- client.body(request.entity().getContentType(), request.entity().getEntity());
- }
-
- ClientResponse<T> response;
-
- try {
- response = client.httpMethod(request.method().name(), request.returnType());
- } catch (Exception e) {
- throw new RuntimeException("Unexpected client exception", e);
- }
-
- if (response.getStatus() == HttpStatus.SC_OK
- || response.getStatus() == HttpStatus.SC_CREATED
- || response.getStatus() == HttpStatus.SC_NO_CONTENT
- || response.getStatus() == HttpStatus.SC_ACCEPTED) {
- return new RESTEasyResponse(client, response);
- }
-
- response.releaseConnection();
-
- throw new OpenStackResponseException(response.getResponseStatus()
- .getReasonPhrase(), response.getStatus());
- }
-
-}
diff --git a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java
deleted file mode 100644
index 0e1e9e9..0000000
--- a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.SocketException;
-
-import org.jboss.resteasy.client.ClientExecutor;
-
-
-public class RESTEasyInputStream extends FilterInputStream {
-
- protected ClientExecutor clientExecutor;
-
- public RESTEasyInputStream(InputStream inputStream, ClientExecutor clientExecutor) {
- super(inputStream);
- this.clientExecutor = clientExecutor;
- }
-
- @Override
- public void close() throws IOException {
- try {
- clientExecutor.close();
- } catch (Exception e) {
- // Silently skip errors in the socket close errors
- }
-
- try {
- super.close();
- } catch (SocketException e) {
- // We expect this exception because the socket is closed
- } catch (IllegalStateException e) {
- // We expect this exception because the socket is closed (httpclient 4.2)
- }
- }
-
-}
diff --git a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java
deleted file mode 100644
index ced748e..0000000
--- a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.connector;
-
-/*
- * Modifications copyright (c) 2017 AT&T Intellectual Property
- */
-
-import org.jboss.resteasy.client.ClientRequest;
-import org.jboss.resteasy.client.ClientResponse;
-import com.woorea.openstack.base.client.OpenStackResponse;
-
-import javax.ws.rs.core.MultivaluedMap;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-public class RESTEasyResponse implements OpenStackResponse {
-
- private ClientRequest client;
-
- private ClientResponse response;
-
- public RESTEasyResponse(ClientRequest client, ClientResponse response) {
- this.client = client;
- this.response = response;
- }
-
- @Override
- public <T> T getEntity(Class<T> returnType) {
- return (T) response.getEntity(returnType);
- }
-
- @Override
- public <T> T getErrorEntity(Class<T> returnType) {
- return (T) response.getEntity(returnType);
- }
-
- @Override
- public InputStream getInputStream() {
- return new RESTEasyInputStream((InputStream) response.getEntity(InputStream.class), client.getExecutor());
- }
-
- @Override
- public String header(String name) {
- return response.getHeaders().getFirst(name).toString();
- }
-
- @Override
- public Map<String, String> headers() {
- Map<String, String> headers = new HashMap<>();
- MultivaluedMap<String, Object> responseHeaders = response.getHeaders();
-
- for (String key : responseHeaders.keySet()) {
- headers.put(key, responseHeaders.getFirst(key).toString());
- }
-
- return headers;
- }
-
-}
diff --git a/openstack-client-connectors/resteasy-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector b/openstack-client-connectors/resteasy-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
deleted file mode 100644
index dbb991d..0000000
--- a/openstack-client-connectors/resteasy-connector/src/main/resources/META-INF/services/com.woorea.openstack.base.client.OpenStackClientConnector
+++ /dev/null
@@ -1 +0,0 @@
-com.woorea.openstack.connector.RESTEasyConnector \ No newline at end of file
diff --git a/openstack-client/src/main/java/com/woorea/openstack/common/client/AbstractOpenStackClient.java b/openstack-client/src/main/java/com/woorea/openstack/common/client/AbstractOpenStackClient.java
deleted file mode 100644
index 4319304..0000000
--- a/openstack-client/src/main/java/com/woorea/openstack/common/client/AbstractOpenStackClient.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.common.client;
-//package org.openstack.common.client;
-//
-//import java.io.IOException;
-//import java.util.logging.Logger;
-//
-//import javax.ws.rs.client.ClientRequestContext;
-//import javax.ws.rs.client.ClientRequestFilter;
-//import javax.ws.rs.client.Entity;
-//import javax.ws.rs.client.Invocation.Builder;
-//import javax.ws.rs.client.WebTarget;
-//import javax.ws.rs.core.MediaType;
-//
-//import org.glassfish.jersey.filter.LoggingFilter;
-//import org.openstack.connector.OpenStack;
-//
-//public class AbstractOpenStackClient {
-//
-// protected String endpointURL;
-//
-// protected String token;
-//
-// protected LoggingFilter loggingFilter;
-//
-// protected ClientRequestFilter tokenFilter = new ClientRequestFilter() {
-//
-// @Override
-// public void filter(ClientRequestContext requestContext) throws IOException {
-// requestContext.getHeaders().putSingle("X-Auth-Token", token);
-// }
-// };
-//
-// public AbstractOpenStackClient(String endpointURL, String token) {
-// this.endpointURL = endpointURL;
-// this.token = token;
-// }
-//
-// public AbstractOpenStackClient(String endpointURL) {
-// this(endpointURL, null);
-// }
-//
-// /**
-// * @param token the token to set
-// */
-// public void setToken(String token) {
-// this.token = token;
-// }
-//
-// public OpenStackRequest request(String uri, String... mediaTypes) {
-// WebTarget endpoint = OpenStack.CLIENT.target(endpointURL);
-// if(token != null) {
-// endpoint.register(tokenFilter);
-// }
-// return new OpenStackRequest(endpoint.path(uri).request(mediaTypes));
-// }
-//
-// public OpenStackRequest request(String uri) {
-// return request(uri, MediaType.APPLICATION_JSON);
-// }
-//
-// protected WebTarget create(String endpoint) {
-// WebTarget target = OpenStack.CLIENT.target(endpoint);
-// if(loggingFilter != null) {
-// target.register(loggingFilter);
-// }
-// if(token != null) {
-// target.register(tokenFilter);
-// }
-// return target;
-// }
-//
-// public void enableLogging(Logger logger, int entitySize) {
-// loggingFilter = new LoggingFilter(logger, entitySize);
-// }
-//
-// public void disableLogging() {
-// loggingFilter = null;
-// }
-//
-// public static class OpenStackRequest {
-//
-// private Builder builder;
-//
-// private OpenStackRequest(Builder builder) {
-// this.builder = builder;
-// }
-//
-// public <ResponseType> ResponseType execute(String method, Class<ResponseType> type) {
-// return builder.method(method, type);
-// }
-//
-// public <RequestType, ResponseType> ResponseType execute(String method, Entity<RequestType> data, Class<ResponseType> type) {
-// return builder.method(method, data, type);
-// }
-//
-// public void execute(String method) {
-// builder.method(method);
-// }
-//
-// public <RequestType> void execute(String method, Entity<RequestType> data) {
-// builder.method(method, data, Void.class);
-// }
-//
-// public <ResponseType> ResponseType get(Class<ResponseType> type) {
-// return execute("GET", type);
-// }
-//
-// public <ResponseType> ResponseType postJson(Object data, Class<ResponseType> type) {
-// return execute("POST", Entity.json(data), type);
-// }
-//
-// public <ResponseType> ResponseType putJson(Object data, Class<ResponseType> type) {
-// return execute("PUT", Entity.json(data), type);
-// }
-//
-// public <ResponseType> ResponseType patchJson(Object data, Class<ResponseType> type) {
-// return execute("PATCH", Entity.json(data), type);
-// }
-//
-// public void delete() {
-// execute("DELETE", Void.class);
-// }
-// }
-//
-//}
diff --git a/openstack-console/pom.xml b/openstack-console/pom.xml
deleted file mode 100644
index 7022293..0000000
--- a/openstack-console/pom.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.so</groupId>
- <artifactId>openstack-java-sdk</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- </parent>
- <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
- <artifactId>openstack-console</artifactId>
- <name>OpenStack Console</name>
- <description>OpenStack Console</description>
- <dependencies>
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- <version>2.10</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>keystone-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>nova-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>jersey</id>
- <dependencies>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>jersey-connector</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>jersey2</id>
- <dependencies>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>jersey2-connector</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>resteasy</id>
- <dependencies>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>resteasy-connector</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <version>1.2.1</version>
- <configuration>
- <mainClass>org.openecomp.mso.openstack.console.Main</mainClass>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/Command.java b/openstack-console/src/main/java/com/woorea/openstack/console/Command.java
deleted file mode 100644
index 8aa56c0..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/Command.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-
-
-public abstract class Command {
-
- protected String name;
-
- public Command(String name) {
- this.name = name;
- }
-
- public abstract void execute(Console console, CommandLine args);
-
- public Options getOptions() {
- return new Options();
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/CommandLineHelper.java b/openstack-console/src/main/java/com/woorea/openstack/console/CommandLineHelper.java
deleted file mode 100644
index c11c403..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/CommandLineHelper.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console;
-
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-public class CommandLineHelper {
-
- public static String[] parse(String input) {
- if (input == null || input.length() == 0) {
- //no command? no string
- return new String[0];
- }
- // parse with a simple finite state machine
-
- final int normal = 0;
- final int inQuote = 1;
- final int inDoubleQuote = 2;
- int state = normal;
- StringTokenizer tok = new StringTokenizer(input, "\"\' ", true);
- Vector v = new Vector();
- StringBuffer current = new StringBuffer();
- boolean lastTokenHasBeenQuoted = false;
-
- while (tok.hasMoreTokens()) {
- String nextTok = tok.nextToken();
- switch (state) {
- case inQuote:
- if ("\'".equals(nextTok)) {
- lastTokenHasBeenQuoted = true;
- state = normal;
- } else {
- current.append(nextTok);
- }
- break;
- case inDoubleQuote:
- if ("\"".equals(nextTok)) {
- lastTokenHasBeenQuoted = true;
- state = normal;
- } else {
- current.append(nextTok);
- }
- break;
- default:
- if ("\'".equals(nextTok)) {
- state = inQuote;
- } else if ("\"".equals(nextTok)) {
- state = inDoubleQuote;
- } else if (" ".equals(nextTok)) {
- if (lastTokenHasBeenQuoted || current.length() != 0) {
- v.addElement(current.toString());
- current = new StringBuffer();
- }
- } else {
- current.append(nextTok);
- }
- lastTokenHasBeenQuoted = false;
- break;
- }
- }
- if (lastTokenHasBeenQuoted || current.length() != 0) {
- v.addElement(current.toString());
- }
- if (state == inQuote || state == inDoubleQuote) {
- throw new RuntimeException("unbalanced quotes in " + input);
- }
- String[] args = new String[v.size()];
- v.copyInto(args);
- return args;
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/Commands.java b/openstack-console/src/main/java/com/woorea/openstack/console/Commands.java
deleted file mode 100644
index d9a395b..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/Commands.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console;
-
-import java.util.Map;
-
-import org.apache.commons.cli.CommandLine;
-
-public class Commands {
-
- public static final Command EXIT = new Command("exit") {
-
- @Override
- public void execute(Console console, CommandLine args) {
- console.exit();
- }
-
- };
-
- public static final Command SET = new Command("set") {
-
- @Override
- public void execute(Console console, CommandLine args) {
- if(args.getArgs().length == 2) {
- console.setProperty(args.getArgs()[0], args.getArgs()[1]);
- } else {
- console.properties();
- }
- }
-
- };
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/Console.java b/openstack-console/src/main/java/com/woorea/openstack/console/Console.java
deleted file mode 100644
index 51a316e..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/Console.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import jline.UnsupportedTerminal;
-import jline.console.ConsoleReader;
-import jline.console.completer.Completer;
-import jline.console.completer.StringsCompleter;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-
-public class Console {
-
- private Properties properties;
-
- private ConsoleReader reader;
-
- private Environment environment;
-
- private HelpFormatter helpFormatter = new HelpFormatter();
-
- private static final CommandLineParser PARSER = new GnuParser();
-
- public Console(Environment environment, Properties properties) {
- this.properties = properties;
- this.environment = environment;
- }
-
- public void start() throws IOException {
- if(System.console() == null) {
- reader = new ConsoleReader(System.in, System.out, new UnsupportedTerminal());
- } else {
- reader = new ConsoleReader();
- }
- do {
- String line = reader.readLine(environment.getPrompt());
- execute(line);
- } while(true);
- }
-
- public void execute(String line) {
- String[] tokens = CommandLineHelper.parse(line);
- if(tokens.length > 0) {
- Command command = environment.commands.get(tokens[0]);
- if(command != null) {
- try {
- CommandLine args = Console.PARSER.parse(command.getOptions(), Arrays.copyOfRange(tokens, 1, tokens.length));
- command.execute(this, args);
- } catch (Exception e) {
- e.printStackTrace();
- helpFormatter.printHelp(command.name, command.getOptions());
- }
- }
- }
- }
-
- public void setEnvironment(Environment environment) {
- Set<Completer> completers = new HashSet<Completer>(reader.getCompleters());
- for(Completer c : completers) {
- reader.removeCompleter(c);
- }
- Set<String> commands = new HashSet<String>();
- for(Map.Entry<String,Command> c : environment.commands.entrySet()) {
- commands.add(c.getKey());
- }
- reader.addCompleter(new StringsCompleter(commands));
- this.environment = environment;
- }
-
- public Environment getEnvironment() {
- return this.environment;
- }
-
- /**
- * @return the properties
- */
- public String getProperty(String name) {
- return properties.getProperty(name);
- }
-
- /**
- * @return the properties
- */
- public void setProperty(String name, Object value) {
- properties.put(name, value);
- }
-
- public void properties() {
- for(Map.Entry<Object, Object> entry : properties.entrySet()) {
- System.out.printf("%25s = %55s",entry.getKey(), entry.getValue());
- }
- }
-
- public void exit() {
- if(environment.parent == null) {
- System.out.println("Goodbye");
- System.exit(1);
- } else {
- environment = environment.parent;
- }
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/Environment.java b/openstack-console/src/main/java/com/woorea/openstack/console/Environment.java
deleted file mode 100644
index 9342349..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/Environment.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console;
-import java.util.Map;
-import java.util.TreeMap;
-
-
-public class Environment {
-
- protected final Environment parent;
-
- protected Map<String, Command> commands = new TreeMap<String, Command>();
-
- public Environment(Environment parent) {
- register(Commands.EXIT);
- register(Commands.SET);
- this.parent = parent;
- }
-
- public Environment() {
- this(null);
- }
-
- public void register(Command command) {
- commands.put(command.name, command);
- }
-
- public String getPrompt() {
- return "> ";
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/Main.java b/openstack-console/src/main/java/com/woorea/openstack/console/Main.java
deleted file mode 100644
index 730ba68..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/Main.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Properties;
-
-import com.woorea.openstack.console.keystone.KeystoneEnvironment;
-import com.woorea.openstack.console.nova.NovaEnvironment;
-
-public class Main {
-
- /**
- * @param args
- */
- public static void main(String[] args) throws IOException {
- Environment environment = new Environment();
- environment.register(KeystoneEnvironment.KEYSTONE);
- environment.register(NovaEnvironment.NOVA);
-
- Properties properties = new Properties();
- properties.load(new FileInputStream("src/main/resources/console.properties"));
-
- Console console = new Console(environment, properties);
- console.start();
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneCommand.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneCommand.java
deleted file mode 100644
index 48cfc9b..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.Command;
-import com.woorea.openstack.console.Console;
-import com.woorea.openstack.keystone.Keystone;
-
-public abstract class KeystoneCommand extends Command {
-
- public KeystoneCommand(String name) {
- super(name);
- }
-
- @Override
- public void execute(Console console, CommandLine args) {
- KeystoneEnvironment environment = (KeystoneEnvironment) console.getEnvironment();
- execute(environment.CLIENT, args);
-
- }
-
- protected abstract void execute(Keystone keystone, CommandLine args);
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneEnvironment.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneEnvironment.java
deleted file mode 100644
index b9c4c3c..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneEnvironment.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.console.Command;
-import com.woorea.openstack.console.Console;
-import com.woorea.openstack.console.Environment;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-
-public class KeystoneEnvironment extends Environment {
-
- public final Keystone CLIENT;
-
- public static final Command KEYSTONE = new Command("keystone") {
-
- @Override
- public void execute(Console console, CommandLine args) {
-
- Keystone client = new Keystone(console.getProperty("keystone.endpoint"));
-
- Access access = client.tokens()
- .authenticate(new UsernamePassword(
- console.getProperty("keystone.username"),
- console.getProperty("keystone.password")
- ))
- .withTenantName(console.getProperty("keystone.tenant_name"))
- .execute();
-
- client.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
-
- KeystoneEnvironment environment = new KeystoneEnvironment(console.getEnvironment(), client);
-
- environment.register(new KeystoneTenantList());
- environment.register(new KeystoneTenantCreate());
- environment.register(new KeystoneTenantDelete());
- environment.register(new KeystoneUserList());
- environment.register(new KeystoneUserCreate());
- environment.register(new KeystoneUserDelete());
- environment.register(new KeystoneRoleList());
- environment.register(new KeystoneRoleDelete());
- environment.register(new KeystoneServiceList());
- console.setEnvironment(environment);
- }
-
- };
-
- public KeystoneEnvironment(Environment parent, Keystone client) {
- super(parent);
- CLIENT = client;
- }
-
- /* (non-Javadoc)
- * @see org.woorea.wsh.Environment#getPrompt()
- */
- @Override
- public String getPrompt() {
- return "keystone> ";
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleCreate.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleCreate.java
deleted file mode 100644
index 7dbba41..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleCreate.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import java.util.Arrays;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-
-import com.woorea.openstack.console.utils.Column;
-import com.woorea.openstack.console.utils.Table;
-import com.woorea.openstack.console.utils.TableModel;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Role;
-
-public class KeystoneRoleCreate extends KeystoneCommand {
-
- public KeystoneRoleCreate() {
- super( "role-create");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- Role role = new Role();
- role.setName(cmd.getOptionValue("name"));
- role.setDescription(cmd.getOptionValue("description"));
- if(cmd.getOptionValue("enabled") != null) {
- role.setEnabled("True");
- }
-
- role = keystone.roles().create(role).execute();
-
- Table t = new Table(new TableModel<Role>(Arrays.asList(role)) {
-
- @Override
- public Column[] getHeaders() {
- return new Column[]{
- new Column("id", 32, Column.ALIGN_LEFT),
- new Column("name", 10, Column.ALIGN_LEFT),
- new Column("description", 32, Column.ALIGN_LEFT),
- new Column("enabled", 7, Column.ALIGN_LEFT)
- };
- }
-
- @Override
- public String[] getRow(Role tenant) {
- return new String[]{
- tenant.getId(),
- tenant.getName(),
- tenant.getDescription(),
- tenant.getEnabled().toString()
- };
- }
- });
- System.out.println(t.render());
- }
-
- /* (non-Javadoc)
- * @see com.billingstack.commands.Command#getOptions()
- */
- @Override
- public Options getOptions() {
- Options opts = super.getOptions();
- opts.addOption(null, "name", true, "tenant name");
- opts.addOption(null, "description", true, "tenant description");
- opts.addOption(null, "enabled", false, "enabled");
- return opts;
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleDelete.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleDelete.java
deleted file mode 100644
index 9adf5c8..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleDelete.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.utils.ConsoleUtils;
-import com.woorea.openstack.keystone.Keystone;
-
-public class KeystoneRoleDelete extends KeystoneCommand {
-
- public KeystoneRoleDelete() {
- super("role-delete");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- String[] args = cmd.getArgs();
- if(args.length == 1) {
- keystone.roles().delete(args[0]).execute();
- System.out.println(new ConsoleUtils().green("OK"));
- }
-
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleList.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleList.java
deleted file mode 100644
index a6c7f2a..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneRoleList.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.utils.Column;
-import com.woorea.openstack.console.utils.Table;
-import com.woorea.openstack.console.utils.TableModel;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Role;
-import com.woorea.openstack.keystone.model.Roles;
-
-public class KeystoneRoleList extends KeystoneCommand {
-
- public KeystoneRoleList() {
- super("role-list");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- final Roles roles = keystone.roles().list().execute();
-
- Table t = new Table(new TableModel<Role>(roles.getList()) {
-
- @Override
- public Column[] getHeaders() {
- return new Column[]{
- new Column("id", 32, Column.ALIGN_LEFT),
- new Column("name", 10, Column.ALIGN_LEFT),
- new Column("description", 32, Column.ALIGN_LEFT),
- new Column("enabled", 7, Column.ALIGN_LEFT),
- };
- }
-
- @Override
- public String[] getRow(Role role) {
- return new String[]{
- role.getId(),
- role.getName(),
- role.getDescription(),
- role.getEnabled()
- };
- }
- });
- System.out.println(t.render());
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneServiceList.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneServiceList.java
deleted file mode 100644
index 9070bd9..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneServiceList.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.utils.Column;
-import com.woorea.openstack.console.utils.Table;
-import com.woorea.openstack.console.utils.TableModel;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Service;
-import com.woorea.openstack.keystone.model.Services;
-
-public class KeystoneServiceList extends KeystoneCommand {
-
- public KeystoneServiceList() {
- super("service-list");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- final Services services = keystone.services().list().execute();
-
- Table t = new Table(new TableModel<Service>(services.getList()) {
-
- @Override
- public Column[] getHeaders() {
- return new Column[]{
- new Column("id", 32, Column.ALIGN_LEFT),
- new Column("type", 10, Column.ALIGN_LEFT),
- new Column("name", 10, Column.ALIGN_LEFT),
- new Column("description", 32, Column.ALIGN_LEFT)
- };
- }
-
- @Override
- public String[] getRow(Service service) {
- return new String[]{
- service.getId(),
- service.getType(),
- service.getName(),
- service.getDescription()
- };
- }
- });
- System.out.println(t.render());
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantCreate.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantCreate.java
deleted file mode 100644
index c77c5b1..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantCreate.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import java.util.Arrays;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-
-import com.woorea.openstack.console.utils.Column;
-import com.woorea.openstack.console.utils.Table;
-import com.woorea.openstack.console.utils.TableModel;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Tenant;
-
-public class KeystoneTenantCreate extends KeystoneCommand {
-
- public KeystoneTenantCreate() {
- super("tenant-create");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- Tenant tenant = new Tenant();
- tenant.setName(cmd.getOptionValue("name"));
- tenant.setDescription(cmd.getOptionValue("description"));
- if(cmd.getOptionValue("enabled") != null) {
- tenant.setEnabled(Boolean.TRUE);
- }
-
- tenant = keystone.tenants().create(tenant).execute();
-
- Table t = new Table(new TableModel<Tenant>(Arrays.asList(tenant)) {
-
- @Override
- public Column[] getHeaders() {
- return new Column[]{
- new Column("id", 32, Column.ALIGN_LEFT),
- new Column("name", 10, Column.ALIGN_LEFT),
- new Column("description", 32, Column.ALIGN_LEFT),
- new Column("enabled", 7, Column.ALIGN_LEFT)
- };
- }
-
- @Override
- public String[] getRow(Tenant tenant) {
- return new String[]{
- tenant.getId(),
- tenant.getName(),
- tenant.getDescription(),
- tenant.getEnabled().toString()
- };
- }
- });
- System.out.println(t.render());
- }
-
- /* (non-Javadoc)
- * @see com.billingstack.commands.Command#getOptions()
- */
- @Override
- public Options getOptions() {
- Options opts = super.getOptions();
- opts.addOption(null, "name", true, "tenant name");
- opts.addOption(null, "description", true, "tenant description");
- opts.addOption(null, "enabled", false, "enabled");
- return opts;
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantDelete.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantDelete.java
deleted file mode 100644
index 1e9a649..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantDelete.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.utils.ConsoleUtils;
-import com.woorea.openstack.keystone.Keystone;
-
-public class KeystoneTenantDelete extends KeystoneCommand {
-
- public KeystoneTenantDelete() {
- super("tenant-delete");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- String[] args = cmd.getArgs();
- if(args.length == 1) {
- keystone.tenants().delete(args[0]).execute();
- System.out.println(new ConsoleUtils().green("OK"));
- }
-
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantList.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantList.java
deleted file mode 100644
index ac8994b..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneTenantList.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.utils.Column;
-import com.woorea.openstack.console.utils.Table;
-import com.woorea.openstack.console.utils.TableModel;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Tenant;
-import com.woorea.openstack.keystone.model.Tenants;
-
-public class KeystoneTenantList extends KeystoneCommand {
-
- public KeystoneTenantList() {
- super("tenant-list");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine args) {
-
- final Tenants tenants = keystone.tenants().list().execute();
-
- Table t = new Table(new TableModel<Tenant>(tenants.getList()) {
-
- @Override
- public Column[] getHeaders() {
- return new Column[]{
- new Column("id", 32, Column.ALIGN_LEFT),
- new Column("name", 32, Column.ALIGN_LEFT),
- new Column("description", 32, Column.ALIGN_LEFT),
- new Column("enabled", 7, Column.ALIGN_LEFT)
- };
- }
-
- @Override
- public String[] getRow(Tenant tenant) {
- return new String[]{
- tenant.getId(),
- tenant.getName(),
- tenant.getDescription(),
- tenant.getEnabled().toString()
- };
- }
- });
- System.out.println(t.render());
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserCreate.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserCreate.java
deleted file mode 100644
index 2da50fc..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserCreate.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import java.util.Arrays;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.Options;
-
-import com.woorea.openstack.console.utils.Column;
-import com.woorea.openstack.console.utils.Table;
-import com.woorea.openstack.console.utils.TableModel;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.User;
-
-public class KeystoneUserCreate extends KeystoneCommand {
-
- public KeystoneUserCreate() {
- super("user-create");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- User user = new User();
- user.setName(cmd.getOptionValue("name"));
- user.setPassword(cmd.getOptionValue("password"));
- user.setEmail(cmd.getOptionValue("email"));
- user.setTenantId(cmd.getOptionValue("tenant"));
- if(cmd.getOptionValue("enabled") != null) {
- user.setEnabled(Boolean.TRUE);
- }
-
- user = keystone.users().create(user).execute();
-
- Table t = new Table(new TableModel<User>(Arrays.asList(user)) {
-
- @Override
- public Column[] getHeaders() {
- return new Column[]{
- new Column("id", 32, Column.ALIGN_LEFT),
- new Column("name", 10, Column.ALIGN_LEFT),
- new Column("email", 22, Column.ALIGN_LEFT),
- new Column("tenant", 32, Column.ALIGN_LEFT),
- new Column("enabled", 7, Column.ALIGN_LEFT)
- };
- }
-
- @Override
- public String[] getRow(User user) {
- return new String[]{
- user.getId(),
- user.getName(),
- user.getEmail(),
- user.getTenantId(),
- user.getEnabled().toString()
- };
- }
- });
- System.out.println(t.render());
- }
-
- /* (non-Javadoc)
- * @see com.billingstack.commands.Command#getOptions()
- */
- @Override
- public Options getOptions() {
- Options opts = super.getOptions();
- opts.addOption(null, "name", true, "user name");
- opts.addOption(null, "password", true, "user password");
- opts.addOption(null, "email", true, "user email");
- opts.addOption(null, "tenant", true, "tenant id");
- opts.addOption(null, "enabled", false, "enabled");
- return opts;
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserDelete.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserDelete.java
deleted file mode 100644
index 0c02887..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserDelete.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.utils.ConsoleUtils;
-import com.woorea.openstack.keystone.Keystone;
-
-public class KeystoneUserDelete extends KeystoneCommand {
-
- public KeystoneUserDelete() {
- super("user-delete");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- String[] args = cmd.getArgs();
- if(args.length == 1) {
- keystone.users().delete(args[0]).execute();
- System.out.println(new ConsoleUtils().green("OK"));
- }
-
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserList.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserList.java
deleted file mode 100644
index 06362f9..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserList.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.utils.Column;
-import com.woorea.openstack.console.utils.Table;
-import com.woorea.openstack.console.utils.TableModel;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.User;
-import com.woorea.openstack.keystone.model.Users;
-
-public class KeystoneUserList extends KeystoneCommand {
-
- public KeystoneUserList() {
- super("user-list");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- final Users users = keystone.users().list().execute();
-
- Table t = new Table(new TableModel<User>(users.getList()) {
-
- @Override
- public Column[] getHeaders() {
- return new Column[]{
- new Column("id", 32, Column.ALIGN_LEFT),
- new Column("name", 10, Column.ALIGN_LEFT),
- new Column("email", 22, Column.ALIGN_LEFT),
- new Column("tenant", 32, Column.ALIGN_LEFT),
- new Column("enabled", 7, Column.ALIGN_LEFT)
- };
- }
-
- @Override
- public String[] getRow(User user) {
- return new String[]{
- user.getId(),
- user.getName(),
- user.getEmail(),
- user.getTenantId(),
- user.getEnabled().toString()
- };
- }
- });
- System.out.println(t.render());
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserShow.java b/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserShow.java
deleted file mode 100644
index c7a8a6e..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/keystone/KeystoneUserShow.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.keystone;
-
-import java.util.Arrays;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.utils.Column;
-import com.woorea.openstack.console.utils.Table;
-import com.woorea.openstack.console.utils.TableModel;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.User;
-
-public class KeystoneUserShow extends KeystoneCommand {
-
- public KeystoneUserShow() {
- super("user-show");
- }
-
- @Override
- public void execute(Keystone keystone, CommandLine cmd) {
-
- String[] args = cmd.getArgs();
- if(args.length == 1) {
- User user = keystone.users().show(args[0]).execute();
- Table t = new Table(new TableModel<User>(Arrays.asList(user)) {
-
- @Override
- public Column[] getHeaders() {
- return new Column[]{
- new Column("id", 32, Column.ALIGN_LEFT),
- new Column("name", 10, Column.ALIGN_LEFT),
- new Column("email", 22, Column.ALIGN_LEFT),
- new Column("tenant", 32, Column.ALIGN_LEFT),
- new Column("enabled", 7, Column.ALIGN_LEFT)
- };
- }
-
- @Override
- public String[] getRow(User user) {
- return new String[]{
- user.getId(),
- user.getName(),
- user.getEmail(),
- user.getTenantId(),
- user.getEnabled().toString()
- };
- }
- });
- System.out.println(t.render());
- }
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaCommand.java b/openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaCommand.java
deleted file mode 100644
index a45c51d..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaCommand.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.nova;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.Command;
-import com.woorea.openstack.console.Console;
-import com.woorea.openstack.nova.Nova;
-
-
-public abstract class NovaCommand extends Command {
-
- public NovaCommand(String name) {
- super(name);
- }
-
- @Override
- public void execute(Console console, CommandLine args) {
- NovaEnvironment environment = (NovaEnvironment) console.getEnvironment();
- execute(environment.CLIENT, args);
-
- }
-
- protected abstract void execute(Nova nova, CommandLine args);
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaEnvironment.java b/openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaEnvironment.java
deleted file mode 100644
index 0f8f07c..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaEnvironment.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.nova;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.console.Command;
-import com.woorea.openstack.console.Console;
-import com.woorea.openstack.console.Environment;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import com.woorea.openstack.nova.Nova;
-
-public class NovaEnvironment extends Environment {
-
- public final Nova CLIENT;
-
- public static final Command NOVA = new Command("nova") {
-
- @Override
- public void execute(Console console, CommandLine args) {
-
- if(args.getArgs().length == 1) {
- Keystone keystone = new Keystone((String) console.getProperty("keystone.endpoint"));
-
- Access access = keystone.tokens().authenticate(
- new UsernamePassword(
- console.getProperty("keystone.username"),
- console.getProperty("keystone.password")
- )
- )
- .withTenantName(console.getProperty("keystone.tenant_name"))
- .execute();
-
- System.out.println(console.getProperty("nova.endpoint"));
-
- Nova client = new Nova(console.getProperty("nova.endpoint")+args.getArgs()[0]);
- client.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
-
- NovaEnvironment environment = new NovaEnvironment(console.getEnvironment(), client);
-
- environment.register(new NovaServerList());
-
- console.setEnvironment(environment);
-
- }
-
- }
-
- };
-
- public NovaEnvironment(Environment parent, Nova client) {
- super(parent);
- CLIENT = client;
- }
-
- /* (non-Javadoc)
- * @see org.woorea.wsh.Environment#getPrompt()
- */
- @Override
- public String getPrompt() {
- return "nova> ";
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaServerList.java b/openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaServerList.java
deleted file mode 100644
index 8f8f20c..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/nova/NovaServerList.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.nova;
-
-import org.apache.commons.cli.CommandLine;
-
-import com.woorea.openstack.console.utils.Column;
-import com.woorea.openstack.console.utils.Table;
-import com.woorea.openstack.console.utils.TableModel;
-import com.woorea.openstack.nova.Nova;
-import com.woorea.openstack.nova.model.Server;
-import com.woorea.openstack.nova.model.Servers;
-
-public class NovaServerList extends NovaCommand {
-
- public NovaServerList() {
- super("list");
- }
-
- @Override
- public void execute(Nova nova, CommandLine cmd) {
-
- final Servers servers = nova.servers().list(true).execute();
-
- Table t = new Table(new TableModel<Server>(servers.getList()) {
-
- @Override
- public Column[] getHeaders() {
- return new Column[]{
- new Column("id", 32, Column.ALIGN_LEFT),
- new Column("name", 10, Column.ALIGN_LEFT)
- };
- }
-
- @Override
- public String[] getRow(Server server) {
- return new String[]{
- server.getId(),
- server.getName()
- };
- }
- });
- System.out.println(t.render());
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/utils/Column.java b/openstack-console/src/main/java/com/woorea/openstack/console/utils/Column.java
deleted file mode 100644
index 755ac17..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/utils/Column.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.utils;
-
-public class Column {
-
- public static final int ALIGN_LEFT = -1;
- public static final int ALIGN_RIGHT = 1;
-
- private String name;
-
- private int size;
-
- private int align;
-
- public Column(String name, int size, int align) {
- super();
- this.name = name;
- this.size = size;
- this.align = align;
- }
-
- /**
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return the size
- */
- public int getSize() {
- return size;
- }
-
- /**
- * @param size the size to set
- */
- public void setSize(int size) {
- this.size = size;
- }
-
- /**
- * @return the align
- */
- public int getAlign() {
- return align;
- }
-
- /**
- * @param align the align to set
- */
- public void setAlign(int align) {
- this.align = align;
- }
-
-
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/utils/ConsoleUtils.java b/openstack-console/src/main/java/com/woorea/openstack/console/utils/ConsoleUtils.java
deleted file mode 100644
index 8166217..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/utils/ConsoleUtils.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.utils;
-
-public class ConsoleUtils {
-
- public static final String RED = "\u001B[31m";
-
- public static final String GREEN = "\u001B[32m";
-
- public static final String YELLOW = "\u001B[33m";
-
- public static final String END = "\u001B[0m";
-
- private StringBuilder sb = new StringBuilder();
-
- public ConsoleUtils append(String text) {
- sb.append(text);
- return this;
- }
-
- public ConsoleUtils red(String text) {
- sb.append(ConsoleUtils.RED).append(text).append(END);
- return this;
- }
-
- public ConsoleUtils green(String text) {
- sb.append(ConsoleUtils.GREEN).append(text).append(END);
- return this;
- }
-
- public ConsoleUtils yellow(String text) {
- sb.append(ConsoleUtils.YELLOW).append(text).append(END);
- return this;
- }
-
- public static void log(String text) {
- System.out.println(new ConsoleUtils().yellow("| ").append(text));
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return sb.toString();
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/utils/Table.java b/openstack-console/src/main/java/com/woorea/openstack/console/utils/Table.java
deleted file mode 100644
index d25d16d..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/utils/Table.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.utils;
-
-
-public class Table {
-
- private StringBuilder sb = new StringBuilder();
-
- private TableModel<?> model;
-
- public Table(TableModel<?> model) {
- this.model = model;
- }
-
- public StringBuilder render() {
- header();
- for(String[] row : model.getRows()) {
- int i = 0;
- for(String column : row) {
- Column columnModel = model.getHeaders()[i];
- sb.append("| ");
- if(column != null) {
- if(Column.ALIGN_RIGHT == columnModel.getAlign()) {
- for(int j = 0; j < columnModel.getSize() - column.length(); j++) {
- sb.append(" ");
- }
- }
- sb.append(column.length() <= columnModel.getSize() ? column : column.substring(0, columnModel.getSize()));
- if(Column.ALIGN_LEFT == columnModel.getAlign()) {
- for(int j = 0; j < columnModel.getSize() - column.length(); j++) {
- sb.append(" ");
- }
- }
- } else {
- for(int k = 0; k < columnModel.getSize(); k++) {
- sb.append(" ");
- }
- }
- sb.append(" ");
- i++;
- }
- sb.append("|\n");
- }
- for(Column c : model.getHeaders()) {
- sb.append("+");
- for(int i = 0; i < c.getSize() + 2; i++) {
- sb.append("-");
- }
- }
- sb.append("+\n");
- return sb;
- }
-
- public void header() {
- for(Column c : model.getHeaders()) {
- sb.append("+");
- for(int i = 0; i < c.getSize() + 2; i++) {
- sb.append("-");
- }
- }
- sb.append("+\n");
-
- for(Column c : model.getHeaders()) {
- sb.append("| ");
- sb.append(c.getName());
- for(int i = 0; i < c.getSize() - c.getName().length(); i++) {
- sb.append(" ");
- }
- sb.append(" ");
- }
- sb.append("|\n");
-
- for(Column c : model.getHeaders()) {
- sb.append("+");
- for(int i = 0; i < c.getSize() + 2; i++) {
- sb.append("-");
- }
- }
- sb.append("+\n");
- }
-
-}
diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/utils/TableModel.java b/openstack-console/src/main/java/com/woorea/openstack/console/utils/TableModel.java
deleted file mode 100644
index 3715c85..0000000
--- a/openstack-console/src/main/java/com/woorea/openstack/console/utils/TableModel.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.console.utils;
-
-import java.util.List;
-
-public abstract class TableModel<T> {
-
- protected List<T> data;
-
- public TableModel(List<T> data) {
- this.data = data;
- }
-
- public abstract Column[] getHeaders();
-
- public final String[][] getRows() {
- String[][] rows = new String[data.size()][];
- for(int i = 0; i < data.size(); i++) {
- rows[i] = getRow(data.get(i));
- }
- return rows;
- }
-
- public abstract String[] getRow(T data);
-
-}
diff --git a/openstack-console/src/main/resources/console.properties b/openstack-console/src/main/resources/console.properties
deleted file mode 100644
index 01902e4..0000000
--- a/openstack-console/src/main/resources/console.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-keystone.endpoint=http://keystone.stacksherpa.org/v2.0
-keystone.username=admin
-keystone.password=secret0
-keystone.tenant_name=admin
-
-nova.endpoint=http://compute/v2/ \ No newline at end of file
diff --git a/openstack-examples/pom.xml b/openstack-examples/pom.xml
deleted file mode 100644
index 4bf6b15..0000000
--- a/openstack-examples/pom.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onap.so</groupId>
- <artifactId>openstack-java-sdk</artifactId>
- <version>1.2.1-SNAPSHOT</version>
- </parent>
- <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
- <artifactId>openstack-examples</artifactId>
- <name>OpenStack Examples</name>
- <description>OpenStack Examples</description>
- <dependencies>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>keystone-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>nova-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>heat-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>swift-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>quantum-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>ceilometer-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>glance-client</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>jersey</id>
- <dependencies>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>jersey-connector</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>jersey2</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>jersey2-connector</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>resteasy</id>
- <dependencies>
- <dependency>
- <groupId>org.onap.so</groupId>
- <artifactId>resteasy-connector</artifactId>
- <version>3.2.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/ExamplesConfiguration.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/ExamplesConfiguration.java
deleted file mode 100644
index 2fa2f5f..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/ExamplesConfiguration.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples;
-
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Tenant;
-
-public class ExamplesConfiguration {
-
- public static final String KEYSTONE_AUTH_URL = "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v3";
-
- public static final String KEYSTONE_USERNAME = "";
-
- public static final String KEYSTONE_PASSWORD = "";
-
- public static final String KEYSTONE_ENDPOINT = "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v3";
-
- public static final String TENANT_NAME = "admin";
-
- public static final String NOVA_ENDPOINT = "http://compute/v2";
-
- public static final String CEILOMETER_ENDPOINT = "";
-
- public static void main(String[] args) {
- Keystone client = new Keystone(KEYSTONE_ENDPOINT);
- client.setTokenProvider(new OpenStackSimpleTokenProvider("secret0"));
- client.tenants().delete("36c481aec1d54fc49190c92c3ef6840a").execute();
- Tenant tenant = client.tenants().create(new Tenant("new_api")).execute();
- System.out.println(tenant);
- System.out.println(client.tenants().list().execute());
- client.tenants().delete(tenant.getId()).execute();
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaCreateServer.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaCreateServer.java
deleted file mode 100644
index 937ab5c..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaCreateServer.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.compute;
-
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.Tenants;
-import com.woorea.openstack.nova.Nova;
-import com.woorea.openstack.nova.model.Flavors;
-import com.woorea.openstack.nova.model.Images;
-import com.woorea.openstack.nova.model.KeyPairs;
-import com.woorea.openstack.nova.model.Server;
-import com.woorea.openstack.nova.model.ServerForCreate;
-
-public class NovaCreateServer {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- // access with unscoped token
- Access access = keystone
- .tokens()
- .authenticate()
- .withUsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)
- .execute();
-
- // use the token in the following requests
- keystone.token(access.getToken().getId());
-
- Tenants tenants = keystone.tenants().list().execute();
-
- // try to exchange token using the first tenant
- if (tenants.getList().size() > 0) {
-
- access = keystone.tokens().authenticate()
- .withToken(access.getToken().getId())
- .withTenantId(tenants.getList().get(0).getId()).execute();
-
- // NovaClient novaClient = new
- // NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(),
- // "compute", null, "public"), access.getToken().getId());
- Nova nova = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat(tenants
- .getList().get(0).getId()));
- nova.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken()
- .getId()));
- // novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
- // create a new keypair
- // KeyPair keyPair =
- // novaClient.execute(KeyPairsExtension.createKeyPair("mykeypair"));
- // System.out.println(keyPair.getPrivateKey());
-
- // create security group
- // SecurityGroup securityGroup =
- // novaClient.execute(SecurityGroupsExtension.createSecurityGroup("mysecuritygroup",
- // "description"));
-
- // novaClient.execute(SecurityGroupsExtension.createSecurityGroupRule(securityGroup.getId(),
- // "UDP", 9090, 9092, "0.0.0.0/0"));
- // novaClient.execute(SecurityGroupsExtension.createSecurityGroupRule(securityGroup.getId(),
- // "TCP", 8080, 8080, "0.0.0.0/0"));
-
- KeyPairs keysPairs = nova.keyPairs().list().execute();
-
- Images images = nova.images().list(true).execute();
-
- Flavors flavors = nova.flavors().list(true).execute();
-
- ServerForCreate serverForCreate = new ServerForCreate();
- serverForCreate.setName("woorea");
- serverForCreate.setFlavorRef(flavors.getList().get(0).getId());
- serverForCreate.setImageRef(images.getList().get(1).getId());
- serverForCreate.setKeyName(keysPairs.getList().get(0).getName());
- serverForCreate.getSecurityGroups()
- .add(new ServerForCreate.SecurityGroup("default"));
- // serverForCreate.getSecurityGroups().add(new
- // ServerForCreate.SecurityGroup(securityGroup.getName()));
-
- Server server = nova.servers().boot(serverForCreate).execute();
- System.out.println(server);
-
- } else {
- System.out.println("No tenants found!");
- }
-
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListFlavors.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListFlavors.java
deleted file mode 100644
index 25b196c..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListFlavors.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.compute;
-
-
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.Tenants;
-import com.woorea.openstack.keystone.model.authentication.TokenAuthentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import com.woorea.openstack.nova.Nova;
-import com.woorea.openstack.nova.model.Flavor;
-import com.woorea.openstack.nova.model.Flavors;
-
-public class NovaListFlavors {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- Access access = keystone.tokens().authenticate(
- new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .execute();
-
- //use the token in the following requests
- keystone.token(access.getToken().getId());
-
- Tenants tenants = keystone.tenants().list().execute();
-
- //try to exchange token using the first tenant
- if(tenants.getList().size() > 0) {
-
- access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
-
- //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
- Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(tenants.getList().get(0).getId()));
- novaClient.token(access.getToken().getId());
- //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
-
- Flavors flavors = novaClient.flavors().list(true).execute();
- for(Flavor flavor : flavors) {
- System.out.println(flavor);
- }
-
- } else {
- System.out.println("No tenants found!");
- }
-
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListImages.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListImages.java
deleted file mode 100644
index 1f7a431..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListImages.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.compute;
-
-
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.Tenants;
-import com.woorea.openstack.keystone.model.authentication.TokenAuthentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import com.woorea.openstack.nova.Nova;
-import com.woorea.openstack.nova.model.Image;
-import com.woorea.openstack.nova.model.Images;
-
-public class NovaListImages {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)).execute();
-
- //use the token in the following requests
- keystone.token(access.getToken().getId());
-
- Tenants tenants = keystone.tenants().list().execute();
-
- //try to exchange token using the first tenant
- if(tenants.getList().size() > 0) {
-
- access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId()))
- .withTenantId(tenants.getList().get(0).getId())
- .execute();
-
- //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
- Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(tenants.getList().get(0).getId()));
- novaClient.token(access.getToken().getId());
- //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
-
- Images images = novaClient.images().list(true).execute();
- for(Image image : images) {
- System.out.println(image);
- }
-
- } else {
- System.out.println("No tenants found!");
- }
-
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListServers.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListServers.java
deleted file mode 100644
index 0331a62..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaListServers.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.compute;
-
-
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import com.woorea.openstack.nova.Nova;
-import com.woorea.openstack.nova.model.Server;
-import com.woorea.openstack.nova.model.Servers;
-
-public class NovaListServers {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .withTenantName("demo")
- .execute();
-
- //use the token in the following requests
- keystone.token(access.getToken().getId());
-
- //NovaClient novaClient = new NovaClient(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "compute", null, "public"), access.getToken().getId());
- Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId()));
- novaClient.token(access.getToken().getId());
- //novaClient.enableLogging(Logger.getLogger("nova"), 100 * 1024);
-
- Servers servers = novaClient.servers().list(true).execute();
- for(Server server : servers) {
- System.out.println(server);
- }
-
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java
deleted file mode 100644
index dfc5f06..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.compute;
-
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import com.woorea.openstack.nova.Nova;
-import com.woorea.openstack.nova.api.ServersResource;
-import com.woorea.openstack.nova.model.Servers;
-
-public class NovaStopStartServer {
- public static void main(String[] args) throws InterruptedException {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .withTenantName(ExamplesConfiguration.TENANT_NAME)
- .execute();
-
- //use the token in the following requests
- keystone.token(access.getToken().getId());
-
- Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId()));
- novaClient.token(access.getToken().getId());
-
- Servers servers = novaClient.servers().list(true).execute();
- if(servers.getList().size() > 0) {
-
- // Server has to be in activated state.
- ServersResource.StopServer stopServer = novaClient.servers().stop(servers.getList().get(0).getId());
- stopServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
- stopServer.execute();
-
- // Wait until server shutdown. Or 400 error occurs.
- Thread.sleep(5000);
-
- ServersResource.StartServer startServer = novaClient.servers().start(servers.getList().get(0).getId());
- startServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT);
- startServer.execute();
- }
- }
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/glance/GlanceListImages.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/glance/GlanceListImages.java
deleted file mode 100644
index f0eef65..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/glance/GlanceListImages.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.glance;
-
-import com.woorea.openstack.glance.model.ImageDownload;
-import com.woorea.openstack.glance.model.ImageUpload;
-import com.woorea.openstack.keystone.utils.KeystoneTokenProvider;
-
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.glance.Glance;
-import com.woorea.openstack.glance.model.Image;
-import com.woorea.openstack.glance.model.Images;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.Access.Service;
-import com.woorea.openstack.keystone.model.Access.Service.Endpoint;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-
-public class GlanceListImages {
-
- protected static String IMAGE_CONTENT = "Hello World!";
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- KeystoneTokenProvider keystone = new KeystoneTokenProvider(
- ExamplesConfiguration.KEYSTONE_AUTH_URL,
- ExamplesConfiguration.KEYSTONE_USERNAME,
- ExamplesConfiguration.KEYSTONE_PASSWORD);
-
- Access access = keystone.getAccessByTenant(ExamplesConfiguration.TENANT_NAME);
-
- Service glanceService = null;
-
- for (Service service : access.getServiceCatalog()) {
- if (service.getType().equals("image")) {
- glanceService = service;
- break;
- }
- }
-
- if (glanceService == null) {
- throw new RuntimeException("Glance service not found");
- }
-
- for (Endpoint endpoint : glanceService.getEndpoints()) {
- Glance glance = new Glance(endpoint.getPublicURL() + "/v1");
- glance.setTokenProvider(keystone
- .getProviderByTenant(ExamplesConfiguration.TENANT_NAME));
-
- // Creating a new image
- Image newImage = new Image();
- newImage.setDiskFormat("raw");
- newImage.setContainerFormat("bare");
- newImage.setName("os-java-glance-test");
- newImage = glance.images().create(newImage).execute();
-
- // Uploading image
- ImageUpload uploadImage = new ImageUpload(newImage);
- uploadImage.setInputStream(new ByteArrayInputStream(IMAGE_CONTENT.getBytes()));
- glance.images().upload(newImage.getId(), uploadImage).execute();
-
- // Downloading the image and displaying the image content
- try {
- byte[] imgContent = new byte[IMAGE_CONTENT.length()];
- ImageDownload downloadImage = glance.images().download(newImage.getId()).execute();
- downloadImage.getInputStream().read(imgContent, 0, imgContent.length);
- System.out.println(new String(imgContent));
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- Images images = glance.images().list(false).execute();
-
- for (Image image : images) {
- System.out.println(glance.images().show(image.getId()).execute());
- }
-
- glance.images().delete(newImage.getId()).execute();
- }
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/heat/HeatListStacks.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/heat/HeatListStacks.java
deleted file mode 100644
index 66a886f..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/heat/HeatListStacks.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.heat;
-
-/*
- * Modifications copyright (c) 2017 AT&T Intellectual Property
- */
-
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.heat.Heat;
-import com.woorea.openstack.heat.model.CreateStackParam;
-import com.woorea.openstack.heat.model.Stack;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.utils.KeystoneTokenProvider;
-import com.woorea.openstack.keystone.utils.KeystoneUtils;
-
-import java.util.Collections;
-
-public class HeatListStacks {
-
- private static String TEMPLATE = "{\n" +
- " \"HeatTemplateFormatVersion\": \"2012-12-12\",\n" +
- " \"Parameters\": {},\n" +
- " \"Mappings\": {},\n" +
- " \"Resources\": {\n" +
- " \"my-test-server\": {\n" +
- " \"Type\": \"OS::Nova::Server\",\n" +
- " \"Properties\": {\n" +
- " \"flavor\": \"m1.small\",\n" +
- " \"image\": \"centos:latest\"\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}";
-
- /**
- * @param args
- */
- public static void main(String[] args) throws InterruptedException {
- KeystoneTokenProvider keystone = new KeystoneTokenProvider(
- ExamplesConfiguration.KEYSTONE_ENDPOINT,
- ExamplesConfiguration.KEYSTONE_USERNAME,
- ExamplesConfiguration.KEYSTONE_PASSWORD
- );
-
- Access access = keystone.getAccessByTenant(ExamplesConfiguration.TENANT_NAME);
-
- String endpointURL = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "orchestration", null, "public");
-
-
- Heat heat = new Heat(endpointURL);
- heat.setTokenProvider(keystone
- .getProviderByTenant(ExamplesConfiguration.TENANT_NAME));
-
- CreateStackParam param = new CreateStackParam();
- param.setStackName("helloWorld");
- param.setTimeoutMinutes(1);
- param.setParameters(Collections.<String, Object>emptyMap());
- param.setTemplate(TEMPLATE);
-
- System.out.printf("Create: " + heat.getStacks().create(param).execute());
- Thread.sleep(3000);
-
- for (Stack s : heat.getStacks().list().execute()) {
- System.out.println(s.getDescription());
- System.out.println(s.getId());
- System.out.println(s.getStackName());
- System.out.println(s.getStackStatus());
- System.out.println(s.getCreationTime());
- System.out.println(s.getUpdatedTime());
- System.out.println(s.getLinks());
-
- System.out.println(heat.getStacks().byName(s.getStackName()).execute());
-
-
- }
- }
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/Keystone3Authentication.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/Keystone3Authentication.java
deleted file mode 100644
index cd12696..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/Keystone3Authentication.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.hpcloud;
-
-
-import com.woorea.openstack.base.client.OpenStackResponse;
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.v3.model.Authentication;
-import com.woorea.openstack.keystone.v3.model.Authentication.Identity;
-import com.woorea.openstack.keystone.v3.Keystone;
-import com.woorea.openstack.keystone.v3.model.Token;
-
-public class Keystone3Authentication {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
-
- Authentication auth = new Authentication();
- auth.setIdentity(Identity.password(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD));
-
- OpenStackResponse response = keystone.tokens().authenticate(auth).request();
-
- String tokenId = response.header("X-Subject-Token");
-
- Token token = response.getEntity(Token.class);
-
- System.out.println(tokenId);
-
- System.out.println(token);
-
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/KeystoneAuthentication.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/KeystoneAuthentication.java
deleted file mode 100644
index f1c764f..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/KeystoneAuthentication.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.hpcloud;
-
-
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-
-public class KeystoneAuthentication {
-
- private static final String KEYSTONE_AUTH_URL = "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0";
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(KEYSTONE_AUTH_URL);
-
- // access with unscoped token
- Access access = keystone
- .tokens()
- .authenticate()
- .withUsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)
- .execute();
-
- System.out.println(access);
-
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/keystone/KeystoneCreateTenant.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/keystone/KeystoneCreateTenant.java
deleted file mode 100644
index 5ef94cb..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/keystone/KeystoneCreateTenant.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.keystone;
-
-
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.Tenant;
-import com.woorea.openstack.keystone.model.authentication.TokenAuthentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-
-public class KeystoneCreateTenant {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- //access with unscoped token
- Access access = keystone.tokens().authenticate(
- new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .execute();
-
- access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantName("admin").execute();
-
- Tenant tenant = new Tenant();
- tenant.setName("benn.cs");
- tenant.setDescription("benn.cs");
- tenant.setEnabled(true);
- //Get the adminURL client and use the token got above
- keystone = new Keystone("http://keystone.x.org/v2.0");
- keystone.token(access.getToken().getId());
- tenant = keystone.tenants().create(tenant).execute();
- System.out.println(tenant);
- keystone.tenants().delete(tenant.getId());
- }
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/keystone/KeystoneCreateUser.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/keystone/KeystoneCreateUser.java
deleted file mode 100644
index e99d1ce..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/keystone/KeystoneCreateUser.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.keystone;
-
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.User;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-
-public class KeystoneCreateUser {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- //access with unscoped token
- Access access = keystone.tokens()
- .authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .withTenantName("admin")
- .execute();
-
- User user = new User();
- user.setEmail("luis@woorea.es");
- user.setUsername("luis.gervaso");
- user.setPassword("password.0");
- user.setName("Luis");
- user.setEnabled(Boolean.TRUE);
-
- keystone = new Keystone("http://keystone.x.org/v2.0");
- keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
- //keystone.enableLogging(Logger.getLogger("keystone"), 10000);
- user = keystone.users().create(user).execute();
- System.out.println(user);
- keystone.users().delete(user.getId()).execute();
- }
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/metering/v2/TestAll.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/metering/v2/TestAll.java
deleted file mode 100644
index bdb20c0..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/metering/v2/TestAll.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.metering.v2;
-
-import java.util.List;
-
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.ceilometer.Ceilometer;
-import com.woorea.openstack.ceilometer.v2.model.Meter;
-import com.woorea.openstack.ceilometer.v2.model.Statistics;
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-
-public class TestAll {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- Access access = keystone.tokens()
- .authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .withTenantName("admin")
- .execute();
-
- Ceilometer ceilometer = new Ceilometer(ExamplesConfiguration.CEILOMETER_ENDPOINT);
- ceilometer.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
-
- /*
- List<Resource> resources = ceilometer.execute(new ResourceList().eq("resource_id", "23b55841eedd41e99d5f3f32149ca086"));
-
-
- for(Resource r : resources) {
- Resource resource = ceilometer.execute(new ResourceShow().id(r.getResource()));
- }
- */
-
- /*
- //List<Meter> meters = ceilometer.meters().list().execute(); //execute(new MeterList().eq("project_id", "948eeb593acd4223ad572c49e1ef5709"));
-
-
- for(Meter m : meters) {
- System.out.println(m);
-
-// List<Sample> samples = ceilometer.execute(new MeterShow().name(m.getName()));
-// for(Sample s : samples) {
-// System.out.println("\t" + s);
-// }
-
- List<Statistics> stats = ceilometer.meters().statistics().execute(); // (new MeterStatistics().name(m.getName()));
- for(Statistics s : stats) {
- System.out.println("\t\t" + s);
- }
-
-
- }
- */
-
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumListNetworks.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumListNetworks.java
deleted file mode 100644
index 3fdaa9d..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumListNetworks.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.network;
-
-import com.woorea.openstack.keystone.utils.KeystoneUtils;
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.Tenants;
-import com.woorea.openstack.keystone.model.authentication.TokenAuthentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import com.woorea.openstack.quantum.Quantum;
-import com.woorea.openstack.quantum.model.Network;
-import com.woorea.openstack.quantum.model.Networks;
-
-public class QuantumListNetworks {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- // access with unscoped token
- Access access = keystone.tokens().authenticate(
- new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .execute();
- // use the token in the following requests
- keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
-
- Tenants tenants = keystone.tenants().list().execute();
- // try to exchange token using the first tenant
- if (tenants.getList().size() > 0) {
- // access with tenant
- access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
-
- Quantum quantum = new Quantum(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", null, "public"));
- quantum.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
-
- Networks networks = quantum.networks().list().execute();
- for (Network network : networks) {
- System.out.println(network);
- }
- } else {
- System.out.println("No tenants found!");
- }
- }
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumNetworkCreate.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumNetworkCreate.java
deleted file mode 100644
index 39f9eea..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumNetworkCreate.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.network;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Scanner;
-
-import com.woorea.openstack.keystone.utils.KeystoneUtils;
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.Tenant;
-import com.woorea.openstack.keystone.model.Tenants;
-import com.woorea.openstack.keystone.model.authentication.TokenAuthentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import com.woorea.openstack.quantum.Quantum;
-import com.woorea.openstack.quantum.api.NetworksResource;
-import com.woorea.openstack.quantum.api.NetworksResource.Create;
-import com.woorea.openstack.quantum.model.Network;
-import com.woorea.openstack.quantum.model.NetworkForCreate;
-import com.woorea.openstack.quantum.model.Networks;
-import com.woorea.openstack.quantum.model.Port;
-import com.woorea.openstack.quantum.model.PortForCreate;
-import com.woorea.openstack.quantum.model.Router;
-import com.woorea.openstack.quantum.model.RouterForAddInterface;
-import com.woorea.openstack.quantum.model.RouterForCreate;
-import com.woorea.openstack.quantum.model.Subnet;
-import com.woorea.openstack.quantum.model.SubnetForCreate;
-import com.woorea.openstack.quantum.model.Subnets;
-
-public class QuantumNetworkCreate {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(
- ExamplesConfiguration.KEYSTONE_AUTH_URL);
- // access with unscoped token
- Access access = keystone
- .tokens()
- .authenticate(
- new UsernamePassword(
- ExamplesConfiguration.KEYSTONE_USERNAME,
- ExamplesConfiguration.KEYSTONE_PASSWORD))
- .execute();
- // use the token in the following requests
- keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access
- .getToken().getId()));
- keystone.token(access.getToken().getId());
- Tenants tenants = keystone.tenants().list().execute();
- // try to exchange token using the first tenant
-
- if (tenants.getList().size() > 0) {
- // access with tenant
- Network network = new Network();
- access = keystone
- .tokens()
- .authenticate(
- new TokenAuthentication(access.getToken().getId()))
- .withTenantId("tenantId").execute();
- Quantum quantum = new Quantum(KeystoneUtils.findEndpointURL(
- access.getServiceCatalog(), "network", null, "public"));
- quantum.setTokenProvider(new OpenStackSimpleTokenProvider(access
- .getToken().getId()));
- NetworkForCreate netcreate = new NetworkForCreate();
- netcreate.setTenantId("tenantId");
- netcreate.setName("net2");
- netcreate.setAdminStateUp(true);
-
- network = quantum.networks().create(netcreate).execute();
-
- // Creating Subnet
- try {
- Subnet sub = new Subnet();
- SubnetForCreate subnet = new SubnetForCreate();
- subnet.setCidr("");
- subnet.setName("");
- subnet.setNetworkId(network.getId());
- subnet.setIpVersion(4);
- sub = quantum.subnets().create(subnet).execute();
- RouterForCreate routerForCreate = new RouterForCreate();
- routerForCreate.setName("routerName");
- routerForCreate.setTenantId("tenantId");
- Router router = quantum.routers().create(routerForCreate)
- .execute();
- RouterForAddInterface routerForAdd = new RouterForAddInterface();
- routerForAdd.setSubnetId(sub.getId());
- routerForAdd.setRouterId(router.getId());
- quantum.routers().addInterface(routerForAdd).execute();
-
- // System.out.println(sub);
- } catch (Exception e) {
- System.out.println(e.getMessage());
- }
-
- Networks networks = quantum.networks().list().execute();
-
- for (Network network1 : networks) {
- System.out.println(network1);
- }
- } else {
- System.out.println("No tenants found!");
- }
-
- }
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumQueryNetworks.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumQueryNetworks.java
deleted file mode 100644
index e442c73..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumQueryNetworks.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.network;
-
-import com.woorea.openstack.keystone.utils.KeystoneUtils;
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.Tenants;
-import com.woorea.openstack.keystone.model.authentication.TokenAuthentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import com.woorea.openstack.quantum.Quantum;
-import com.woorea.openstack.quantum.model.Network;
-
-public class QuantumQueryNetworks {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- // access with unscoped token
- Access access = keystone.tokens().authenticate(
- new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .execute();
- // use the token in the following requests
- keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
-
- Tenants tenants = keystone.tenants().list().execute();
- // try to exchange token using the first tenant
- if (tenants.getList().size() > 0) {
- // access with tenant
- access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
-
- Quantum quantumClient = new Quantum(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", null, "public"));
- quantumClient.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
-
- Network networkQuery = new Network();
- networkQuery.setName("benn.cs");
- networkQuery.setAdminStateUp(true);
- /*
- Networks networks = quantumClient.execute(NetworkQuery.queryNetworks(networkQuery));
-
- for (Network network : networks) {
- System.out.println(network);
- }
-
- Subnet subnetQuery = new Subnet();
- subnetQuery.setIpversion(Subnet.IpVersion.IPV4);
- Subnets Subnets = quantumClient.execute(NetworkQuery.querySubnets(subnetQuery));
- for (Subnet subnet : Subnets) {
- System.out.println(subnet);
- }
- */
- } else {
- System.out.println("No tenants found!");
- }
- }
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/objectstore/SwiftExample.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/objectstore/SwiftExample.java
deleted file mode 100644
index 36d0e08..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/objectstore/SwiftExample.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.objectstore;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import com.woorea.openstack.keystone.utils.KeystoneUtils;
-
-import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider;
-import com.woorea.openstack.examples.ExamplesConfiguration;
-import com.woorea.openstack.keystone.Keystone;
-import com.woorea.openstack.keystone.model.Access;
-import com.woorea.openstack.keystone.model.Tenants;
-import com.woorea.openstack.keystone.model.authentication.TokenAuthentication;
-import com.woorea.openstack.keystone.model.authentication.UsernamePassword;
-import com.woorea.openstack.swift.Swift;
-import com.woorea.openstack.swift.model.ObjectDownload;
-import com.woorea.openstack.swift.model.ObjectForUpload;
-
-public class SwiftExample {
-
- private static final File TEST_FILE = new File("pom.xml");
-
- /**
- * @param args
- */
- public static void main(String[] args) throws Exception {
- Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL);
- //access with unscoped token
- Access access = keystone.tokens().authenticate(
- new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD))
- .execute();
-
- //use the token in the following requests
- keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
-
- Tenants tenants = keystone.tenants().list().execute();
-
- //try to exchange token using the first tenant
- if(tenants.getList().size() > 0) {
-
- access = keystone.tokens().authenticate(new TokenAuthentication(access.getToken().getId())).withTenantId(tenants.getList().get(0).getId()).execute();
-
- Swift swift = new Swift(KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "object-store", null, "public"));
- swift.setTokenProvider(new OpenStackSimpleTokenProvider(access.getToken().getId()));
-
- //swiftClient.execute(new DeleteContainer("navidad2"));
-
- swift.containers().create("navidad2").execute();
-
- System.out.println(swift.containers().list());
-
- ObjectForUpload upload = new ObjectForUpload();
- upload.setContainer("navidad2");
- upload.setName("example2");
- upload.setInputStream(new FileInputStream(TEST_FILE));
- swift.containers().container("navidad2").upload(upload).execute();
-
-// System.out.println(swiftClient.execute(new ListObjects("navidad2", new HashMap<String, String>() {{
-// put("path", "");
-// }})).get(0).getContentType());
-
-
- ObjectDownload download = swift.containers().container("navidad").download("example2").execute();
- write(download.getInputStream(), "example2");
- }
-
- }
-
- private static void write(InputStream is, String path) {
- try {
- OutputStream stream = new BufferedOutputStream(new FileOutputStream(path));
- int bufferSize = 1024;
- byte[] buffer = new byte[bufferSize];
- int len = 0;
- while ((len = is.read(buffer)) != -1) {
- stream.write(buffer, 0, len);
- }
- stream.close();
- } catch(IOException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
-
- }
-
-}
diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/simple/OpenStackSimpleClient.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/simple/OpenStackSimpleClient.java
deleted file mode 100644
index a2f9eb5..0000000
--- a/openstack-examples/src/main/java/com/woorea/openstack/examples/simple/OpenStackSimpleClient.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package com.woorea.openstack.examples.simple;
-
-
-public class OpenStackSimpleClient {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-// OpenStackClient client = new OpenStackClient(ExamplesConfiguration.KEYSTONE_AUTH_URL);
-// Access access = client.request("/tokens").execute("POST", Entity.json("{\"auth\":{\"passwordCredentials\":{\"username\":\"\",\"password\":\"\"}}}"), Access.class);
-// System.out.println(access);
- }
-
-}
diff --git a/openstack-java-sdk-master/.travis.yml b/openstack-java-sdk-master/.travis.yml
deleted file mode 100644
index f2ad391..0000000
--- a/openstack-java-sdk-master/.travis.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-language: java
-
-install: mvn clean package -DskipTests=true \ No newline at end of file