shared_lvm.patch

SZTAKI ITAK, 07/23/2012 09:50 AM

Download (37.6 KB)

View differences:

opennebula-3.5.80-shared_lvm/install.sh 2012-07-09 08:37:41.339406750 +0200
226 226
          $VAR_LOCATION/remotes/tm/ \
227 227
          $VAR_LOCATION/remotes/tm/dummy \
228 228
          $VAR_LOCATION/remotes/tm/shared \
229
          $VAR_LOCATION/remotes/tm/shared_lvm \
229 230
          $VAR_LOCATION/remotes/tm/qcow2 \
230 231
          $VAR_LOCATION/remotes/tm/ssh \
231 232
          $VAR_LOCATION/remotes/tm/vmware \
......
239 240
          $VAR_LOCATION/remotes/datastore/vmware \
240 241
          $VAR_LOCATION/remotes/datastore/iscsi \
241 242
          $VAR_LOCATION/remotes/datastore/lvm \
243
          $VAR_LOCATION/remotes/datastore/shared_lvm \
242 244
          $VAR_LOCATION/remotes/auth \
243 245
          $VAR_LOCATION/remotes/auth/plain \
244 246
          $VAR_LOCATION/remotes/auth/ssh \
......
401 403
    VMM_EXEC_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/vmm/vmware
402 404
    TM_FILES:$VAR_LOCATION/remotes/tm
403 405
    TM_SHARED_FILES:$VAR_LOCATION/remotes/tm/shared
406
    TM_SHARED_LVM_FILES:$VAR_LOCATION/remotes/tm/shared_lvm
404 407
    TM_QCOW2_FILES:$VAR_LOCATION/remotes/tm/qcow2
405 408
    TM_SSH_FILES:$VAR_LOCATION/remotes/tm/ssh
406 409
    TM_VMWARE_FILES:$VAR_LOCATION/remotes/tm/vmware
......
413 416
    DATASTORE_DRIVER_VMWARE_SCRIPTS:$VAR_LOCATION/remotes/datastore/vmware
414 417
    DATASTORE_DRIVER_ISCSI_SCRIPTS:$VAR_LOCATION/remotes/datastore/iscsi
415 418
    DATASTORE_DRIVER_LVM_SCRIPTS:$VAR_LOCATION/remotes/datastore/lvm
419
    DATASTORE_DRIVER_SHARED_LVM_SCRIPTS:$VAR_LOCATION/remotes/datastore/shared_lvm
416 420
    NETWORK_FILES:$VAR_LOCATION/remotes/vnm
417 421
    NETWORK_8021Q_FILES:$VAR_LOCATION/remotes/vnm/802.1Q
418 422
    NETWORK_DUMMY_FILES:$VAR_LOCATION/remotes/vnm/dummy
......
803 807
#   - DUMMY TM, $VAR_LOCATION/tm/dummy
804 808
#   - VMWARE TM, $VAR_LOCATION/tm/vmware
805 809
#   - ISCSI TM, $VAR_LOCATION/tm/iscsi
810
#   - SHARED_LVM TM, $VAR_LOCATION/tm/shared_lvm
806 811
#   - LVM TM, $VAR_LOCATION/tm/lvm
807 812
#-------------------------------------------------------------------------------
808 813

  
......
865 870
                 src/tm_mad/lvm/mvds \
866 871
                 src/tm_mad/lvm/delete"
867 872

  
873
TM_SHARED_LVM_FILES="src/tm_mad/shared_lvm/clone \
874
                 src/tm_mad/shared_lvm/ln \
875
                 src/tm_mad/shared_lvm/mv \
876
                 src/tm_mad/shared_lvm/mvds \
877
                 src/tm_mad/shared_lvm/delete"
868 878
#-------------------------------------------------------------------------------
869 879
# Datastore drivers, to be installed under $REMOTES_LOCATION/datastore
870 880
#   - Dummy Image Repository, $REMOTES_LOCATION/datastore/dummy
......
902 912
                         src/datastore_mad/remotes/iscsi/clone \
903 913
                         src/datastore_mad/remotes/iscsi/iscsi.conf"
904 914

  
915
DATASTORE_DRIVER_SHARED_LVM_SCRIPTS="src/datastore_mad/remotes/shared_lvm/cp \
916
                         src/datastore_mad/remotes/shared_lvm/mkfs \
917
                         src/datastore_mad/remotes/shared_lvm/stat \
918
                         src/datastore_mad/remotes/shared_lvm/rm \
919
                         src/datastore_mad/remotes/shared_lvm/clone \
920
                         src/datastore_mad/remotes/shared_lvm/shared_lvm.conf"
921

  
905 922
DATASTORE_DRIVER_LVM_SCRIPTS="src/datastore_mad/remotes/lvm/cp \
906 923
                         src/datastore_mad/remotes/lvm/mkfs \
907 924
                         src/datastore_mad/remotes/lvm/stat \
opennebula-3.5.80-shared_lvm/share/etc/oned.conf 2012-07-09 08:21:31.155406751 +0200
286 286

  
287 287
TM_MAD = [
288 288
    executable = "one_tm",
289
    arguments  = "-t 15 -d dummy,lvm,shared,qcow2,ssh,vmware,iscsi" ]
289
    arguments  = "-t 15 -d dummy,lvm,shared,qcow2,ssh,vmware,iscsi,shared_lvm" ]
290 290

  
291 291
#*******************************************************************************
292 292
# Datastore Driver Configuration
......
303 303

  
304 304
DATASTORE_MAD = [
305 305
    executable = "one_datastore",
306
    arguments  = "-t 15 -d fs,vmware,iscsi,lvm"
306
    arguments  = "-t 15 -d fs,vmware,iscsi,lvm,shared_lvm"
307 307
]
308 308

  
309 309
#*******************************************************************************
opennebula-3.5.80-shared_lvm/src/datastore_mad/remotes/shared_lvm/clone 2012-07-09 08:17:28.543406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
###############################################################################
20
# This script is used to copy a VM image (SRC) to the image repository as DST
21
# Several SRC types are supported
22
###############################################################################
23
# -------- Set up the environment to source common tools & conf ------------
24
if [ -z "${ONE_LOCATION}" ]; then
25
    LIB_LOCATION=/usr/lib/one
26
else
27
    LIB_LOCATION=$ONE_LOCATION/lib
28
fi
29

  
30
. $LIB_LOCATION/sh/scripts_common.sh
31

  
32
DRIVER_PATH=$(dirname $0)
33
source ${DRIVER_PATH}/../libfs.sh
34
source ${DRIVER_PATH}/shared_lvm.conf
35

  
36
# -------- Get cp and datastore arguments from OpenNebula core ------------
37

  
38
DRV_ACTION=$1
39
ID=$2
40

  
41
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
42

  
43
unset i XPATH_ELEMENTS
44

  
45
while IFS= read -r -d '' element; do
46
    XPATH_ELEMENTS[i++]="$element"
47
done < <($XPATH     /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
48
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \
49
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
50
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \
51
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VG_NAME \
52
                    /DS_DRIVER_ACTION_DATA/IMAGE/PATH \
53
                    /DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
54

  
55
BASE_PATH="${XPATH_ELEMENTS[0]}"
56
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
57
SAFE_DIRS="${XPATH_ELEMENTS[2]}"
58
UMASK="${XPATH_ELEMENTS[3]}"
59
VG_NAME="${XPATH_ELEMENTS[4]:-$VG_NAME}"
60
SRC="${XPATH_ELEMENTS[5]}"
61
SIZE="${XPATH_ELEMENTS[6]}"
62

  
63
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
64

  
65
LV_NAME="lv-one-${ID}"
66
DEV="/dev/$VG_NAME/$LV_NAME"
67

  
68
let TID=ID+BASE_TID
69

  
70
LV_SRC=$(echo $SRC|awk -F. '{print $NF}')
71
DEV_SRC="/dev/$VG_NAME/$LV_SRC"
72

  
73
CLONE_CMD="
74
    $SUDO $LVCREATE -L${SIZE}M ${VG_NAME} -n ${LV_NAME}
75
    $SUDO $DD if=$DEV_SRC of=$DEV bs=64k"
76

  
77
exec_and_log "$DST_HOST" "$CLONE_CMD" \
78
    "Error cloning $DEV_SRC to $DEV in $DST_HOST"
79

  
80
echo "$IQN"
opennebula-3.5.80-shared_lvm/src/datastore_mad/remotes/shared_lvm/cp 2012-07-09 08:17:28.543406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
###############################################################################
20
# This script is used to copy a VM image (SRC) to the image repository as DST
21
# Several SRC types are supported
22
###############################################################################
23

  
24
# -------- Set up the environment to source common tools & conf ------------
25

  
26
if [ -z "${ONE_LOCATION}" ]; then
27
    LIB_LOCATION=/usr/lib/one
28
else
29
    LIB_LOCATION=$ONE_LOCATION/lib
30
fi
31

  
32
. $LIB_LOCATION/sh/scripts_common.sh
33

  
34
DRIVER_PATH=$(dirname $0)
35
source ${DRIVER_PATH}/../libfs.sh
36
source ${DRIVER_PATH}/shared_lvm.conf
37

  
38
UTILS_PATH="${DRIVER_PATH}/.."
39

  
40
# -------- Get cp and datastore arguments from OpenNebula core ------------
41

  
42
DRV_ACTION=$1
43
ID=$2
44

  
45
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
46

  
47
unset i XPATH_ELEMENTS
48

  
49
while IFS= read -r -d '' element; do
50
    XPATH_ELEMENTS[i++]="$element"
51
done < <($XPATH     /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
52
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \
53
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
54
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \
55
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VG_NAME \
56
                    /DS_DRIVER_ACTION_DATA/IMAGE/PATH \
57
                    /DS_DRIVER_ACTION_DATA/IMAGE/SIZE \
58
                    /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \
59
                    /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1)
60

  
61
BASE_PATH="${XPATH_ELEMENTS[0]}"
62
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
63
SAFE_DIRS="${XPATH_ELEMENTS[2]}"
64
UMASK="${XPATH_ELEMENTS[3]}"
65
VG_NAME="${XPATH_ELEMENTS[4]:-$VG_NAME}"
66
SRC="${XPATH_ELEMENTS[5]}"
67
SIZE="${XPATH_ELEMENTS[6]}"
68
MD5="${XPATH_ELEMENTS[7]}"
69
SHA1="${XPATH_ELEMENTS[8]}"
70

  
71
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
72

  
73
LV_NAME="lv-one-${ID}"
74
DEV="/dev/$VG_NAME/$LV_NAME"
75

  
76
HASHES=""
77

  
78
if [ -n "$MD5" ]; then
79
    HASHES="$HASHES --md5 $MD5"
80
fi
81

  
82
if [ -n "$SHA1" ]; then
83
    HASHES="$HASHES --sha1 $SHA1"
84
fi
85

  
86
COPY_COMMAND="$UTILS_PATH/downloader.sh $HASHES $SRC -"
87

  
88
case $SRC in
89
http://*)
90
    log "Downloading $SRC to the image repository"
91

  
92
    DUMP="$COPY_COMMAND"
93
    ;;
94

  
95
*)
96
    if [ `check_restricted $SRC` -eq 1 ]; then
97
        log_error "Not allowed to copy images from $RESTRICTED_DIRS"
98
        error_message "Not allowed to copy image file $SRC"
99
        exit -1
100
    fi
101
    log "Copying local image $SRC to the image repository"
102

  
103
    DUMP="$COPY_COMMAND"
104
    ;;
105
esac
106

  
107
NEWLV_CMD="$SUDO $LVCREATE -L${SIZE}M ${VG_NAME} -n ${LV_NAME}"
108

  
109
exec_and_log "$NEWLV_CMD" "Error creating new logical volume: $DEV"
110

  
111
exec_and_log "eval $DUMP | $SUDO $DD of=$DEV bs=64k" \
112
    "Error dumping $SRC to $DEV"
113

  
114
echo "$DEV"
opennebula-3.5.80-shared_lvm/src/datastore_mad/remotes/shared_lvm/mkfs 2012-07-09 08:17:28.543406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
###############################################################################
20
# This script is used to create a VM image (SRC) of size (SIZE) and formatted
21
# as (FS)
22
###############################################################################
23

  
24
# -------- Set up the environment to source common tools & conf ------------
25

  
26
if [ -z "${ONE_LOCATION}" ]; then
27
    LIB_LOCATION=/usr/lib/one
28
else
29
    LIB_LOCATION=$ONE_LOCATION/lib
30
fi
31

  
32
. $LIB_LOCATION/sh/scripts_common.sh
33

  
34
DRIVER_PATH=$(dirname $0)
35
source ${DRIVER_PATH}/../libfs.sh
36
source ${DRIVER_PATH}/shared_lvm.conf
37

  
38
# -------- Get mkfs and datastore arguments from OpenNebula core ------------
39

  
40
DRV_ACTION=$1
41
ID=$2
42

  
43
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
44

  
45
unset i XPATH_ELEMENTS
46

  
47
while IFS= read -r -d '' element; do
48
    XPATH_ELEMENTS[i++]="$element"
49
done < <($XPATH     /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \
50
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/RESTRICTED_DIRS \
51
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/SAFE_DIRS \
52
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \
53
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/HOST \
54
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/VG_NAME \
55
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_IQN \
56
                    /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/BASE_TID \
57
                    /DS_DRIVER_ACTION_DATA/IMAGE/FSTYPE \
58
                    /DS_DRIVER_ACTION_DATA/IMAGE/SIZE)
59

  
60

  
61
BASE_PATH="${XPATH_ELEMENTS[0]}"
62
RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}"
63
SAFE_DIRS="${XPATH_ELEMENTS[2]}"
64
UMASK="${XPATH_ELEMENTS[3]}"
65
DST_HOST="${XPATH_ELEMENTS[4]:-$HOST}"
66
VG_NAME="${XPATH_ELEMENTS[5]:-$VG_NAME}"
67
FSTYPE="${XPATH_ELEMENTS[8]}"
68
SIZE="${XPATH_ELEMENTS[9]:-0}"
69

  
70
set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK"
71

  
72
LV_NAME="lv-one-${ID}"
73
DEV="/dev/$VG_NAME/$LV_NAME"
74

  
75
# ------------ Image to save_as disk, no need to create a FS ------------
76

  
77
if [ "$FSTYPE" = "save_as" ]; then
78
    NEWLV_CMD="$SUDO $LVCREATE -L${SIZE}M ${VG_NAME} -n ${LV_NAME}"
79
    
80
    exec_and_log "$NEWLV_CMD" \
81
    "Error creating new logical volume: $DEV"
82

  
83
    echo "$DEV $SIZE"
84
    exit 0
85
fi
86

  
87
# ------------ Create the image to the repository ------------
88

  
89
NEWLV_CMD="$SUDO $LVCREATE -L${SIZE}M ${VG_NAME} -n ${LV_NAME}"
90

  
91
exec_and_log "$NEWLV_CMD" \
92
    "Error creating new logical volume: $DEV"
93

  
94
MKFS_CMD="$SUDO $(mkfs_command $DEV $FSTYPE)"
95

  
96
exec_and_log "$MKFS_CMD" \
97
    "Error make $FSTYPE filesystem on $DEV"
98

  
99
echo "$DEV"
opennebula-3.5.80-shared_lvm/src/datastore_mad/remotes/shared_lvm/rm 2012-07-09 08:17:28.543406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
###############################################################################
20
# This script is used to remove a VM image (SRC) from the image repository
21
###############################################################################
22

  
23
# ------------ Set up the environment to source common tools ------------
24
if [ -z "${ONE_LOCATION}" ]; then
25
    LIB_LOCATION=/usr/lib/one
26
else
27
    LIB_LOCATION=$ONE_LOCATION/lib
28
fi
29

  
30
. $LIB_LOCATION/sh/scripts_common.sh
31

  
32
DRIVER_PATH=$(dirname $0)
33
source ${DRIVER_PATH}/../libfs.sh
34
source ${DRIVER_PATH}/shared_lvm.conf
35

  
36
# -------- Get rm and datastore arguments from OpenNebula core ------------
37

  
38
DRV_ACTION=$1
39
ID=$2
40

  
41
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
42

  
43
unset i XPATH_ELEMENTS
44

  
45
while IFS= read -r -d '' element; do
46
    XPATH_ELEMENTS[i++]="$element"
47
done < <($XPATH     /DS_DRIVER_ACTION_DATA/IMAGE/SOURCE \
48
        )
49

  
50
echo $XPATH_ELEMENTS > /tmp/xpath
51

  
52
DEV="${XPATH_ELEMENTS[0]}"
53

  
54
RM_COMMAND="$SUDO $LVREMOVE -f $DEV"
55

  
56
log "Removing $DEV from the volume group"
57

  
58
exec_and_log "$RM_COMMAND" \
59
    "Error removing $DEV"
60

  
61
exit 0
opennebula-3.5.80-shared_lvm/src/datastore_mad/remotes/shared_lvm/shared_lvm.conf 2012-07-09 08:17:28.543406751 +0200
1
# -------------------------------------------------------------------------- #
2
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
3
#                                                                            #
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
5
# not use this file except in compliance with the License. You may obtain    #
6
# a copy of the License at                                                   #
7
#                                                                            #
8
# http://www.apache.org/licenses/LICENSE-2.0                                 #
9
#                                                                            #
10
# Unless required by applicable law or agreed to in writing, software        #
11
# distributed under the License is distributed on an "AS IS" BASIS,          #
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
13
# See the License for the specific language governing permissions and        #
14
# limitations under the License.                                             #
15
#--------------------------------------------------------------------------- #
16

  
17
# Default volume group
18
VG_NAME=shared_lvm
19

  
20
# Lists of hosts (separated by spaces) for which no iscsiadm login or logout
21
# is performed.
22
NO_ISCSI="$HOSTNAME"
opennebula-3.5.80-shared_lvm/src/datastore_mad/remotes/shared_lvm/stat 2012-07-09 08:17:28.543406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
###############################################################################
20
# This script is used to copy a VM image (SRC) to the image repository as DST
21
# Several SRC types are supported
22
###############################################################################
23

  
24
# -------- Set up the environment to source common tools & conf ------------
25

  
26
if [ -z "${ONE_LOCATION}" ]; then
27
    LIB_LOCATION=/usr/lib/one
28
else
29
    LIB_LOCATION=$ONE_LOCATION/lib
30
fi
31

  
32
. $LIB_LOCATION/sh/scripts_common.sh
33

  
34
DRIVER_PATH=$(dirname $0)
35
source ${DRIVER_PATH}/../libfs.sh
36

  
37
# -------- Get cp and datastore arguments from OpenNebula core ------------
38

  
39
DRV_ACTION=$1
40
ID=$2
41

  
42
XPATH="${DRIVER_PATH}/../xpath.rb -b $DRV_ACTION"
43

  
44
unset i XPATH_ELEMENTS
45

  
46
while IFS= read -r -d '' element; do
47
    XPATH_ELEMENTS[i++]="$element"
48
done < <($XPATH /DS_DRIVER_ACTION_DATA/IMAGE/PATH)
49

  
50
SRC="${XPATH_ELEMENTS[0]}"
51

  
52
SIZE=`fs_size $SRC`
53

  
54
if [ "$SIZE" = "0" ]; then
55
    log_error "Cannot determine size for $SRC"
56
    exit -1
57
fi
58

  
59
echo "$SIZE"
opennebula-3.5.80-shared_lvm/src/sunstone/public/js/plugins/datastores-tab.js 2012-07-09 08:22:44.595406751 +0200
61 61
        <option value="vmware">' + tr("VMware") + '</option>\
62 62
        <option value="iscsi">' + tr("iSCSI") + '</option>\
63 63
        <option value="lvm">' + tr("LVM") + '</option>\
64
        <option value="shared_lvm">' + tr("Shared LVM") + '</option>\
64 65
  </select>\
65 66
  <label>' + tr("Transfer manager") + ':</label>\
66 67
  <select id="tm_mad" name="tm_mad">\
67 68
        <option value="shared">' + tr("Shared") + '</option>\
68 69
        <option value="ssh">' + tr("SSH") + '</option>\
69 70
        <option value="iscsi">' + tr("iSCSI") + '</option>\
71
        <option value="shared_lvm">' + tr("Shared LVM") + '</option>\
70 72
        <option value="dummy">' + tr("Dummy") + '</option>\
71 73
  </select>\
72 74
  <label>' + tr("Disk type") + ':</label>\
opennebula-3.5.80-shared_lvm/src/tm_mad/shared_lvm/clone 2012-07-09 08:18:10.187406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
# clone fe:SOURCE host:remote_system_ds/disk.i size
20
#   - fe is the front-end hostname
21
#   - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
22
#   - host is the target host to deploy the VM
23
#   - remote_system_ds is the path for the system datastore in the host
24

  
25
SRC=$1
26
DST=$2
27

  
28
if [ -z "${ONE_LOCATION}" ]; then
29
    TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
30
else
31
    TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
32
fi
33

  
34
DRIVER_PATH=$(dirname $0)
35

  
36
. $TMCOMMON
37

  
38
SRC_DEV=`arg_path $SRC`
39
DST_PATH=`arg_path $DST`
40
DST_HOST=`arg_host $DST`
41
DST_DIR=`dirname $DST_PATH`
42
VM_ID=`echo $DST_DIR | awk '{split($0,a,"/"); print a[length(a)];}'`
43
NEW_DEV=$SRC_DEV-$VM_ID
44

  
45
VG_NAME=`echo $SRC_DEV | sed -r 's/.dev\/([^\/]*).*/\1/g'`
46
LV_NAME=`echo $SRC_DEV | sed -r 's/.dev\/[^\/]*\/(.*)/\1/g'`
47

  
48

  
49
SIZE=`$SUDO lvdisplay $SRC_DEV | awk '/Current LE/ {print $3}'`
50

  
51
log "Create LV"
52
$SUDO $LVCREATE -l${SIZE} ${VG_NAME} -n ${NEW_DEV}
53

  
54
log "Cloning $SRC_DEV to ${NEW_DEV}"
55
$SUDO $DD if=$SRC_DEV of=$NEW_DEV bs=64k
56

  
57
DISCOVER_CMD=$(cat <<EOF
58
    set -e
59
    mkdir -p $DST_DIR
60
    sudo lvscan
61
    sudo lvchange -a y $NEW_DEV
62
    ln -s "$NEW_DEV" "$DST_PATH"
63
EOF
64
)
65

  
66
ssh_exec_and_log "$DST_HOST" "$DISCOVER_CMD" \
67
        "Error registering $NEW_DEV"
68

  
69
exit 0
opennebula-3.5.80-shared_lvm/src/tm_mad/shared_lvm/delete 2012-07-09 08:18:10.187406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
# DELETE <host:remote_system_ds/disk.i|host:remote_system_ds/>
20
#   - host is the target host to deploy the VM
21
#   - remote_system_ds is the path for the system datastore in the host
22

  
23
DST=$1
24

  
25
if [ -z "${ONE_LOCATION}" ]; then
26
    TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
27
else
28
    TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
29
fi
30

  
31
. $TMCOMMON
32

  
33
#-------------------------------------------------------------------------------
34
# Return if deleting a disk, we will delete them when removing the
35
# remote_system_ds directory for the VM (remotely)
36
#-------------------------------------------------------------------------------
37
DST_PATH=`arg_path $DST`
38
DST_DIR=`dirname $DST_PATH`
39
DST_HOST=`arg_host $DST`
40

  
41
if [ `is_disk $DST_PATH` -eq 1 ]; then
42
    # Disk
43
    LV_PATH=`$SSH $DST_HOST readlink $DST_PATH`
44
    LV_NAME=`echo $LV_PATH | sed -r 's/.dev\/[^\/]*\/(.*)/\1/g'`
45
    LEN=`echo -n $LV_NAME | grep -o - | wc -c`
46
    $SSH $DST_HOST "lvchange -a n $LV_PATH"
47
    if [ $LEN -eq 6 ]; then #Non persistent
48
	log "Removing non persistent disk from shared LVM DS"
49
        exec_and_log "$SUDO $LVREMOVE -f $LV_PATH" \
50
    	    "Error while removing LV $LV_PATH"
51
    fi
52
else
53
    # Directory
54
    log "Deleting $DST_PATH"
55
    ssh_exec_and_log "$DST_HOST" "rm -rf $DST_PATH" "Error deleting $DST_PATH"
56
fi
57

  
58
exit 0
opennebula-3.5.80-shared_lvm/src/tm_mad/shared_lvm/ln 2012-07-09 08:18:10.187406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
# clone fe:SOURCE host:remote_system_ds/disk.i size
20
#   - fe is the front-end hostname
21
#   - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
22
#   - host is the target host to deploy the VM
23
#   - remote_system_ds is the path for the system datastore in the host
24

  
25
SRC=$1
26
DST=$2
27

  
28
if [ -z "${ONE_LOCATION}" ]; then
29
    TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
30
else
31
    TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
32
fi
33

  
34
. $TMCOMMON
35

  
36
#-------------------------------------------------------------------------------
37
# Set dst path and dir
38
#-------------------------------------------------------------------------------
39

  
40
IQN=$SRC
41
DEV=`arg_path $SRC`
42
DST_PATH=`arg_path $DST`
43
DST_HOST=`arg_host $DST`
44
DST_DIR=`dirname $DST_PATH`
45

  
46
DISCOVER_CMD=$(cat <<EOF
47
    set -e
48
    mkdir -p $DST_DIR
49
    sudo lvscan
50
    sudo lvchange -a y $DEV
51
    ln -s "$DEV" "$DST_PATH"
52
EOF
53
)
54

  
55
ssh_exec_and_log "$DST_HOST" "$DISCOVER_CMD" \
56
        "Error registering $DST_HOST:$DEV"
