# Buggy code
def initialize_app(self, argv):
    super(OpenIOShell, self).initialize_app(argv)

    for module in clientmanager.PLUGIN_MODULES:
        api = module.API_NAME
        cmd_group = "openio." + api.replace("-", "_")
        self.command_manager.add_command_group(cmd_group)
        self.log.debug("%s API: cmd group %s" % (api, cmd_group))
    self.command_manager.add_command_group("openio.common")
    self.command_manager.add_command_group("openio.ext")

    options = {
        "namespace": self.options.ns,
        "account_name": self.options.account_name,
        "proxyd_url": self.options.proxyd_url,
        "admin_mode": self.options.admin_mode,
    }

    self.print_help_if_requested()
    self.client_manager = clientmanager.ClientManager(options)


# Traceback (ConnectionError)
# openio --oio-ns=VCFR1 directory bootstrap --replicas 3 -v --debug
Starting new HTTP connection (1): 172.17.25.5
"GET /v3.0/VCFR1/conscience/list?type=meta1 HTTP/1.1" 200 376
Computing meta1 prefix mapping...
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
Equilibrating...
META1 Digits = 4
Replicas = 3
Scored positively = 3
Ideal number of prefixes per meta1: 65536
Rebalance moved 0 prefixes
Saving...
Starting new HTTP connection (1): 172.17.25.5
"POST /v3.0/VCFR1/admin/meta0_force HTTP/1.1" 204 0
Assigning rdir services to rawx services...
Starting new HTTP connection (1): 172.17.25.5
"GET /v3.0/VCFR1/conscience/list?type=rawx HTTP/1.1" 200 256
"GET /v3.0/VCFR1/conscience/list?full=1&amp;type=rdir HTTP/1.1" 200 642
Starting new HTTP connection (1): 172.17.25.5
"GET /v3.0/VCFR1/reference/show?acct=_RDIR&amp;ref=172.17.25.7%3A6004&amp;type=rdir HTTP/1.1" 404 59
('Connection aborted.', BadStatusLine("''",))
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/cliff/app.py", line 374, in run_subcommand
result = cmd.run(parsed_args)
File "/usr/lib/python2.7/dist-packages/cliff/command.py", line 54, in run
self.take_action(parsed_args)
File "/usr/lib/python2.7/dist-packages/oio/cli/admin/directory.py", line 60, in take_action
self.app.client_manager.admin.volume.assign_all_rawx()
File "/usr/lib/python2.7/dist-packages/oio/rdir/client.py", line 38, in assign_all_rawx
rdir = self._smart_link_rdir(rawx['addr'], cs, all_rdir)
File "/usr/lib/python2.7/dist-packages/oio/rdir/client.py", line 68, in _smart_link_rdir
polled = cs.poll('rdir', avoid=avoids, known=known)[0]
File "/usr/lib/python2.7/dist-packages/oio/conscience/client.py", line 47, in poll
data=json.dumps(ibody))
File "/usr/lib/python2.7/dist-packages/oio/common/client.py", line 51, in _request
return self._direct_request(method, url, **kwargs)
File "/usr/lib/python2.7/dist-packages/oio/common/client.py", line 37, in _direct_request
**kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 426, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', BadStatusLine("''",))
Exception raised: ('Connection aborted.', BadStatusLine("''",))

# Fixed code
def initialize_app(self, argv):
    super(OpenIOShell, self).initialize_app(argv)

    for module in clientmanager.PLUGIN_MODULES:
        api = module.API_NAME
        cmd_group = "openio." + api.replace("-", "_")
        self.command_manager.add_command_group(cmd_group)
        self.log.debug("%s API: cmd group %s" % (api, cmd_group))
    self.command_manager.add_command_group("openio.common")
    self.command_manager.add_command_group("openio.ext")

    options = {
        "namespace": self.options.ns,
        "account_name": self.options.account_name,
        "proxyd_url": self.options.proxyd_url,
        "admin_mode": self.options.admin_mode,
        "log_level": logging.getLevelName(logging.getLogger("").getEffectiveLevel()),
        "is_cli": True,
    }

    self.print_help_if_requested()
    self.client_manager = clientmanager.ClientManager(options)