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
Initial commit for Appliance commands #2985
Conversation
@vivsriaus, |
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.
Please fix code style and add tests to offer basic code coverage.
# split at the first ':', both principalId and roldeDefinitionId should not have a ':' | ||
principalId, roleDefinitionId = name_value.split(':', 1) | ||
#print('>>>>>>>principalId: {}'.format(principalId)) | ||
#print('>>>>>>>roleDefinitionId: {}'.format(roleDefinitionId)) |
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.
Please remove the commented code.
applianceAuth.append(applianceAuth1) | ||
#applianceAuth1 = ApplianceProviderAuthorization("d5d74787-be93-4a54-baae-e9ed29bfe353","8e3af657-a8ff-443c-a75c-2fe8c4bcb635") | ||
#applianceAuth = [applianceAuth1] | ||
#applianceDefProperties = ApplianceDefinitionProperties(ApplianceLockLevel.can_not_delete, applianceAuth, package_file_uri, display_name, None, description) |
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.
Remove commented code.
Please include the -h output for the group and the create/update commands. This aids in review. |
@vivsriaus please rebase your changes again. There are changes made to |
@@ -64,6 +73,110 @@ def create_resource_group(rg_name, location, tags=None): | |||
) | |||
return rcf.resource_groups.create_or_update(rg_name, parameters) | |||
|
|||
def create_appliance(resource_group_name, appliance_name, managed_rg_id, location, kind, appliance_definition_id=None, plan_name=None, plan_publisher=None, plan_product=None, plan_version=None, tags=None, parameters=None): |
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.
managedby_resource_group_id
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.
Sure. But it would be very verbose IMHO
@@ -64,6 +73,110 @@ def create_resource_group(rg_name, location, tags=None): | |||
) | |||
return rcf.resource_groups.create_or_update(rg_name, parameters) | |||
|
|||
def create_appliance(resource_group_name, appliance_name, managed_rg_id, location, kind, appliance_definition_id=None, plan_name=None, plan_publisher=None, plan_product=None, plan_version=None, tags=None, parameters=None): |
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.
appliance - we made a decision call this "managed application" - can we change the cmdlet to create_managed_app
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.
Done
raise CLIError('--appliance-definition-id is required if kind is ServiceCatalog') | ||
elif kind.lower() == 'marketplace': | ||
if plan_name is None and plan_product is None and plan_publisher is None and plan_version is None: | ||
raise CLIError('--plan-name, --plan-product, --plan-publisher and --plan-version are all required if kind is ServiceCatalog') |
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 has to be marketplace
if plan_name is None and plan_product is None and plan_publisher is None and plan_version is None: | ||
raise CLIError('--plan-name, --plan-product, --plan-publisher and --plan-version are all required if kind is ServiceCatalog') | ||
else: | ||
appliancePlan = Plan(plan_name, plan_publisher, plan_product, plan_version) |
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.
We don't need this intermediate variable
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.
of course!
|
||
return racf.appliances.create_or_update(resource_group_name, appliance_name, appliance) | ||
|
||
def show_appliance(resource_group_name=None, appliance_name=None, appliance_id=None): |
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.
Still learning this CLI, but shouldn't appliance_id be documented below?
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.
It is in the params file. We don't necessarily add param description for all params in custom file
appliance = racf.appliances.get(resource_group_name, appliance_name) | ||
return appliance | ||
|
||
def show_appliancedefinition(resource_group_name=None, appliance_definition_name=None, appliance_definition_id=None): |
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.
same documentation comment
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.
Same as above.
appliancedef = racf.appliance_definitions.get(resource_group_name, appliance_definition_name) | ||
return appliancedef | ||
|
||
def create_appliancedefinition(resource_group_name, appliance_definition_name, location, lock_level, package_file_uri, authorizations, description, display_name, tags=None): |
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.
just making sure o camel casing? Is that not standard if not please ignore
''' | ||
racf = _resource_appliances_client_factory() | ||
authorizations = authorizations or [] | ||
applianceAuth = [] |
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.
applianceAuthList so that you don't have to name applianceAuth1 below
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.
Makes sense
principalId, roleDefinitionId = name_value.split(':', 1) | ||
applianceAuth1 = ApplianceProviderAuthorization(principalId, roleDefinitionId) | ||
applianceAuth.append(applianceAuth1) | ||
applianceDefProperties = ApplianceDefinitionProperties(lock_level, applianceAuth, package_file_uri, display_name, None, description) |
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.
Why one of the param is "None"?
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've flattened the Appliance model. We no longer have properties model for both Appliance and ApplianceDefinitions
principalId, roleDefinitionId = name_value.split(':', 1) | ||
applianceAuth1 = ApplianceProviderAuthorization(principalId, roleDefinitionId) | ||
applianceAuth.append(applianceAuth1) | ||
applianceDefProperties = ApplianceDefinitionProperties(lock_level, applianceAuth, package_file_uri, display_name, None, description) |
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.
nit: applianceDefinitionProperties
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.
NA anymore after flattening
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.
Please see my suggestions/comments
…ppliance2 # Conflicts: # src/command_modules/azure-cli-resource/azure/cli/command_modules/resource/custom.py
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.
Addressed comments
@@ -64,6 +73,110 @@ def create_resource_group(rg_name, location, tags=None): | |||
) | |||
return rcf.resource_groups.create_or_update(rg_name, parameters) | |||
|
|||
def create_appliance(resource_group_name, appliance_name, managed_rg_id, location, kind, appliance_definition_id=None, plan_name=None, plan_publisher=None, plan_product=None, plan_version=None, tags=None, parameters=None): |
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.
Done
@@ -64,6 +73,110 @@ def create_resource_group(rg_name, location, tags=None): | |||
) | |||
return rcf.resource_groups.create_or_update(rg_name, parameters) | |||
|
|||
def create_appliance(resource_group_name, appliance_name, managed_rg_id, location, kind, appliance_definition_id=None, plan_name=None, plan_publisher=None, plan_product=None, plan_version=None, tags=None, parameters=None): |
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.
Sure. But it would be very verbose IMHO
if plan_name is None and plan_product is None and plan_publisher is None and plan_version is None: | ||
raise CLIError('--plan-name, --plan-product, --plan-publisher and --plan-version are all required if kind is ServiceCatalog') | ||
else: | ||
appliancePlan = Plan(plan_name, plan_publisher, plan_product, plan_version) |
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.
of course!
|
||
return racf.appliances.create_or_update(resource_group_name, appliance_name, appliance) | ||
|
||
def show_appliance(resource_group_name=None, appliance_name=None, appliance_id=None): |
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.
It is in the params file. We don't necessarily add param description for all params in custom file
appliance = racf.appliances.get(resource_group_name, appliance_name) | ||
return appliance | ||
|
||
def show_appliancedefinition(resource_group_name=None, appliance_definition_name=None, appliance_definition_id=None): |
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.
Same as above.
principalId, roleDefinitionId = name_value.split(':', 1) | ||
applianceAuth1 = ApplianceProviderAuthorization(principalId, roleDefinitionId) | ||
applianceAuth.append(applianceAuth1) | ||
applianceDefProperties = ApplianceDefinitionProperties(lock_level, applianceAuth, package_file_uri, display_name, None, description) |
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've flattened the Appliance model. We no longer have properties model for both Appliance and ApplianceDefinitions
principalId, roleDefinitionId = name_value.split(':', 1) | ||
applianceAuth1 = ApplianceProviderAuthorization(principalId, roleDefinitionId) | ||
applianceAuth.append(applianceAuth1) | ||
applianceDefProperties = ApplianceDefinitionProperties(lock_level, applianceAuth, package_file_uri, display_name, None, description) |
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.
NA anymore after flattening
''' | ||
racf = _resource_appliances_client_factory() | ||
authorizations = authorizations or [] | ||
applianceAuth = [] |
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.
Makes sense
@vivsriaus changes look good. Waiting for tests. |
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.
Important fix
racf = _resource_managedapps_client_factory() | ||
|
||
if resource_group_name: | ||
return racf.appliances.list_by_resource_group(resource_group_name) |
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.
CLI does not support iterator, change this to:
if resource_group_name:
result = racf.appliances.list_by_resource_group(resource_group_name)
else:
result = racf.appliances.list_by_subscription()
return list(result)
@johanste should be documented? Twice issues like this today.
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.
@lmazuel returning a list above still won't work for us, because "value" will be missing.
…ppliance2 # Conflicts: # src/command_modules/azure-cli-vm/setup.py
@lmazuel Thanks for the suggestion, modified the command to always return a list. |
@azuresdkci test this please |
Last thing. Can you add a HIstory file? The PR has modified HISTORY.rst with an appropriate description of the change (see Modifying change log). |
@troydai Modified HISTORY.rst |
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Command Guidelines
(see Authoring Command Modules)