Revision 129d3848
b/snf-astakos-app/astakos/scripts/snf-register-components | ||
---|---|---|
16 | 16 |
ex_url[pithos]='https://object-store.example.synnefo.org/pithos/' |
17 | 17 |
|
18 | 18 |
|
19 |
changed=0 |
|
20 |
|
|
21 | 19 |
register_services () { |
22 | 20 |
echo "Registering ${component}'s services and resources..." |
23 |
snf-service-export $component $base_url | snf-manage service-import --json -
|
|
21 |
snf-service-export $1 $2 | snf-manage service-import --json -
|
|
24 | 22 |
} |
25 | 23 |
|
26 | 24 |
ex_ui_url () { |
27 |
echo "$(echo $base_url | sed -e 's/\/*$//g')/ui/" |
|
25 |
echo "$(echo $1 | sed -e 's/\/*$//g')/ui/" |
|
26 |
} |
|
27 |
|
|
28 |
changed=0 |
|
29 |
|
|
30 |
decide () { |
|
31 |
while true; do |
|
32 |
echo -n "$1" |
|
33 |
read response |
|
34 |
case $response in |
|
35 |
[Yy]* ) return 0;; |
|
36 |
[Nn]* ) return 1;; |
|
37 |
* ) echo "Please answer yes or no.";; |
|
38 |
esac |
|
39 |
done |
|
40 |
|
|
28 | 41 |
} |
29 | 42 |
|
30 | 43 |
register_component () { |
... | ... | |
37 | 50 |
echo -n 'Base URL: ' |
38 | 51 |
read base_url |
39 | 52 |
echo "Give the URL of the $component UI" \ |
40 |
"(e.g. $(ex_ui_url))" |
|
53 |
"(e.g. $(ex_ui_url $base_url))"
|
|
41 | 54 |
echo -n 'UI URL: ' |
42 | 55 |
read ui_url |
43 |
while true; do |
|
44 |
echo -n "Register $component with the given URLs (y/n)? " |
|
45 |
read response |
|
46 |
case $response in |
|
47 |
[Yy]* ) break;; |
|
48 |
[Nn]* ) return;; |
|
49 |
* ) echo "Please answer yes or no.";; |
|
50 |
esac |
|
51 |
done |
|
52 |
snf-manage component-add $component $ui_url |
|
56 |
decide "Register $component with the given URLs (y/n)? " |
|
53 | 57 |
if [ $? -eq 0 ]; then |
54 |
read -p "Please write down the token and press Enter to continue. " |
|
55 |
register_services $1 |
|
56 |
changed=1 |
|
58 |
snf-manage component-add $component $ui_url |
|
59 |
if [ $? -eq 0 ]; then |
|
60 |
read -p "Please write down the token and press Enter to continue. " |
|
61 |
register_services $component $base_url |
|
62 |
changed=1 |
|
63 |
echo |
|
64 |
fi |
|
65 |
fi |
|
66 |
} |
|
67 |
|
|
68 |
register_comp_serv () { |
|
69 |
component=$1 |
|
70 |
component_desc=${desc[$component]} |
|
71 |
component_ex_url=${ex_url[$component]} |
|
72 |
echo "Registering services for $component:" |
|
73 |
echo "Give the URL of $component base installation" \ |
|
74 |
"(e.g. $component_ex_url)" |
|
75 |
echo -n 'Base URL: ' |
|
76 |
read base_url |
|
77 |
decide "Register ${component}'s services with the given URL (y/n)? " |
|
78 |
if [ $? -eq 0 ]; then |
|
79 |
register_services $component $base_url |
|
57 | 80 |
echo |
58 | 81 |
fi |
59 | 82 |
} |
... | ... | |
62 | 85 |
registered=$(snf-manage component-list --output-format=csv --no-headers | |
63 | 86 |
cut -d ',' -f 2) |
64 | 87 |
|
65 |
register_all () { |
|
66 |
flag=0 |
|
67 |
for component in ${components[@]}; do |
|
68 |
echo $registered | grep -q -w $component |
|
69 |
if [ $? -ne 0 ]; then |
|
70 |
flag=1 |
|
71 |
while true; do |
|
72 |
echo -n "Do you want to register the ${desc[$component]}" \ |
|
73 |
"($component) (y/n)? " |
|
74 |
read response |
|
75 |
case $response in |
|
76 |
[Yy]* ) |
|
77 |
register_component $component |
|
78 |
break;; |
|
79 |
[Nn]* ) |
|
80 |
break;; |
|
81 |
* ) echo "Please answer yes or no.";; |
|
82 |
esac |
|
83 |
done |
|
88 |
register_one () { |
|
89 |
component=$1 |
|
90 |
echo $registered | grep -q -w $component |
|
91 |
if [ $? -ne 0 ]; then |
|
92 |
decide "Register the ${desc[$component]} ($component) (y/n)? " |
|
93 |
if [ $? -eq 0 ]; then |
|
94 |
register_component $component |
|
95 |
fi |
|
96 |
else |
|
97 |
echo "The ${desc[$component]} ($component) is registered." |
|
98 |
decide "Update its registered services (y/n)? " |
|
99 |
if [ $? -eq 0 ]; then |
|
100 |
register_comp_serv $component |
|
84 | 101 |
fi |
85 |
done |
|
86 |
|
|
87 |
if [ $flag -eq 0 ]; then |
|
88 |
echo All standard Synnefo components are already registered. |
|
89 |
exit |
|
90 | 102 |
fi |
91 |
}
|
|
103 |
} |
|
92 | 104 |
|
93 | 105 |
# Attempt to register only the specified service |
94 | 106 |
if [[ $1 ]]; then |
... | ... | |
97 | 109 |
echo $1 is not a recognized Synnefo component. |
98 | 110 |
exit |
99 | 111 |
fi |
100 |
echo $registered | grep -q -w $1 |
|
101 |
if [ $? -ne 0 ]; then |
|
102 |
register_component $1 |
|
103 |
else |
|
104 |
echo $1 is already registered. |
|
105 |
fi |
|
112 |
register_one $1 |
|
106 | 113 |
else |
107 |
register_all |
|
114 |
for component in ${components[@]}; do |
|
115 |
register_one $component |
|
116 |
done |
|
108 | 117 |
fi |
109 | 118 |
|
110 | 119 |
if [ $changed -eq 1 ]; then |
Also available in: Unified diff