diff options
author | seshukm <seshu.kumar.m@huawei.com> | 2018-07-25 19:36:49 +0800 |
---|---|---|
committer | seshukm <seshu.kumar.m@huawei.com> | 2018-07-25 19:36:49 +0800 |
commit | b976af3397c98517d09aa605ea09cf71d21a5f68 (patch) | |
tree | 396f0ab9f52a53be1eb057b35bacb712059c974f /openstack-console/src/main/java | |
parent | 60bfc985e39353ee97f23b68ea612bf79124da43 (diff) |
code refactoring take 2
Issue-ID: SO-729
Change-Id: I82efa7420f9b9917175e6c47caa0929fa697d78d
Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'openstack-console/src/main/java')
10 files changed, 327 insertions, 327 deletions
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 index 9214149..7dbba41 100644 --- 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 @@ -28,58 +28,58 @@ import com.woorea.openstack.keystone.Keystone; import com.woorea.openstack.keystone.model.Role; public class KeystoneRoleCreate extends KeystoneCommand { - - public KeystoneRoleCreate() { - super( "role-create"); - } + + 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 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 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()); - } + @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; - } - + /* (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 index 5dde646..9adf5c8 100644 --- 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 @@ -22,20 +22,20 @@ import com.woorea.openstack.console.utils.ConsoleUtils; import com.woorea.openstack.keystone.Keystone; public class KeystoneRoleDelete extends KeystoneCommand { - - public KeystoneRoleDelete() { - super("role-delete"); - } + + 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")); - } - - } - + @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 index bc59140..a6c7f2a 100644 --- 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 @@ -26,39 +26,39 @@ import com.woorea.openstack.keystone.model.Role; import com.woorea.openstack.keystone.model.Roles; public class KeystoneRoleList extends KeystoneCommand { - - public KeystoneRoleList() { - super("role-list"); - } + + 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 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 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()); - } + @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 index 931d1ab..9070bd9 100644 --- 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 @@ -26,39 +26,39 @@ import com.woorea.openstack.keystone.model.Service; import com.woorea.openstack.keystone.model.Services; public class KeystoneServiceList extends KeystoneCommand { - - public KeystoneServiceList() { - super("service-list"); - } + + 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 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 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()); - } + @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 index 04177a6..c77c5b1 100644 --- 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 @@ -28,58 +28,58 @@ import com.woorea.openstack.keystone.Keystone; import com.woorea.openstack.keystone.model.Tenant; public class KeystoneTenantCreate extends KeystoneCommand { - - public KeystoneTenantCreate() { - super("tenant-create"); - } + + 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 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 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()); - } + @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; - } - + /* (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 index bd34ca9..1e9a649 100644 --- 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 @@ -22,20 +22,20 @@ import com.woorea.openstack.console.utils.ConsoleUtils; import com.woorea.openstack.keystone.Keystone; public class KeystoneTenantDelete extends KeystoneCommand { - - public KeystoneTenantDelete() { - super("tenant-delete"); - } + + 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")); - } - - } - + @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 index 31d0899..ac8994b 100644 --- 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 @@ -26,39 +26,39 @@ import com.woorea.openstack.keystone.model.Tenant; import com.woorea.openstack.keystone.model.Tenants; public class KeystoneTenantList extends KeystoneCommand { - - public KeystoneTenantList() { - super("tenant-list"); - } + + 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 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 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()); - } + @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 index baa799b..2da50fc 100644 --- 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 @@ -28,64 +28,64 @@ import com.woorea.openstack.keystone.Keystone; import com.woorea.openstack.keystone.model.User; public class KeystoneUserCreate extends KeystoneCommand { - - public KeystoneUserCreate() { - super("user-create"); - } + + 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 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 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()); - } + @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; - } - + /* (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 index 59626c6..0c02887 100644 --- 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 @@ -22,20 +22,20 @@ import com.woorea.openstack.console.utils.ConsoleUtils; import com.woorea.openstack.keystone.Keystone; public class KeystoneUserDelete extends KeystoneCommand { - - public KeystoneUserDelete() { - super("user-delete"); - } + + 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")); - } - - } - + @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 index 919c765..06362f9 100644 --- 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 @@ -26,41 +26,41 @@ import com.woorea.openstack.keystone.model.User; import com.woorea.openstack.keystone.model.Users; public class KeystoneUserList extends KeystoneCommand { - - public KeystoneUserList() { - super("user-list"); - } + + 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 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 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()); - } + @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()); + } } |