Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

HPOneViewException not raised when connection with paused VM fails #309

Closed
llvieira opened this issue Aug 26, 2017 · 2 comments
Closed

HPOneViewException not raised when connection with paused VM fails #309

llvieira opened this issue Aug 26, 2017 · 2 comments
Assignees

Comments

@llvieira
Copy link
Member

llvieira commented Aug 26, 2017

Hi guys,

When I try to create the OneView client but my VM is paused, an OSError exception is raised instead of a HPOneViewException. The HPOneViewException should not cover this type of exception in this scenario? For treat this exception is only possible if I catch an OSError, but is seems odd for me since this also could be used as a HPOneViewException maybe.

Code example:

#VM paused
config = {
	"ip": "x.x.x.x",
	"credentials": {
		"userName": "user_name",
		"password": "pass"
	}
}

oneview_client = OneViewClient(config)

Result:

Traceback (most recent call last):
  File "one_view.py", line 89, in <module>
    one_view = OneView(config)
  File "one_view.py", line 12, in __init__
    self.oneview_client = OneViewClient(config)
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/oneview_client.py", line 118, in __init__
    self.__connection.login(config["credentials"])
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/connection.py", line 483, in login
    self.validateVersion()
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/connection.py", line 79, in validateVersion
    version = self.get(uri['version'])
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/connection.py", line 324, in get
    resp, body = self.do_http('GET', uri, '')
  File "/usr/local/lib/python3.5/dist-packages/hpOneView/connection.py", line 126, in do_http
    conn.request(method, path, body, http_headers)
  File "/usr/lib/python3.5/http/client.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1151, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1102, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
    self.send(msg)
  File "/usr/lib/python3.5/http/client.py", line 877, in send
    self.connect()
  File "/usr/lib/python3.5/http/client.py", line 1252, in connect
    super().connect()
  File "/usr/lib/python3.5/http/client.py", line 849, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.5/socket.py", line 711, in create_connection
    raise err
  File "/usr/lib/python3.5/socket.py", line 702, in create_connection
    sock.connect(sa)
OSError: [Errno 113] No route to host
@fgbulsoni fgbulsoni changed the title HPOneViewException not raised when I try to create a connection with VM paused HPOneViewException not raised when connection with paused VM fails Aug 28, 2017
@fgbulsoni fgbulsoni self-assigned this Aug 28, 2017
@fgbulsoni
Copy link
Contributor

Seems like a valid request, possible solution in #310 .

Not every http error is being caught that way, as it is not impossible for those to happen in some other part of the code, but this should catch the errors coming from a first attempt at connecting to the appliance, usually timeout or no route to host.

@llvieira
Copy link
Member Author

@fgbulsoni Thanks for answer and for your new PR related to this request.

AnushaY1916 pushed a commit that referenced this issue Mar 2, 2018
Update a few documentation typos
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants