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

Add a guide for writing a new provider from scratch #457

Merged
merged 8 commits into from
Apr 6, 2021

Conversation

agrare
Copy link
Member

@agrare agrare commented Mar 30, 2021

TODO:

  • Generate the provider plugin
  • Set up override_gem from core and symlink to core
  • Create the EMS record
  • Add the provider sdk gem to the plugin's gemspec
  • Implement .raw_connect, .verify_credentials, #connect, and #verify_credentials
  • Add params_for_create and be able to add via the UI
  • Writing a simple refresh (writing the collector, parser, etc...)

@agrare agrare added the wip label Mar 30, 2021
Fryguy
Fryguy previously approved these changes Mar 30, 2021
providers/writing_a_new_provider.md Outdated Show resolved Hide resolved
providers/writing_a_new_provider.md Outdated Show resolved Hide resolved
@Fryguy Fryguy dismissed their stale review March 30, 2021 17:12

Accidentally approved :)

@agrare agrare force-pushed the generating_a_new_provider branch 3 times, most recently from 4d1496b to 6dc4781 Compare April 5, 2021 16:49
@agrare
Copy link
Member Author

agrare commented Apr 5, 2021

Okay I ran through this end-to-end with the example code segments and all were successful. Taking out of WIP

@agrare agrare changed the title [WIP] Add a guide for writing a new provider from scratch Add a guide for writing a new provider from scratch Apr 5, 2021
end
```

You'll have to add your vendor name to the core `VmOrTemplate` `VENDOR_TYPES` in order for the VMs to be saved.
Copy link
Member Author

Choose a reason for hiding this comment

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

NOTE: we have a checklist item for this ManageIQ/manageiq#19440

@agrare agrare force-pushed the generating_a_new_provider branch from c52b6d0 to 8a46407 Compare April 5, 2021 17:14
@agrare agrare force-pushed the generating_a_new_provider branch from 8a46407 to 61f5847 Compare April 5, 2021 17:29
:name => image.name,
:location => "unknown",
:raw_power_state => "never",
:template => true,
Copy link
Member Author

Choose a reason for hiding this comment

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

raw_power_state and template are the same for every provider, consider adding these as default values to the core miq_templates inventory collection definition

:location => "unknown",
:raw_power_state => "never",
:template => true,
:vendor => "awesome_cloud"
Copy link
Member Author

Choose a reason for hiding this comment

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

We could have this as a default value as well by pulling the vendor type from the ext_management_system.

@agrare agrare removed the wip label Apr 6, 2021
>> ems = ManageIQ::Providers::AwesomeCloud::CloudManager.create!(:name => "My Awesome Cloud", :zone => Zone.default_zone)
```

Now that we have that done it is time to start filling out our new provider. The first step is to find the SDK gem for this provider. If there isn't a provider SDK for Ruby you have a few options which we'll cover later. For now lets assume that Awesome Cloud has a ruby gem called 'awesome_cloud'.
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but we might want to rename this fake gem to "awesome_cloud_client" or "awesome_cloud_sdk" or something to make it clearer.

# it (instance-lavel) it fails.
def self.validate_connection(connection)
# Perform a simple and fast operation that verifies the credentials are correct
!!connection.list_regions
Copy link
Member

Choose a reason for hiding this comment

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

Is this the method that must return a boolean? If so, should we state that here? I wonder there's a nice way to ensure that at the base level

Copy link
Member Author

Choose a reason for hiding this comment

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

No this can return anything, we handle the "must return a boolean" in core.

@Fryguy
Copy link
Member

Fryguy commented Apr 6, 2021

We should add more ### markdown titles, as it creates a nice TOC, but that can be a followup

Copy link
Member

@Fryguy Fryguy left a comment

Choose a reason for hiding this comment

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

All minor stuff

@agrare
Copy link
Member Author

agrare commented Apr 6, 2021

Applied review feedback, PTAL @Fryguy

@Fryguy Fryguy merged commit 06fcdd8 into ManageIQ:master Apr 6, 2021
@agrare agrare deleted the generating_a_new_provider branch April 6, 2021 21:35
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.

3 participants