[v2,1/1] start-sru-cycle: New option 'usemasterbug'

Message ID 20180712142038.4790-1-khalid.elmously@canonical.com
State New
Headers show
Series
  • [v2,1/1] start-sru-cycle: New option 'usemasterbug'
Related show

Commit Message

Khalid Elmously July 12, 2018, 2:20 p.m.
New option '--usemasterbug' to use pre-existing master bug instead of creating a new one.

Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
---
 ktl/tracking_bug.py    | 4 ++++
 stable/start-sru-cycle | 8 +++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

Comments

Stefan Bader July 17, 2018, 3:56 p.m. | #1
On 12.07.2018 16:20, Khalid Elmously wrote:
> New option '--usemasterbug' to use pre-existing master bug instead of creating a new one.
> 
> Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  ktl/tracking_bug.py    | 4 ++++
>  stable/start-sru-cycle | 8 +++++++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/ktl/tracking_bug.py b/ktl/tracking_bug.py
> index 8956fa90..efea3678 100644
> --- a/ktl/tracking_bug.py
> +++ b/ktl/tracking_bug.py
> @@ -357,6 +357,10 @@ class TrackingBug:
>          s.reset_tasks(bug)
>          return bug
>  
> +    def get_bug(self, bug_id):
> +        bug = self.lp.get_bug(bug_id)
> +        return bug
> +
>      def open(self, package, version, new_abi, master_bug, series_specified, private=False):
>          center(self.__class__.__name__ + '.open')
>          cdebug('    package: %s' % package)
> diff --git a/stable/start-sru-cycle b/stable/start-sru-cycle
> index 60525c20..7e7a2626 100755
> --- a/stable/start-sru-cycle
> +++ b/stable/start-sru-cycle
> @@ -130,7 +130,12 @@ class Crankers():
>  
>                  print('        %s:%s' % (series, master_package))
>                  if not s.args.dryrun:
> -                    master_bug = s.tb.open(master_package, '<version to be filled>', True, None, series)
> +                    if s.args.usemasterbug:
> +                        master_bug = s.tb.get_bug(s.args.usemasterbug[0])
> +                        print("Using pre-existing master-bug: %s" %(master_bug.id))
> +                    else:
> +                        master_bug = s.tb.open(master_package, '<version to be filled>', True, None, series)
> +
>                      for task in master_bug.tasks:
>                          # Move the primary package to Confirmed, link-to-tracker and
>                          # shanky will keep on top of the others and move them as needed.
> @@ -196,6 +201,7 @@ Examples:
>      parser.add_argument('--source', action='append', default=[], metavar='source', help='Only create tracking bugs for the specified source package(s). Requiers exactly one series argument to be given. This option can be used multiple times.')
>      parser.add_argument('--staging', action='store_true', default=False, help='Use the staging LP server to create the bug. This is just for testing and will go away when the staging database is reset.')
>      parser.add_argument('--dry-run', '--dryrun', action='store_true', default=False, help='Make no permanent changes.', dest='dryrun')
> +    parser.add_argument('--usemasterbug', type=int, nargs=1, help='Use pre-existing master-bug instead of creating a new one')
>  
>      args = parser.parse_args()
>  
>
Kleber Souza July 19, 2018, 8:41 a.m. | #2
On 07/12/18 16:20, Khalid Elmously wrote:
> New option '--usemasterbug' to use pre-existing master bug instead of creating a new one.
> 
> Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
> ---
>  ktl/tracking_bug.py    | 4 ++++
>  stable/start-sru-cycle | 8 +++++++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/ktl/tracking_bug.py b/ktl/tracking_bug.py
> index 8956fa90..efea3678 100644
> --- a/ktl/tracking_bug.py
> +++ b/ktl/tracking_bug.py
> @@ -357,6 +357,10 @@ class TrackingBug:
>          s.reset_tasks(bug)
>          return bug
>  
> +    def get_bug(self, bug_id):
> +        bug = self.lp.get_bug(bug_id)
> +        return bug
> +
>      def open(self, package, version, new_abi, master_bug, series_specified, private=False):
>          center(self.__class__.__name__ + '.open')
>          cdebug('    package: %s' % package)
> diff --git a/stable/start-sru-cycle b/stable/start-sru-cycle
> index 60525c20..7e7a2626 100755
> --- a/stable/start-sru-cycle
> +++ b/stable/start-sru-cycle
> @@ -130,7 +130,12 @@ class Crankers():
>  
>                  print('        %s:%s' % (series, master_package))
>                  if not s.args.dryrun:
> -                    master_bug = s.tb.open(master_package, '<version to be filled>', True, None, series)
> +                    if s.args.usemasterbug:
> +                        master_bug = s.tb.get_bug(s.args.usemasterbug[0])
> +                        print("Using pre-existing master-bug: %s" %(master_bug.id))
> +                    else:
> +                        master_bug = s.tb.open(master_package, '<version to be filled>', True, None, series)
> +
>                      for task in master_bug.tasks:
>                          # Move the primary package to Confirmed, link-to-tracker and
>                          # shanky will keep on top of the others and move them as needed.
> @@ -196,6 +201,7 @@ Examples:
>      parser.add_argument('--source', action='append', default=[], metavar='source', help='Only create tracking bugs for the specified source package(s). Requiers exactly one series argument to be given. This option can be used multiple times.')
>      parser.add_argument('--staging', action='store_true', default=False, help='Use the staging LP server to create the bug. This is just for testing and will go away when the staging database is reset.')
>      parser.add_argument('--dry-run', '--dryrun', action='store_true', default=False, help='Make no permanent changes.', dest='dryrun')
> +    parser.add_argument('--usemasterbug', type=int, nargs=1, help='Use pre-existing master-bug instead of creating a new one')
>  
>      args = parser.parse_args()
>  
> 

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Stefan Bader July 19, 2018, 8:53 a.m. | #3
On 12.07.2018 16:20, Khalid Elmously wrote:
> New option '--usemasterbug' to use pre-existing master bug instead of creating a new one.
> 
> Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
> ---
>  ktl/tracking_bug.py    | 4 ++++
>  stable/start-sru-cycle | 8 +++++++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/ktl/tracking_bug.py b/ktl/tracking_bug.py
> index 8956fa90..efea3678 100644
> --- a/ktl/tracking_bug.py
> +++ b/ktl/tracking_bug.py
> @@ -357,6 +357,10 @@ class TrackingBug:
>          s.reset_tasks(bug)
>          return bug
>  
> +    def get_bug(self, bug_id):
> +        bug = self.lp.get_bug(bug_id)
> +        return bug
> +
>      def open(self, package, version, new_abi, master_bug, series_specified, private=False):
>          center(self.__class__.__name__ + '.open')
>          cdebug('    package: %s' % package)
> diff --git a/stable/start-sru-cycle b/stable/start-sru-cycle
> index 60525c20..7e7a2626 100755
> --- a/stable/start-sru-cycle
> +++ b/stable/start-sru-cycle
> @@ -130,7 +130,12 @@ class Crankers():
>  
>                  print('        %s:%s' % (series, master_package))
>                  if not s.args.dryrun:
> -                    master_bug = s.tb.open(master_package, '<version to be filled>', True, None, series)
> +                    if s.args.usemasterbug:
> +                        master_bug = s.tb.get_bug(s.args.usemasterbug[0])
> +                        print("Using pre-existing master-bug: %s" %(master_bug.id))
> +                    else:
> +                        master_bug = s.tb.open(master_package, '<version to be filled>', True, None, series)
> +
>                      for task in master_bug.tasks:
>                          # Move the primary package to Confirmed, link-to-tracker and
>                          # shanky will keep on top of the others and move them as needed.
> @@ -196,6 +201,7 @@ Examples:
>      parser.add_argument('--source', action='append', default=[], metavar='source', help='Only create tracking bugs for the specified source package(s). Requiers exactly one series argument to be given. This option can be used multiple times.')
>      parser.add_argument('--staging', action='store_true', default=False, help='Use the staging LP server to create the bug. This is just for testing and will go away when the staging database is reset.')
>      parser.add_argument('--dry-run', '--dryrun', action='store_true', default=False, help='Make no permanent changes.', dest='dryrun')
> +    parser.add_argument('--usemasterbug', type=int, nargs=1, help='Use pre-existing master-bug instead of creating a new one')
>  
>      args = parser.parse_args()
>  
>

