-
Notifications
You must be signed in to change notification settings - Fork 2
/
84-create_storage_repositories.sh
executable file
·91 lines (74 loc) · 2.09 KB
/
84-create_storage_repositories.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
84
85
86
87
88
89
90
91
#!/bin/bash
set -eu
set -xv
# Create and Configure Storage Repositories
source host.conf
function parse_cifs_url {
local url="$1"
local delim="$2"
local str="${url#cifs://}"
local hostname="${str%%/*}"
local path="/${str#*/}"
if [[ -z $hostname || -z $path ]]; then
echo "Error parsing cifs:// url '$url'"
exit 3
fi
echo "${hostname%/}$delim${path%/}"
}
for sr in "${sr_iso_sr_list[@]-}"; do
[[ $sr ]] || continue
sr_name_label="${sr%%:*}"
sr_url="${sr#*:}"
echo ""
echo "sr_definition : $sr"
echo "sr_name_label : $sr_name_label"
echo "sr_url : $sr_url"
if [[ $sr_url = cifs://* ]]; then
cifs_parts=($( parse_cifs_url "$sr_url" ' '))
cifs_server="${cifs_parts[0]}"
cifs_path="${cifs_parts[1]}"
cifs_options=""
for domain_def in "${sr_iso_sr_cifs_options[@]}"; do
domain="${domain_def%%:*}"
options="${domain_def#*:}"
if [[ $cifs_server = *$domain ]]; then
cifs_options="$options"
break
fi
done
if [[ -n $cifs_options ]]; then
autostack.xenserver.sr.cifs_iso.create -u "$sr_url" -s "$sr_name_label" -o "$cifs_options" -v
else
autostack.xenserver.sr.cifs_iso.create -u "$sr_url" -s "$sr_name_label" -v
fi
elif [[ $sr_url = nfs://* ]]; then
echo "Mounting NFS ISO SRs currently not implemented."
exit 3
else
echo "No ISO SR processor for '$sr_url' implemented"
exit 3
fi
done
for sr in "${sr_vm_sr_list[@]-}"; do
[[ $sr ]] || continue
sr_name_label="${sr%%:*}"
sr_url="${sr#*:}"
echo ""
echo "sr_definition : $sr"
echo "sr_name_label : $sr_name_label"
echo "sr_url : $sr_url"
if [[ $sr_url = nfs://* ]]; then
autostack.xenserver.sr.nfs_vm.create -u "$sr_url" -s "$sr_name_label"
else
echo "No VM SR processor for $sr_url implemented"
exit 3
fi
done
if [[ $sr_vm_sr_default ]]; then
pool_uuid=$(xe pool-list params=uuid --minimal)
xe sr-list name-label="$sr_vm_sr_default" params=uuid --minimal |
sed -r 's/,/\n/g' |
while read sr_uuid _; do
xe pool-param-set uuid="$pool_uuid" default-SR="$sr_uuid"
done
fi