Merge "Add "--property" option to "snapshot create" command in volumev2"
This commit is contained in:
		@@ -16,6 +16,7 @@ Create new snapshot
 | 
				
			|||||||
        [--name <name>]
 | 
					        [--name <name>]
 | 
				
			||||||
        [--description <description>]
 | 
					        [--description <description>]
 | 
				
			||||||
        [--force]
 | 
					        [--force]
 | 
				
			||||||
 | 
					        [--property <key=value> [...] ]
 | 
				
			||||||
        <volume>
 | 
					        <volume>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. option:: --name <name>
 | 
					.. option:: --name <name>
 | 
				
			||||||
@@ -30,6 +31,12 @@ Create new snapshot
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    Create a snapshot attached to an instance. Default is False
 | 
					    Create a snapshot attached to an instance. Default is False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.. option:: --property <key=value>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    Set a property to this snapshot (repeat option to set multiple properties)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *Volume version 2 only*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. _snapshot_create-snapshot:
 | 
					.. _snapshot_create-snapshot:
 | 
				
			||||||
.. describe:: <volume>
 | 
					.. describe:: <volume>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,12 +70,15 @@ class TestSnapshotCreate(TestSnapshot):
 | 
				
			|||||||
            "--name", self.new_snapshot.name,
 | 
					            "--name", self.new_snapshot.name,
 | 
				
			||||||
            "--description", self.new_snapshot.description,
 | 
					            "--description", self.new_snapshot.description,
 | 
				
			||||||
            "--force",
 | 
					            "--force",
 | 
				
			||||||
 | 
					            '--property', 'Alpha=a',
 | 
				
			||||||
 | 
					            '--property', 'Beta=b',
 | 
				
			||||||
            self.new_snapshot.volume_id,
 | 
					            self.new_snapshot.volume_id,
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
        verifylist = [
 | 
					        verifylist = [
 | 
				
			||||||
            ("name", self.new_snapshot.name),
 | 
					            ("name", self.new_snapshot.name),
 | 
				
			||||||
            ("description", self.new_snapshot.description),
 | 
					            ("description", self.new_snapshot.description),
 | 
				
			||||||
            ("force", True),
 | 
					            ("force", True),
 | 
				
			||||||
 | 
					            ('property', {'Alpha': 'a', 'Beta': 'b'}),
 | 
				
			||||||
            ("volume", self.new_snapshot.volume_id),
 | 
					            ("volume", self.new_snapshot.volume_id),
 | 
				
			||||||
        ]
 | 
					        ]
 | 
				
			||||||
        parsed_args = self.check_parser(self.cmd, arglist, verifylist)
 | 
					        parsed_args = self.check_parser(self.cmd, arglist, verifylist)
 | 
				
			||||||
@@ -86,7 +89,8 @@ class TestSnapshotCreate(TestSnapshot):
 | 
				
			|||||||
            self.new_snapshot.volume_id,
 | 
					            self.new_snapshot.volume_id,
 | 
				
			||||||
            force=True,
 | 
					            force=True,
 | 
				
			||||||
            name=self.new_snapshot.name,
 | 
					            name=self.new_snapshot.name,
 | 
				
			||||||
            description=self.new_snapshot.description
 | 
					            description=self.new_snapshot.description,
 | 
				
			||||||
 | 
					            metadata={'Alpha': 'a', 'Beta': 'b'},
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        self.assertEqual(self.columns, columns)
 | 
					        self.assertEqual(self.columns, columns)
 | 
				
			||||||
        self.assertEqual(self.data, data)
 | 
					        self.assertEqual(self.data, data)
 | 
				
			||||||
@@ -110,7 +114,8 @@ class TestSnapshotCreate(TestSnapshot):
 | 
				
			|||||||
            self.new_snapshot.volume_id,
 | 
					            self.new_snapshot.volume_id,
 | 
				
			||||||
            force=True,
 | 
					            force=True,
 | 
				
			||||||
            name=None,
 | 
					            name=None,
 | 
				
			||||||
            description=self.new_snapshot.description
 | 
					            description=self.new_snapshot.description,
 | 
				
			||||||
 | 
					            metadata=None,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        self.assertEqual(self.columns, columns)
 | 
					        self.assertEqual(self.columns, columns)
 | 
				
			||||||
        self.assertEqual(self.data, data)
 | 
					        self.assertEqual(self.data, data)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,6 +51,13 @@ class CreateSnapshot(command.ShowOne):
 | 
				
			|||||||
            help=_("Create a snapshot attached to an instance. "
 | 
					            help=_("Create a snapshot attached to an instance. "
 | 
				
			||||||
                   "Default is False")
 | 
					                   "Default is False")
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					        parser.add_argument(
 | 
				
			||||||
 | 
					            "--property",
 | 
				
			||||||
 | 
					            metavar="<key=value>",
 | 
				
			||||||
 | 
					            action=parseractions.KeyValueAction,
 | 
				
			||||||
 | 
					            help=_("Set a property to this snapshot "
 | 
				
			||||||
 | 
					                   "(repeat option to set multiple properties)"),
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
        return parser
 | 
					        return parser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def take_action(self, parsed_args):
 | 
					    def take_action(self, parsed_args):
 | 
				
			||||||
@@ -61,7 +68,8 @@ class CreateSnapshot(command.ShowOne):
 | 
				
			|||||||
            volume_id,
 | 
					            volume_id,
 | 
				
			||||||
            force=parsed_args.force,
 | 
					            force=parsed_args.force,
 | 
				
			||||||
            name=parsed_args.name,
 | 
					            name=parsed_args.name,
 | 
				
			||||||
            description=parsed_args.description
 | 
					            description=parsed_args.description,
 | 
				
			||||||
 | 
					            metadata=parsed_args.property,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        snapshot._info.update(
 | 
					        snapshot._info.update(
 | 
				
			||||||
            {'properties': utils.format_dict(snapshot._info.pop('metadata'))}
 | 
					            {'properties': utils.format_dict(snapshot._info.pop('metadata'))}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								releasenotes/notes/bug-1597192-52801f7520287309.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								releasenotes/notes/bug-1597192-52801f7520287309.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					---
 | 
				
			||||||
 | 
					features:
 | 
				
			||||||
 | 
					  - Add ``--property`` option to ``snapshot create`` command.
 | 
				
			||||||
 | 
					    [Bug `1597192 <https://bugs.launchpad.net/bugs/1597192>`_]
 | 
				
			||||||
		Reference in New Issue
	
	Block a user