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

Commit

Permalink
Merge pull request #329 from HewlettPackard/refactor/removing-unused-…
Browse files Browse the repository at this point in the history
…methods-from-connection

Fixed #330
  • Loading branch information
fgbulsoni authored Oct 27, 2017
2 parents 7c5d52d + 42631ef commit fc70f21
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 50 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
- [ ] All tests pass for Python 2.7+ & 3.4+(`$ tox`).
- [ ] New functionality has been documented in the README if applicable.
- [ ] New functionality has been thoroughly documented in the examples (please include helpful comments).
- [ ] New endpoints supported are updated in the endpoints-support.md file.
- [ ] Changes are documented in the CHANGELOG.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Added endpoints-support.md to track the supported and tested endpoints for the d

#### Bug fixes & Enhancements
- [#320](https://github.com/HewlettPackard/python-hpOneView/issues/320) Issue with pickling HPOneViewException
- [#330](https://github.com/HewlettPackard/python-hpOneView/issues/330) Remove unused/legacy code from connection.py

# v4.2.0
#### New Resources:
Expand Down
2 changes: 1 addition & 1 deletion endpoints-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
|<sub>/rest/fcoe-networks/{id}</sub> | PUT | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/fcoe-networks/{id}</sub> | DELETE | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **Firmware Bundle** |
|<sub>/rest/firmware-bundles/{id}/script</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/firmware-bundles/</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **Firmware Driver** |
|<sub>/rest/firmware-drivers/</sub> | GET | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/firmware-drivers/</sub> | POST | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Expand Down
49 changes: 0 additions & 49 deletions hpOneView/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,55 +368,6 @@ def post(self, uri, body, custom_headers=None):
def patch(self, uri, body, custom_headers=None):
return self.__do_rest_call('PATCH', uri, body, custom_headers=custom_headers)

def get_entities_byrange(self, uri, field, xmin, xmax, count=-1):
new_uri = uri + '?filter="\'' + field + '\'%20>%20\'' + xmin \
+ '\'"&filter="\'' + field + '\'%20<%20\'' + xmax \
+ '\'"&start=0&count=' + str(count)
body = self.get(new_uri)
return get_members(body)

def get_entities_byfield(self, uri, field, value, count=-1):
new_uri = uri + '?start=0&count=' + str(count) \
+ '&filter=' + field + '=\'' + value + '\''
try:
body = self.get(new_uri)
except:
print(new_uri)
raise
return get_members(body)

def get_entity_byfield(self, uri, field, value, count=-1):
new_uri = uri + '?filter="\'' + field + '\'%20=%20\'' + value \
+ '\'"&start=0&count=' + str(count)

try:
body = self.get(new_uri)
except:
print(new_uri)
raise
return get_member(body)

def conditional_post(self, uri, body):
try:
task, entity = self.post(uri, body)
except HPOneViewException as e:
# this may have failed because the entity already exists,
# unfortunately there is not a uniform way to report this,
# so we just try to find an existing entity with the same name
# and return it assuming all names are unique (which is a
# reasonable assumption)
if 'DUPLICATE' in e.errorCode and 'NAME' in e.errorCode:
try:
entity = self.get_entity_byfield(uri, 'name', body['name'])
except Exception:
# Didn't find the entity, raise exception
raise e
if not entity:
raise e
else:
raise e
return entity

def __body_content_is_task(self, body):
return isinstance(body, dict) and 'category' in body and body['category'] == 'tasks'

Expand Down

0 comments on commit fc70f21

Please sign in to comment.