OpenStack Image Registry and Delivery Service (Glance)

Glance cli produces 'invalid literal for int' error when using ssl

Reported by Stuart McLaren on 2011-11-30
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glance
Medium
Stuart McLaren

Bug Description

If glance is configured to use ssl I see the following:

$ glance index -H https://localhost
Failed to show index. Got error:
invalid literal for int() with base 10: '//localhost'

One potential way to fix this (which would be consistent with
the swift cli) would be to change to provide some parameters
(http vs https, hostname, port, possibly version) via a URL, eg:

 https://localhost:9292/v1

and parse this accordingly.

Jay Pipes (jaypipes) wrote :

Stuart, shall I assign this one to you?

Changed in glance:
status: New → Confirmed
importance: Undecided → Medium

Why not.

On Wed, 30 Nov 2011, Jay Pipes wrote:

> Stuart, shall I assign this one to you?
>
> ** Changed in: glance
> Status: New => Confirmed
>
> ** Changed in: glance
> Importance: Undecided => Medium
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/898097
>
> Title:
> Glance cli produces 'invalid literal for int' error when using ssl
>
> Status in OpenStack Image Registry and Delivery Service (Glance):
> Confirmed
>
> Bug description:
>
> If glance is configured to use ssl I see the following:
>
> $ glance index -H https://localhost
> Failed to show index. Got error:
> invalid literal for int() with base 10: '//localhost'
>
> One potential way to fix this (which would be consistent with
> the swift cli) would be to change to provide some parameters
> (http vs https, hostname, port, possibly version) via a URL, eg:
>
> https://localhost:9292/v1
>
> and parse this accordingly.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/glance/+bug/898097/+subscriptions
>

Jay Pipes (jaypipes) wrote :

Thanks, Stuart!

Changed in glance:
assignee: nobody → Stuart McLaren (stuart-mclaren)
milestone: none → essex-3
Stuart McLaren (stuart-mclaren) wrote :
Download full text (3.2 KiB)

Jay,

Something along these lines? How controversial is it to remove the
-H and -p options? (There is collateral stuff I would need to fix
up.)

@@ -30,6 +30,8 @@
  import sys
  import time

+from urlparse import urlparse
+
  # If ../glance/__init__.py exists, add ../ to Python search path, so that
  # it will override what happens to be installed in /usr/(local/)lib/python...
  possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
@@ -49,6 +51,8 @@
  SUCCESS = 0
  FAILURE = 1

+DEFAULT_PORT = "9292"
+

  #TODO(sirp): make more of the actions use this decorator
  def catch_error(action):
@@ -981,7 +985,7 @@
                   auth_url=os.getenv('OS_AUTH_URL'),
                   strategy=os.getenv('OS_AUTH_STRATEGY', 'noauth'))

- use_ssl = (options.host.find('https') != -1 or (
+ use_ssl = (options.use_ssl or (
          creds['auth_url'] is not None and
          creds['auth_url'].find('https') != -1))

@@ -1001,12 +1005,8 @@
                        help="Print more verbose output")
      parser.add_option('-d', '--debug', default=False, action="store_true",
                        help="Print more verbose output")
- parser.add_option('-H', '--host', metavar="ADDRESS", default="0.0.0.0",
- help="Address of Glance API host. "
- "Default: %default")
- parser.add_option('-p', '--port', dest="port", metavar="PORT",
- type=int, default=9292,
- help="Port the Glance API host listens on. "
+ parser.add_option('-U', '--url', metavar="URL",
                        default="http://localhost:" + DEFAULT_PORT + "/v1",
+ help="URL of Glance API host. "
                             "Default: %default")
      parser.add_option('-A', '--auth_token', dest="auth_token",
                        metavar="TOKEN", default=None,
@@ -1057,6 +1057,16 @@

      command_name = args.pop(0)
      command = lookup_command(parser, command_name)
+ u = urlparse(options.url)
+ options.host = u.hostname
+
+ if u.port is not None:
+ options.port = u.port
+ else:
+ options.port = DEFAULT_PORT
+
+ options.use_ssl = (u.scheme == 'https')

On Wed, 30 Nov 2011, Jay Pipes wrote:

> Stuart, shall I assign this one to you?
>
> ** Changed in: glance
> Status: New => Confirmed
>
> ** Changed in: glance
> Importance: Undecided => Medium
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/898097
>
> Title:
> Glance cli produces 'invalid literal for int' error when using ssl
>
> Status in OpenStack Image Registry and Delivery Service (Glance):
> Confirmed
>
> Bug description:
>
> If glance is configured to use ssl I see the following:
>
> $ glance index -H https://localhost
> Failed to show index. Got error:
> invalid literal for int() with base 10: '//localhost'
>
> One potential way to fix this (which would be consistent with
> the swift cli) would be to change to provide some parameters
> (http vs https, hostname, port, possibly version) via a URL, eg:
>
> https://localhost:9292/v1
>
> and parse this accordingly.
>...

Read more...

Reviewed: https://review.openstack.org/2010
Committed: http://github.com/openstack/glance/commit/0e9c16dccf27cc4f85e6772e1d2abfd820af7756
Submitter: Jenkins
Branch: master

 status fixcommitted
 done

commit 0e9c16dccf27cc4f85e6772e1d2abfd820af7756
Author: Stuart McLaren <email address hidden>
Date: Thu Dec 1 17:32:44 2011 +0000

    Add --url option to glance cli.

    Adds ability to select between http/https protocols.

    Fixes bug 898097.

    Change-Id: I1d20f314fb7dd8c5462c1f1ff22161ab59c35016

Changed in glance:
status: Confirmed → Fix Committed
Thierry Carrez (ttx) on 2012-01-25
Changed in glance:
status: Fix Committed → Fix Released
Thierry Carrez (ttx) on 2012-04-05
Changed in glance:
milestone: essex-3 → 2012.1
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers