Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge changes made in master 1.1 into dev #18

Merged
merged 4 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions sandbox_scripts/QualiEnvironmentUtils/Resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
from cloudshell.api.cloudshell_api import *
from cloudshell.api.common_cloudshell_api import *
from QualiUtils import *
from cloudshell.shell.core.interfaces.save_restore import OrchestrationSavedArtifactInfo
from cloudshell.shell.core.interfaces.save_restore import OrchestrationRestoreRules
from cloudshell.shell.core.interfaces.save_restore import OrchestrationSavedArtifact
from cloudshell.shell.core.interfaces.save_restore import OrchestrationSaveResult

import datetime
import json
Expand Down
16 changes: 8 additions & 8 deletions sandbox_scripts/environment/savesnapshot/SaveSnapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ def execute(self):
try:

username = helpers.get_reservation_context_details().owner_user
if sandbox.get_storage_server_resource():
snapshot_name = sandbox.Blueprint_name+"_"+username+"_"+ os.environ['name']
sandbox.save_sandbox_as_blueprint(snapshot_name)

snapshot_name = sandbox.Blueprint_name+"_"+username+"_"+ os.environ['name']
# replace spaces with _ in the snapshot's name
snapshot_name = snapshot_name.replace(' ', '_')

sandbox.save_sandbox_as_blueprint(snapshot_name)


# replace spaces with _ in the snapshot's name
snapshot_name = snapshot_name.replace(' ', '_')

saveNRestoreTool.save_config(snapshot_name=snapshot_name, config_type='running',
saveNRestoreTool.save_config(snapshot_name=snapshot_name, config_type='running',
ignore_models=['Generic TFTP server', 'Config Set Pool','Generic FTP server',
'netscout switch 3912'])
else:
sandbox.report_error("There is no storage resource (e.g. FTP) available in the reservation",True,True)

except QualiError as qe:
self.logger.error("Save snapshot failed. " + str(qe))
Expand Down
45 changes: 22 additions & 23 deletions sandbox_scripts/environment/setup/setup_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,31 @@ def execute(self):
sandbox = SandboxBase(self.reservation_id, self.logger)
saveNRestoreTool = NetworkingSaveRestore(sandbox)

api = helpers.get_api_session()

api.WriteMessageToReservationOutput(reservationId=self.reservation_id,
message='Beginning resources config load')

sandbox.report_info('Beginning resources config load')

try:
sandbox.clear_all_resources_live_status()

# Get the config set name from the orchestration's params
config_set_name = ''
try:
config_set_name = os.environ['Set Name']
except:
pass
ignore_models=['Generic TFTP server', 'Config Set Pool','Generic FTP server','netscout switch 3912']

if saveNRestoreTool.get_storage_client():
if saveNRestoreTool.is_snapshot():
saveNRestoreTool.load_config(config_stage='Snapshots', config_type='Running',
ignore_models=ignore_models)

else:
saveNRestoreTool.load_config(config_stage='Gold', config_type='Running',
ignore_models=ignore_models,
config_set_name=config_set_name)
if sandbox.get_storage_server_resource():
# Get the config set name from the orchestration's params
config_set_name = ''
try:
config_set_name = os.environ['Set Name']
except:
pass
ignore_models=['Generic TFTP server', 'Config Set Pool','Generic FTP server','netscout switch 3912']

if saveNRestoreTool.get_storage_client():
if saveNRestoreTool.is_snapshot():
saveNRestoreTool.load_config(config_stage='Snapshots', config_type='Running',
ignore_models=ignore_models)

else:
saveNRestoreTool.load_config(config_stage='Gold', config_type='Running',
ignore_models=ignore_models,
config_set_name=config_set_name)
else:
sandbox.report_info("Skipping load configuration. No storage resource associated with the blueprint ",
write_to_output_window=True)

# power on Vms that might be powered off because of the snapshot configuration
sandbox.power_on_vms()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_flow_ok_with_snapshots(self, mock_save, mock_sandboxbase, mock_api_sess
#mock_api_session.return_value.GetActiveTopologyNames = Mock(return_value = tli)
mock_save.return_value.is_snapshot.return_value = True
self.setup_script.execute()
mock_api_session.return_value.WriteMessageToReservationOutput.assert_called_with(message='Beginning resources config load', reservationId=u'5487c6ce-d0b3-43e9-8ee7-e27af8406905')
mock_sandboxbase.return_value.report_info.assert_called_with('Beginning resources config load')
mock_sandboxbase.return_value.clear_all_resources_live_status.assert_called_with()
mock_save.return_value.load_config.assert_called_with(config_stage='Snapshots', config_type='Running', ignore_models=['Generic TFTP server', 'Config Set Pool', 'Generic FTP server', 'netscout switch 3912'])
mock_sandboxbase.return_value.power_on_vms.assert_called_with()
Expand All @@ -56,7 +56,7 @@ def test_flow_ok_with_gold(self, mock_save, mock_sandboxbase, mock_api_session):
#mock_api_session.return_value.GetActiveTopologyNames = Mock(return_value = tli)
mock_save.return_value.is_snapshot.return_value = False
self.setup_script.execute()
mock_api_session.return_value.WriteMessageToReservationOutput.assert_called_with(message='Beginning resources config load', reservationId=u'5487c6ce-d0b3-43e9-8ee7-e27af8406905')
mock_sandboxbase.return_value.report_info.assert_called_with('Beginning resources config load')
mock_sandboxbase.return_value.clear_all_resources_live_status.assert_called_with()
mock_save.return_value.load_config.assert_called_with(config_set_name='', config_stage='Gold', config_type='Running', ignore_models=['Generic TFTP server', 'Config Set Pool', 'Generic FTP server', 'netscout switch 3912'])
mock_sandboxbase.return_value.power_on_vms.assert_called_with()
Expand Down
12 changes: 4 additions & 8 deletions sandbox_scripts/environment/teardown/teardown_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,17 @@ def execute(self):
sandbox = SandboxBase(self.reservation_id, self.logger)
saveNRestoreTool = NetworkingSaveRestore(sandbox)

api = helpers.get_api_session()

api.WriteMessageToReservationOutput(reservationId=self.reservation_id,
message='Beginning resources config load')


sandbox.report_info("Beginning resources config load")
sandbox.clear_all_resources_live_status()
try:

if saveNRestoreTool.get_storage_client():
ignore_models = ['Generic TFTP server', 'Config Set Pool', 'Generic FTP server', 'netscout switch 3912',
'OnPATH Switch 3903', 'Ixia Traffic generator']
saveNRestoreTool.load_config(config_stage='Base', config_type='Running',
ignore_models=ignore_models, remove_temp_files=True, in_teardown_mode=True)

else:
sandbox.report_info("Skipping load configuration. No storage resource associated with the blueprint ",
write_to_output_window=True)

except QualiError as qe:
self.logger.error("Teardown failed. " + str(qe))
Expand Down
4 changes: 2 additions & 2 deletions sandbox_scripts/helpers/Networking/NetworkingSaveNRestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def __init__(self, sandbox):
self.config_files_root = self.storage_client.get_configs_root()
else:
if self.is_resources_in_reservation_to_restore(ignore_models = None):
self.sandbox.report_error("Failed to find a storage server resource (e.g. tftp) in the sandbox. ", raise_error=True,
write_to_output_window=True)
self.sandbox.report_info("Failed to find a storage server resource (e.g. tftp) in the sandbox. ",
write_to_output_window=False)

# ----------------------------------
# load_network_config(ResourceName,config_type, RestoreMethod=Override)
Expand Down