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

Enable provisioning from Volumes and Volume Snapshots via a proxy type #104

Conversation

mansam
Copy link
Contributor

@mansam mansam commented Sep 28, 2017

This pull request implements proxies for Volumes and Volume Snapshots as subclasses of MiqTemplate, allowing them to be selected during the ManageIQ provisioning workflow. Openstack will automatically create a volume of the appropriate size if a Snapshot is chosen as the boot source.

See also:
ManageIQ/manageiq#16066
ManageIQ/manageiq-ui-classic#2253

@mansam mansam force-pushed the volume-snapshot-template-enable-provisioning-from-volume-snapshots branch from b214242 to 7d8cdb3 Compare September 28, 2017 15:00
@mansam mansam changed the title Enable provisioning from Volumes and Volume Snapshots via a proxy type [WIP] Enable provisioning from Volumes and Volume Snapshots via a proxy type Sep 28, 2017
@miq-bot miq-bot added the wip label Sep 28, 2017
@gmcculloug
Copy link
Member

@agrare Can you review or assign someone. Thanks


belongs_to :cloud_tenant

def volume_snapshot_template?
Copy link
Member

Choose a reason for hiding this comment

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

Where is this used? Better to just use .kind_of?(klass) I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are in line with image? and snapshot? which are present on the parent class and used for differentiating type in the UI.

Copy link
Member

Choose a reason for hiding this comment

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

👍 thanks


belongs_to :cloud_tenant

def volume_template?
Copy link
Member

@agrare agrare Oct 4, 2017

Choose a reason for hiding this comment

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

Same

@agrare
Copy link
Member

agrare commented Oct 4, 2017

So I'm not a huge fan of creating a dummy miq_template record in refresh so that we can provision from it instead of changing the provision workflow to be able to use the volume as the source, @Fryguy thoughts?

@agrare agrare requested a review from Fryguy October 4, 2017 18:33
@agrare agrare self-assigned this Oct 4, 2017
@@ -296,9 +309,17 @@ def assert_ems
expect(@ems.key_pairs.size).to eq compute_data.key_pairs.count
security_groups_count = @ems.security_groups.count { |x| x.name != 'default' }
expect(security_groups_count).to eq security_groups_count
expect(@ems.vms_and_templates.size).to eq vms_count + images_count
if ::Settings.ems.ems_openstack.try(:refresh).try(:inventory_object_refresh) || ::Settings.ems.ems_refresh.try(:openstack).try(:inventory_object_refresh)
Copy link
Member

@Fryguy Fryguy Oct 9, 2017

Choose a reason for hiding this comment

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

Alternately, fetch_path is usable on Settings as well, so this could be

Settings.ems.fetch_path(:ems_openstack, :refresh, :inventory_object_refresh) || Settings.ems.fetch_path(:ems_refresh, :openstack, :inventory_object_refresh)

On that note, why are there even 2 ways to configure things? Pick whichever one you want to be the "official" one (I suggest the former, so you can own the setting in your repo), and create a data migration to convert the other 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.

Good to know fetch_path is available on Settings. There are two ways to configure things because the latter (incorrect) option was put in first and merged into a release. I put together a PR to support the correct way and the old way to avoid breaking anyone's deployment since I wasn't aware I could use a migration to change things over. Since the PR that implements the new openstack-owned approach wasn't merged yet, I should be able to implement a migration and get this all cleaned up. :)

end

def volumes_by_id
@volumes_by_id ||= Hash[volume_templates.collect { |f| [f.id, f] }]
Copy link
Member

Choose a reason for hiding this comment

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

Alternately, you can use the index_by method.

@volumes_by_id ||= volume_templates.index_by(&: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.

Thanks for that shortcut!

@Fryguy
Copy link
Member

Fryguy commented Oct 9, 2017

@agrare I don't see it creating dummy data, unless I'm mistaken about how the collector works?

@agrare
Copy link
Member

agrare commented Oct 9, 2017

@Fryguy there already are CloudVolume and CloudVolumeSnapshot models, this also creates volumes as a MiqTemplate type instead of a CloudVolume type. So a duplicate record of another type is probably more correct than a dummy record.

@mansam
Copy link
Contributor Author

mansam commented Oct 16, 2017

@agrare @Fryguy other than the minor changes regarding volume_snapshot_template? and volume_template?, did you have any other thoughts? This feature is a requirement for 4.6 so I'd like to know what else needs to be done to get it in.

@miq-bot
Copy link
Member

miq-bot commented Oct 17, 2017

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

@agrare
Copy link
Member

agrare commented Oct 23, 2017

Given the requirements for provisioning I'm good with this, ideally we would be able to provision from things other than a template but I understand that would be a large undertaking.

@mansam if this is ready can you take it out of [WIP] and rebase to fix up the conflicts?

@mansam
Copy link
Contributor Author

mansam commented Oct 23, 2017

@agrare rebase in progress :)

Refresh will now populate VolumeTemplates, which are
a subclass of MiqTemplate that allows for provisioning
from Openstack volumes until a more general purpose
refactoring of the provisioning workflow can be implemented.
@mansam mansam force-pushed the volume-snapshot-template-enable-provisioning-from-volume-snapshots branch from 07f7164 to 4f82edd Compare October 23, 2017 16:23
@miq-bot
Copy link
Member

miq-bot commented Oct 23, 2017

Some comments on commits mansam/manageiq-providers-openstack@4220abd~...4f82edd

spec/models/manageiq/providers/openstack/cloud_manager/stubbed_refresher_spec.rb

  • ⚠️ - 137 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 138 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented Oct 23, 2017

Checked commits mansam/manageiq-providers-openstack@4220abd~...4f82edd with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
11 files checked, 3 offenses detected

spec/models/manageiq/providers/openstack/cloud_manager/refresh_spec_common.rb

@mansam mansam changed the title [WIP] Enable provisioning from Volumes and Volume Snapshots via a proxy type Enable provisioning from Volumes and Volume Snapshots via a proxy type Oct 23, 2017
@miq-bot miq-bot removed the wip label Oct 23, 2017
@agrare agrare merged commit a356c02 into ManageIQ:master Oct 23, 2017
@agrare agrare added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 23, 2017
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.

5 participants