-
Notifications
You must be signed in to change notification settings - Fork 6
Add third party plugins #54
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
base: chameleoncloud/xena
Are you sure you want to change the base?
Conversation
…oud/blazar into third_party_plugins
…tus to ERROR" This reverts commit d78c38a. Change-Id: Ia80e00a1aac3ad0c02a5062e997447fe243bacc6
Change-Id: Iaa8a88fb96d32c0bfe351af6115550bef5f80889
Change-Id: I8263254dc7710d57bd50cd37ea3da2485dbbb38a
Change-Id: Ib1a06802ba827b2159de4fc61c97f2df273aff36
Change-Id: Ib1a06802ba827b2159de4fc61c97f2df273aff36
Change-Id: Idb31b4a048d6499cab6bbe1b90b93599c519a442
Change-Id: Ic9bc1c9645aee9c7a98fd1d8ecb8f0169404161d
Change-Id: I9f0d7f47e92ed222cbb7cd042304317f6c2e74ee
Change-Id: I714c7389067e7d6d625790a3f776a07484652cb9
Note: This git history is too messy to merge on it's own, we should squash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of comments, but considering the sheer volume of code here, I think that's a pretty good ratio! I tried my best to fully understand everything going on here, and it helped that I've been working a little bit on plugins recently, but I did find myself getting a bit lost in the sauce. I hope my comments make sense and are useful.
# Add extra filter if using 3rd party resource type | ||
if resource_type not in EXTRA_CAPABILITY_MODELS: | ||
query = query.join(models.Resource).filter_by( | ||
resource_type=resource_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it could be consolidated into the above else
body instead of performing this check again.
blazar/manager/service.py
Outdated
"An unexpected exception type was generated. This " | ||
"indicates that some exception is not being wrapped " | ||
"properly in a BlazarException.")) | ||
except common_ex.BlazarException: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we're excluding the warning that used to be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only exists in our fork, I'll revert my change for now
blazar/manager/service.py
Outdated
'status': status.reservation.PENDING | ||
} | ||
reservation = db_api.reservation_create(reservation_values) | ||
plugin = self.plugin_manager.get(resource_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing any other references to ManagerService.plugin_manager
in blazar. Is this supposed to be a call to self._get_plugin
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea how this got here, the branch is unreachable anyway since _get_plugin
handles it already.
resource_type=resource_type) | ||
|
||
plugin = self.plugins.get(resource_type) | ||
plugin = self._get_plugin(resource_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._get_plugin
doesn't appear to have an appropriate check to throw UnsupportedResourceType
and might result in confusing errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what is better, unsupported resource type or invalid plugin name, which is raised right after if no plugin is returned. I left it as "invalid plugin name" to reduce the code base a bit.
blazar/manager/service.py
Outdated
|
||
if resource_type not in self.plugins: | ||
if resource_type in self.plugins: | ||
plugin = self.plugins.get(resource_type) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we're not using self._get_plugin
here? It seems that most of this code is duplicated between the regular and third party plugin branches of this conditional. We could just use _get_plugin
and most of the same code for both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Like above I've similarly made this just raise "invalid plugin name"
policy.check_enforcement(self.resource_type(), "delete") | ||
resource = db_api.resource_get(self.resource_type(), resource_id) | ||
if resource is None: | ||
raise manager_ex.ResourceNotFound( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exception appears to come from plugin_ex
, not manager_ex
.
|
||
def api_update(self, resource_id, data): | ||
policy.check_enforcement(self.resource_type(), "put") | ||
extras = data["extras"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be data.get("extras")
? I see we check for not extras
in a couple lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a good idea. I guess this would be the difference between not including it in the API request and it being empty. Either way, returning None is fine.
return rest | ||
|
||
def query_resource_allocations(self, resources, lease_id=None, | ||
reservation_id=None, detail=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detail
appears unused
return resource_policy | ||
|
||
|
||
class ResourceMonitorPlugin(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this implement BaseMonitorPlugin
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point
if port["data"]["port_id"] in active_port_ids | ||
] | ||
except Exception as e: | ||
LOG.exception('Skipping health check. %s', str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect it to return empty lists in the next statement, this is copied from the host monitor.
This adds third party plugins, by creating a robust base class that manages the API, the service functions, the policies, and monitoring.
Notes for review: