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

Initial commit for Appliance commands #2985

Merged
merged 37 commits into from May 5, 2017
Merged

Conversation

vivsriaus
Copy link
Contributor


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • The PR has modified HISTORY.rst with an appropriate description of the change (see Modifying change log).

Command Guidelines

  • Each command and parameter has a meaningful description.
  • Each new command has a test.

(see Authoring Command Modules)

@msftclas
Copy link

@vivsriaus,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@derekbekoe derekbekoe changed the title [Do Not Merge] Initial commit for Appliance commands Initial commit for Appliance commands Apr 25, 2017
Copy link
Contributor

@troydai troydai left a 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))
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove commented code.

@tjprescott
Copy link
Member

Please include the -h output for the group and the create/update commands. This aids in review.

@troydai
Copy link
Contributor

troydai commented May 1, 2017

@vivsriaus please rebase your changes again. There are changes made to master branch results in the merge conflicts. Please make sure to keep your branch up-to-date so we can review and approve the changes timely. Otherwise, the fast evolving master branch may keep causing the merge conflicts. Please also be noted that we're running PEP8 check on most modules now, including the resource module. As a result, it is recommended to run check_style --ci before push to ensure code styles are compliant.

@troydai troydai added this to the Build Milestone milestone May 1, 2017
@@ -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):

Choose a reason for hiding this comment

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

managedby_resource_group_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.

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):

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

Copy link
Contributor Author

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')

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)

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

Copy link
Contributor Author

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):

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?

Copy link
Contributor Author

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):

Choose a reason for hiding this comment

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

same documentation comment

Copy link
Contributor Author

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):

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 = []
Copy link

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

Copy link
Contributor Author

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)

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"?

Copy link
Contributor Author

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)

Choose a reason for hiding this comment

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

nit: applianceDefinitionProperties

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NA anymore after flattening

Copy link

@gandhiniraj gandhiniraj left a 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

Copy link
Contributor Author

@vivsriaus vivsriaus left a 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):
Copy link
Contributor Author

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):
Copy link
Contributor Author

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)
Copy link
Contributor Author

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):
Copy link
Contributor Author

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):
Copy link
Contributor Author

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)
Copy link
Contributor Author

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)
Copy link
Contributor Author

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 = []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense

@troydai
Copy link
Contributor

troydai commented May 3, 2017

@vivsriaus changes look good. Waiting for tests.

Copy link
Member

@lmazuel lmazuel left a 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)
Copy link
Member

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.

Copy link
Contributor Author

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.

@vivsriaus
Copy link
Contributor Author

@lmazuel Thanks for the suggestion, modified the command to always return a list.

@vivsriaus
Copy link
Contributor Author

@azuresdkci test this please

@troydai
Copy link
Contributor

troydai commented May 5, 2017

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).

@vivsriaus
Copy link
Contributor Author

@troydai Modified HISTORY.rst

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

9 participants