/
generate_reporting_data.sh
executable file
·84 lines (69 loc) · 2 KB
/
generate_reporting_data.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
#
# Script to generate fake reporting data for testing of reporting.
#
# Usage: generate_reporting_data adminPassword (create|delete) (instance|storage|s3)+
#
# This calls the FalseDataGenerator classes in a running Eucalyptus instance,
# by using the CommandServlet. The FalseDataGenerator classes then generate
# fake reporting data for testing. None of this is deployed in non-test
# Eucalyptus installations.
#
# NOTE: You must first deploy the test classes by stopping Euca, then:
# "cd $SRC/clc; ant build build-test install", then starting Euca again.
#
# (c)2011 Eucalyptus Systems, inc. All rights reserved.
# author: tom.werges
#
# Verify number of params, and display usage if wrong number
if [ "$#" -lt "3" ]
then
echo "Usage: generate_false_data adminPassword (create|delete) (instance|storage|s3)+"
exit 1
fi
# Parse password and command params, and get method name
password=$1
command=$2
shift 2
case "$command" in
"create" )
method="generateFalseData"
;;
"delete" )
method="removeFalseData"
;;
* )
echo "No such command:$command"
echo "Usage: generate_false_data adminPassword (create|delete) (instance|storage|s3)+"
exit 1
esac
# Login using LoginServlet
wget -O /tmp/sessionId --no-check-certificate "https://localhost:8443/loginservlet?adminPw=$password"
if [ "$?" -ne "0" ]
then
echo "Login failed"
exit 1
fi
export session=`cat /tmp/sessionId`
echo "session id:" $session
# Parse type params and execute commands for instance, storage, and/or s3
for xx in ${@}
do
case "$xx" in
"instance" )
class="com.eucalyptus.reporting.instance.FalseDataGenerator"
;;
"storage" )
class="com.eucalyptus.reporting.storage.FalseDataGenerator"
;;
"s3" )
class="com.eucalyptus.reporting.s3.FalseDataGenerator"
;;
esac
wget --no-check-certificate -O /tmp/nothing "https://localhost:8443/commandservlet?sessionId=$session&className=$class&methodName=$method"
if [ "$?" -ne "0" ]
then
echo "Command failed; session:$session class:$class method:$method"
exit 1
fi
done