summaryrefslogtreecommitdiffstats
path: root/openstack-console
diff options
context:
space:
mode:
Diffstat (limited to 'openstack-console')
-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
28 files changed, 0 insertions, 1765 deletions
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