57
exit 0
opennebula-3.5.80-shared_lvm/src/tm_mad/shared_lvm/mv 2012-07-09 08:18:10.187406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
# MV <hostA:system_ds/disk.i|hostB:system_ds/disk.i>
20
#    <hostA:system_ds/|hostB:system_ds/>
21
#   - hostX is the target host to deploy the VM
22
#   - system_ds is the path for the system datastore in the host
23

  
24
SRC=$1
25
DST=$2
26

  
27
if [ -z "${ONE_LOCATION}" ]; then
28
    TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
29
else
30
    TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
31
fi
32

  
33
. $TMCOMMON
34

  
35
DRIVER_PATH=$(dirname $0)
36

  
37
source ${DRIVER_PATH}/../../datastore/iscsi/iscsi.conf
38

  
39
#-------------------------------------------------------------------------------
40
# Return if moving a disk, we will move them when moving the whole system_ds
41
# directory for the VM
42
#-------------------------------------------------------------------------------
43
SRC_PATH=`arg_path $SRC`
44
DST_PATH=`arg_path $DST`
45

  
46
SRC_HOST=`arg_host $SRC`
47
DST_HOST=`arg_host $DST`
48

  
49
DST_DIR=`dirname $DST_PATH`
50

  
51
if [ `is_disk $SRC_PATH` -eq 0 ]; then
52
    ssh_make_path $DST_HOST $DST_DIR
53

  
54
    log "Moving $SRC to $DST"
55

  
56
    exec_and_log "$SCP -r $SRC $DST" "Could not copy $SRC to $DST"
57

  
58
    ssh_exec_and_log "$SRC_HOST" "rm -rf $SRC_PATH" \
59
        "Could not remove $SRC_HOST:$SRC_PATH"
60

  
61
	exit 0
62
fi
63

  
64
if [ "$SRC" == "$DST" ]; then
65
    log "Not moving $SRC to $DST, they are the same path"
66
	exit 0
67
fi
68

  
69
DEV=`$SSH $SRC_HOST readlink $SRC_PATH`
70

  
71
LOGIN_CMD=$(cat <<EOF
72
    set -e
73
    mkdir -p $DST_DIR
74
    sudo lvscan
75
    sudo lvchange -a y $DEV
76
    ln -sf "$DEV" "$DST_PATH"
77
EOF
78
)
79

  
80
ssh_exec_and_log "$DST_HOST" "$LOGIN_CMD" \
81
        "Error changing LV state to active"
82

  
83
exit 0
opennebula-3.5.80-shared_lvm/src/tm_mad/shared_lvm/mvds 2012-07-09 08:18:10.187406751 +0200
1
#!/bin/bash
2

  
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

  
19
# mvds host:remote_system_ds/disk.i fe:SOURCE
20
#   - fe is the front-end hostname
21
#   - SOURCE is the path of the disk image in the form DS_BASE_PATH/disk
22
#   - host is the target host to deploy the VM
23
#   - remote_system_ds is the path for the system datastore in the host
24

  
25
SRC=$1
26
DST=$2
27

  
28
if [ -z "${ONE_LOCATION}" ]; then
29
    TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh
30
else
31
    TMCOMMON=$ONE_LOCATION/var/remotes/tm/tm_common.sh
32
fi
33

  
34
. $TMCOMMON
35

  
36
SRC_HOST=`arg_host $SRC`
37
SRC_PATH=`arg_path $SRC`
38
DEV=`$SSH $SRC_HOST readlink $SRC_PATH`
39

  
40
LV_NAME=`echo $DEV | sed -r 's/.dev\/[^\/]*\/(.*)/\1/g'`
41

  
42
LEN=`echo -n $LV_NAME | grep -o - | wc -c`
43

  
44
if [ $LEN -eq 6 ]; then
45
#non persistent
46
    log "Copy non persistent image"
47
    $SUDO $DD if=$DEV of=$DST bs=64k
48
    $SUDO $LVREMOVE -f $DEV
49
    exit 0
50

  
51
exit 0
52
fi
53