#NEWLINE# def create_host_and_service( instance , warn_if_exists = True ) : #NEWLINE# #INDENT# if ( not ZABBIX_ENABLED ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# zabbix_client = ZabbixApiClient ( ) #NEWLINE# zabbix_client . create_host ( instance , warn_if_host_exists = warn_if_exists ) #NEWLINE# zabbix_client . create_service ( instance , warn_if_service_exists = warn_if_exists ) #NEWLINE# #UNINDENT# except ZabbixError as e : #NEWLINE# #INDENT# logger . error ( ( 'Zabbix host creation flow has been broken %s' % e ) , exc_info = 1 ) #NEWLINE# event_logger . zabbix . error ( 'Unable to add instance {instance_name} to Zabbix' , event_type = 'zabbix_host_creation_failed' , event_context = { #NEWLINE# #INDENT# 'instance' : instance , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# event_logger . zabbix . info ( 'Added instance {instance_name} to Zabbix' , event_type = 'zabbix_host_creation_succeeded' , event_context = { #NEWLINE# #INDENT# 'instance' : instance , #NEWLINE# #UNINDENT# } )