#NEWLINE# def do( self , workflow_dict ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( 'databaseinfraattr' in workflow_dict ) : #NEWLINE# #INDENT# LOG . info ( 'Creating dns for databaseinfraattr...' ) #NEWLINE# for infra_attr in workflow_dict [ 'databaseinfraattr' ] : #NEWLINE# #INDENT# if infra_attr . is_write : #NEWLINE# #INDENT# dnsname = workflow_dict [ 'databaseinfra' ] . name #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dnsname = ( workflow_dict [ 'databaseinfra' ] . name + '-r' ) #NEWLINE# #UNINDENT# dnsname = add_dns_record ( databaseinfra = workflow_dict [ 'databaseinfra' ] , name = dnsname , ip = infra_attr . ip , type = FLIPPER ) #NEWLINE# infra_attr . dns = dnsname #NEWLINE# infra_attr . save ( ) #NEWLINE# if infra_attr . is_write : #NEWLINE# #INDENT# LOG . info ( 'Updating databaseinfra dns endpoint' ) #NEWLINE# databaseinfra = workflow_dict [ 'databaseinfra' ] #NEWLINE# databaseinfra . endpoint_dns = ( infra_attr . dns + ( ':%i' % 3306 ) ) #NEWLINE# databaseinfra . save ( ) #NEWLINE# workflow_dict [ 'databaseinfra' ] = databaseinfra #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# LOG . info ( 'Creating dns for hosts...' ) #NEWLINE# for host_name in zip ( workflow_dict [ 'hosts' ] , workflow_dict [ 'names' ] [ 'vms' ] ) : #NEWLINE# #INDENT# host = host_name [ 0 ] #NEWLINE# host . hostname = add_dns_record ( databaseinfra = workflow_dict [ 'databaseinfra' ] , name = host_name [ 1 ] , ip = host . address , type = HOST ) #NEWLINE# host . save ( ) #NEWLINE# #UNINDENT# LOG . info ( 'Creating dns for instances...' ) #NEWLINE# for instance_name in zip ( workflow_dict [ 'instances' ] , workflow_dict [ 'names' ] [ 'vms' ] ) : #NEWLINE# #INDENT# instance = instance_name [ 0 ] #NEWLINE# instance . dns = add_dns_record ( databaseinfra = workflow_dict [ 'databaseinfra' ] , name = instance_name [ 1 ] , ip = instance . address , type = INSTANCE ) #NEWLINE# instance . save ( ) #NEWLINE# if ( workflow_dict [ 'qt' ] == 1 ) : #NEWLINE# #INDENT# LOG . info ( 'Updating databaseinfra dns endpoint' ) #NEWLINE# databaseinfra = workflow_dict [ 'databaseinfra' ] #NEWLINE# databaseinfra . endpoint_dns = ( instance . dns + ( ':%i' % instance . port ) ) #NEWLINE# databaseinfra . save ( ) #NEWLINE# workflow_dict [ 'databaseinfra' ] = databaseinfra #NEWLINE# #UNINDENT# #UNINDENT# LOG . info ( 'Calling dnsapi provider...' ) #NEWLINE# DNSAPIProvider . create_database_dns ( databaseinfra = workflow_dict [ 'databaseinfra' ] ) #NEWLINE# return True #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# traceback = full_stack ( ) #NEWLINE# workflow_dict [ 'exceptions' ] [ 'error_codes' ] . append ( DBAAS_0007 ) #NEWLINE# workflow_dict [ 'exceptions' ] [ 'traceback' ] . append ( traceback ) #NEWLINE# return False