Using service dialog element value in an Assertion in the Approval Statemachine?


#1

Hey Everyone,

We extended our approval statemachine with a few states (AD checks, external change control, etc). We now have a “sandbox” use case, if the requester selects it, then the approval statemachine should be be skipped. Assertion is the way to go (I would say?).

‘${/#evm.root[‘miq_request’].options[:dialog][‘dialog_sandbox’]}’ == ‘Yes’

Statemachine:
/ Service / Provisioning / StateMachines / ServiceProvisionRequestApproval

Seems like dialog/element based (or nested) values dont work (blank) in this statemachine? For example ‘${/#evm.root[‘miq_request’].options[:cart_state]}’ returns the value…

Thanks


#2

The leading ‘/’ in the assertion implies $evm.root, so try something like:

"${/#miq_request.options[:dialog]['dialog_sandbox']}" == "Yes"

Although if your dialog was a check box this returns ‘t’ or ‘f’ as values rather than “Yes” or “No”

pemcg


#3

Hey Pete @pemcg,

No joy…

 --- $evm.current_* details ---
 $evm.current_namespace = CPA/ObjectWalker   (type: String)
 $evm.current_class = ObjectWalker   (type: String)
 $evm.current_instance = objectwalker   (type: String)
 $evm.current_method = object_walker   (type: String)
 $evm.current_message = create   (type: String)
 $evm.current_object = /CPA/ObjectWalker/ObjectWalker/objectwalker   (type: DRb::DRbObject, URI: druby://127.0.0.1:45769)
 $evm.current_object.current_field_name = execute   (type: String)
 $evm.current_object.current_field_type = method   (type: String)
 --- automation instance hierarchy ---
 /ManageIQ/System/Process/Event  ($evm.root)
 |    /ManageIQ/System/Event/RequestEvent/Request/request_created
 |    |    /ManageIQ/System/Policy/request_created
 |    |    |    /ManageIQ/System/Process/parse_provider_category
 |    |    |    /ManageIQ/System/Policy/ServiceTemplateProvisionRequest_created
 |    |    |    |    /ManageIQ/service/Provisioning/Profile/EvmGroup-super_administrator
 |    |    |    |    /CPA/service/Provisioning/StateMachines/ServiceProvisionRequestApproval/Default  ($evm.parent)
 |    |    |    |    |    /CPA/ObjectWalker/ObjectWalker/objectwalker  ($evm.object)
 |    $evm.root['miq_request'] => #<MiqAeMethodService::MiqAeServiceServiceTemplateProvisionRequest:0x00561295122d68>   (type: DRb::DRbObject, URI: druby://127.0.0.1:45769)
 |    |    --- attributes follow ---
 |    |    $evm.root['miq_request'].approval_state = pending_approval   (type: String)
 |    |    $evm.root['miq_request'].created_on = 2018-01-22 03:12:29 UTC   (type: ActiveSupport::TimeWithZone)
 |    |    $evm.root['miq_request'].destination_id = nil
 |    |    $evm.root['miq_request'].destination_type = nil
 |    |    $evm.root['miq_request'].fulfilled_on = nil
 |    |    $evm.root['miq_request'].id = 123   (type: Fixnum)
 |    |    $evm.root['miq_request'].message = Service_Template_Provisioning - Request Created   (type: String)
 |    |    $evm.root['miq_request'].options[:cart_state] = ordered   (type: String)
 |    |    $evm.root['miq_request'].options[:dialog] = {"dialog_job_template_name"=>"Linux_Base.App.AP", "dialog_zone"=>"Green"}   (type: Hash)
 |    |    $evm.root['miq_request'].options[:requester_group] = EvmGroup-super_administrator   (type: String)
 |    |    $evm.root['miq_request'].options[:src_id] = 1   (type: Fixnum)

Error in evm.log:
[----] E, [2018-01-22T03:42:10.960316 #386:2b0945d7f130] ERROR – : MIQ(MiqAeEngine.deliver) Error delivering {:event_type=>“request_created”, “EventStream::event_stream”=>7176, :event_stream_id=>7176, “ServiceTemplateProvisionRequest::service_template_provision_request”=>124, “User::user”=>1} for object [ServiceTemplateProvisionRequest.124] with state [] to Automate: bad URI(is not URI?): /#miq_request.options[:dialog][‘dialog_zone’]

Have also tried:
"${/#service_template_provision_request.options[:dialog][‘dialog_zone’]" == "Green"
gives same error…


#4

Have you tried get_option ? See mkanoor’s examples in Assertions in Automate Models


#5

Hey @xian, yes have tried that same error message…


#6

Hmm, well assertions are always processed first, so if you’re getting that objectwalker dump then it suggests that the assertion has evaluated to ‘true’. Are you sure the error isn’t coming from somewhere else? The ‘bad URI(is not URI?)’ error suggests that you’re using the assertion string in a relationship field somewhere.

pemcg


#7

Hey Pete, I do have to set the assertion to skip for the objectwalker to run. Not sure about the error and relationship comment…

Automate log:
[----] I, [2018-01-25T05:10:03.000287 #31259:2b0945d7f130] INFO – : MiqAeEvent.build_evm_event >> event=<“request_created”> inputs=<{“EventStream::event_stream”=>7653, :event_stream_id=>7653}>
[----] I, [2018-01-25T05:10:07.853937 #31277:2b0945d7f130] INFO – : Instantiating [/System/Process/Event?EventStream%3A%3Aevent_stream=7653&MiqRequest%3A%3Amiq_request=125&MiqServer%3A%3Amiq_server=1&ServiceTemplateProvisionRequest%3A%3Aservice_template_provision_request=125&User%3A%3Auser=1&event_stream_id=7653&event_type=request_created&object_name=Event&vmdb_object_type=service_template_provision_request]
[----] I, [2018-01-25T05:10:07.876180 #31277:2b0945d7f130] INFO – : Updated namespace [/System/Process/Event?EventStream%3A%3Aevent_stream=7653&MiqRequest%3A%3Amiq_request=125&MiqServer%3A%3Amiq_server=1&ServiceTemplateProvisionRequest%3A%3Aservice_template_provision_request=125&User%3A%3Auser=1&event_stream_id=7653&event_type=request_created&object_name=Event&vmdb_object_type=service_template_provision_request ManageIQ/System]
[----] I, [2018-01-25T05:10:08.010791 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/System/Event/RequestEvent/Request/request_created#create]
[----] I, [2018-01-25T05:10:08.026315 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/System/Event/RequestEvent/Request/request_created#create ManageIQ/System/Event/RequestEvent]
[----] I, [2018-01-25T05:10:08.049095 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/System/Policy/request_created#create]
[----] I, [2018-01-25T05:10:08.055443 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/System/Policy/request_created#create ManageIQ/System]
[----] I, [2018-01-25T05:10:08.074412 #31277:2b0945d7f130] INFO – : Updated namespace [System/Policy/get_request_type ManageIQ/System]
[----] I, [2018-01-25T05:10:08.079810 #31277:2b0945d7f130] INFO – : Invoking [inline] method [/ManageIQ/System/Policy/get_request_type] with inputs [{}]
[----] I, [2018-01-25T05:10:08.089915 #31277:2b0945d7f130] INFO – : <AEMethod [/ManageIQ/System/Policy/get_request_type]> Starting
[----] I, [2018-01-25T05:10:09.818014 #31277:2b0945d70630] INFO – : Request Type:
[----] I, [2018-01-25T05:10:09.845704 #31277:2b0945d7f130] INFO – : <AEMethod [/ManageIQ/System/Policy/get_request_type]> Ending
[----] I, [2018-01-25T05:10:09.845794 #31277:2b0945d7f130] INFO – : Method exited with rc=MIQ_OK
[----] I, [2018-01-25T05:10:09.846875 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/System/Process/parse_provider_category#create]
[----] I, [2018-01-25T05:10:09.883975 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/System/Process/parse_provider_category#create ManageIQ/System]
[----] I, [2018-01-25T05:10:09.896357 #31277:2b0945d7f130] INFO – : Updated namespace [System/Process/parse_provider_category ManageIQ/System]
[----] I, [2018-01-25T05:10:09.902200 #31277:2b0945d7f130] INFO – : Invoking [builtin] method [/ManageIQ/System/Process/parse_provider_category] with inputs [{}]
[----] I, [2018-01-25T05:10:09.956608 #31277:2b0945d7f130] INFO – : Setting provider_category to:
[----] I, [2018-01-25T05:10:09.957720 #31277:2b0945d7f130] INFO – : Followed Relationship [miqaedb:/System/Process/parse_provider_category#create]
[----] I, [2018-01-25T05:10:09.958062 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/System/Policy/ServiceTemplateProvisionRequest_created#create]
[----] I, [2018-01-25T05:10:09.962418 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/System/Policy/ServiceTemplateProvisionRequest_created#create ManageIQ/System]
[----] I, [2018-01-25T05:10:09.970307 #31277:2b0945d7f130] INFO – : Evaluating substituted assertion [true]
[----] I, [2018-01-25T05:10:09.973301 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/service/Provisioning/Profile/EvmGroup-super_administrator#get_auto_approval_state_machine]
[----] I, [2018-01-25T05:10:10.067730 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/service/Provisioning/Profile/EvmGroup-super_administrator#get_auto_approval_state_machine ManageIQ/service/Provisioning]
[----] I, [2018-01-25T05:10:10.123149 #31277:2b0945d7f130] INFO – : Instance [/ManageIQ/service/Provisioning/Profile/EvmGroup-super_administrator] not found in MiqAeDatastore - trying [.missing]
[----] I, [2018-01-25T05:10:10.136363 #31277:2b0945d7f130] INFO – : Followed Relationship [miqaedb:/service/Provisioning/Profile/EvmGroup-super_administrator#get_auto_approval_state_machine]
[----] I, [2018-01-25T05:10:10.137664 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/service/Provisioning/StateMachines/ServiceProvisionRequestApproval/Default#create]
[----] I, [2018-01-25T05:10:10.327075 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/service/Provisioning/StateMachines/ServiceProvisionRequestApproval/Default#create CPA/service/Provisioning/StateMachines]

EVM log:
[----] I, [2018-01-25T05:10:08.079714 #31277:2b0945d7f130] INFO – : Invoking [inline] method [/ManageIQ/System/Policy/get_request_type] with inputs [{}]
[----] I, [2018-01-25T05:10:08.089801 #31277:2b0945d7f130] INFO – : <AEMethod [/ManageIQ/System/Policy/get_request_type]> Starting
[----] I, [2018-01-25T05:10:09.817826 #31277:2b0945d70630] INFO – : Request Type:
[----] I, [2018-01-25T05:10:09.845614 #31277:2b0945d7f130] INFO – : <AEMethod [/ManageIQ/System/Policy/get_request_type]> Ending
[----] I, [2018-01-25T05:10:09.845764 #31277:2b0945d7f130] INFO – : Method exited with rc=MIQ_OK
[----] I, [2018-01-25T05:10:09.846795 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/System/Process/parse_provider_category#create]
[----] I, [2018-01-25T05:10:09.883812 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/System/Process/parse_provider_category#create ManageIQ/System]
[----] I, [2018-01-25T05:10:09.896270 #31277:2b0945d7f130] INFO – : Updated namespace [System/Process/parse_provider_category ManageIQ/System]
[----] I, [2018-01-25T05:10:09.902110 #31277:2b0945d7f130] INFO – : Invoking [builtin] method [/ManageIQ/System/Process/parse_provider_category] with inputs [{}]
[----] I, [2018-01-25T05:10:09.956516 #31277:2b0945d7f130] INFO – : Setting provider_category to:
[----] I, [2018-01-25T05:10:09.957658 #31277:2b0945d7f130] INFO – : Followed Relationship [miqaedb:/System/Process/parse_provider_category#create]
[----] I, [2018-01-25T05:10:09.957984 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/System/Policy/ServiceTemplateProvisionRequest_created#create]
[----] I, [2018-01-25T05:10:09.962302 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/System/Policy/ServiceTemplateProvisionRequest_created#create ManageIQ/System]
[----] I, [2018-01-25T05:10:09.970221 #31277:2b0945d7f130] INFO – : Evaluating substituted assertion [true]
[----] I, [2018-01-25T05:10:09.973215 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/service/Provisioning/Profile/EvmGroup-super_administrator#get_auto_approval_state_machine]
[----] I, [2018-01-25T05:10:10.067614 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/service/Provisioning/Profile/EvmGroup-super_administrator#get_auto_approval_state_machine ManageIQ/service/Provisioning]
[----] I, [2018-01-25T05:10:10.123037 #31277:2b0945d7f130] INFO – : Instance [/ManageIQ/service/Provisioning/Profile/EvmGroup-super_administrator] not found in MiqAeDatastore - trying [.missing]
[----] I, [2018-01-25T05:10:10.136266 #31277:2b0945d7f130] INFO – : Followed Relationship [miqaedb:/service/Provisioning/Profile/EvmGroup-super_administrator#get_auto_approval_state_machine]
[----] I, [2018-01-25T05:10:10.137583 #31277:2b0945d7f130] INFO – : Following Relationship [miqaedb:/service/Provisioning/StateMachines/ServiceProvisionRequestApproval/Default#create]
[----] I, [2018-01-25T05:10:10.326979 #31277:2b0945d7f130] INFO – : Updated namespace [miqaedb:/service/Provisioning/StateMachines/ServiceProvisionRequestApproval/Default#create CPA/service/Provisioning/StateMachines]
[----] E, [2018-01-25T05:10:10.451999 #31277:2b0945d7f130] ERROR – : MIQ(MiqAeEngine.deliver) Error delivering {:event_type=>“request_created”, “EventStream::event_stream”=>7653, :event_stream_id=>7653, “ServiceTemplateProvisionRequest::service_templ
ate_provision_request”=>125, “User::user”=>1} for object [ServiceTemplateProvisionRequest.125] with state [] to Automate: bad URI(is not URI?): /#miq_request.options[:dialog][‘dialog_zone’]
[----] I, [2018-01-25T05:10:10.452630 #31277:2b0945d7f130] INFO – : MIQ(MiqQueue#delivered) Message id: [232538], State: [ok], Delivered in [2.67747021] seconds


#8

Try this (pretty ugly but worked for me in a service reconfiguration assertion):

"${/#miq_request.options.fetch(:dialog).with_indifferent_access.fetch(:dialog_zone)}" == "Green"

The trick seems to be eliminate all []' from the urI.


#9

That works like a charm! Thanks man :+1::fist_right:

:mage: xian :slightly_smiling_face: