Implemented backup with rotation.
This commit is contained in:
parent
459e51b14e
commit
04ef226676
|
@ -47,7 +47,7 @@ copyright = u'Rackspace, based on work by Jacob Kaplan-Moss'
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = '2.5'
|
version = '2.5'
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = '2.5.5'
|
release = '2.5.6'
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|
|
@ -47,7 +47,7 @@ class ImageManager(base.ManagerWithFind):
|
||||||
return self._list("/images%s" % detail, "images")
|
return self._list("/images%s" % detail, "images")
|
||||||
|
|
||||||
|
|
||||||
def create(self, name, server):
|
def create(self, server, image_type="snapshot", name=None, rotation=None):
|
||||||
"""
|
"""
|
||||||
Create a new image by snapshotting a running :class:`Server`
|
Create a new image by snapshotting a running :class:`Server`
|
||||||
|
|
||||||
|
@ -55,7 +55,17 @@ class ImageManager(base.ManagerWithFind):
|
||||||
:param server: The :class:`Server` (or its ID) to make a snapshot of.
|
:param server: The :class:`Server` (or its ID) to make a snapshot of.
|
||||||
:rtype: :class:`Image`
|
:rtype: :class:`Image`
|
||||||
"""
|
"""
|
||||||
data = {"image": {"serverId": base.getid(server), "name": name}}
|
if image_type not in ("daily", "weekly", "snapshot"):
|
||||||
|
raise Exception("Invalid image_type: must be daily, "
|
||||||
|
"weekly or snapshot")
|
||||||
|
|
||||||
|
if image_type == "snapshot" and not name:
|
||||||
|
raise Exception("name is required for snapshots")
|
||||||
|
elif image_type != "snapshot" and not rotation:
|
||||||
|
raise Exception("rotation is required for backups")
|
||||||
|
|
||||||
|
data = {"image": {"serverId": base.getid(server), "name": name,
|
||||||
|
"image_type": image_type, "rotation": rotation}}
|
||||||
return self._create("/images", data, "image")
|
return self._create("/images", data, "image")
|
||||||
|
|
||||||
def delete(self, image):
|
def delete(self, image):
|
||||||
|
|
|
@ -474,11 +474,19 @@ class OpenStackShell(object):
|
||||||
print_list(self.cs.images.list(), ['ID', 'Name', 'Status'])
|
print_list(self.cs.images.list(), ['ID', 'Name', 'Status'])
|
||||||
|
|
||||||
@arg('server', metavar='<server>', help='Name or ID of server.')
|
@arg('server', metavar='<server>', help='Name or ID of server.')
|
||||||
@arg('name', metavar='<name>', help='Name for the new image.')
|
@arg('image_type', metavar='<image_type>', default='snapshot', help='daily, weekly or snapshot (default)')
|
||||||
|
@arg('--rotation',
|
||||||
|
default=None,
|
||||||
|
metavar='<rotation>',
|
||||||
|
help="Number of backups to retain. (for image-type daily or weekly)")
|
||||||
|
@arg('--name',
|
||||||
|
default=None,
|
||||||
|
metavar='<name>',
|
||||||
|
help="Name of the new snapshot")
|
||||||
def do_image_create(self, args):
|
def do_image_create(self, args):
|
||||||
"""Create a new image by taking a snapshot of a running server."""
|
"""Create a new image by taking a snapshot of a running server."""
|
||||||
server = self._find_server(args.server)
|
server = self._find_server(args.server)
|
||||||
image = self.cs.images.create(args.name, server)
|
image = self.cs.images.create(server, image_type=args.image_type, name=args.name, rotation=args.rotation)
|
||||||
print_dict(image._info)
|
print_dict(image._info)
|
||||||
|
|
||||||
@arg('image', metavar='<image>', help='Name or ID of image.')
|
@arg('image', metavar='<image>', help='Name or ID of image.')
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -11,7 +11,7 @@ if sys.version_info < (2,6):
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name = "python-novaclient",
|
name = "python-novaclient",
|
||||||
version = "2.5.5",
|
version = "2.5.6",
|
||||||
description = "Client library for OpenStack Nova API",
|
description = "Client library for OpenStack Nova API",
|
||||||
long_description = read('README.rst'),
|
long_description = read('README.rst'),
|
||||||
url = 'https://github.com/rackspace/python-novaclient',
|
url = 'https://github.com/rackspace/python-novaclient',
|
||||||
|
|
Loading…
Reference in New Issue