15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/cloudrail_si/servicecode/InitSelfTest.rb', line 15
def execute(servicename)
test_state = true
service_code = {
'selfTest' => [
['create', '$L0', 'Object'],
['create', '$L1', 'Object'],
['create', '$L1.client', 'Object'],
['create', '$L1.app', 'Object'],
['set', '$L1.client.mac', '$P1'],
['set', '$L1.client.platform', '$P0.platform'],
['set', '$L1.client.os', '$P0.os'],
['set', '$L1.app.name', '$P2'],
['set', '$L1.app.version', '$P3'],
['json.stringify', '$L3', '$L1.client'],
['callFunc', 'hashString', '$L4', '$L3'],
['json.stringify', '$L5', '$L1.app'],
['callFunc', 'hashString', '$L6', '$L5'],
['delete', '$L1.client.mac'],
['create', '$L8', 'Object'],
['set', '$L8.method', 'GET'],
['string.concat', '$L8.url', 'https://stat-si.cloudrail.com/current_version?service=', '$P0.serviceName', '&client=', '$L4', '&app=', '$L6'],
['create', '$L8.requestHeaders', 'Object'],
['json.stringify', '$L8.requestHeaders.clientdata', '$L1.client'],
['json.stringify', '$L8.requestHeaders.appdata', '$L1.app'],
['http.requestCall', '$L9', '$L8']
],
'hashString' => [
['hash.md5', '$L0', '$P1'],
['size', '$L1', '$L0'],
['set', '$L2', 0],
['set', '$P0', ''],
['get', '$L3', '$L0', '$L2'],
['string.format', '$L4', '%02X', '$L3'],
['string.concat', '$P0', '$P0', '$L4'],
['math.add', '$L2', '$L2', 1],
['if>=than', '$L2', '$L1', -5]
]
};
interpreter_storage = {
'serviceName' => servicename,
'platform' => 'Ruby',
'os' => get_os
}
mac = get_mac
nv = get_name_version
interpreter = Interpreter.new(Sandbox.new(service_code, [], {}))
interpreter.call_function('selfTest', interpreter_storage, mac, nv['name'], nv['version'])
test_state
end
|