Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support operation create on CloudObjectStoreContainer #651

Merged
merged 6 commits into from
Apr 24, 2017

Conversation

miha-plesko
Copy link
Contributor

@miha-plesko miha-plesko commented Mar 10, 2017

This commit adds a new page /cloud_object_store_container/new where user can create new CloudObjectStoreContainer. Page is fully functional and extendable. Tested on Amazon S3 provider.

Button that redirects to /cloud_object_store_container/new appears in center toolbar:
capture

And the /cloud_object_store_container/new page itself:
capture

Depends on:

@miq-bot add_label enhancement
@miq-bot assign @h-kataria

@miq-bot
Copy link
Member

miq-bot commented Mar 20, 2017

This pull request is not mergeable. Please rebase and repush.

@miha-plesko
Copy link
Contributor Author

@h-kataria I would kindly ask for a review. This PR is very similar to the PR that @gberginc and yourself discussed in detail (and then merged) a week ago or so: #517. At the moment only Amazon provider supports this functionality (supports? :cloud_object_store_container_create).

/cc @gberginc

@gberginc
Copy link
Contributor

@miha-plesko I was working on those PRs with @AparnaKarve.

@miha-plesko
Copy link
Contributor Author

Huh, when you try to do something quick at the end of working day when your girlfriend's waiting at the door...

@h-kataria, @AparnaKarve, ladies, my deepest apologies for the confusion. I'm all trembling now how rigorous your review might be 😄

@AparnaKarve
Copy link
Contributor

ladies, my deepest apologies for the confusion. I'm all trembling now how rigorous your review might be 😄

@miha-plesko Relax, take a deep breath :)
I'll get to the review sometime today.

Copy link
Contributor

@gberginc gberginc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few comments in the code. Appologies for typos (working on phone).

"prefix" => "default",
"reset-validation-status" => "default_auth_status")

%table{:width => '100%'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other button here? Perhaps you could reuse the layout partial layouts/angular/x_edit_buttons_angular, proposed in #676.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct...you'll need Cancel button as well.
Please use the layouts/angular/x_edit_buttons_angular partial

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one 👍


def disabled?
# TODO: disable button if no active providers support create action
false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you have a consition that would ensure you have at least one object storage manager supporting creation of buckets?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -32,8 +32,98 @@ def self.display_methods
%w(cloud_object_store_objects)
end

def new
assert_privileges("cloud_object_store_container_new")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, I wonder if the cloud prefix is intentional in the name cloud_object_store_container? To me, object storage is something that is not related to the "cloud" (contrary to, for example cloud volumes and cloud networks).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Models app/models/cloud_object_store_container.rb and app/models/cloud_object_store_object existed in the miq core before and I never thought to change it. I understand what you're saying, but there is reasoning behing cloud prefix as well: the storage is in cloud, not on local machine. I must admin, however, that the name really is rather long :D

# Depending on the storage manager type, collect required form params.
case params[:emstype]
when "ManageIQ::Providers::Amazon::StorageManager::S3"
options[:bucket] = params[:name] if params[:name]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that S3 API requires :bucket in options, but I wonder if you could resolve this in the backend? You are setting the :name above and the provider could perhaps check if only name is present and set the :bucket on its own.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I understand that you need :name to show proper flash messages; this is why I am asking to use name instead of bucket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for rising this question, let me argument my thinking. I had to decide where to perform mapping:

A. pass entire HTML form inputs to the backend (1 mapping)

frontend: no mapping
backend: HTML form fields -> options

B. slightly modified HTML form inputs to the backend (2 mappings)

frontend: HTML form fields -> slightly modified options
backend: slightly modified options-> options

C. pass fully-mapped options to backend (1 mapping)

frontend: HTML form fields -> options
backend: no mapping

My thinking here was that A should be avoided since backend shouldn't care much about how the HTML form inputs are named. Then B is not very reasonable since we only want to map once. So C is the way to go and is also employed in cloud_volume_controller.rb where we give each provider what it actually needs.

To sum up: I would prefer to perform all the mapping on frontend. This being said, please let me know of your opinion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood; the only concern was that name and bucket are duplicated. Name is used for flash messages, bucket for s3 provider. That's why I thought it may be worth considering that the name is checked in the backend if bucket is not provided.: so, if bucket is in options in the backend, use it, otherwise check if there is name and set it to bucket.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

managers = ManageIQ::Providers::CloudManager.supported_subclasses.select(&:supports_regions?)
managers.each_with_object({}) do |manager, provider_regions|
regions = manager.parent::Regions.all.sort_by { |r| r[:description] }
provider_regions[manager.name] = regions.map do |region|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make in single line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

"ng-model" => "cloudContainerModel.storage_manager_id",
"ng-change" => "storageManagerChanged(cloudContainerModel.storage_manager_id)",
"required" => "",
:miqrequired => true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thibk :miqrequired is no longer used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. Please remove miqrequired.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,62 @@
%form#form_div{:name => "angularForm", 'ng-controller' => "cloudObjectStoreContainerFormController"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking: did you notice any flicker when you open this page? First, browser default controls are displayed for a short period, then proper controls used by miq. If you did, check ng-cloak.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't aware on ng-cloak, thanks!

"checkchange" => "",
"selectpicker-for-select-tag" => "",
"prefix" => "default",
"reset-validation-status" => "default_auth_status")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is prefix and reset-validation-status? Are they intentional?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a copy-paste from the ems form.
reset-validation-status is specific to the Validation portion of the ems form and not applicable here. Please remove it.

