diff --git a/openstack/image/v2/image.py b/openstack/image/v2/image.py index 7a941f082..5a79c9c1c 100644 --- a/openstack/image/v2/image.py +++ b/openstack/image/v2/image.py @@ -264,15 +264,32 @@ class Image(resource.Resource, tag.TagMixin, _download.DownloadMixin): """ self._action(session, "reactivate") - def upload(self, session): - """Upload data into an existing image""" + def upload(self, session, *, data=None): + """Upload data into an existing image + + :param session: The session to use for making this request + :param data: Optional data to be uploaded. If not provided, the + `~Image.data` attribute will be used + :returns: The server response + """ + if data: + self.data = data url = utils.urljoin(self.base_path, self.id, 'file') return session.put(url, data=self.data, headers={"Content-Type": "application/octet-stream", "Accept": ""}) - def stage(self, session): - """Stage binary image data into an existing image""" + def stage(self, session, *, data=None): + """Stage binary image data into an existing image + + :param session: The session to use for making this request + :param data: Optional data to be uploaded. If not provided, the + `~Image.data` attribute will be used + :returns: The server response + """ + if data: + self.data = data + url = utils.urljoin(self.base_path, self.id, 'stage') response = session.put( url, data=self.data,