From d0b5b4541d5b1b2f23bd902ab6dec572905f59d5 Mon Sep 17 00:00:00 2001 From: Roni Dover Date: Wed, 30 Mar 2016 11:42:40 +0300 Subject: [PATCH] update logger and update travis --- .travis.yml | 4 ++-- README.md | 24 +++++++++++++++++-- environment_scripts/env_setup/setup_script.py | 4 +++- .../env_teardown/teardown_script.py | 4 +++- .../context_based_logger_factory.py | 8 +++---- orchestration_service/orchestrator.py | 2 +- .../utilites/context_based_logger_factory.py | 6 ++--- .../common/wrappers/command_wrapper.py | 2 +- .../test_utilities/test_command_wrapper.py | 2 +- .../test_vcenter/test_vmomi_service.py | 2 -- vlan_service_scripts/connect/connect_all.py | 4 +++- 11 files changed, 43 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1416aa74..c5f9a424 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,8 @@ python: - "2.7" install: - - pip install -r package/requirements.txt - - pip install cloudshell-shell-core + - pip install -r package/requirements.txt --extra-index-url https://testpypi.python.org/pypi + - pip install cloudshell-shell-core --extra-index-url https://testpypi.python.org/pypi - pip install -r test_requirements.txt - pip install coveralls diff --git a/README.md b/README.md index f190287a..16df1d81 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,32 @@ [![Build Status](https://travis-ci.org/QualiSystems/vCenterShell.svg?branch=master)](https://travis-ci.org/QualiSystems/vCenterShell) [![Coverage Status](https://coveralls.io/repos/QualiSystems/vCenterShell/badge.svg?branch=develop&service=github)](https://coveralls.io/github/QualiSystems/vCenterShell?branch=develop) [![Code Climate](https://codeclimate.com/github/QualiSystems/vCenterShell/badges/gpa.svg)](https://codeclimate.com/github/QualiSystems/vCenterShell) [ ![Foo](https://qualisystems.getbadges.io/shield/company/qualisystems) ](https://getbadges.io) [![Stories in Ready](https://badge.waffle.io/QualiSystems/vCenterShell.svg?label=ready&title=Ready)](http://waffle.io/QualiSystems/vCenterShell) [![Join the chat at https://gitter.im/QualiSystems/vCenterShell](https://badges.gitter.im/QualiSystems/vCenterShell.svg)](https://gitter.im/QualiSystems/vCenterShell?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Analytics](https://ga-beacon.appspot.com/UA-72194260-1/QualiSystems/vCenterShell)](https://github.com/QualiSystems/vCenterShell/) -A lightweight CloudShell 'shell' that allows integrating with vCenter as an app deployment option. +A repository for projects providing out of the box capabilities within CloudShell to define VMWare vCenter instances in CloudShell and leverage vCenter's capabilities to deploy and connect apps in CloudShell sandboxes. -## Requirements +## Projects +* **Deployment Drivers** + + These projects extend CloudShell apps with new deployment types + * **deploy_from_image** + App deployment type driver for deploying from vCenter OVF images + * **deploy_from_template** + App deployment type driver for cloning from vCenter templates + + +* **package** + + The vCenter Python package hosted in [PyPi](https://pypi.python.org/). The package contains most of the logic relate + to working with the vCenter API. + +* **vcentershell_driver** + + The CloudShell driver for controlling vCenter via CloudShell. + +## Installation * [QualiSystems CloudShell 7.0](http://www.qualisystems.com/products/cloudshell/cloudshell-overview/) * [pyvmomi 6.0](https://github.com/vmware/pyvmomi) * [jsonpickle latest](https://jsonpickle.github.io/) + ## Getting Started 1. Download vCenterShell.zip from Releases page diff --git a/environment_scripts/env_setup/setup_script.py b/environment_scripts/env_setup/setup_script.py index 843b1b49..5a32f9dc 100644 --- a/environment_scripts/env_setup/setup_script.py +++ b/environment_scripts/env_setup/setup_script.py @@ -15,7 +15,9 @@ class EnvironmentSetup(object): def __init__(self): self.reservation_id = helpers.get_reservation_context_details().id - self.logger = qs_logger.get_qs_logger(name="CloudShell Sandbox Setup", reservation_id=self.reservation_id) + self.logger = qs_logger.get_qs_logger(log_file_prefix="CloudShell Sandbox Setup", + log_group=self.reservation_id, + log_category='Setup') @profileit(scriptName='Setup') def execute(self): diff --git a/environment_scripts/env_teardown/teardown_script.py b/environment_scripts/env_teardown/teardown_script.py index b691c98c..40e6d07a 100644 --- a/environment_scripts/env_teardown/teardown_script.py +++ b/environment_scripts/env_teardown/teardown_script.py @@ -12,7 +12,9 @@ class EnvironmentTeardown: def __init__(self): self.reservation_id = helpers.get_reservation_context_details().id - self.logger = qs_logger.get_qs_logger(name="CloudShell Sandbox Teardown", reservation_id=self.reservation_id) + self.logger = qs_logger.get_qs_logger(log_file_prefix="CloudShell Sandbox Teardown", + log_group=self.reservation_id, + log_category='Teardown') @profileit(scriptName="Teardown") def execute(self): diff --git a/orchestration_service/context_based_logger_factory.py b/orchestration_service/context_based_logger_factory.py index 10708068..ab85fece 100644 --- a/orchestration_service/context_based_logger_factory.py +++ b/orchestration_service/context_based_logger_factory.py @@ -10,7 +10,7 @@ def create_logger_for_context(self, logger_name, context): :param logger_name: :type logger_name: str :param context: - :return: + :return: logging.Logger """ if self._is_instance_of(context, 'AutoLoadCommandContext'): reservation_id = 'Autoload' @@ -23,9 +23,9 @@ def create_logger_for_context(self, logger_name, context): handler_name = context.remote_endpoints[0].name else: raise Exception(ContextBasedLoggerFactory.UNSUPPORTED_CONTEXT_PROVIDED, context) - logger = get_qs_logger(name=logger_name, - handler_name=handler_name, - reservation_id=reservation_id) + logger = get_qs_logger(log_file_prefix=handler_name, + log_group=reservation_id, + log_category=logger_name) return logger @staticmethod diff --git a/orchestration_service/orchestrator.py b/orchestration_service/orchestrator.py index 47b41296..038c673b 100644 --- a/orchestration_service/orchestrator.py +++ b/orchestration_service/orchestrator.py @@ -14,7 +14,7 @@ def __init__(self): def deploy(self, context): """ Deploys app from template - :type context: cloudshell.shell.core.driver_context.ResourceCommandContext + :type context: cloudshell.shell.core.context.ResourceCommandContext """ logger = self.context_based_logger_factory.create_logger_for_context( logger_name='DeployAppOrchestrationDriver', diff --git a/package/cloudshell/cp/vcenter/common/utilites/context_based_logger_factory.py b/package/cloudshell/cp/vcenter/common/utilites/context_based_logger_factory.py index 04b167e6..82b9da14 100644 --- a/package/cloudshell/cp/vcenter/common/utilites/context_based_logger_factory.py +++ b/package/cloudshell/cp/vcenter/common/utilites/context_based_logger_factory.py @@ -23,9 +23,9 @@ def create_logger_for_context(self, logger_name, context): handler_name = context.remote_endpoints[0].name else: raise Exception(ContextBasedLoggerFactory.UNSUPPORTED_CONTEXT_PROVIDED, context) - logger = get_qs_logger(name=logger_name, - handler_name=handler_name, - reservation_id=reservation_id) + logger = get_qs_logger(log_file_prefix=handler_name, + log_group=reservation_id, + log_category=logger_name) return logger @staticmethod diff --git a/package/cloudshell/cp/vcenter/common/wrappers/command_wrapper.py b/package/cloudshell/cp/vcenter/common/wrappers/command_wrapper.py index e46998de..5a536907 100644 --- a/package/cloudshell/cp/vcenter/common/wrappers/command_wrapper.py +++ b/package/cloudshell/cp/vcenter/common/wrappers/command_wrapper.py @@ -42,7 +42,7 @@ def execute_command_with_connection(self, context, command, *args): Note: session & vcenter_data_model objects will be injected dynamically to the command :param command: :param context: instance of ResourceCommandContext or AutoLoadCommandContext - :type context: cloudshell.shell.core.driver_context.ResourceCommandContext + :type context: cloudshell.shell.core.context.ResourceCommandContext :param args: """ diff --git a/package/cloudshell/tests/test_common/test_utilities/test_command_wrapper.py b/package/cloudshell/tests/test_common/test_utilities/test_command_wrapper.py index d23ffeef..489b87b8 100644 --- a/package/cloudshell/tests/test_common/test_utilities/test_command_wrapper.py +++ b/package/cloudshell/tests/test_common/test_utilities/test_command_wrapper.py @@ -1,5 +1,5 @@ from unittest import TestCase -from cloudshell.shell.core.driver_context import ResourceCommandContext, \ +from cloudshell.shell.core.context import ResourceCommandContext, \ ReservationContextDetails, ResourceContextDetails, ConnectivityContext from mock import Mock, create_autospec diff --git a/package/cloudshell/tests/test_common/test_vcenter/test_vmomi_service.py b/package/cloudshell/tests/test_common/test_vcenter/test_vmomi_service.py index db1369cd..2f993f7c 100644 --- a/package/cloudshell/tests/test_common/test_vcenter/test_vmomi_service.py +++ b/package/cloudshell/tests/test_common/test_vcenter/test_vmomi_service.py @@ -7,7 +7,6 @@ from pyVmomi import vim from cloudshell.cp.vcenter.common.vcenter.vmomi_service import pyVmomiService from cloudshell.tests.utils.testing_credentials import TestCredentials -logger = get_qs_logger() class TestVmomiService(unittest.TestCase): @@ -34,7 +33,6 @@ def integration_clone_vm_destory(self): now = datetime.now() res = pv_service.clone_vm(clone_params=params, logger=Mock()) - logger.debug('clone took: %s' % (str(datetime.now() - now))) '#assert' self.assertTrue(type(res.vm), vim.VirtualMachine) diff --git a/vlan_service_scripts/connect/connect_all.py b/vlan_service_scripts/connect/connect_all.py index ada29e0f..b96d4817 100644 --- a/vlan_service_scripts/connect/connect_all.py +++ b/vlan_service_scripts/connect/connect_all.py @@ -5,7 +5,9 @@ class ConnectAll: def __init__(self): self.reservation_id = helpers.get_reservation_context_details().id - self.logger = qs_logger.get_qs_logger(name="Connect All", reservation_id=self.reservation_id) + self.logger = qs_logger.get_qs_logger(log_file_prefix='Connect_All', + log_group=self.reservation_id, + log_category="Connect All") def execute(self): api = helpers.get_api_session()