Remove prefix as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whooops, busted, this is a copy-paste from ems form. Removed prefix and reset-validation-status.

= _('Storage Manager')
.col-md-8
= select_tag("storage_manager_id",
options_for_select([["<#{_('Choose')}>", nil]] + @storage_manager_choices.sort, disabled: ["<#{_('Choose')}>", nil]),
Copy link
Contributor

@AparnaKarve AparnaKarve Mar 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an effort to make our angular forms that add new functionality (like this one) make use of REST API, could we populate this dropdown using a REST API call as well instead of using the instance variable @storage_manager_choices?

Can you try out this API and let me know if it works well for this dropdown?

/api/providers?expand=resources&filter[]=type='*StorageManager::S3*'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to list those storage managers that support :cloud_object_store_container_create feature. Is it possible to filter them by supported feature using API? Unfortunately supports? function is not a column in database nor virtual column so I'm not sure how to filter by this. Is it possible to filter based on utility functions at all?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to filter them by the supported feature, then I guess we'd have to create a PR in manageiq core to address this.

Copy link
Contributor

@AparnaKarve AparnaKarve Mar 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miha-plesko Can you try this API and LMK if it gets you the right storage managers :

/api/providers?expand=resources&filter[]=supports_block_storage?=true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to get a list of those that support cloud_object_store_container_create so I've inserted this in the link above. And viola, yes, the list is correct! 👍

/api/providers?expand=resources&filter[]=supports_cloud_object_store_container_create?=true

result:
{
   "name":"providers",
   "count":4,
   "subcount":1,
   "resources":[
      {
         "href":"http://172.16.117.115:3000/api/providers/4",
         "id":4,
         "name":"AWS S3 Storage Manager",
         "created_on":"2017-03-20T14:30:59Z",
         "updated_on":"2017-03-30T14:16:49Z",
         "zone_id":1,
         "type":"ManageIQ::Providers::Amazon::StorageManager::S3",
         "provider_region":"us-west-2",
         "last_refresh_date":"2017-03-30T14:16:49Z",
         "tenant_id":1,
         "parent_ems_id":1,
         "actions":[
            {
               "name":"edit",
               "method":"post",
               "href":"http://172.16.117.115:3000/api/providers/4"
            },
            {
               "name":"refresh",
               "method":"post",
               "href":"http://172.16.117.115:3000/api/providers/4"
            },
            {
               "name":"delete",
               "method":"post",
               "href":"http://172.16.117.115:3000/api/providers/4"
            },
            {
               "name":"delete",
               "method":"delete",
               "href":"http://172.16.117.115:3000/api/providers/4"
            }
         ]
      }
   ],
   "actions":[
      {
         "name":"query",
         "method":"post",
         "href":"http://172.16.117.115:3000/api/providers"
      },
      {
         "name":"create",
         "method":"post",
         "href":"http://172.16.117.115:3000/api/providers"
      },
      {
         "name":"edit",
         "method":"post",
         "href":"http://172.16.117.115:3000/api/providers"
      },
      {
         "name":"refresh",
         "method":"post",
         "href":"http://172.16.117.115:3000/api/providers"
      },
      {
         "name":"delete",
         "method":"post",
         "href":"http://172.16.117.115:3000/api/providers"
      }
   ]
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for trying the API @miha-plesko

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miha-plesko if you don't need all the attributes, I suggest you limit the list to those that are important, e.g. add &attributes=id,name to the request to get just the name and id:

{
  "name": "providers",
  "count": 8,
  "subcount": 2,
  "resources": [
    {
      "href": "http://localhost:3000/api/providers/17",
      "id": 17,
      "name": "OS XLAB Cinder Manager"
    },
    {
      "href": "http://localhost:3000/api/providers/23",
      "id": 23,
      "name": "AWS XLAB EBS Storage Manager"
    }
  ],
  "actions": [
    {
      "name": "query",
      "method": "post",
      "href": "http://localhost:3000/api/providers"
    },
    {
      "name": "create",
      "method": "post",
      "href": "http://localhost:3000/api/providers"
    },
    {
      "name": "edit",
      "method": "post",
      "href": "http://localhost:3000/api/providers"
    },
    {
      "name": "refresh",
      "method": "post",
      "href": "http://localhost:3000/api/providers"
    },
    {
      "name": "delete",
      "method": "post",
      "href": "http://localhost:3000/api/providers"
    }
  ]
}

= _('Region')
.col-md-8
- @provider_regions.each do |name, regions|
= select_tag('provider_region',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes here... an API would be preferable.
Will get back to you on the exact API that you can use later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I'd need API to be able to access class constant. Currently, regions are obtained from here: https://github.com/ManageIQ/manageiq-providers-amazon/blob/master/app/models/manageiq/providers/amazon/regions.rb#L8-L84

Is there a way to fetch them thru API?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this as is.

Would have to dig deeper into this to find out what is involved to get the Amazon Regions via the API.

@@ -1868,6 +1868,7 @@ def process_cloud_object_storage_buttons(pressed)
task = pressed.sub("#{klass.name.underscore.to_sym}_", "")

return tag(klass) if task == "tag"
return javascript_redirect(:controller => klass.name.underscore.to_sym, :action => "new") if task == "new"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem right.
This logic needs to be in the cloud_object_store_container controller, not here.

Can you look up a few examples and fix this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some research and now I'm confused: should "Add CloudObjectStoreContainer" option appear only next to the list of all containers and be hidden next to the list of containers per Manager?

In other words, should this be hidden:
capture
?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope not; I think that creating a new bucket from the list of provider's buckets should be supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comment is more about the location of the change. We discussed why in ci_processing some time ago, but I don't remember exactly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the button be visible both from /cloud_object_store_container/show_list and /ems_storage/ID?display=cloud_object_store_containers, it would probably make more sense to have this logic in ci_processing (which is included by both controllers).

@AparnaKarve would you prefer me to copy line 1871 to above this line and to above this line?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miha-plesko All button handling for cloud_object_store_container should be in that controller itself, not in ci_processing
Check this out for instance --
https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/cloud_network_controller.rb#L38-#L41

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miha-plesko I see that you have already added delete code in ci_processing and now you are about to add new.
The delete handling should have been added in cloud_object_store_container_controller.rb

The button handling for new, edit, delete should all live in the acting controller code.
Let me give you another code example that was recently added --
https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/ansible_credential_controller.rb#L27-L35
It's clear, concise and easy to follow. Could we implement something like that?

Copy link
Contributor

@AparnaKarve AparnaKarve Mar 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it needs to be accessible from ems_storage as well, then you also add the button handling in ems_common.rb. Something like this --
https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/ems_common.rb#L455-L456

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable. Let me try to do it this way. What confuses me still is this line in ems_storage controller: https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/controllers/ems_common.rb#L285. It seems like delete for cloud_volume is implemented in ci_processing while other operations are elsewhere. Let me try to refactor this, we shall see if any problem arises.

@AparnaKarve
Copy link
Contributor

screen shot 2017-03-21 at 4 13 48 pm

Does that seem like a valid error?
If yes, why?

@gberginc
Copy link
Contributor

This error is legit, because bucket names must be globaly unique (across all users and all regions). S3 console would warn with a simple message that the bucket already exists.

Copy link
Contributor Author

@miha-plesko miha-plesko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AparnaKarve @gberginc thanks for initial pass. I've answered to your comments, please take a look.

@@ -32,8 +32,98 @@ def self.display_methods
%w(cloud_object_store_objects)
end

def new
assert_privileges("cloud_object_store_container_new")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Models app/models/cloud_object_store_container.rb and app/models/cloud_object_store_object existed in the miq core before and I never thought to change it. I understand what you're saying, but there is reasoning behing cloud prefix as well: the storage is in cloud, not on local machine. I must admin, however, that the name really is rather long :D

# Depending on the storage manager type, collect required form params.
case params[:emstype]
when "ManageIQ::Providers::Amazon::StorageManager::S3"
options[:bucket] = params[:name] if params[:name]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for rising this question, let me argument my thinking. I had to decide where to perform mapping:

A. pass entire HTML form inputs to the backend (1 mapping)

frontend: no mapping
backend: HTML form fields -> options

B. slightly modified HTML form inputs to the backend (2 mappings)

frontend: HTML form fields -> slightly modified options
backend: slightly modified options-> options

C. pass fully-mapped options to backend (1 mapping)

frontend: HTML form fields -> options
backend: no mapping

My thinking here was that A should be avoided since backend shouldn't care much about how the HTML form inputs are named. Then B is not very reasonable since we only want to map once. So C is the way to go and is also employed in cloud_volume_controller.rb where we give each provider what it actually needs.

To sum up: I would prefer to perform all the mapping on frontend. This being said, please let me know of your opinion.


def disabled?
# TODO: disable button if no active providers support create action
false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,62 @@
%form#form_div{:name => "angularForm", 'ng-controller' => "cloudObjectStoreContainerFormController"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't aware on ng-cloak, thanks!

= _('Storage Manager')
.col-md-8
= select_tag("storage_manager_id",
options_for_select([["<#{_('Choose')}>", nil]] + @storage_manager_choices.sort, disabled: ["<#{_('Choose')}>", nil]),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to list those storage managers that support :cloud_object_store_container_create feature. Is it possible to filter them by supported feature using API? Unfortunately supports? function is not a column in database nor virtual column so I'm not sure how to filter by this. Is it possible to filter based on utility functions at all?

= _('Region')
.col-md-8
- @provider_regions.each do |name, regions|
= select_tag('provider_region',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I'd need API to be able to access class constant. Currently, regions are obtained from here: https://github.com/ManageIQ/manageiq-providers-amazon/blob/master/app/models/manageiq/providers/amazon/regions.rb#L8-L84

Is there a way to fetch them thru API?

"checkchange" => "",
"selectpicker-for-select-tag" => "",
"prefix" => "default",
"reset-validation-status" => "default_auth_status")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whooops, busted, this is a copy-paste from ems form. Removed prefix and reset-validation-status.

"prefix" => "default",
"reset-validation-status" => "default_auth_status")

%table{:width => '100%'}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one 👍

@@ -1868,6 +1868,7 @@ def process_cloud_object_storage_buttons(pressed)
task = pressed.sub("#{klass.name.underscore.to_sym}_", "")

return tag(klass) if task == "tag"
return javascript_redirect(:controller => klass.name.underscore.to_sym, :action => "new") if task == "new"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some research and now I'm confused: should "Add CloudObjectStoreContainer" option appear only next to the list of all containers and be hidden next to the list of containers per Manager?

In other words, should this be hidden:
capture
?

managers = ManageIQ::Providers::CloudManager.supported_subclasses.select(&:supports_regions?)
managers.each_with_object({}) do |manager, provider_regions|
regions = manager.parent::Regions.all.sort_by { |r| r[:description] }
provider_regions[manager.name] = regions.map do |region|
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks.

@miha-plesko
Copy link
Contributor Author

@AparnaKarve I apologize that it took me so long to apply your comments. I've added two commits to this PR: one of them modernizes JavaScript code so that Angular now makes use of fancy this.vm paradigm. The other commit is an attempt to address issue regarding controller logic placement.

I was not able to fully satisfy your concerns regarding "moving all the logic out of ci_processing.rb" utility controller. Let me try to explain my problem here, but I'm also willing to perform a videocall to demonstrate you in person if needed.

So, there are two groups of operations that central button can trigger:

  1. operations with own view
    e.g. cloud_object_store_container_new with new.html.haml
  2. operations without view
    e.g. cloud_object_store_container_delete that has no view
    e.g. cloud_object_store_container_clear that also has no view

For group (1) there is no doubt what to do when user triggers them: just redirect to the controller that manages corresponding view. But for group (2) this is not possible since there is nothing to redirect to! So the current controller (either ems_common.rb or cloud_object_store_container_controller.rb, depending on URL that we're at) must execute the operation on its own. And that is why I put the code for operations "delete container", "delete object", "clear container" in ci_processing.rb - code there is directly callable from either controller.

To put it simple: if ems_common.rb controller is to redirect to cloud_object_store_container_controller.rb, and cloud_object_store_container_controller.rb has no view for operation, what is supposed to be rendered to the user?

/cc @gberginc

@AparnaKarve
Copy link
Contributor

@miha-plesko If I test this PR now in it's current state, would I be able to see the issue that you have described in scenario2 for operations: cloud_object_store_container_delete and cloud_object_store_container_clear without a view to render?

@miha-plesko
Copy link
Contributor Author

@AparnaKarve no, the way it's implemented now everything works. The problem would arise only if I wanted to extract delete and clear out of ci_processing.rb and put it into cloud_object_store_container.rb. IMO this is not be part of this PR anyway ;)

Copy link
Contributor Author

@miha-plesko miha-plesko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AparnaKarve thank you for another iteration. I've pushed an additional commit where I apply your suggestions. I'd argue with you only regarding storage_manager_id topic since I think you've tested it on a wrong StorageManager, while the code is actually ok. See this comment.

I'm looking forward to any further suggestions that you might have.

};

// fetch StorageManager from querystring
if (! isNaN(parseInt(storageManagerId, 10))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thank you.


// If storage manager ID was provided, we need to refresh the form and show
// corresponding form fields.
if (storageManagerId) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

"model-copy" => "vm.modelCopy"}
= render :partial => "layouts/flash_msg"
%h3
= _('Basic Information')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

'ng-model' => "vm.cloudContainerModel.name",
'ng-maxlength' => 255,
:miqrequired => true,
:checkchange => true}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I've also fixed the same issue for other inputs.

@miha-plesko miha-plesko reopened this Apr 21, 2017
This commit adds a new page /cloud_object_store_container/new where user
can create new CloudObjectStoreContainer. Page is fully functional and
extendable. Tested on Amazon S3 provider.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
Here we move the logic that redirects user to
`cloud_object_store_container/new` from common
place to each of the calling controllers. This
way we are able to differentiate whether the button
was cliked on a list of all Containers or on a list
of Containers for specific StorageManager.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
There were some _("Required") missing on the form. With this commit
I add them where needed. This commit also moves logic for parsing manager
id obtained thru querystring to the haml by using angular filter.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
@breadcrumbs.pop if @breadcrumbs
session[:flash_msgs] = @flash_array.dup if @flash_array

javascript_redirect :action => "show_list"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to :

javascript_redirect previous_breadcrumb_url

Useful while adding a New Cloud Object Store Container from the Storage Manager Summary page.
Once the Add is done, the page will redirected back to the Summary page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks.

"ng-model" => "vm.cloudContainerModel.provider_region",
"ng-switch-when" => name,
"required" => "",
"checkchange" => "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a search capability in this dropdown would be a good idea since it could be a fairly long list.

All you need to do is add these 2 parameters to the Regions select

:multiple => false,
"data-live-search" => true,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, done.

@AparnaKarve
Copy link
Contributor

@miha-plesko Just those couple minor things above...but otherwise, this is looking great.

Question about edit: Would you be creating a PR for editing the Cloud Object Store containers after this is merged?

@miha-plesko
Copy link
Contributor Author

@AparnaKarve just answering your question immediately (I shall apply other changes on Monday):
At this point I'm fully focusing on :new. The idea is, of course, to equip this with with :edit in the future, but I'm not sure if I'm gonna be the one implementing it.

@AparnaKarve
Copy link
Contributor

At this point I'm fully focusing on :new. The idea is, of course, to equip this with with :edit in the future,

Agree. Let's get new merged first, edit should be fairly simple after that.

but I'm not sure if I'm gonna be the one implementing it.

Ok, not a problem.

Copy link
Contributor Author

@miha-plesko miha-plesko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AparnaKarve thank you for the two very useful comments, I've added one commit to address each.

Talking about :edit operation, I've realized that at this point we allow user to input only information that is immutable (name and location). In other words, it is not possible* to rename any S3 bucket - to achieve such behavior you must create new bucket with new name, copy objects there, and delete the old one. So supporting an :edit operation would result in all field greyed-out at the moment anyway 😄

*by not possible I mean it cannot be done due to limitations on S3 side, not MiQ side

@breadcrumbs.pop if @breadcrumbs
session[:flash_msgs] = @flash_array.dup if @flash_array

javascript_redirect :action => "show_list"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks.

"ng-model" => "vm.cloudContainerModel.provider_region",
"ng-switch-when" => name,
"required" => "",
"checkchange" => "",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, done.

Currently we were redirecting to the list of all Cloud Containers when
user created a new bucket. But that's not OK when user came from manager's
page. This commit redirects user one step back in breadcrumb instead.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
There are 15 bucket regions to select from so it makes
sense to offer user a search field as part of the drop-down.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
@miq-bot
Copy link
Member

miq-bot commented Apr 24, 2017

Checked commits miha-plesko/manageiq-ui-classic@5a7a3ad~...731488e with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
7 files checked, 1 offense detected

app/views/cloud_object_store_container/new.html.haml

  • ⚠️ - Line 50 - Use hash rockets syntax.

@bronaghs
Copy link

@miq-bot remove_label blocker

@miq-bot miq-bot removed the blocker label Apr 24, 2017
@bronaghs
Copy link

Removed the blocker label because S3 will be disabled by default in the Fine release (see: ManageIQ/manageiq-providers-amazon#213)

@AparnaKarve
Copy link
Contributor

In other words, it is not possible* to rename any S3 bucket - to achieve such behavior you must create new bucket with new name, copy objects there, and delete the old one. So supporting an :edit operation would result in all field greyed-out at the moment anyway 😄

Oh, that is good to know. Thanks for that vital piece of information.
So bottomline, AWS itself does not support editing buckets and hence edit does not apply in this case at all. Awesome! :)

@AparnaKarve
Copy link
Contributor

AparnaKarve commented Apr 24, 2017

@miha-plesko Thank you for addressing all the feedback!
Successfully tested in the UI. This is working really great!

@dclarizio @h-kataria This is good to merge.
All the CC errors are regarding "Similar code found in 1 other location", something that cannot be dealt with immediately (or at least in this PR)

@h-kataria h-kataria added this to the Sprint 59 Ending Apr 24, 2017 milestone Apr 24, 2017
@h-kataria h-kataria merged commit ac62737 into ManageIQ:master Apr 24, 2017
simaishi pushed a commit that referenced this pull request Apr 24, 2017
Support operation `create` on CloudObjectStoreContainer
(cherry picked from commit ac62737)
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit 88795e89e9368f9661470fdf7ba5b696f9b5ac80
Author: Harpreet Kataria <hkataria@redhat.com>
Date:   Mon Apr 24 13:52:53 2017 -0400

    Merge pull request #651 from miha-plesko/add_aws_bucket
    
    Support operation `create` on CloudObjectStoreContainer
    (cherry picked from commit ac62737c8dfbb282d65ccda4c0daa316b6ed436b)

@miha-plesko miha-plesko deleted the add_aws_bucket branch January 7, 2019 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants