Android Question SSH_CmdExecuted not firing in order?

emockler

Member
Licensed User
Longtime User
So, I am trying to get the power state of a number of VM's, in the test case it's 22. They are identified by VMID, which I have in a list. As you can see I have the event counting up from 100 - 121, that's for troubleshooting since I am getting the results out of order. I have tried Initializing & closing ssh2 in each iteration, which does not help. Without the wait, I get maybe 3/4 of the results, but any more than 1 sec does not make it better. I am setting up buttons & labels here, and I think I may have to set each button & label individually. Like check os, name, pwr state -->btn & lbl, next - to more definitely seperate the tests.

For v = 0 To vmidList.Size -1
vm = vmidList.get(v)
T=100+v
SSH2.execCommand("vim-cmd vmsvc/power.getstate " & vm,t )


Wait(1)
<----- tried changing this, 1 sec is enough.

Next [/CODE]



I have this also:

Sub SSH_CmdExecuted (Success As Boolean, Result As List, TaskId As Int)
Dim pwr As String

Log (TaskId)
If TaskId = 15 Then
Dim vmidList As List

If Success Then
pwr=Result.Get(1)
'Return(pwr)
If pwr.Contains("on") Then
Powerstate.add ("on")
'Return("on")
Else
'If pwr.Contains("off") Then
Powerstate.add("off")
'Return("off")
End If
End If

Which should add "on" & "off" in the order encountered. However I am getting the results kind of in order, but I really need them exactly in order. I set the event to increment for t-shooting, and I get this:


>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed. -----> this is the for/next executing
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
>>> [SSH]: Command was successfully executed.
** Activity (main) Resume **
100
101
102
103
104
105
106
107
110
108 --------> on/off written to list in this order, these are the iterated events firing
111
112
113
114
115
116
118
119
120
121
117
109

Or maybe I should continue to iterate the events, & test for the event to maintain the order? I'm hoping someone here has run into this & has an elegant solution. I was able to do this by pushing a script to the server & pulling a file it creates, which is one line in b4a. That's ok for MY server......

Thanks!
Eric
 

emockler

Member
Licensed User
Longtime User
I kind of fixed it.......


I modified the SSH_CmdExecuted to be like this:
If TaskId > 99 Then
If Success Then
pwr=Result.Get(1)
If pwr.Contains("on") Then
Powerstate.set( TaskId -100,"on")
'Return("on")
Else
'If pwr.Contains("off") Then
Powerstate.set(TaskId -100,"off")
'Return("off")
End If
End If


So it puts the result in the list in the same order as the Taskid.


If anyone has a better way.......
 
Upvote 0
Top