Revision bd924ffd

b/shared-filer/attach
1
#!/usr/bin/env python
2
#
3
# Copyright (C) 2012 Greek Research and Technology Network
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

  
20
"""Map an existing file Image to a loop device
21

  
22
This program maps an existing file Image to a block device
23
e.g. /dev/loop{X} and returns the device path. If the mapping
24
already exists, it returns the corresponding device path.
25

  
26
It takes it's input from environment variables. Specifically the
27
following variables should be present:
28

  
29
 - VOL_NAME: The name of the Image to map
30

  
31
Returns the block device path (which maps the Image) as a string
32
upon success, or 1 upon failure
33

  
34
"""
35

  
36
import os
37
import sys
38

  
39
sys.path.append("/usr/share/ganeti")
40

  
41
from ganeti import utils
42

  
43

  
44
# Default shared directory
45
SHARED_DIR = "/srv/ganeti/shared-file-storage"
46
#SHARED_DIR = "/mnt/okeanos/shared_dir"
47

  
48

  
49
def ReadEnv():
50
  """Read the mandatory enviromental variables
51

  
52
  """
53
  name = os.getenv("VOL_NAME")
54
  if name is None:
55
    sys.stderr.write('The environment variable VOL_NAME is missing.\n')
56
    return None
57
  shared_dir_param = os.getenv("EXTP_SHARED_DIR")
58
  if shared_dir_param is not None:
59
    sys.stderr.write('Found shared dir param, value: %s\n' % shared_dir_param)
60

  
61
  return (name, shared_dir_param)
62

  
63

  
64
def _ParseLosetupOutput(output, filename):
65
  """Parse the output of `losetup -j <filename>`
66

  
67
  This method parses the output of `losetup -j <filename>` and returns
68
  the corresponding loop device path for this filename
69
  (e.g. /dev/loop0)
70

  
71
  @type output: string
72
  @param output: the whole output of `losetup -j filename`
73
  @type filename: string
74
  @param filename: the complete file path to the file we search for
75
  @rtype: string or None
76
  @return: loop device path if the file is losetup, else None
77

  
78
  """
79
  # `losetup -j file1` output looks like this
80
  #   /dev/loop0: [X]:Y (/path/to/file1)
81
  # if the file has been losetup. If not there is no output.
82
  # If the file has been losetup more than once, then there will be
83
  # multiple lines like the one above.
84
  #
85
  # We assume the following format (space is the seperator):
86
  # field0: field1 (field2)
87

  
88
  field0 = 0
89
  field_sep = " "
90
  
91
  lines = output.splitlines()
92
  splitted_lines = map(lambda l: l.split(field_sep), lines)
93

  
94
  # Check empty output. If empty, the file is not losetup
95
  if not splitted_lines:
96
    return None
97

  
98
  # Check if we have more than one lines in the output
99
  if len(splitted_lines) > 1:
100
    sys.stderr.write("The file %s is losetup more than once" % filename)
101
    sys.exit(1)
102

  
103
  # The file is losetup only once
104
  # Take field0, remove the ":" at the end and we have our path
105
  dev_path = splitted_lines[0][field0].split(":")[0]
106

  
107
  return dev_path
108

  
109

  
110
def main():
111
  sys.stderr.write('Attaching started: reading environment...\n')
112

  
113
  # Read environment
114
  env = ReadEnv()
115
  if env is None:
116
    sys.stderr.write('Wrong environment. Aborting\n')
117
    return 1
118

  
119
  file_name, shared_dir_param = env
120

  
121
  if shared_dir_param is None:
122
    shared_dir_param = SHARED_DIR
123

  
124
  file_path = utils.PathJoin(shared_dir_param, file_name)
125

  
126
  sys.stderr.write('Read environment successfully: file name: %s\n' % file_path)
127

  
128
  # Check if the file exists
129
  if not os.path.exists(file_path):
130
    sys.stderr.write("File %s does not exist. Aborting\n" % file_path)
131
    return 1
132

  
133
  # Check if the file is already losetup
134
  cmd1 = ["losetup", "-j", "%s" % file_path]
135
  result = utils.RunCmd(cmd1)
136
  if result.failed:
137
    sys.stderr.write("losetup -j %s failed (%s): %s" %
138
                     (file_path, result.fail_reason, result.output))
139
    return 1
140
  else:
141
    # Parse the result's output
142
    dev_path = _ParseLosetupOutput(result.output, file_path)
143

  
144
    if dev_path is None:
145
      # The file is not attached. Attach it
146
      cmd2 = ["losetup", "-f", "--show", "%s" % file_path]
147
      result = utils.RunCmd(cmd2)
148
      if result.failed:
149
        sys.stderr.write('Cannot losetup file %s, attachment failed (%s): %s' %
150
                         file_path, result.fail_reason, result.output)
151
        return 1
152

  
153
      # The '--show' option returns an EOL at the end. Remove it.
154
      dev_path = result.output.split("\n")[0]
155

  
156
      # The file was losetup successfully. Return the loop device.
157
      sys.stderr.write('File %s successfully attached at %s\n' %
158
                       (file_path, dev_path))
159
      sys.stdout.write("%s" % str(dev_path))
160
      return 0
161

  
162
    else:
163
      # The file is already losetup. Return the loop device path
164
      sys.stderr.write('File %s successfully attached at %s\n' %
165
                       (file_path, dev_path))
166
      sys.stdout.write("%s" % str(dev_path))
167
      return 0
168

  
169

  
170
if __name__ == "__main__":
171
    sys.exit(main())
b/shared-filer/attach.wrap
1
#!/bin/bash
2

  
3
# This file can be used to log all error output of the attach script,
4
# which is currently not being logged under /var/log/ganeti/extstorage/
5
# due to the way Ganeti handles stdout and logfiles (RunResult).
6
# All other scripts (create, detach, remove) are logged under that dir.
7
#
8
# To do so, do the following:
9
# 
10
#  * rename the `attach' script to `attach.py'
11
#  * rename the `attach.wrap' script to `attach'
12
#  * set LOGFILE to point to a logfile of your choise
13
#    (by default this logs under the same dir as all other scripts)
14

  
15
ATTACH_SCRIPT=/usr/share/ganeti/extstorage/shared-filer/attach.py
16
LOGFILE=/tmp/attach-shared-filer-$(date +%Y%M%d%H:%m:%S.%N)
17

  
18
exec "$ATTACH_SCRIPT" 2>"$LOGFILE"
b/shared-filer/create
1
#!/usr/bin/env python
2
#
3
# Copyright (C) 2012 Greek Research and Technology Network
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

  
20
"""Create a new file under a shared directory
21

  
22
This program creates a new file inside a shared directory. It will be
23
used to host a disk Image. It takes it's input from environment variables.
24
Specifically the following variables should be present:
25

  
26
 - VOL_NAME: The name of the new Image file
27
 - VOL_SIZE: The size of the new Image (in mebibytes)
28

  
29
Returns O after successfull creation, 1 on failure
30

  
31
"""
32

  
33
import os
34
import sys
35
import errno
36

  
37
sys.path.append("/usr/share/ganeti")
38

  
39
from ganeti import utils
40

  
41
# Default shared directory
42
SHARED_DIR = "/srv/ganeti/shared-file-storage"
43

  
44

  
45
def ReadEnv():
46
  """Read the mandatory enviromental variables
47

  
48
  """
49
  name = os.getenv("VOL_NAME")
50
  if name is None:
51
    sys.stderr.write('The environment variable VOL_NAME is missing.\n')
52
    return None
53
  size = os.getenv("VOL_SIZE")
54
  if size is None:
55
    sys.stderr.write('The environment variable VOL_SIZE is missing.\n')
56
    return None
57
  shared_dir_param = os.getenv("EXTP_SHARED_DIR")