Patch

diff --git a/ktl/tracking_bug.py b/ktl/tracking_bug.py
index 8956fa90..efea3678 100644
--- a/ktl/tracking_bug.py
+++ b/ktl/tracking_bug.py
@@ -357,6 +357,10 @@  class TrackingBug:
         s.reset_tasks(bug)
         return bug
 
+    def get_bug(self, bug_id):
+        bug = self.lp.get_bug(bug_id)
+        return bug
+
     def open(self, package, version, new_abi, master_bug, series_specified, private=False):
         center(self.__class__.__name__ + '.open')
         cdebug('    package: %s' % package)
diff --git a/stable/start-sru-cycle b/stable/start-sru-cycle
index 60525c20..7e7a2626 100755
--- a/stable/start-sru-cycle
+++ b/stable/start-sru-cycle
@@ -130,7 +130,12 @@  class Crankers():
 
                 print('        %s:%s' % (series, master_package))
                 if not s.args.dryrun:
-                    master_bug = s.tb.open(master_package, '<version to be filled>', True, None, series)
+                    if s.args.usemasterbug:
+                        master_bug = s.tb.get_bug(s.args.usemasterbug[0])
+                        print("Using pre-existing master-bug: %s" %(master_bug.id))
+                    else:
+                        master_bug = s.tb.open(master_package, '<version to be filled>', True, None, series)
+
                     for task in master_bug.tasks:
                         # Move the primary package to Confirmed, link-to-tracker and
                         # shanky will keep on top of the others and move them as needed.
@@ -196,6 +201,7 @@  Examples:
     parser.add_argument('--source', action='append', default=[], metavar='source', help='Only create tracking bugs for the specified source package(s). Requiers exactly one series argument to be given. This option can be used multiple times.')
     parser.add_argument('--staging', action='store_true', default=False, help='Use the staging LP server to create the bug. This is just for testing and will go away when the staging database is reset.')
     parser.add_argument('--dry-run', '--dryrun', action='store_true', default=False, help='Make no permanent changes.', dest='dryrun')
+    parser.add_argument('--usemasterbug', type=int, nargs=1, help='Use pre-existing master-bug instead of creating a new one')
 
     args = parser.parse_args()