From 132c063c27ff2763af8fa48976482ca13d324499 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Mon, 5 Feb 2018 15:20:01 -0800 Subject: [PATCH] webapp extension for appservice (#46) * Updating cmd to be new Updating index.json for webapp extension Changing the extension to webapp from 'webapps' updating variable rg to rg_name updating hashcode updating hash after updates updating to SHA256 hash * updating hash --- .github/CODEOWNERS | 4 +- src/index.json | 45 +++++++++++++++++++ .../azext_webapp}/__init__.py | 20 ++++----- .../azext_webapp}/_help.py | 5 ++- .../azext_webapp}/azext_metadata.json | 0 .../azext_webapp}/create_util.py | 0 .../azext_webapp}/custom.py | 35 +++++++-------- src/{webapps => webapp}/setup.cfg | 0 src/{webapps => webapp}/setup.py | 4 +- 9 files changed, 79 insertions(+), 34 deletions(-) rename src/{webapps/azext_webapps => webapp/azext_webapp}/__init__.py (61%) rename src/{webapps/azext_webapps => webapp/azext_webapp}/_help.py (79%) rename src/{webapps/azext_webapps => webapp/azext_webapp}/azext_metadata.json (100%) rename src/{webapps/azext_webapps => webapp/azext_webapp}/create_util.py (100%) rename src/{webapps/azext_webapps => webapp/azext_webapp}/custom.py (81%) rename src/{webapps => webapp}/setup.cfg (100%) rename src/{webapps => webapp}/setup.py (97%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5c81da022d1..1ef765a95d6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -8,6 +8,6 @@ /src/eventhubs/ @v-ajnava -/src/webapps/ @panchagnula +/src/webapp/ @panchagnula -/src/aem/ @yugangw-msft \ No newline at end of file +/src/aem/ @yugangw-msft diff --git a/src/index.json b/src/index.json index a77e1417e2b..9796a381ace 100644 --- a/src/index.json +++ b/src/index.json @@ -367,6 +367,51 @@ "version": "0.0.1" } } + ], + "webapp": [ + { + "filename": "webapp-0.0.6-py2.py3-none-any.whl", + "sha256Digest": "65ffc1f0c34bb4b7b3fa0e3d3b3c49b745d8b46d04c2653ae0e0a22d01329669", + "downloadUrl": "https://github.com/panchagnula/azure-cli-extensions/raw/sisirap-extensions-whl/dist/webapp-0.0.6-py2.py3-none-any.whl", + "metadata": { + "classifiers": [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "Programming Language :: Python", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "License :: OSI Approved :: MIT License" + ], + "extensions": { + "python.details": { + "contacts": [ + { + "email": "sisirap@microsoft.com", + "name": "Sisira Panchagnula", + "role": "author" + } + ], + "document_names": { + "description": "DESCRIPTION.rst" + }, + "project_urls": { + "Home": "https://github.com/Azure/azure-cli-extensions" + } + } + }, + "generator": "bdist_wheel (0.29.0)", + "license": "MIT", + "metadata_version": "2.0", + "name": "webapp", + "summary": "An Azure CLI Extension to manage appservice resources", + "version": "0.0.6" + } + } ] } } \ No newline at end of file diff --git a/src/webapps/azext_webapps/__init__.py b/src/webapp/azext_webapp/__init__.py similarity index 61% rename from src/webapps/azext_webapps/__init__.py rename to src/webapp/azext_webapp/__init__.py index f0f56153d7b..581e1590978 100644 --- a/src/webapps/azext_webapps/__init__.py +++ b/src/webapp/azext_webapp/__init__.py @@ -7,30 +7,30 @@ # pylint: disable=unused-import -import azext_webapps._help +import azext_webapp._help -class WebappsExtCommandLoader(AzCommandsLoader): +class WebappExtCommandLoader(AzCommandsLoader): def __init__(self, cli_ctx=None): from azure.cli.core.commands import CliCommandType - webapps_custom = CliCommandType( - operations_tmpl='azext_webapps.custom#{}') - super(WebappsExtCommandLoader, self).__init__(cli_ctx=cli_ctx, - custom_command_type=webapps_custom, - min_profile="2017-03-10-profile") + webapp_custom = CliCommandType( + operations_tmpl='azext_webapp.custom#{}') + super(WebappExtCommandLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=webapp_custom, + min_profile="2017-03-10-profile") def load_command_table(self, _): with self.command_group('webapp') as g: - g.custom_command('quickstart', 'create_deploy_webapp') + g.custom_command('new', 'create_deploy_webapp') return self.command_table def load_arguments(self, _): - with self.argument_context('webapp quickstart') as c: + with self.argument_context('webapp new') as c: c.argument('name', options_list=['--name', '-n'], help='name of the new webapp') c.argument('dryrun', help="shows summary of the create and deploy operation instead of executing it", default=False, action='store_true') -COMMAND_LOADER_CLS = WebappsExtCommandLoader +COMMAND_LOADER_CLS = WebappExtCommandLoader diff --git a/src/webapps/azext_webapps/_help.py b/src/webapp/azext_webapp/_help.py similarity index 79% rename from src/webapps/azext_webapps/_help.py rename to src/webapp/azext_webapp/_help.py index 1c2ab604a5f..1fe177a5612 100644 --- a/src/webapps/azext_webapps/_help.py +++ b/src/webapp/azext_webapp/_help.py @@ -6,11 +6,12 @@ from knack.help_files import helps -helps['webapp quickstart'] = """ +helps['webapp new'] = """ type: command short-summary: Create and deploy a node web app examples: - name: Create a web app with the default configuration. text: > - az webapp quickstart -n MyUniqueAppName + az webapp new -n MyUniqueAppName --dryrun \n + az webapp new -n MyUniqueAppName -l locationName """ diff --git a/src/webapps/azext_webapps/azext_metadata.json b/src/webapp/azext_webapp/azext_metadata.json similarity index 100% rename from src/webapps/azext_webapps/azext_metadata.json rename to src/webapp/azext_webapp/azext_metadata.json diff --git a/src/webapps/azext_webapps/create_util.py b/src/webapp/azext_webapp/create_util.py similarity index 100% rename from src/webapps/azext_webapps/create_util.py rename to src/webapp/azext_webapp/create_util.py diff --git a/src/webapps/azext_webapps/custom.py b/src/webapp/azext_webapp/custom.py similarity index 81% rename from src/webapps/azext_webapps/custom.py rename to src/webapp/azext_webapp/custom.py index 02d2ba4b4ae..1665994e07b 100644 --- a/src/webapps/azext_webapps/custom.py +++ b/src/webapp/azext_webapp/custom.py @@ -51,7 +51,7 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): loc_name = location.replace(" ", "") asp = "appsvc_asp_{}_{}".format(os_val, loc_name) - rg = "appsvc_rg_{}_{}".format(os_val, loc_name) + rg_name = "appsvc_rg_{}_{}".format(os_val, loc_name) # the code to deploy is expected to be the current directory the command is running from src_dir = os.getcwd() @@ -75,15 +75,15 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): # Resource group: check if default RG is set default_rg = cmd.cli_ctx.config.get('defaults', 'group', fallback=None) - if (default_rg and check_resource_group_supports_linux(cmd, default_rg, location)): - rg = default_rg + if default_rg and check_resource_group_supports_linux(cmd, default_rg, location): + rg_name = default_rg rg_mssg = "[Using default Resource group]" else: rg_mssg = "" runtime_version = "{}|{}".format(language, version_used_create) src_path = "{} {}".format(src_dir.replace("\\", "\\\\"), str_no_contents_warn) - rg_str = "{} {}".format(rg, rg_mssg) + rg_str = "{} {}".format(rg_name, rg_mssg) dry_run_str = r""" { "name" : "%s", @@ -101,46 +101,45 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): create_json = json.dumps(json.loads(dry_run_str), indent=4, sort_keys=True) if dryrun: - logger.warning(""" - Web app will be created with the below configuration, - re-run command without the --dryrun flag to create & deploy a new app - """) + logger.warning("Web app will be created with the below configuration,re-run command " + "without the --dryrun flag to create & deploy a new app") logger.warning(create_json) return None # create RG if the RG doesn't already exist - if not check_resource_group_exists(cmd, rg): - logger.warning("Creating Resource group '%s' ...", rg) - create_resource_group(cmd, rg, location) + if not check_resource_group_exists(cmd, rg_name): + logger.warning("Creating Resource group '%s' ...", rg_name) + create_resource_group(cmd, rg_name, location) logger.warning("Resource group creation complete") else: - logger.warning("Resource group '%s' already exists.", rg) + logger.warning("Resource group '%s' already exists.", rg_name) # create asp - if not check_if_asp_exists(cmd, rg, asp): + if not check_if_asp_exists(cmd, rg_name, asp): logger.warning("Creating App service plan '%s' ...", asp) sku_def = SkuDescription(tier=full_sku, name=sku, capacity=1) plan_def = AppServicePlan(loc_name, app_service_plan_name=asp, sku=sku_def, reserved=True) - client.app_service_plans.create_or_update(rg, asp, plan_def) + client.app_service_plans.create_or_update(rg_name, asp, plan_def) logger.warning("App service plan creation complete") else: logger.warning("App service plan '%s' already exists.", asp) # create the Linux app logger.warning("Creating app '%s' ....", name) - create_webapp(cmd, rg, name, asp, runtime_version) + create_webapp(cmd, rg_name, name, asp, runtime_version) logger.warning("Webapp creation complete") # setting to build after deployment logger.warning("Updating app settings to enable build after deployment") - update_app_settings(cmd, rg, name, ["SCM_DO_BUILD_DURING_DEPLOYMENT=true"]) + update_app_settings(cmd, rg_name, name, ["SCM_DO_BUILD_DURING_DEPLOYMENT=true"]) # zip contents & deploy logger.warning("Creating zip with contents of dir %s ...", src_dir) zip_file_path = zip_contents_from_dir(src_dir) - logger.warning("Deploying and building contents to app. This operation can take some time to finish...") - enable_zip_deploy(cmd, rg, name, zip_file_path) + logger.warning("Deploying and building contents to app." + "This operation can take some time to finish...") + enable_zip_deploy(cmd, rg_name, name, zip_file_path) logger.warning("All done. %s", create_json) return None diff --git a/src/webapps/setup.cfg b/src/webapp/setup.cfg similarity index 100% rename from src/webapps/setup.cfg rename to src/webapp/setup.cfg diff --git a/src/webapps/setup.py b/src/webapp/setup.py similarity index 97% rename from src/webapps/setup.py rename to src/webapp/setup.py index 599f9fd3b43..c2cdff2b61c 100644 --- a/src/webapps/setup.py +++ b/src/webapp/setup.py @@ -8,7 +8,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = "0.0.4" +VERSION = "0.0.6" CLASSIFIERS = [ 'Development Status :: 4 - Beta', @@ -27,7 +27,7 @@ DEPENDENCIES = [] setup( - name='webapps', + name='webapp', version=VERSION, description='An Azure CLI Extension to manage appservice resources', long_description='An Azure CLI Extension to manage appservice resources',