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

Allow to receive datastore by name or by id #15101

Closed

Conversation

masayag
Copy link
Contributor

@masayag masayag commented May 16, 2017

Datastores on the same setup may have the same name. In order to add a
disk on a specific datastore, it is better to use the datastore id.

https://bugzilla.redhat.com/show_bug.cgi?id=1450952

@masayag
Copy link
Contributor Author

masayag commented May 16, 2017

Another PR was proposed to ManageIQ/manageiq-providers-ovirt#37 in order to support the new parameter.

if options[:datastore]
datastore = Storage.find_by(:name => options[:datastore])
if options[:datastore] || options[:datastore_id]
datastore = Storage.find(:name => options[:datastore_id]) if options[:datastore_id]
Copy link
Member

Choose a reason for hiding this comment

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

why the query on :name matching the datastore_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a mistake. I pulled the same code which is common ovirt-provider and automation to Storage and covered with tests.

Datastores on the same setup may have the same name. In order to add a
disk on a specific datastore, it is better to use the datastore id.

https://bugzilla.redhat.com/show_bug.cgi?id=1450952
@masayag masayag force-pushed the accept_datastore_id_when_adding_disk branch from 5dc5ba4 to 1e2a674 Compare May 17, 2017 12:56
@miq-bot
Copy link
Member

miq-bot commented May 17, 2017

Checked commit masayag@1e2a674 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks fine. 🍰

@masayag
Copy link
Contributor Author

masayag commented May 17, 2017

Copy link

@bronaghs bronaghs left a comment

Choose a reason for hiding this comment

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

One suggestion, otherwise this looks good.

@@ -73,8 +73,8 @@ def disconnect_floppies

def raw_add_disk(disk_name, disk_size_mb, options = {})
raise _("VM has no EMS, unable to add disk") unless ext_management_system
if options[:datastore]
datastore = Storage.find_by(:name => options[:datastore])
if options[:datastore] || options[:datastore_id]

Choose a reason for hiding this comment

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

Hi @masayag - renaming :datastore to datastore_name would offer more clarity, as : datastore_id does

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bronaghs, @abellotti wouldn't it be considered as breaking the API ?

In [1] the datastore is exposed as diskscsi##.datastore=<datastore name>, therefore changing it to datastore_name will cause any existing users/customer scripts not to work.

I can add diskscsi##.datastore_name in addition, with the same semantics as the diskscsi##.datastore, and later on to deprecate the latter, but I'm not familiar with the API deprecation policy.

[1] https://access.redhat.com/documentation/en-US/Red_Hat_CloudForms/3.2/html/Red_Hat_CloudForms_SOAP_API/Defining_new_disks_during_provisioning.html

Choose a reason for hiding this comment

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

I will defer to @abellotti on using datastore_name in addition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gmcculloug could you review ?

Copy link
Member

Choose a reason for hiding this comment

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

Can we skip all this logic and just look for the datastore based on the ext_management_system handle to avoid this issue?

datastore = ext_management_system.storages.find_by(:name => options[:datastore])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gmcculloug that's good idea. I'll update the PR to address it.

Copy link
Member

Choose a reason for hiding this comment

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

hmm, I thought the root cause is having a datastore with the same name twice under the the same ems. If this is the case, then scoping it to ems does not help

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed by #15245, closing the current one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@durandom the use case in which datastore appears twice for the same RHV provider happened when the provider was first added to manageiq, then removed and added again.

The previous datastore remained on cmdb, however, its association with any provider was removed. Therefore the code above will allow to select only a datastore which is associated with a datastore related to the provider in which the vm is about to be added.

However, @agrare raised an issue on ManageIQ/manageiq-providers-ovirt#42 where VMware might have several datastores with the same name.

@masayag masayag closed this May 29, 2017
@masayag masayag deleted the accept_datastore_id_when_adding_disk branch May 29, 2017 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants