Specifying order or Service Dialog Options


#1

I’m building a service dialog where I have a set of dropdown boxes like so:

  1. Tenant
  2. Network
  3. Floating IP
  4. Security Group
  5. etc.

When the user selects a tenant the remaining dialog element workflows get ran so that the user can only select the appropriate network, floating IP, etc for the tenant they selected. When I look at the automation.log file I see that the workflows don’t run in the order they are listed in the service dialog. For example, I’ll see the Floating IP workflow run before the Tenant workflow. I’d like to be able to specify the order so that the Tenant workflow will run first and set a value as opposed to being empty each time and requiring the user to select a tenant. A majority of the time the user will only have a single tenant option to select from so it would be nice if it was pre-populated. Is this possible? Thanks.


#2

@dclarizio or @gmccullough can you review this question from @sg_chris and forward to SME if necessary.


#3

Hi @sg_chris,

As I recall the fields are not run in a predictable order, but we should be running them by the order they are defined in the dialogs. This would have to account for the order of the tabs, groups and fields.

@eclarizio Any other thoughts around this topic?

@sg_chris Please create a git issue for this, thanks.


#4

@gmccullough Correct, if we’re talking about auto-refreshable fields (which it seems like this is?), then there is no specific order that they are run in. They are all simply listening for an auto-refresh cue. If order is needed, then right now I think the only way to do it is to not have them set to auto-refresh and use a manual refresh button.

Alternatively, for the majority of the cases, since there is only one tenant, could the dynamic automate methods that are being used for Network/Floating IP/etc take into account the tenant instead of it needing to be selected? I’m not sure if there is a way to get that information?


#5

What I was trying to do is create a few dynamic dropdown list like so:

  • Tenant: Auto Refresh other fields when modied
  • Network: Auto Refresh
  • Security Groups: Auto Refresh
  • etc

So that when a user selects a tenant, the Network and Security Groups dropdown list get populated with objects under the tenant that the user selected. For example, as soon as the user selects tenantA, the Network dropdown list would get called and built up like this.

...
  cloud_tenant_id = $evm.root['dialog_cloud_tenant']
  cloud_tenant = nil
    
  $evm.log(:info, "networks, found cloud tenant: #{cloud_tenant_id}")
  
  # In case this dialog gets called before cloud_tenant is set.
  begin
    cloud_tenant = $evm.vmdb('CloudTenant').find(cloud_tenant_id)
  rescue => error
    $evm.log(:error, "[#{error}]\n#{error.backtrace.join("\n")}")
    #MIQ_STOP
  end

  networks = {}
  #networks['!'] = 'Select Network'

  if cloud_tenant    
    cloud_tenant.cloud_networks.each do |network| 
      networks[network.id] = network.name 
    end
  end

  list_values	= {
    'sort_by'   => :value,
    'required'  =>  true,
    'data_type' => :integer, 
    'values'    =>  networks,
  }
...

I’ve been doing a lot of experimenting so that’s probably not how it will end up but you probably get the idea.

One problem I’m noticing on last night’s build is that sometimes the code above will get called 5 times in a row and I’ll start seeing errors like this in automation.log:

[----] E, [2016-04-18T16:38:23.201232 #12126:81a1f00] ERROR -- : Method STDERR: The following error occurred during inline method preamble evaluation:
[----] E, [2016-04-18T16:38:23.201386 #12126:81a1f00] ERROR -- : Method STDERR:   DRb::DRbConnError: druby://127.0.0.1:33671 - #<Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 33671>
[----] E, [2016-04-18T16:38:23.201503 #12126:81a1f00] ERROR -- : Method STDERR:   /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:744:in `rescue in block in open'
[----] E, [2016-04-18T16:38:23.201617 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:738:in `block in open'
[----] E, [2016-04-18T16:38:23.201794 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:737:in `each'
[----] E, [2016-04-18T16:38:23.201937 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:737:in `open'
[----] E, [2016-04-18T16:38:23.202049 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1248:in `initialize'
[----] E, [2016-04-18T16:38:23.202167 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1228:in `new'
[----] E, [2016-04-18T16:38:23.202286 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1228:in `open'
[----] E, [2016-04-18T16:38:23.202393 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1141:in `block in method_missing'
[----] E, [2016-04-18T16:38:23.202502 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1160:in `with_friend'
[----] E, [2016-04-18T16:38:23.202609 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1140:in `method_missing'
[----] E, [2016-04-18T16:38:23.202761 #12126:81a1f00] ERROR -- : Method STDERR: -:31:in `<main>'
[----] E, [2016-04-18T16:38:23.202881 #12126:81a1f00] ERROR -- : Method STDERR: /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:744:in `rescue in block in open': druby://127.0.0.1:33671 - #<Errno::ECONNREFUSED: Connection refused - connect(2) for "127.0.0.1" port 33671> (DRb::DRbConnError)
[----] E, [2016-04-18T16:38:23.202994 #12126:81a1f00] ERROR -- : Method STDERR:         from /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:738:in `block in open'
[----] E, [2016-04-18T16:38:23.203111 #12126:81a1f00] ERROR -- : Method STDERR:         from /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:737:in `each'
[----] E, [2016-04-18T16:38:23.203231 #12126:81a1f00] ERROR -- : Method STDERR:         from /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:737:in `open'
[----] E, [2016-04-18T16:38:23.203346 #12126:81a1f00] ERROR -- : Method STDERR:         from /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1248:in `initialize'
[----] E, [2016-04-18T16:38:23.203465 #12126:81a1f00] ERROR -- : Method STDERR:         from /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1228:in `new'
[----] E, [2016-04-18T16:38:23.203587 #12126:81a1f00] ERROR -- : Method STDERR:         from /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1228:in `open'
[----] E, [2016-04-18T16:38:23.203752 #12126:81a1f00] ERROR -- : Method STDERR:         from /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1141:in `block in method_missing'
[----] E, [2016-04-18T16:38:23.203873 #12126:81a1f00] ERROR -- : Method STDERR:         from /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1160:in `with_friend'
[----] E, [2016-04-18T16:38:23.203979 #12126:81a1f00] ERROR -- : Method STDERR:         from /opt/rubies/ruby-2.2.4/lib/ruby/2.2.0/drb/drb.rb:1140:in `method_missing'
[----] E, [2016-04-18T16:38:23.204084 #12126:81a1f00] ERROR -- : Method STDERR:         from -:31:in `<main>'
[----] I, [2016-04-18T16:38:23.257536 #12126:887cb4]  INFO -- : <AEMethod [/Seagate/Dialogs/Methods/available_networks2]> Ending
[----] E, [2016-04-18T16:38:23.257843 #12126:887cb4] ERROR -- : Aborting instantiation (unknown method return code) because [Method exited with rc=Unknown RC: [1]]

I wanted to try something like this, but haven’t been able to get it to work yet:

service = $evm.root.attributes["service_template"] || $evm.root.attributes["service"]
if service.respond_to?(:orchestration_manager) && service.orchestration_manager
  service.orchestration_manager.flavors.each { |f| flavor_list[f.name] = f.name }
end

If I remember correctly, I get the service but it doesn’t respond to orchestration_manager.

In our environment we are going to implement MIQ but users are also allowed to directly access OpenStack. We aren’t allowed to force them to use MIQ. The idea is that most of the users will get confused by OpenStack’s interface so we are going to use MIQ as a more user friendly self-service portal, and then the more advanced users can access OpenStack directly. We can also use a lot of MIQs features such as injecting cloud-init scripts.

So by looking at the MIQ documentation it looks like it’s intended to control a single OpenStack org/project, and then all of the user, quota, etc management would be done in MIQ. In our case we will have users in both MIQ and OpenStack and will have to sync those somehow. We aren’t that far along yet.

So what I do is when I build the Tenant dropdown list is to reach out to OpenStack and figure out what all projects the MIQ user is in inside of OpenStack. The curl command is:

curl -s -H "X-Auth-Token: $OS_TOKEN" ${OS_AUTH_URL}/v3/role_assignments?user.id=${userid}

Then in MIQ they are only allowed to select from tenants they are in inside of OpenStack.

We are still experimenting so we may end up just having one big OpenStack tenant that MIQ manages then other OpenStack tenants that MIQ can’t see. Regardless of what we do, I’d like to be able to build these service dialogs as I think it’s a powerful feature. Thanks.