58
  if shared_dir_param is not None:
59
    sys.stderr.write('Found shared dir param, value: %s\n' % shared_dir_param)
60

  
61
  return (name, size, shared_dir_param)
62

  
63

  
64
def main():
65
  sys.stderr.write('Creation started: reading environment...\n')
66

  
67
  # Read environment
68
  env = ReadEnv()
69
  if env is None:
70
    sys.stderr.write('Wrong environment. Aborting\n')
71
    return 1
72

  
73
  file_name, size, shared_dir_param = env
74

  
75
  if shared_dir_param is None:
76
    shared_dir_param = SHARED_DIR
77

  
78
  file_path = utils.PathJoin(shared_dir_param, file_name)
79

  
80
  sys.stderr.write('Read environment successfully: file name: %s, '
81
                   'size: %sMB\n' % (file_path, size))
82

  
83
  # Check if directory exists
84
  if not os.path.isdir(shared_dir_param):
85
    sys.stderr.write('%s is not a valid directory. Aborting' % shared_dir_param)
86
    return 1
87

  
88
  # Create file
89
  try:
90
    fd = os.open(file_path, os.O_RDWR | os.O_CREAT | os.O_EXCL)
91
    f = os.fdopen(fd, "w")
92
    f.truncate(int(size) * 1024 * 1024)
93
    f.close()
94
  except EnvironmentError, err:
95
    if err.errno == errno.EEXIST:
96
      sys.stderr.write('File already existing: %s\n' % file_path)
97
      return 1
98
    sys.stderr.write('Error in file creation: %\n' % str(err))
99
    return 1
100

  
101
  sys.stderr.write('Image file created successfully\n')
102
  return 0
103

  
104

  
105
if __name__ == "__main__":
106
    sys.exit(main())
b/shared-filer/detach
1
#!/usr/bin/env python
2
#
3
# Copyright (C) 2012 Greek Research and Technology Network
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

  
20
"""Detach the Image file from the loop device
21

  
22
This program detaches an Image file from the loop device it attached to.
23
It is idempotent, if the file isn't losetup at all.
24

  
25
It takes it's input from environment variables. Specifically the
26
following variable should be present:
27

  
28
 - VOL_NAME: The name of the Image file to which the device points
29

  
30
Returns O upon successfull unmapping, 1 upon failure
31

  
32
"""
33

  
34
import os
35
import sys
36

  
37
sys.path.append("/usr/share/ganeti/")
38

  
39
from ganeti import utils
40

  
41

  
42
# Default shared directory
43
SHARED_DIR = "/srv/ganeti/shared-file-storage"
44

  
45

  
46
def ReadEnv():
47
  """Read the mandatory enviromental variables
48

  
49
  """
50
  name = os.getenv("VOL_NAME")
51
  if name is None:
52
    sys.stderr.write('The environment variable VOL_NAME is missing.\n')
53
    return None
54
  shared_dir_param = os.getenv("EXTP_SHARED_DIR")
55
  if shared_dir_param is not None:
56
    sys.stderr.write('Found shared dir param, value: %s\n' % shared_dir_param)
57

  
58
  return (name, shared_dir_param)
59

  
60

  
61
def _ParseLosetupOutput(output, filename):
62
  """Parse the output of `losetup -j <filename>`
63

  
64
  This method parses the output of `losetup -j <filename>` and returns
65
  the corresponding loop device path for this filename
66
  (e.g. /dev/loop0)
67

  
68
  @type output: string
69
  @param output: the whole output of `losetup -j filename`
70
  @type filename: string
71
  @param filename: the complete file path to the file we search for
72
  @rtype: string or None
73
  @return: loop device path if the file is losetup, else None
74

  
75
  """
76
  # `losetup -j file1` output looks like this
77
  #   /dev/loop0: [X]:Y (/path/to/file1)
78
  # if the file has been losetup. If not there is no output.
79
  # If the file has been losetup more than once, then there will be
