Skip to content

Commit

Permalink
Merge pull request #815 from QualiSystems/release/v1.4.0
Browse files Browse the repository at this point in the history
Release/v1.4.0
  • Loading branch information
alexazarh authored Nov 6, 2016
2 parents 184ed8e + a2a9545 commit 7d9ef87
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion deployment_drivers/deploy_clone_from_vm/drivermetadata.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Driver Description="Deploy App From VM" MainClass="driver.DeployCloneFromVMDriver" Name="Deploy Clone From VM Driver" Version="1.3.0">
<Driver Description="Deploy App From VM" MainClass="driver.DeployCloneFromVMDriver" Name="Deploy Clone From VM Driver" Version="1.4.0">
<Layout>
<Category Name="App Management">
<Command Description="" DisplayName="Deploy" Name="Deploy" Tags="allow_shared" />
Expand Down
2 changes: 1 addition & 1 deletion deployment_drivers/deploy_clone_from_vm/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jsonpickle==0.9.3
cloudshell-automation-api>=7.1.0.0,<7.2.0.0
cloudshell-cp-vcenter>=1.3.0,<1.4.0
cloudshell-cp-vcenter>=1.4.0,<1.5.0
cloudshell-shell-core>=2.0.0,<2.1.0
2 changes: 1 addition & 1 deletion deployment_drivers/deploy_from_image/drivermetadata.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Driver Description="Deploy App From Image" MainClass="driver.DeployFromImage" Name="VM Deployment From Image" Version="1.3.0">
<Driver Description="Deploy App From Image" MainClass="driver.DeployFromImage" Name="VM Deployment From Image" Version="1.4.0">
<Layout>
<Category Name="App Management">
<Command Description="" DisplayName="Deploy" Name="Deploy" Tags="allow_shared" />
Expand Down
2 changes: 1 addition & 1 deletion deployment_drivers/deploy_from_image/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jsonpickle==0.9.3
cloudshell-automation-api>=7.1.0.0,<7.2.0.0
cloudshell-cp-vcenter>=1.3.0,<1.4.0
cloudshell-cp-vcenter>=1.4.0,<1.5.0
cloudshell-shell-core>=2.0.0,<2.1.0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Driver Description="Deploy App From VM" MainClass="driver.DeployCloneFromVMDriver" Name="Deploy Clone From VM Driver" Version="1.3.0">
<Driver Description="Deploy App From VM" MainClass="driver.DeployCloneFromVMDriver" Name="Deploy Clone From VM Driver" Version="1.4.0">
<Layout>
<Category Name="App Management">
<Command Description="" DisplayName="Deploy" Name="Deploy" Tags="allow_shared" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jsonpickle==0.9.3
cloudshell-automation-api>=7.1.0.0,<7.2.0.0
cloudshell-cp-vcenter>=1.3.0,<1.4.0
cloudshell-cp-vcenter>=1.4.0,<1.5.0
cloudshell-shell-core>=2.0.0,<2.1.0
2 changes: 1 addition & 1 deletion deployment_drivers/deploy_from_template/drivermetadata.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Driver Description="Deploy App From Template" MainClass="driver.DeployFromTemplateDriver" Name="VM Deployment From Template" Version="1.3.0">
<Driver Description="Deploy App From Template" MainClass="driver.DeployFromTemplateDriver" Name="VM Deployment From Template" Version="1.4.0">
<Layout>
<Category Name="App Management">
<Command Description="" DisplayName="Deploy" Name="Deploy" Tags="allow_shared" />
Expand Down
2 changes: 1 addition & 1 deletion deployment_drivers/deploy_from_template/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jsonpickle==0.9.3
cloudshell-automation-api>=7.1.0.0,<7.2.0.0
cloudshell-cp-vcenter>=1.3.0,<1.4.0
cloudshell-cp-vcenter>=1.4.0,<1.5.0
cloudshell-shell-core>=2.0.0,<2.1.0
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import traceback
from multiprocessing.pool import ThreadPool

import jsonpickle
Expand Down Expand Up @@ -345,7 +346,8 @@ def _remove_vlan(self, action_mappings, si, vm_uuid, logger):
results.append(action_result)
final_res = self._consolidate_duplicate_results(results)
except Exception as e:
self.logger.error('Exception raised while disconnecting vm({0}) with exception: {1}'.format(vm_uuid, e))
self.logger.error('Exception raised while disconnecting vm({0}) with exception: {1}'
.format(vm_uuid, traceback.format_exc()))
for mode, actions in mode_to_actions.items():
for action in actions:
error_result = self._create_error_action_res(action, e)
Expand Down
2 changes: 2 additions & 0 deletions package/cloudshell/cp/vcenter/common/vcenter/task_waiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def wait_for_task(self, task, logger, action_name='job', hide_result=False):
multi_msg = ', '.join([err.message for err in task.info.error.faultMessage])

logger.info(multi_msg)
logger.info("task info dump: {0}".format(task.info))

raise Exception(multi_msg)

return task.info.result
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
from cloudshell.cp.vcenter.common.utilites.common_utils import str2bool
from cloudshell.cp.vcenter.common.vcenter.task_waiter import SynchronousTaskWaiter


