From 97883f2ea837b537808af6a3262042687547f455 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Wed, 31 Jan 2018 22:51:55 -0800 Subject: [PATCH 01/10] Adding webapp extension plus the whl file Updating resource client factory by adding def Fixing build adding blank line More build fixes fixing pylint errors Build errors PYlint fix More PYlint fixes FW: --- src/webapps/azext_webapps/__init__.py | 32 ++++ src/webapps/azext_webapps/_help.py | 16 ++ src/webapps/azext_webapps/azext_metadata.json | 3 + src/webapps/azext_webapps/create_util.py | 85 +++++++++++ src/webapps/azext_webapps/custom.py | 144 ++++++++++++++++++ src/webapps/setup.cfg | 2 + src/webapps/setup.py | 41 +++++ 7 files changed, 323 insertions(+) create mode 100644 src/webapps/azext_webapps/__init__.py create mode 100644 src/webapps/azext_webapps/_help.py create mode 100644 src/webapps/azext_webapps/azext_metadata.json create mode 100644 src/webapps/azext_webapps/create_util.py create mode 100644 src/webapps/azext_webapps/custom.py create mode 100644 src/webapps/setup.cfg create mode 100644 src/webapps/setup.py diff --git a/src/webapps/azext_webapps/__init__.py b/src/webapps/azext_webapps/__init__.py new file mode 100644 index 00000000000..b81feefcf02 --- /dev/null +++ b/src/webapps/azext_webapps/__init__.py @@ -0,0 +1,32 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +import azext_webapps._help # pylint: disable=unused-import + + +class WebappsCommandLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + webapps_custom = CliCommandType( + operations_tmpl='azext_webapps.custom#{}') + super(WebappsCommandLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=webapps_custom) + + def load_command_table(self, _): + with self.command_group('webapp') as g: + g.custom_command('quickstart', 'create_deploy_webapp') + return self.command_table + + def load_arguments(self, _): + with self.argument_context('webapp quickstart') as c: + c.argument('name', options_list=['--name', '-n'], help='name of the new webapp') + c.argument('dryrun', + help="shows summary of the create operation instead of actually creating and deploying the app", + default=False) + + +COMMAND_LOADER_CLS = WebappsCommandLoader diff --git a/src/webapps/azext_webapps/_help.py b/src/webapps/azext_webapps/_help.py new file mode 100644 index 00000000000..1c2ab604a5f --- /dev/null +++ b/src/webapps/azext_webapps/_help.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from knack.help_files import helps + + +helps['webapp quickstart'] = """ + 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 +""" diff --git a/src/webapps/azext_webapps/azext_metadata.json b/src/webapps/azext_webapps/azext_metadata.json new file mode 100644 index 00000000000..bbe67260f34 --- /dev/null +++ b/src/webapps/azext_webapps/azext_metadata.json @@ -0,0 +1,3 @@ +{ + "azext.minCliCoreVersion": "2.0.24" +} \ No newline at end of file diff --git a/src/webapps/azext_webapps/create_util.py b/src/webapps/azext_webapps/create_util.py new file mode 100644 index 00000000000..99d5e9f1524 --- /dev/null +++ b/src/webapps/azext_webapps/create_util.py @@ -0,0 +1,85 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import os +import zipfile +from azure.cli.core.commands.client_factory import get_mgmt_service_client +from azure.mgmt.resource.resources.models import ResourceGroup + + +def _resource_client_factory(cli_ctx, **_): + from azure.cli.core.profiles import ResourceType + return get_mgmt_service_client(cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES) + + +def web_client_factory(cli_ctx, **_): + from azure.mgmt.web import WebSiteManagementClient + return get_mgmt_service_client(cli_ctx, WebSiteManagementClient) + + +def zip_contents_from_dir(dirPath): + relroot = os.path.abspath(os.path.join(dirPath, os.pardir)) + path_and_file = os.path.splitdrive(dirPath)[1] + file_val = os.path.split(path_and_file)[1] + zip_file_path = relroot + "\\" + file_val + ".zip" + abs_src = os.path.abspath(dirPath) + with zipfile.ZipFile("{}".format(zip_file_path), "w", zipfile.ZIP_DEFLATED) as zf: + for dirname, subdirs, files in os.walk(dirPath): + # skip node_modules folder for Node apps, + # since zip_deployment will perfom the build operation + if 'node_modules' in subdirs: + subdirs.remove('node_modules') + for filename in files: + absname = os.path.abspath(os.path.join(dirname, filename)) + arcname = absname[len(abs_src) + 1:] + zf.write(absname, arcname) + return zip_file_path + + +def is_node_application(path): + # for node application, package.json should exisit in the application root dir + # if this exists we pass the path of the file to read it contents & get version + package_json_file = os.path.join(path, 'package.json') + if os.path.isfile(package_json_file): + return package_json_file + return '' + + +def get_node_runtime_version_toSet(): + version_val = "8.0" + # trunc_version = float(node_version[:3]) + # TODO: call the list_runtimes once there is an API that returs the supported versions + return version_val + + +def create_resource_group(cmd, rg_name, location): + rcf = _resource_client_factory(cmd.cli_ctx) + rg_params = ResourceGroup(location=location) + return rcf.resource_groups.create_or_update(rg_name, rg_params) + + +def check_resource_group_exists(cmd, rg_name): + rcf = _resource_client_factory(cmd.cli_ctx) + return rcf.resource_groups.check_existence(rg_name) + + +def check_resource_group_supports_linux(cmd, rg_name, location): + # get all appservice plans from RG + client = web_client_factory(cmd.cli_ctx) + plans = list(client.app_service_plans.list_by_resource_group(rg_name)) + # filter by location & reserverd=false + for item in plans: + if item.location == location and not item.reserved: + return False + return True + + +def check_if_asp_exists(cmd, rg_name, asp_name): + # get all appservice plans from RG + client = web_client_factory(cmd.cli_ctx) + for item in list(client.app_service_plans.list_by_resource_group(rg_name)): + if item.name == asp_name: + return True + return False diff --git a/src/webapps/azext_webapps/custom.py b/src/webapps/azext_webapps/custom.py new file mode 100644 index 00000000000..d3e3d64bf4c --- /dev/null +++ b/src/webapps/azext_webapps/custom.py @@ -0,0 +1,144 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from __future__ import print_function +from knack.log import get_logger + +from azure.mgmt.web.models import (AppServicePlan, SkuDescription) + +from azure.cli.command_modules.appservice.custom import ( + enable_zip_deploy, + create_webapp, + update_app_settings, + _get_sku_name) + +from .create_util import ( + zip_contents_from_dir, + is_node_application, + get_node_runtime_version_toSet, + create_resource_group, + check_resource_group_exists, + check_resource_group_supports_linux, + check_if_asp_exists, + web_client_factory +) + +logger = get_logger(__name__) + +# pylint:disable=no-member,too-many-lines,too-many-locals,too-many-statements + + +def create_deploy_webapp(cmd, name, location=None, dryrun=False): + import os + import json + + client = web_client_factory(cmd.cli_ctx) + sku = "S1" + os_val = "Linux" + language = "node" + full_sku = _get_sku_name(sku) + + if location is None: + locs = client.list_geo_regions(sku, True) + available_locs = [] + for loc in locs: + available_locs.append(loc.geo_region_name) + location = available_locs[0] + + # Remove spaces from the location string, incase the GeoRegion string is used + loc_name = location.replace(" ", "") + + asp = "appsvc_asp_{}_{}".format(os_val, loc_name) + rg = "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() + + # if dir is empty, show a message in dry run + do_deployment = False if os.listdir(src_dir) == [] else True + package_json_path = is_node_application(src_dir) + + str_no_contents_warn = "" + if not do_deployment: + str_no_contents_warn = "[Empty directory, no deployment will be triggered]" + + if package_json_path == '': + node_version = "[No package.json file found in root directory, not a Node app?]" + version_used_create = "8.0" + else: + with open(package_json_path) as data_file: + data = json.load(data_file) + node_version = data['version'] + version_used_create = get_node_runtime_version_toSet() + + # ResourceGroup: check if default RG is set + default_rg = cmd.cli_ctx.config.get('defaults', 'group') + if (default_rg and check_resource_group_supports_linux(cmd, default_rg, location)): + rg = default_rg + rg_mssg = "[Using default ResourceGroup]" + 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) + + dry_run_str = r""" { + "name" : "%s", + "appServicePlan" : "%s", + "resourceGroup" : "%s", + "sku": "%s", + "os": "%s", + "location" : "%s", + "src_path" : "%s", + "version_detected": "%s", + "version_to_create": "%s" + } + """ % (name, asp, rg_str, full_sku, os_val, location, src_path, + node_version, runtime_version) + + 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 + """) + return logger.warning(create_json) + + # create RG if the RG doesn't already exist + if not check_resource_group_exists(cmd, rg): + logger.warning("Creating ResourceGroup '%s' ...", rg) + create_resource_group(cmd, rg, location) + logger.warning("ResourceGroup creation complete") + else: + logger.warning("Resource Group '%s' already exists.", rg) + + # create asp + if not check_if_asp_exists(cmd, rg, 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) + logger.warning("AppServicePlan creation complete") + else: + logger.warning("AppServicePlan '%s' already exists.", asp) + + # create the Linux app + logger.warning("Creating app '%s' ....", name) + create_webapp(cmd, rg, 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"]) + + # 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) + return logger.warning("All done. %s", create_json) diff --git a/src/webapps/setup.cfg b/src/webapps/setup.cfg new file mode 100644 index 00000000000..3c6e79cf31d --- /dev/null +++ b/src/webapps/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/src/webapps/setup.py b/src/webapps/setup.py new file mode 100644 index 00000000000..f97d1bf9e06 --- /dev/null +++ b/src/webapps/setup.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +from codecs import open +from setuptools import setup, find_packages + +VERSION = "0.0.1" + +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', +] + +DEPENDENCIES = [] + +setup( + name='webapps', + version=VERSION, + description='An Azure CLI Extension to manage appservice resources', + long_description='An Azure CLI Extension to manage appservice resources', + license='MIT', + author='Sisira Panchagnula', + author_email='sisirap@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions', + classifiers=CLASSIFIERS, + packages=find_packages(exclude=["tests"]), + install_requires=DEPENDENCIES +) From 2e3c7f9a3d3861e9f7946034eca6b85f0659657c Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Thu, 1 Feb 2018 14:18:27 -0800 Subject: [PATCH 02/10] Updating code owners for webapps --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fa59007ae91..6aa73ed9190 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,3 +7,5 @@ /src/servicebus/ @v-ajnava /src/eventhubs/ @v-ajnava + +/src/webapps/ @panchagnula \ No newline at end of file From 2bf64ca669106b0972d160466146580830880334 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Thu, 1 Feb 2018 15:00:48 -0800 Subject: [PATCH 03/10] addressing PR feedback --- src/webapps/azext_webapps/__init__.py | 10 +++++----- src/webapps/azext_webapps/create_util.py | 2 +- src/webapps/azext_webapps/custom.py | 24 +++++++++++++----------- src/webapps/setup.py | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/webapps/azext_webapps/__init__.py b/src/webapps/azext_webapps/__init__.py index b81feefcf02..4b4951d8320 100644 --- a/src/webapps/azext_webapps/__init__.py +++ b/src/webapps/azext_webapps/__init__.py @@ -7,14 +7,14 @@ import azext_webapps._help # pylint: disable=unused-import -class WebappsCommandLoader(AzCommandsLoader): +class WebappsExtCommandLoader(AzCommandsLoader): def __init__(self, cli_ctx=None): from azure.cli.core.commands import CliCommandType webapps_custom = CliCommandType( operations_tmpl='azext_webapps.custom#{}') - super(WebappsCommandLoader, self).__init__(cli_ctx=cli_ctx, - custom_command_type=webapps_custom) + super(WebappsExtCommandLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=webapps_custom, min_profile="2017-03-10-profile") def load_command_table(self, _): with self.command_group('webapp') as g: @@ -26,7 +26,7 @@ def load_arguments(self, _): c.argument('name', options_list=['--name', '-n'], help='name of the new webapp') c.argument('dryrun', help="shows summary of the create operation instead of actually creating and deploying the app", - default=False) + default=False, action='store_true') -COMMAND_LOADER_CLS = WebappsCommandLoader +COMMAND_LOADER_CLS = WebappsExtCommandLoader diff --git a/src/webapps/azext_webapps/create_util.py b/src/webapps/azext_webapps/create_util.py index 99d5e9f1524..fdb85a4af39 100644 --- a/src/webapps/azext_webapps/create_util.py +++ b/src/webapps/azext_webapps/create_util.py @@ -50,7 +50,7 @@ def is_node_application(path): def get_node_runtime_version_toSet(): version_val = "8.0" # trunc_version = float(node_version[:3]) - # TODO: call the list_runtimes once there is an API that returs the supported versions + # TODO: call the list_runtimes once there is an API that returns the supported versions return version_val diff --git a/src/webapps/azext_webapps/custom.py b/src/webapps/azext_webapps/custom.py index d3e3d64bf4c..84881833a80 100644 --- a/src/webapps/azext_webapps/custom.py +++ b/src/webapps/azext_webapps/custom.py @@ -73,11 +73,11 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): node_version = data['version'] version_used_create = get_node_runtime_version_toSet() - # ResourceGroup: check if default RG is set + # Resource group: check if default RG is set default_rg = cmd.cli_ctx.config.get('defaults', 'group') if (default_rg and check_resource_group_supports_linux(cmd, default_rg, location)): rg = default_rg - rg_mssg = "[Using default ResourceGroup]" + rg_mssg = "[Using default Resource group]" else: rg_mssg = "" @@ -87,8 +87,8 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): dry_run_str = r""" { "name" : "%s", - "appServicePlan" : "%s", - "resourceGroup" : "%s", + "serverfarm" : "%s", + "resourcegroup" : "%s", "sku": "%s", "os": "%s", "location" : "%s", @@ -105,15 +105,16 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): Web app will be created with the below configuration, re-run command without the --dryrun flag to create & deploy a new app """) - return logger.warning(create_json) + logger.warning(create_json) + return # create RG if the RG doesn't already exist if not check_resource_group_exists(cmd, rg): - logger.warning("Creating ResourceGroup '%s' ...", rg) + logger.warning("Creating Resource group '%s' ...", rg) create_resource_group(cmd, rg, location) - logger.warning("ResourceGroup creation complete") + logger.warning("Resource group creation complete") else: - logger.warning("Resource Group '%s' already exists.", rg) + logger.warning("Resource group '%s' already exists.", rg) # create asp if not check_if_asp_exists(cmd, rg, asp): @@ -122,9 +123,9 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): 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) - logger.warning("AppServicePlan creation complete") + logger.warning("App service plan creation complete") else: - logger.warning("AppServicePlan '%s' already exists.", asp) + logger.warning("App service plan '%s' already exists.", asp) # create the Linux app logger.warning("Creating app '%s' ....", name) @@ -141,4 +142,5 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): 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) - return logger.warning("All done. %s", create_json) + logger.warning("All done. %s", create_json) + return None diff --git a/src/webapps/setup.py b/src/webapps/setup.py index f97d1bf9e06..8ac4d3722a1 100644 --- a/src/webapps/setup.py +++ b/src/webapps/setup.py @@ -8,7 +8,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = "0.0.1" +VERSION = "0.0.2" CLASSIFIERS = [ 'Development Status :: 4 - Beta', From 944664b4a8b53e31ea8d0ded3303a2b82dfda7d8 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Thu, 1 Feb 2018 15:13:24 -0800 Subject: [PATCH 04/10] adding return None --- src/webapps/azext_webapps/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webapps/azext_webapps/custom.py b/src/webapps/azext_webapps/custom.py index 84881833a80..48d243ecbcf 100644 --- a/src/webapps/azext_webapps/custom.py +++ b/src/webapps/azext_webapps/custom.py @@ -106,7 +106,7 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): re-run command without the --dryrun flag to create & deploy a new app """) logger.warning(create_json) - return + return None # create RG if the RG doesn't already exist if not check_resource_group_exists(cmd, rg): From 4135561077d25c623379bca6fae99c566b5dc0bb Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Thu, 1 Feb 2018 15:15:54 -0800 Subject: [PATCH 05/10] PYlint fixes --- src/webapps/azext_webapps/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/webapps/azext_webapps/__init__.py b/src/webapps/azext_webapps/__init__.py index 4b4951d8320..ced8ceb4bb7 100644 --- a/src/webapps/azext_webapps/__init__.py +++ b/src/webapps/azext_webapps/__init__.py @@ -13,8 +13,7 @@ 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") + super(WebappsExtCommandLoader, self).__init__(cli_ctx=cli_ctx, custom_command_type=webapps_custom, min_profile="2017-03-10-profile") def load_command_table(self, _): with self.command_group('webapp') as g: From e6c5c7fbcd390970ae5b85f4c9fa80e7ebcc1740 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Thu, 1 Feb 2018 15:21:22 -0800 Subject: [PATCH 06/10] diabling too-long pylint --- src/webapps/azext_webapps/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/webapps/azext_webapps/__init__.py b/src/webapps/azext_webapps/__init__.py index ced8ceb4bb7..5d7701fd597 100644 --- a/src/webapps/azext_webapps/__init__.py +++ b/src/webapps/azext_webapps/__init__.py @@ -6,6 +6,8 @@ from azure.cli.core import AzCommandsLoader import azext_webapps._help # pylint: disable=unused-import +# pylint: disable=line-too-long + class WebappsExtCommandLoader(AzCommandsLoader): From 18627f06c03bbeaf231f682d9ad336e23c7a3136 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Thu, 1 Feb 2018 15:50:21 -0800 Subject: [PATCH 07/10] FW: --- src/webapps/azext_webapps/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/webapps/azext_webapps/__init__.py b/src/webapps/azext_webapps/__init__.py index 5d7701fd597..f18e8ae9a52 100644 --- a/src/webapps/azext_webapps/__init__.py +++ b/src/webapps/azext_webapps/__init__.py @@ -4,9 +4,7 @@ # -------------------------------------------------------------------------------------------- from azure.cli.core import AzCommandsLoader -import azext_webapps._help # pylint: disable=unused-import - -# pylint: disable=line-too-long +import azext_webapps._help class WebappsExtCommandLoader(AzCommandsLoader): @@ -15,7 +13,9 @@ 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") + super(WebappsExtCommandLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=webapps_custom, + min_profile="2017-03-10-profile") def load_command_table(self, _): with self.command_group('webapp') as g: From c93166f71c9e0cf9129afbaa97bc9304b58915f7 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Thu, 1 Feb 2018 16:06:14 -0800 Subject: [PATCH 08/10] FW: Pylint --- src/webapps/azext_webapps/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/webapps/azext_webapps/__init__.py b/src/webapps/azext_webapps/__init__.py index f18e8ae9a52..6ed0b4123ab 100644 --- a/src/webapps/azext_webapps/__init__.py +++ b/src/webapps/azext_webapps/__init__.py @@ -4,6 +4,9 @@ # -------------------------------------------------------------------------------------------- from azure.cli.core import AzCommandsLoader + + # pylint: disable=unused-import + import azext_webapps._help @@ -13,8 +16,8 @@ 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, + super(WebappsExtCommandLoader, self).__init__(cli_ctx=cli_ctx, + custom_command_type=webapps_custom, min_profile="2017-03-10-profile") def load_command_table(self, _): @@ -26,7 +29,7 @@ def load_arguments(self, _): with self.argument_context('webapp quickstart') as c: c.argument('name', options_list=['--name', '-n'], help='name of the new webapp') c.argument('dryrun', - help="shows summary of the create operation instead of actually creating and deploying the app", + help="shows summary of the create and deploy operation instead of executing it", default=False, action='store_true') From 80a537361674887c31549f3b36f1a068c6aa776c Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Thu, 1 Feb 2018 16:35:37 -0800 Subject: [PATCH 09/10] FW: fixing an issue where passing location value was not working correctly --- src/webapps/azext_webapps/__init__.py | 2 +- src/webapps/azext_webapps/custom.py | 2 +- src/webapps/setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/webapps/azext_webapps/__init__.py b/src/webapps/azext_webapps/__init__.py index 6ed0b4123ab..f0f56153d7b 100644 --- a/src/webapps/azext_webapps/__init__.py +++ b/src/webapps/azext_webapps/__init__.py @@ -5,7 +5,7 @@ from azure.cli.core import AzCommandsLoader - # pylint: disable=unused-import +# pylint: disable=unused-import import azext_webapps._help diff --git a/src/webapps/azext_webapps/custom.py b/src/webapps/azext_webapps/custom.py index 48d243ecbcf..bab37d7e240 100644 --- a/src/webapps/azext_webapps/custom.py +++ b/src/webapps/azext_webapps/custom.py @@ -48,7 +48,7 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): location = available_locs[0] # Remove spaces from the location string, incase the GeoRegion string is used - loc_name = location.replace(" ", "") + loc_name = location.replace(" ", "") asp = "appsvc_asp_{}_{}".format(os_val, loc_name) rg = "appsvc_rg_{}_{}".format(os_val, loc_name) diff --git a/src/webapps/setup.py b/src/webapps/setup.py index 8ac4d3722a1..442cc71cf18 100644 --- a/src/webapps/setup.py +++ b/src/webapps/setup.py @@ -8,7 +8,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = "0.0.2" +VERSION = "0.0.3" CLASSIFIERS = [ 'Development Status :: 4 - Beta', From d6b21c7ab95f79225f3cb668429e59d16a1dfe79 Mon Sep 17 00:00:00 2001 From: Sisira Panchagnula Date: Thu, 1 Feb 2018 16:53:53 -0800 Subject: [PATCH 10/10] fet default was failing when no default was set --- src/webapps/azext_webapps/custom.py | 2 +- src/webapps/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/webapps/azext_webapps/custom.py b/src/webapps/azext_webapps/custom.py index bab37d7e240..02d2ba4b4ae 100644 --- a/src/webapps/azext_webapps/custom.py +++ b/src/webapps/azext_webapps/custom.py @@ -74,7 +74,7 @@ def create_deploy_webapp(cmd, name, location=None, dryrun=False): version_used_create = get_node_runtime_version_toSet() # Resource group: check if default RG is set - default_rg = cmd.cli_ctx.config.get('defaults', 'group') + 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 rg_mssg = "[Using default Resource group]" diff --git a/src/webapps/setup.py b/src/webapps/setup.py index 442cc71cf18..599f9fd3b43 100644 --- a/src/webapps/setup.py +++ b/src/webapps/setup.py @@ -8,7 +8,7 @@ from codecs import open from setuptools import setup, find_packages -VERSION = "0.0.3" +VERSION = "0.0.4" CLASSIFIERS = [ 'Development Status :: 4 - Beta',