Skip to content

Commit

Permalink
Few messages cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
kalsky committed Apr 26, 2017
1 parent c431b4b commit c6176bd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions sandbox_scripts/QualiEnvironmentUtils/ConfigPoolManager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# coding=utf-8
from sandbox_scripts.QualiEnvironmentUtils.Sandbox import *
from sandbox_scripts.QualiEnvironmentUtils.Sandbox import SandboxBase
from sandbox_scripts.QualiEnvironmentUtils.Resource import ResourceBase
from sandbox_scripts.QualiEnvironmentUtils.QualiUtils import QualiError
import re


Expand Down Expand Up @@ -63,9 +65,7 @@ def pool_data_to_dict(self):
for resource_from_pool in self.pool_resource.details.ChildResources:
split_name = resource_from_pool.Name.split('/')
name_of_resource_from_pool = split_name[len(split_name)-1]
#resource_attributes_dict = dict()
for attribute in resource_from_pool.ResourceAttributes:
resource_dict_key = str('{ConfigPool:' + name_of_resource_from_pool + ':' + attribute.Name + '}').lower()
#resource_attributes_dict[resource_dict_key] = attribute.Value
pool_data_dict[resource_dict_key] = attribute.Value
return pool_data_dict
11 changes: 5 additions & 6 deletions sandbox_scripts/QualiEnvironmentUtils/Sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ def is_apps_in_reservation(self):
apps = details.ReservationDescription.App

if not apps or (len(apps) == 1 and not apps[0].Name):
self.report_info("No apps found in reservation {0}".format(self.reservation_id))
self.api_session.WriteMessageToReservationOutput(reservationId=self.reservation_id,
message='No apps in reservation')
self.report_info(message='No apps in reservation',
log_message="No apps found in reservation {0}".format(self.reservation_id),
write_to_output_window=True)
return False

return True
Expand All @@ -411,9 +411,8 @@ def power_on_vms(self, write_to_output=True):
if resource.is_app():
deployed_app_name = resource.name
if write_to_output:
self.api_session.WriteMessageToReservationOutput(reservationId=self.id,
message='Power on Apps again')
write_to_output = False # to prevent more prints
self.report_info(message='Power on Apps again', write_to_output_window=True)
write_to_output = False # to prevent more prints

self.api_session.ExecuteResourceConnectedCommand(self.id, deployed_app_name, "PowerOn", "power")