80
  # multiple lines like the one above.
81
  #
82
  # We assume the following format (space is the seperator):
83
  # field0: field1 (field2)
84

  
85
  field0 = 0
86
  field_sep = " "
87
  
88
  lines = output.splitlines()
89
  splitted_lines = map(lambda l: l.split(field_sep), lines)
90

  
91
  # Check empty output. If empty, the file is not losetup
92
  if not splitted_lines:
93
    return None
94

  
95
  # Check if we have more than one lines in the output
96
  if len(splitted_lines) > 1:
97
    sys.stderr.write("The file %s is losetup more than once" % filename)
98
    sys.exit(1)
99

  
100
  # The file is losetup only once
101
  # Take field0, remove the ":" at the end and we have our path
102
  dev_path = splitted_lines[0][field0].split(":")[0]
103

  
104
  return dev_path
105

  
106

  
107
def main():
108
  sys.stderr.write('Detaching started: reading environment...\n')
109

  
110
  # Read environment
111
  env = ReadEnv()
112
  if env is None:
113
    sys.stderr.write('Wrong environment. Aborting\n')
114
    return 1
115

  
116
  file_name, shared_dir_param = env
117

  
118
  if shared_dir_param is None:
119
    shared_dir_param = SHARED_DIR
120

  
121
  file_path = utils.PathJoin(shared_dir_param, file_name)
122

  
123
  sys.stderr.write('Read environment successfully: file name: %s\n' % file_path)
124

  
125
  # Check if the file exists
126
  if not os.path.exists(file_path):
127
    sys.stderr.write('File %s does not exist. Aborting\n' % file_path)
128
    return 1
129

  
130
  # Check if the file is losetup
131
  cmd1 = ["losetup", "-j", "%s" % file_path]
132
  result = utils.RunCmd(cmd1)
133
  if result.failed:
134
    sys.stderr.write('losetup -j %s failed (%s): %s' %
135
                     (dev_path, result.fail_reason, result.output))
136
    return 1
137
  else:
138
    # Parse the result's output
139
    dev_path = _ParseLosetupOutput(result.output, file_path)
140

  
141
    if dev_path is None:
142
      # The file is not losetup (device is not attached). Return.
143
      sys.stderr.write('File %s successfully detached\n' % file_path)
144
      return 0
145
    else:
146
      # The file is losetup (device attached). Detach it.
147
      cmd2 = ["losetup", "-d", "%s" % dev_path]
148
      result = utils.RunCmd(cmd2)
149
      if result.failed:
150
        sys.stderr.write('Cannot `losetup -d` device: %s, detachment failed '
151
                         '(%s): %s\n' %
152
                          (dev_path, result.fail_reason, result.output))
153
        return 1
154

  
155
      sys.stderr.write('File %s successfully detached\n' % file_path)
156
      return 0
157

  
158

  
159
if __name__ == "__main__":
160
    sys.exit(main())
b/shared-filer/grow
1
#!/usr/bin/env python
2
#
3
# Copyright (C) 2012 Greek Research and Technology Network
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

  
20
"""Grow an existing Image file
21

  
22
This program grows an existing Image file which resides under a
23
shared directory.
24

  
25
It takes it's input from environment variables. Specifically the
26
following variables should be present:
27

  
28
 - VOL_NAME: The name of the Image to grow
29
 - VOL_SIZE: The current Image's size
30
 - VOL_NEW_SIZE: The new size of the Image after it's grown
31

  
32
Returns 0 upon successful grow, 1 upon failure
33

  
34
"""
35

  
36
import os
37
import sys
38

  
39
sys.path.append("/usr/share/ganeti/")
40

  
41
from ganeti import utils
42

  
43

  
44
# Default shared directory
45
SHARED_DIR = "/srv/ganeti/shared-file-storage"
46

  
47

  
48
def ReadEnv():
49
  """Read the mandatory enviromental variables
50

  
51
  """
52
  name = os.getenv("VOL_NAME")
53
  if name is None:
54
    sys.stderr.write('The environment variable VOL_NAME is missing.\n')
55
    return None
56
  new_size = os.getenv("VOL_NEW_SIZE")
57
  if new_size is None:
58
    sys.stderr.write('The environment variable VOL_NEW_SIZE is missing.\n')
59
    return None
60
  shared_dir_param = os.getenv("EXTP_SHARED_DIR")
61
  if shared_dir_param is not None:
62
    sys.stderr.write('Found shared dir param, value: %s\n' % shared_dir_param)
63

  
64
  return (name, new_size, shared_dir_param)
65

  
66

  
67
def _ParseLosetupOutput(output, filename):
68
  """Parse the output of `losetup -j <filename>`
69

  
70
  This method parses the output of `losetup -j <filename>` and returns
71
  the corresponding loop device path for this filename
72
  (e.g. /dev/loop0)
73

  
74
  @type output: string
75
  @param output: the whole output of `losetup -j filename`
76
  @type filename: string
77
  @param filename: the complete file path to the file we search for
78
  @rtype: string or None
79
  @return: loop device path if the file is losetup, else None
80

  
81
  """
82
  # `losetup -j file1` output looks like this
83
  #   /dev/loop0: [X]:Y (/path/to/file1)
84
  # if the file has been losetup. If not there is no output.
85
  # If the file has been losetup more than once, then there will be
86
  # multiple lines like the one above.
87
  #
88
  # We assume the following format (space is the seperator):
89
  # field0: field1 (field2)
90

  
91
  field0 = 0
92
  field_sep = " "
93
  
94
  lines = output.splitlines()
95
  splitted_lines = map(lambda l: l.split(field_sep), lines)
96

  
97
  # Check empty output. If empty, the file is not losetup
98
  if not splitted_lines:
99
    return None
100

  
101
  # Check if we have more than one lines in the output
102
  if len(splitted_lines) > 1:
103
    sys.stderr.write("The file %s is losetup more than once" % filename)
104
    sys.exit(1)
105

  
106
  # The file is losetup only once
107
  # Take field0, remove the ":" at the end and we have our path
108
  dev_path = splitted_lines[0][field0].split(":")[0]
109

  
110
  return dev_path
111

  
112

  
113
def main():
114
  sys.stderr.write('Creation started: reading environment...\n')
115

  
116
  # Read environment.
117
  env = ReadEnv()
118
  if env is None:
119
    sys.stderr.write('Wrong environment. Aborting\n')
120
    return 1
121

  
122
  file_name, new_size, shared_dir_param = env
123

  
124
  if shared_dir_param is None:
125
    shared_dir_param = SHARED_DIR
126

  
127
  file_path = utils.PathJoin(shared_dir_param, file_name)
128

  
129
  sys.stderr.write('Read environment successfully: file name: %s, '
130
                   'new size: %sMB\n' % (file_path, new_size))
131

  
132
  # Check if the file exists.
133
  if not os.path.exists(file_path):
134
    sys.stderr.write("File %s does not exist. Aborting\n" % file_path)
135
    return 1
136

  
137
  # Grow file.
138
  try:
139
    f = open(file_path, "a+")
140
    f.truncate(int(new_size) * 1024 * 1024)
141
    f.close()
142
  except EnvironmentError, err:
143
    sys.stderr.write('Error in file growth: %' % str(err))
144
    return 1
145

  
146
  # Growth successful.
147
  # Now the loop device needs to reread the size of the associated file.
148

  
149
  # Find out the loop device path first.
150
  cmd1 = ["losetup", "-j", "%s" % file_path]
151
  result = utils.RunCmd(cmd1)
152
  if result.failed:
153
    sys.stderr.write("losetup -j %s failed (%s): %s" %
154
                     (dev_path, result.fail_reason, result.output))
155
    return 1
156
  else:
157
    # Parse the result's output.
158
    dev_path = _ParseLosetupOutput(result.output, file_path)
159

  
160
    if dev_path is None:
161
      # The file is not attached. We should never get here during growth.
162
      sys.stderr.write('File %s is not losetup during growth (%s): %s\n'
163
                       'This should not happen. Aborting\n' %
164
                        file_path, result.fail_reason, result.output)
165
      return 1
166

  
167
    else:
168
      # The file is losetup as expected. Reread size of file.
169
      cmd2 = ["losetup", "-c", "%s" % dev_path]
170
      result = utils.RunCmd(cmd2)
171
      if result.failed:
172
        sys.stderr.write('losetup -c %s failed (%s): %s' %
173
                         (dev_path, result.fail_reason, result.output))
174
        sys.stderr.write('You have to manually reread size of loop device `%s` '
175
                         'since its associated file `%s` has grown\n' %
176
                         (dev_path, file_path,
177
                          result.fail_reason, result.output))
178
        return 1
179

  
180
      # Growth and reread successful.
181
      sys.stderr.write('Grow successful for file: %s\n' % file_path)
182
      return 0
183

  
184

  
185
if __name__ == "__main__":
186
    sys.exit(main())
b/shared-filer/parameters.list
1
shared_dir The shared directory under which to put the Image files
b/shared-filer/remove
1
#!/usr/bin/env python
2
#
3
# Copyright (C) 2012 Greek Research and Technology Network
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

  
20
"""Remove an existing file under a shared directory
21

  
22
This program removes an existing file from a shared directory. It takes
23
it's input from environment variables. Specifically the following variables
24
should be present:
25

  
26
 - VOL_NAME: The name of the new Image file
27

  
28
Returns O after successfull creation, 1 on failure
29

  
30
"""
31

  
32
import os
33
import sys
34

  
35
sys.path.append("/usr/share/ganeti/")
36

  
37
from ganeti import utils
38

  
39

  
40
# Default shared directory
41
SHARED_DIR = "/srv/ganeti/shared-file-storage"
42

  
43

  
44
def ReadEnv():
45
  """Read the mandatory enviromental variables
46

  
47
  """
48
  name = os.getenv("VOL_NAME")
49
  if name is None:
50
    sys.stderr.write('The environment variable VOL_NAME is missing.\n')
51
    return None
52
  shared_dir_param = os.getenv("EXTP_SHARED_DIR")
53
  if shared_dir_param is not None:
54
    sys.stderr.write('Found shared dir param, value: %s\n' % shared_dir_param)
55

  
56
  return (name, shared_dir_param)
57

  
58

  
59
def main():
60
  sys.stderr.write('Removal started: reading environment...\n')
61

  
62
  # Read environment
63
  env = ReadEnv()
64
  if env is None:
65
    sys.stderr.write('Wrong environment. Aborting\n')
66
    return 1
67

  
68
  file_name, shared_dir_param = env
69

  
70
  if shared_dir_param is None:
71
    shared_dir_param = SHARED_DIR
72

  
73
  file_path = utils.PathJoin(shared_dir_param, file_name)
74

  
75
  sys.stderr.write('Read environment successfully: file name: %s\n' % file_path)
76

  
77
  # Remove file
78
  cmd = ["rm", "-f", "%s" % file_path]
79
  result = utils.RunCmd(cmd)
80
  if result.failed:
81
    sys.stderr.write('Cannot remove Image file %s with `rm -f`: %s - %s\n' %
82
                     (file_path, result.fail_reason, result.output))
83
    return 1
84

  
85
  sys.stderr.write('Image file %s removed successfully\n' % file_path)
86
  return 0
87

  
88

  
89
if __name__ == "__main__":
90
    sys.exit(main())
b/shared-filer/setinfo
1
#!/bin/bash
2

  
3
exit 0
b/shared-filer/snapshot
1
#!/bin/bash
2

  
3
exit 0
b/shared-filer/verify
1
#!/bin/bash
2

  
3
exit 0

Also available in: Unified diff