diff options
Diffstat (limited to 'openstack-console/src/main/java/com/woorea/openstack/console/keystone')
13 files changed, 0 insertions, 830 deletions
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()); - } - } - -} |