Expand Down
16 changes: 8 additions & 8 deletions sandbox_scripts/environment/setup/setup_VM.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@ def _power_on_refresh_ip(self, lock, message_status, resource):
try:
self._power_on(deployed_app_name, power_on, lock, message_status)
except Exception as exc:
self.logger.error("Error powering on deployed app {0} in reservation {1}. Error: {2}"
self.logger.error("Error powering on deployed app '{0}' in reservation '{1}'. Error: {2}"
.format(deployed_app_name, self.reservation_id, str(exc)))
return False, "Error powering on deployed app {0}".format(deployed_app_name)
return False, "Error powering on deployed app '{0}'".format(deployed_app_name)

try:
if wait_for_ip.lower() == "true":
self._wait_for_ip(deployed_app_name, lock, message_status)
else:
self.logger.info("Wait For IP is off for deployed app {0} in reservation {1}"
self.logger.info("Wait For IP is off for deployed app '{0}' in reservation '{1}'"
.format(deployed_app_name, self.reservation_id))
except Exception as exc:
self.logger.error("Error refreshing IP on deployed app {0} in reservation {1}. Error: {2}"
self.logger.error("Error refreshing IP on deployed app '{0}' in reservation '{1}'. Error: {2}"
.format(deployed_app_name, self.reservation_id, str(exc)))
return False, "Error refreshing IP deployed app {0}. Error: {1}".format(deployed_app_name, exc.message)
return False, "Error refreshing IP deployed app '{0}'. Error: {1}".format(deployed_app_name, exc.message)

return True, ""

Expand All @@ -113,7 +113,7 @@ def _wait_for_ip(self, deployed_app_name, lock, message_status):
self.sandbox.report_info(message='Waiting for apps IP addresses, this may take a while...',
write_to_output_window=True)

self.logger.info("Executing 'Refresh IP' on deployed app {0} in reservation {1}"
self.logger.info("Executing 'Refresh IP' on deployed app '{0}' in reservation '{1}'"
.format(deployed_app_name, self.reservation_id))

with lock:
Expand All @@ -131,9 +131,9 @@ def _power_on(self, deployed_app_name, power_on, lock, message_status):
message_status['power_on'] = True
self.sandbox.report_info('Apps are powering on... ')

self.sandbox.report_info(message="Executing 'Power On' on deployed app {0} "
self.sandbox.report_info(message="Executing 'Power On' on deployed app '{0}' "
.format(deployed_app_name),
log_message="Executing 'Power On' on deployed app {0} in reservation {1}"
log_message="Executing 'Power On' on deployed app '{0}' in reservation '{1}'"
.format(deployed_app_name, self.reservation_id),
write_to_output_window=True)

Expand Down
23 changes: 12 additions & 11 deletions sandbox_scripts/environment/setup/tests/test_setup_VM.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
conContext = '''{"serverAddress": "localhost",
"adminAuthToken": "anAdminToken"}'''


class SetupVMTests(unittest.TestCase):

@patch('sandbox_scripts.environment.setup.setup_VM.get_qs_logger')
Expand Down Expand Up @@ -113,19 +114,19 @@ def resource_details_mock_side_effect(name):

report_info_calls = [call('Beginning VMs power on'),
call('Apps are powering on... '),
call(log_message="Executing 'Power On' on deployed app r2 in reservation "
"5487c6ce-d0b3-43e9-8ee7-e27af8406905",
message="Executing 'Power On' on deployed app r2 ", write_to_output_window=True)]
call(log_message="Executing 'Power On' on deployed app 'r2' in reservation "
"'5487c6ce-d0b3-43e9-8ee7-e27af8406905'",
message="Executing 'Power On' on deployed app 'r2' ", write_to_output_window=True)]
mock_sandboxbase.return_value.report_info.assert_has_calls(report_info_calls)

logger_debug_calls = [call("Resource r2 is a static app")]
self.setup_script.logger.debug.assert_has_calls(logger_debug_calls)

logger_info_calls = [call('Wait For IP is off for deployed app r2 in '
'reservation 5487c6ce-d0b3-43e9-8ee7-e27af8406905')]
logger_info_calls = [call("Wait For IP is off for deployed app 'r2' in reservation "
"'5487c6ce-d0b3-43e9-8ee7-e27af8406905'")]
self.setup_script.logger.info.assert_has_calls(logger_info_calls)

api_calls = [call(u'5487c6ce-d0b3-43e9-8ee7-e27af8406905', 'r2', 'PowerOn', 'power')]
api_calls = [call('5487c6ce-d0b3-43e9-8ee7-e27af8406905', 'r2', 'PowerOn', 'power')]
mock_sandboxbase.return_value.api_session.ExecuteResourceConnectedCommand.assert_has_calls(api_calls)


Expand Down Expand Up @@ -159,15 +160,15 @@ def resource_details_mock_side_effect(name):

report_info_calls = [call('Beginning VMs power on'),
call('Apps are powering on... '),
call(log_message="Executing 'Power On' on deployed app r2 in reservation "
"5487c6ce-d0b3-43e9-8ee7-e27af8406905",
message="Executing 'Power On' on deployed app r2 ", write_to_output_window=True),
call(log_message="Executing 'Power On' on deployed app 'r2' in reservation "
"'5487c6ce-d0b3-43e9-8ee7-e27af8406905'",
message="Executing 'Power On' on deployed app 'r2' ", write_to_output_window=True),
call(message='Waiting for apps IP addresses, this may take a while...',
write_to_output_window=True)]
mock_sandboxbase.return_value.report_info.assert_has_calls(report_info_calls)

api_calls = [call(u'5487c6ce-d0b3-43e9-8ee7-e27af8406905', 'r2', 'PowerOn', 'power'),
call(u'5487c6ce-d0b3-43e9-8ee7-e27af8406905', 'r2', 'remote_refresh_ip', 'remote_connectivity')]
api_calls = [call('5487c6ce-d0b3-43e9-8ee7-e27af8406905', 'r2', 'PowerOn', 'power'),
call('5487c6ce-d0b3-43e9-8ee7-e27af8406905', 'r2', 'remote_refresh_ip', 'remote_connectivity')]
mock_sandboxbase.return_value.api_session.ExecuteResourceConnectedCommand.assert_has_calls(api_calls)


Expand Down

0 comments on commit c6176bd

Please sign in to comment.