#1227 Added volume id as argument to livemedia and livecd tasks
Merged 3 years ago by mikem. Opened 3 years ago by breilly.
breilly/koji volumeid-833  into  master

file modified
+18 -2
@@ -3122,7 +3122,14 @@ 

          cmd = ['/usr/bin/livecd-creator', '-c', kskoji, '-d', '-v',

                 '--logfile', livecd_log, '--cache', cachedir]

          isoname = '%s-%s-%s' % (name, version, release)

-         cmd.extend(['-f', self._shortenVolID(name, version, release)])

+         volid = opts.get('volid')

+         if not volid:

+             volid = self._shortenVolID(name, version, release)

+         else:

+             if len(volid) > 32:

+                 logger.warning("volume ID is longer than 32 characters, it will be truncated")

+                 volid = volid[:32]

+         cmd.extend(['-f', volid])

  

          # Run livecd-creator

          rv = broot.mock(['--cwd', broot.tmpdir(within=True), '--chroot', '--'] + cmd)
@@ -3307,11 +3314,20 @@ 

                 #'--tmp', '/tmp'

                ]

  

+ 

+         volid = opts.get('volid')

+         if not volid:

+             volid = self._shortenVolID(name, version, release)

+         else:

+             if len(volid) > 32:

+                 logger.warning("volume ID is longer than 32 characters, it will be truncated")

+                 volid = volid[:32]

+ 

          # note: at the moment, we are only generating live isos. We may add support

          # for other types in the future

  

          cmd.extend(['--make-iso',

-                     '--volid', self._shortenVolID(name, version, release),

+                     '--volid', volid,

                      '--iso-only',

                     ])

  

file modified
+7 -1
@@ -5376,6 +5376,7 @@ 

                 "RPMs in the LiveCD. May be used multiple times. The " +

                 "build tag repo associated with the target is the default."))

      parser.add_option("--release", help=_("Forcibly set the release field"))

+     parser.add_option("--volid", help=_("Set the volume id"))

      parser.add_option("--specfile", metavar="URL",

          help=_("SCM URL to spec file fragment to use to generate wrapper RPMs"))

      parser.add_option("--skip-tag", action="store_true",
@@ -5389,6 +5390,8 @@ 

                         " architecture, a build target, and a relative path to" +

                         " a kickstart file."))

          assert False  # pragma: no cover

+     if task_options.volid is not None and len(task_options.volid) > 32:

+         parser.error(_('Volume ID has a maximum length of 32 characters'))

      return _build_image(options, task_options, session, args, 'livecd')

  

  
@@ -5424,6 +5427,7 @@ 

                 "build tag repo associated with the target is the default."))

      parser.add_option("--release", help=_("Forcibly set the release field"))

      parser.add_option("--title", help=_("Set the image title (defaults to <name>)"))

+     parser.add_option("--volid", help=_("Set the volume id"))

      parser.add_option("--specfile", metavar="URL",

          help=_("SCM URL to spec file fragment to use to generate wrapper RPMs"))

      parser.add_option("--skip-tag", action="store_true",
@@ -5449,6 +5453,8 @@ 

      if task_options.lorax_url is not None and task_options.lorax_dir is None:

          parser.error(_('The "--lorax_url" option requires that "--lorax_dir" '

                         'also be used.'))

+     if task_options.volid is not None and len(task_options.volid) > 32:

+         parser.error(_('Volume ID has a maximum length of 32 characters'))

      return _build_image(options, task_options, session, args, 'livemedia')

  

  
@@ -5827,7 +5833,7 @@ 

      passthru_opts = [

          'format', 'install_tree_url', 'isoname', 'ksurl',

          'ksversion', 'release', 'repo', 'scratch', 'skip_tag',

-         'specfile', 'title', 'vcpu', 'vmem', 'optional_arches',

+         'specfile', 'title', 'vcpu', 'vmem', 'volid', 'optional_arches',

          'lorax_dir', 'lorax_url',

          ]

      for opt in passthru_opts:

@@ -22,6 +22,7 @@ 

      "ksversion": None,

      "repo": None,

      "release": None,

+     "volid": None,

      "specfile": None,

  }

  
@@ -41,6 +42,7 @@ 

      "lorax_url": None,

      "optional_arches": None,

      "title": None,

+     "volid": None,

  }

  

  APPLIANCE_OPTIONS = {
@@ -413,6 +415,7 @@ 

                          is the default.

    --release=RELEASE     Forcibly set the release field

    --title=TITLE         Set the image title (defaults to <name>)

+   --volid=VOLID         Set the volume id

    --specfile=URL        SCM URL to spec file fragment to use to generate

                          wrapper RPMs

    --skip-tag            Do not attempt to tag package
@@ -499,6 +502,7 @@ 

                         The build tag repo associated with the target is the

                         default.

    --release=RELEASE    Forcibly set the release field

+   --volid=VOLID        Set the volume id

    --specfile=URL       SCM URL to spec file fragment to use to generate

                         wrapper RPMs

    --skip-tag           Do not attempt to tag package

no initial comment

Maybe log some warning if supplied volid was truncated? Also I would check it on CLI side, so we can fail the command with wrong (long) volid.

To be clear, do you mean log a warning if the volid passed is longer than 32 characters, and if a volid longer than 32 characters was passed via the CLI, fail at that point?

1 new commit added

  • Added warnings and failures for too long volid
3 years ago

Also, I wonder if the task should just fail outright if a passed-in volid is too long. We're failing on the cli side.

Yeah, I think it's better to error early if the passed in volid is too long. I've made that change here and I'll merge that

https://github.com/mikem23/koji-playground/commits/pagure/pr/1227

Commit 4f45059 fixes this pull-request

Pull-Request has been merged by mikem

3 years ago