class VCenterAuthError (Exception):
def __init__(self, original_exception):
super(VCenterAuthError, self).__init__(original_exception.message)
self.original_exception = original_exception


class pyVmomiService:
# region consts
ChildEntity = 'childEntity'
Expand Down Expand Up @@ -61,7 +68,7 @@ def connect(self, address, user, password, port=443):
si = self.pyvmomi_connect(host=address, user=user, pwd=password, port=port)
return si
except vim.fault.InvalidLogin as e:
raise ValueError(e.msg)
raise VCenterAuthError(e.msg)
except IOError as e:
# logger.info("I/O error({0}): {1}".format(e.errno, e.strerror))
raise ValueError('Cannot connect to vCenter, please check that the address is valid')
Expand Down
34 changes: 26 additions & 8 deletions package/cloudshell/cp/vcenter/common/wrappers/command_wrapper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import inspect
from threading import Lock

from retrying import retry

from cloudshell.cp.vcenter.common.model_factory import ResourceModelParser
from cloudshell.cp.vcenter.common.cloud_shell.driver_helper import CloudshellDriverHelper
from cloudshell.cp.vcenter.common.vcenter.vmomi_service import pyVmomiService
from cloudshell.cp.vcenter.common.vcenter.vmomi_service import pyVmomiService, VCenterAuthError
from cloudshell.cp.vcenter.models.VMwarevCenterResourceModel import VMwarevCenterResourceModel

DISCONNCTING_VCENERT = 'disconnecting from vcenter: {0}'
Expand All @@ -21,6 +25,10 @@
LOG_FORMAT = 'action:{0} command_name:{1}'


def retry_if_auth_error(ex):
return isinstance(ex, VCenterAuthError)


class CommandWrapper:
def __init__(self, pv_service, cloud_shell_helper, resource_model_parser, context_based_logger_factory):
"""
Expand All @@ -36,7 +44,11 @@ def __init__(self, pv_service, cloud_shell_helper, resource_model_parser, contex
self.cs_helper = cloud_shell_helper # type: CloudshellDriverHelper
self.resource_model_parser = resource_model_parser # type: ResourceModelParser
self.context_based_logger_factory = context_based_logger_factory # type ContextBasedLoggerFactory
# add lock
self.lock = Lock()
self.si = None

@retry(stop_max_attempt_number=3, wait_fixed=2000, retry_on_exception=retry_if_auth_error)
def execute_command_with_connection(self, context, command, *args):
"""
Note: session & vcenter_data_model objects will be injected dynamically to the command
Expand Down Expand Up @@ -80,10 +92,7 @@ def execute_command_with_connection(self, context, command, *args):
connection_details.username,
connection_details.port))

si = self.pv_service.connect(connection_details.host,
connection_details.username,
connection_details.password,
connection_details.port)
si = self.get_py_service_connection(connection_details,logger)
if si:
logger.info(CONNECTED_TO_CENTER.format(connection_details.host))
command_args.append(si)
Expand All @@ -110,11 +119,20 @@ def execute_command_with_connection(self, context, command, *args):
logger.exception(e)
raise
finally:
if si:
logger.info(DISCONNCTING_VCENERT.format(connection_details.host))
self.pv_service.disconnect(si)
logger.info(LOG_FORMAT.format(END, command_name))

def get_py_service_connection(self, connection_details, logger):
logger.info("get_py_service_connection")
if self.si is None:
with self.lock:
if self.si is None:
logger.info("Creating a new connection.")
self.si = self.pv_service.connect(connection_details.host,
connection_details.username,
connection_details.password,
connection_details.port)
return self.si

@staticmethod
def _get_domain(context):
# noinspection PyBroadException
Expand Down
3 changes: 2 additions & 1 deletion package/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ cloudshell-automation-api>=7.1.0.0,<7.2.0.0
cloudshell-core>=2.0.0,<2.1.0
pyvmomi==6.0.0
jsonpickle==0.9.3
enum==0.4.6
enum==0.4.6
retrying==1.3.3
2 changes: 1 addition & 1 deletion package/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.4.0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cloudshell-automation-api>=7.1.0.0,<7.2.0.0
cloudshell-core>=2.0.0,<2.1.0
cloudshell-cp-vcenter>=1.3.0,<1.4.0
cloudshell-cp-vcenter>=1.4.0,<1.5.0
cloudshell-shell-core>=2.3.0,<2.4.0
2 changes: 1 addition & 1 deletion vcentershell_driver/drivermetadata.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Driver Description="this driver manage all the commands that runs at the vcenter context" MainClass="driver.VCenterShellDriver" Name="VCenter Driver" Version="1.3.0">
<Driver Description="this driver manage all the commands that runs at the vcenter context" MainClass="driver.VCenterShellDriver" Name="VCenter Driver" Version="1.4.0">
<Layout>
<Category Name="Deployment">
<Command Description="" DisplayName="Deploy From Template" Name="deploy_from_template" Tags="allow_unreserved" />
Expand Down
2 changes: 1 addition & 1 deletion vcentershell_driver/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cloudshell-shell-core>=2.0.0,<2.1.0
cloudshell-cp-vcenter>=1.3.0,<1.4.0
cloudshell-cp-vcenter>=1.4.0,<1.5.0
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.0
1.4.0

0 comments on commit 7d9ef87

Please sign in to comment.