Skip to content

Commit 62b5865

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add --owner to image create"
2 parents 53fc20f + 5ad5996 commit 62b5865

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

doc/source/command-objects/image.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ Create/upload an image
5757

5858
Image owner project name or ID
5959

60-
*Image version 1 only.*
61-
6260
.. option:: --size <size>
6361

6462
Image size, in bytes (only used with --location and --copy-from)

openstackclient/image/v2/image.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,14 @@ class CreateImage(show.ShowOne):
112112
"""Create/upload an image"""
113113

114114
log = logging.getLogger(__name__ + ".CreateImage")
115-
deadopts = ('owner', 'size', 'location', 'copy-from', 'checksum', 'store')
115+
deadopts = ('size', 'location', 'copy-from', 'checksum', 'store')
116116

117117
def get_parser(self, prog_name):
118118
parser = super(CreateImage, self).get_parser(prog_name)
119119
# TODO(mordred): add --volume and --force parameters and support
120120
# TODO(bunting): There are additional arguments that v1 supported
121121
# that v2 either doesn't support or supports weirdly.
122122
# --checksum - could be faked clientside perhaps?
123-
# --owner - could be set as an update after the put?
124123
# --location - maybe location add?
125124
# --size - passing image size is actually broken in python-glanceclient
126125
# --copy-from - does not exist in v2
@@ -149,6 +148,11 @@ def get_parser(self, prog_name):
149148
help="Image disk format "
150149
"(default: %s)" % DEFAULT_DISK_FORMAT,
151150
)
151+
parser.add_argument(
152+
"--owner",
153+
metavar="<owner>",
154+
help="Image owner project name or ID",
155+
)
152156
parser.add_argument(
153157
"--min-disk",
154158
metavar="<disk-gb>",
@@ -229,7 +233,7 @@ def take_action(self, parsed_args):
229233
copy_attrs = ('name', 'id',
230234
'container_format', 'disk_format',
231235
'min_disk', 'min_ram',
232-
'tags')
236+
'tags', 'owner')
233237
for attr in copy_attrs:
234238
if attr in parsed_args:
235239
val = getattr(parsed_args, attr, None)

openstackclient/tests/image/v2/test_image.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def test_image_reserve_options(self, mock_open):
112112
'--disk-format', 'fs',
113113
'--min-disk', '10',
114114
'--min-ram', '4',
115+
'--owner', '123456',
115116
'--protected',
116117
'--private',
117118
image_fakes.image_name,
@@ -121,6 +122,7 @@ def test_image_reserve_options(self, mock_open):
121122
('disk_format', 'fs'),
122123
('min_disk', 10),
123124
('min_ram', 4),
125+
('owner', '123456'),
124126
('protected', True),
125127
('unprotected', False),
126128
('public', False),
@@ -139,6 +141,7 @@ def test_image_reserve_options(self, mock_open):
139141
disk_format='fs',
140142
min_disk=10,
141143
min_ram=4,
144+
owner='123456',
142145
protected=True,
143146
visibility='private',
144147
)
@@ -213,11 +216,10 @@ def test_image_create_file(self, mock_open):
213216
def test_image_create_dead_options(self):
214217

215218
arglist = [
216-
'--owner', 'nobody',
219+
'--store', 'somewhere',
217220
image_fakes.image_name,
218221
]
219222
verifylist = [
220-
('owner', 'nobody'),
221223
('name', image_fakes.image_name),
222224
]
223225
parsed_args = self.check_parser(self.cmd, arglist, verifylist)

0 commit comments

Comments
 (0)