Skip to content

Commit

Permalink
Merge pull request #795 from QualiSystems/release/v1.3.1
Browse files Browse the repository at this point in the history
Release/v1.3.1
  • Loading branch information
alexazarh committed Sep 15, 2016
2 parents 3173974 + c52edc8 commit cdca89e
Show file tree
Hide file tree
Showing 32 changed files with 405 additions and 37 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ deployment

#Misc
.imdone
develop.cmd
develop.cmd
*.zip
debug.xml
debug_info.txt
42 changes: 21 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
after_success: coveralls
env:
- CLOUD_SHELL_SHELL_CORE=1
- CLOUD_SHELL_SHELL_CORE=2
install:
- pip install -r external_requirements.txt
- pip install -r test_requirements.txt
- pip install "cloudshell-core>=2.0.0,<2.1.0" --extra-index-url https://testpypi.python.org/simple
- chmod 777 ./cloudshell_shell_core_install.sh
- ./cloudshell_shell_core_install.sh
- pip install "cloudshell-automation-api>=7.1.0.0,<7.2.0.0" --extra-index-url https://testpypi.python.org/simple
language: python
python:
- "2.7"

install:
- pip install -r external_requirements.txt
- pip install -r test_requirements.txt
- pip install "cloudshell-core>=2.0.0,<2.1.0" --extra-index-url https://testpypi.python.org/simple
- pip install "cloudshell-shell-core>=2.0.0,<2.1.0" --extra-index-url https://testpypi.python.org/simple
- pip install "cloudshell-automation-api>=7.1.0.0,<7.2.0.0" --extra-index-url https://testpypi.python.org/simple

script:
- pushd package
- python setup.py develop
- popd
- python runtests.py --with-coverage --cover-package=package --exclude-dir=integration

after_success:
coveralls

notifications:
webhools: https://qualisystems.getbadges.io/api/app/webhook/63350e33-4119-49c3-8127-075aaa022926
notifications:
webhools: "https://qualisystems.getbadges.io/api/app/webhook/63350e33-4119-49c3-8127-075aaa022926"
python:
- "2.7"
script:
- pushd package
- python setup.py develop
- popd
- chmod 777 ./run_static_or_vcenter_tests.sh
- ./run_static_or_vcenter_tests.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![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)
[![PyPI](https://img.shields.io/pypi/v/cloudshell-cp-vcenter.svg?maxAge=2592000)](https://pypi.python.org/pypi/cloudshell-cp-vcenter/) [![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)
[![Dependency Status](https://dependencyci.com/github/QualiSystems/vCenterShell/badge)](https://dependencyci.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/)

Expand Down
7 changes: 7 additions & 0 deletions cloudshell_shell_core_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
if [ "${CLOUD_SHELL_SHELL_CORE}" -eq 1 ]
then
pip install "cloudshell-shell-core>=2.0.0,<2.1.0" --extra-index-url https://testpypi.python.org/simple
else
pip install "cloudshell-shell-core>=2.4.0,<2.5.0" --extra-index-url https://testpypi.python.org/simple
fi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import time
from datetime import date
from datetime import datetime, date
import jsonpickle
from cloudshell.cp.vcenter.models.OrchestrationSaveResult import OrchestrationSaveResult
from cloudshell.cp.vcenter.models.OrchestrationSavedArtifactsInfo import OrchestrationSavedArtifactsInfo
Expand Down Expand Up @@ -324,7 +324,8 @@ def refresh_ip(self, context, cancellation_context, ports):
self.refresh_ip_command.refresh_ip,
resource_details.vm_uuid,
resource_details.fullname,
cancellation_context)
cancellation_context,
context.remote_endpoints[0].app_context.app_request_json)
return set_command_result(result=res, unpicklable=False)

# remote command
Expand Down Expand Up @@ -454,7 +455,7 @@ def orchestration_save(self, context, mode="shallow", custom_params=None):
:rtype: SavedResults
"""
resource_details = self._parse_remote_model(context)
created_date = date.today()
created_date = datetime.now()
snapshot_name = created_date.strftime('%y_%m_%d %H_%M_%S_%f')
created_snapshot_path = self.save_snapshot(context=context, snapshot_name=snapshot_name)

Expand Down
13 changes: 9 additions & 4 deletions package/cloudshell/cp/vcenter/commands/refresh_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ def __init__(self, pyvmomi_service, resource_model_parser, ip_manager):
self.resource_model_parser = resource_model_parser
self.ip_manager = ip_manager

def refresh_ip(self, si, logger, session, vcenter_data_model, vm_uuid, resource_name, cancellation_context):
def _do_not_run_on_static_vm(self, app_request_json):
if app_request_json == '' or app_request_json is None:
raise ValueError('This command cannot be executed on a Static VM.')

def refresh_ip(self, si, logger, session, vcenter_data_model, vm_uuid, resource_name, cancellation_context,app_request_json):
"""
Refreshes IP address of virtual machine and updates Address property on the resource
Expand All @@ -27,7 +31,10 @@ def refresh_ip(self, si, logger, session, vcenter_data_model, vm_uuid, resource_
:param VMwarevCenterResourceModel vcenter_data_model: the vcenter data model attributes
:param cancellation_context:
"""
default_network = VMLocation.combine([vcenter_data_model.default_datacenter, vcenter_data_model.holding_network])
self._do_not_run_on_static_vm(app_request_json=app_request_json)

default_network = VMLocation.combine(
[vcenter_data_model.default_datacenter, vcenter_data_model.holding_network])

resource = session.GetResourceDetails(resource_name)

Expand Down Expand Up @@ -79,5 +86,3 @@ def _get_custom_param(resource, custom_param_name):
if custom_param_values:
return custom_param_values[0]
return None


2 changes: 1 addition & 1 deletion package/cloudshell/cp/vcenter/commands/save_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ def _verify_snapshot_uniquness(snapshot_path_to_be_created, vm):
def _get_snapshot_name_to_be_created(snapshot_name, vm):
current_snapshot_name = SnapshotRetriever.get_current_snapshot_name(vm)
if not current_snapshot_name:
return ''
return snapshot_name
return SnapshotRetriever.combine(current_snapshot_name, snapshot_name)
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import TestCase
from freezegun import freeze_time

import jsonpickle
from cloudshell.api.cloudshell_api import ResourceInfo
Expand Down Expand Up @@ -36,6 +37,8 @@ def setUp(self):
remote_resource.uuid = 'this is full uuis of the remote resource'
self.connection_details = Mock()
self.context.resource = self.resource
self.context.resource.app_context = Mock()
self.context.remote_endpoints = Mock()
self.context.remote_endpoints = [self.resource]
self.command_orchestrator = CommandOrchestrator()
self.command_orchestrator.command_wrapper.execute_command_with_connection = Mock(return_value=True)
Expand Down Expand Up @@ -131,7 +134,7 @@ def test_get_snapshots(self):
self.command_orchestrator.get_snapshots(self.context)
self.assertTrue(self.command_orchestrator.command_wrapper.execute_command_with_connection.called)

def test_orchestration_save(self):
def test_orchestration_save_double_quotes_in_snapshot_name_should_be_stripped(self):
# Arrange
with patch(SAVE_SNAPSHOT) as save_snapshot_mock:
save_snapshot_mock.return_value = '"new_snapshot"'
Expand Down Expand Up @@ -159,6 +162,30 @@ def test_orchestration_save(self):
self.assertEqual(saved_result_dict['saved_artifacts_info']['resource_name'], 'vcenter')
self.assertIsNotNone(saved_result_dict['saved_artifacts_info']['created_date'])

@freeze_time("1984-12-31 11:12:13.4567")
def test_orchestration_save_snapshot_name_should_contain_full_datetime(self):
# Arrange
with patch(SAVE_SNAPSHOT) as save_snapshot_mock:
save_snapshot_mock.return_value = '"new_snapshot"'

remote_command_context = create_autospec(ResourceRemoteCommandContext)
remote_command_context.resource = create_autospec(ResourceContextDetails)
remote_command_context.resource.fullname = 'vcenter'
endpoint = create_autospec(ResourceContextDetails)
endpoint.fullname = 'vm_111'
endpoint.app_context = create_autospec(AppContext)
endpoint.app_context.deployed_app_json = '{"vmdetails": {"uid": "vm_uuid1"}}'
remote_command_context.remote_endpoints = [endpoint]

# Act
CommandOrchestrator().orchestration_save(context=remote_command_context,
mode='shallow',
custom_params=None)

# Assert
args, kwargs = save_snapshot_mock.call_args
self.assertEqual(kwargs['snapshot_name'], "84_12_31 11_12_13_456700")

def test_orchestration_restore(self):
# Arrange
with patch(RESTORE_SNAPSHOT) as mock_restore_snapshot:
Expand Down
19 changes: 14 additions & 5 deletions package/cloudshell/tests/test_commands/test_refresh_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class TestRefreshIpCommand(TestCase):

def test_refresh_ip(self):
nic1 = Mock()
nic1.network = 'A Network'
Expand Down Expand Up @@ -53,11 +52,12 @@ def test_refresh_ip(self):
# Act
refresh_ip_command.refresh_ip(si=si,
session=session,
vcenter_data_model= center_resource_model,
vcenter_data_model=center_resource_model,
vm_uuid='machine1',
resource_name='default_network',
cancellation_context=cancellation_context,
logger=Mock())
logger=Mock(),
app_request_json=Mock())

# Assert
self.assertTrue(session.UpdateResourceAddress.called_with('machine1', '192.168.1.1'))
Expand Down Expand Up @@ -119,7 +119,8 @@ def test_refresh_ip_choose_ipv4(self):
vm_uuid='machine1',
resource_name='default_network',
cancellation_context=cancellation_context,
logger=Mock())
logger=Mock(),
app_request_json=Mock())

# Assert
self.assertTrue(session.UpdateResourceAddress.called_with('machine1', '192.168.1.1'))
Expand Down Expand Up @@ -173,7 +174,15 @@ def test_refresh_ip_choose_ip_by_regex(self):
vm_uuid='machine1',
resource_name='default_network',
cancellation_context=cancellation_context,
logger=Mock())
logger=Mock(),
app_request_json=Mock())

# Assert
self.assertTrue(session.UpdateResourceAddress.called_with('machine1', '192.168.1.1'))

def test_refresh_ip_should_fail_static_vm(self):
# Act
refresh_ip_command = RefreshIpCommand(Mock(), Mock(), Mock())
# assert
self.assertRaises(ValueError, refresh_ip_command.refresh_ip, Mock(), Mock(), Mock(), Mock(), Mock(), Mock(),
Mock(), None)
9 changes: 9 additions & 0 deletions run_static_or_vcenter_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
if [ "${CLOUD_SHELL_SHELL_CORE}" -eq 1 ]
then
echo "Running vCenter Tests"
python runtests.py --with-coverage --cover-package=package --exclude-dir=integration
else
echo "Running static VM Tests"
python runtestsStaticVM.py --with-coverage --cover-package=package --exclude-dir=integration
fi
7 changes: 7 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import re
import nose
import nose.config
import sys
from nose.plugins.manager import DefaultPluginManager
c = nose.config.Config()
c.plugins=DefaultPluginManager()
c.srcDirs = ['package']

c.ignoreFiles.append(re.compile(r'^vm_autoload_driver\.py$'))
c.ignoreFiles.append(re.compile(r'^test_get_inventory\.py$'))



if not nose.run(config=c):
sys.exit(1)
9 changes: 9 additions & 0 deletions runtestsStaticVM.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import nose
import nose.config
import sys
from nose.plugins.manager import DefaultPluginManager
c = nose.config.Config()
c.plugins=DefaultPluginManager()
c.srcDirs = ['static_vm_package']
if not nose.run(config=c):
sys.exit(1)
4 changes: 4 additions & 0 deletions static_vm_package/Pack.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
python -m pip install qpm --no-cache-dir --upgrade
python -m qpm pack --package_name VCenterAutoloadStaticVMDriver

4 changes: 4 additions & 0 deletions static_vm_package/PackInstall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@echo off
python -m pip install qpm --no-cache-dir --upgrade
python -m qpm pack --package_name VCenterAutoloadStaticVMDriver
python -m qpm install --package_name VCenterAutoloadStaticVMDriver
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Driver Description="Deploy App" MainClass="vm_autoload_driver.DeployAppOrchestrationDriver" Name="vCenter Static VM Autoload" Version="1.0.0">
</Driver>
Original file line number Diff line number Diff line change
@@ -0,0 +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-shell-core>=2.4.0,<2.5.0
Loading

0 comments on commit cdca89e

Please sign in to comment.