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

Fixes #29819 - Support byos images on azurerm #88

Merged
merged 1 commit into from Jun 9, 2020

Conversation

apuntamb
Copy link
Member

BYOS images on azure are a different type of marketplace images. They just need an added parameter from PurchasePlan class of the sdk. This PR provisions the host using rhel byos image if the image terms have been accepted. Refer the MSFT doc to accept image terms.
Currently, I have to test if with this change the already supported images still function correctly or not hence, adding WIP label. Will remove the label once verified that it works smoothly for every single image category.

Copy link
Member

@ShimShtein ShimShtein left a comment

Choose a reason for hiding this comment

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

LGTM, If you could add a couple of words on image creation page, that would be awesome.
So the user will be reminded he needs to do it. I won't block merging if @vijay8451 approves it.

@vijay8451
Copy link

@ShimShtein sure will give a try once have this enable over my Azure cloud account .

@apuntamb
Copy link
Member Author

apuntamb commented Jun 2, 2020

Tested VM creation as per Vijay's directions as he couldn't get the byos images activated for his az account. VM creation works fine.
Let's see if @vijay8451 has some results for image creation testing.

@vijay8451
Copy link

Test Results:
Works:

  • Able to create/edit/delete BYOS image using marketplace:// prefix
  • Able to create/edit/delete marketplace image using marketplace:// prefix
  • Able to create/edit/delete shared gallery image using gallery:// prefix
  • Able to create/edit/delete custom image using custom:// prefix

Found a minor issue:

  • Able to create duplicate images using same URN (by just changing the case)

i.e. you could create two images using below URNs and the only diff in them is R/r in RedHat

marketplace://RedHat:rhel-byos:rhel-lvm81:8.1.2019123006
marketplace://redHat:rhel-byos:rhel-lvm81:8.1.2019123006

@ShimShtein @apuntamb thanks ACK from my end .

@apuntamb
Copy link
Member Author

apuntamb commented Jun 2, 2020

Test Results:
Works:

* Able to create/edit/delete BYOS image using `marketplace://` prefix

* Able to create/edit/delete marketplace image using `marketplace://` prefix

* Able to create/edit/delete shared gallery image using `gallery://` prefix

* Able to create/edit/delete custom image using `custom://` prefix

Found a minor issue:

* Able to create duplicate images using same URN (by just changing the case)

i.e. you could create two images using below URNs and the only diff in them is R/r in RedHat

marketplace://RedHat:rhel-byos:rhel-lvm81:8.1.2019123006
marketplace://redHat:rhel-byos:rhel-lvm81:8.1.2019123006

Good catch @vijay8451! I have fixed this too in my latest commit.

@ShimShtein @apuntamb thanks ACK from my end .

@ShimShtein I have added case sensitive validation in the engine file for this.
Also, mentioned byos-images in the Image create form.

Copy link
Member

@ShimShtein ShimShtein left a comment

Choose a reason for hiding this comment

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

One small issue found

@@ -42,7 +42,7 @@ class Engine < ::Rails::Engine
require 'azure_mgmt_subscriptions'

# Add format validation for azure images
::Image.validates :uuid, format: { with: /\A((marketplace|custom|gallery):\/\/)[^:]+(:[^:]+:[^:]+:[^:]+)?\z/,
::Image.validates :uuid, uniqueness: { case_sensitive: false }, format: { with: /\A((marketplace|custom|gallery):\/\/)[^:]+(:[^:]+:[^:]+:[^:]+)?\z/,
Copy link
Member

Choose a reason for hiding this comment

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

This means you cannot add the same image ID to different Azure compute resources.
You should use scope to limit the uniqueness. Example: https://github.com/theforeman/foreman/blob/develop/app/models/image.rb#L13

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @ShimShtein for the catch! Made changes.

Copy link
Member

@ShimShtein ShimShtein left a comment

Choose a reason for hiding this comment

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

Almost there!

@@ -59,6 +59,24 @@ def define_data_disks(vm_name, data_disks)
end
end

def marketplace_image_plan(image)
image_type, image_id = image.split('://')
if image_type == 'marketplace' && image_id.include?('byos')
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick:

Suggested change
if image_type == 'marketplace' && image_id.include?('byos')
return nil unless image_type == 'marketplace' && image_id.include?('byos')

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@ShimShtein
Copy link
Member

Merged, thanks @apuntamb!

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.

None yet

4 participants