Skip to content

Commit 4ea4f6f

Browse files
committed
openstack image create : --file and --volume exclude each other
Added parser.add_mutually_exclusive_group() for --file and --volume in openstack image create. Change-Id: I4d9fc6314801d569354e5644e231ddd6c7f1853d Closes-Bug: 1666551
1 parent 1450e8f commit 4ea4f6f

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

openstackclient/image/v1/image.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,13 @@ def get_parser(self, prog_name):
128128
metavar="<image-url>",
129129
help=_("Copy image from the data store (similar to --location)"),
130130
)
131-
parser.add_argument(
131+
source_group = parser.add_mutually_exclusive_group()
132+
source_group.add_argument(
132133
"--file",
133134
metavar="<file>",
134135
help=_("Upload image from local file"),
135136
)
136-
parser.add_argument(
137+
source_group.add_argument(
137138
"--volume",
138139
metavar="<volume>",
139140
help=_("Create image from a volume"),

openstackclient/image/v2/image.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,13 @@ def get_parser(self, prog_name):
164164
type=int,
165165
help=_("Minimum RAM size needed to boot image, in megabytes"),
166166
)
167-
parser.add_argument(
167+
source_group = parser.add_mutually_exclusive_group()
168+
source_group.add_argument(
168169
"--file",
169170
metavar="<file>",
170171
help=_("Upload image from local file"),
171172
)
172-
parser.add_argument(
173+
source_group.add_argument(
173174
"--volume",
174175
metavar="<volume>",
175176
help=_("Create image from a volume"),

0 commit comments

Comments
 (0)