Skip to content

Commit

Permalink
Merge 1e41153 into 4078ee5
Browse files Browse the repository at this point in the history
  • Loading branch information
sijeesh committed Apr 11, 2019
2 parents 4078ee5 + 1e41153 commit 37de44f
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 91 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ This release extends the planned support of the modules to OneView REST API vers
- oneview_enclosure_facts
- oneview_fc_network
- oneview_fc_network_facts
- oneview_sas_interconnect
- oneview_sas_interconnect_facts
- oneview_sas_interconnect_type_facts

## v5.2.0
Expand Down
8 changes: 4 additions & 4 deletions endpoints-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@
|<sub>/rest/sas-interconnect-types</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-interconnect-types/{id}</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **SAS Interconnects** |
|<sub>/rest/sas-interconnects</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-interconnects/{id}</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-interconnects/{id}</sub> | PATCH | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-interconnects/{id}/refreshState</sub> | PUT | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-interconnects</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-interconnects/{id}</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-interconnects/{id}</sub> | PATCH | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-interconnects/{id}/refreshState</sub> | PUT | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **SAS Logical Interconnect Groups** |
|<sub>/rest/sas-logical-interconnect-groups</sub> | POST | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-logical-interconnect-groups</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
Expand Down
4 changes: 2 additions & 2 deletions examples/oneview_sas_interconnect.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###
# Copyright (2016-2017) Hewlett Packard Enterprise Development LP
# Copyright (2016-2019) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand All @@ -18,7 +18,7 @@
- hosts: all
vars:
config: "{{ playbook_dir }}/oneview_config.json"
name: "0000A66101, interconnect 1" # change for your SAS Interconnect name
name: "SYN03_Frame3, interconnect 1" # change for your SAS Interconnect name
tasks:
- name: Ensure that a SAS Interconnect is powered on
oneview_sas_interconnect:
Expand Down
2 changes: 1 addition & 1 deletion examples/oneview_sas_interconnect_facts.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###
# Copyright (2016-2017) Hewlett Packard Enterprise Development LP
# Copyright (2016-2019) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down
42 changes: 16 additions & 26 deletions library/oneview_sas_interconnect.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2017) Hewlett Packard Enterprise Development LP
# Copyright (2016-2019 Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,7 +30,7 @@
version_added: "2.3"
requirements:
- "python >= 2.7.9"
- "hpOneView >= 3.0.0"
- "hpOneView >= 5.0.0"
author: "Bruno Souza (@bsouza)"
options:
state:
Expand Down Expand Up @@ -61,7 +61,7 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: powered_on
name: "0000A66101, interconnect 1"
Expand All @@ -70,7 +70,7 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: refreshed
name: "0000A66101, interconnect 1"
Expand All @@ -79,17 +79,17 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: hard_reset
name: "0000A66101, interconnect 1"
'''

RETURN = ''' # '''

from ansible.module_utils.oneview import OneViewModuleBase, OneViewModuleResourceNotFound
from ansible.module_utils.oneview import OneViewModule, OneViewModuleResourceNotFound


class SasInterconnectModule(OneViewModuleBase):
class SasInterconnectModule(OneViewModule):
MSG_NOT_FOUND = 'SAS Interconnect not found.'
MSG_NOTHING_TO_DO = 'Nothing to do.'

Expand Down Expand Up @@ -122,47 +122,37 @@ class SasInterconnectModule(OneViewModuleBase):

def __init__(self):
super(SasInterconnectModule, self).__init__(additional_arg_spec=self.argument_spec, validate_etag_support=True)
self.resource_client = self.oneview_client.sas_interconnects
self.set_resource_object(self.oneview_client.sas_interconnects)

def execute_module(self):
name = self.module.params.get('name')

changed, msg, facts = False, '', dict()
sas_interconnect = self.__get_by_name(name)
if not self.current_resource:
raise OneViewModuleResourceNotFound(self.MSG_NOT_FOUND)

if self.state == 'refreshed':
facts['sas_interconnect'] = self.resource_client.refresh_state(
id_or_uri=sas_interconnect['uri'],
facts['sas_interconnect'] = self.current_resource.refresh_state(
configuration=dict(refreshState="RefreshPending")
)
changed = True
msg = self.states_success_message[self.state]
elif self.states.get(self.state):
changed, msg, facts['sas_interconnect'] = self.change_state(self.state, sas_interconnect)
changed, msg, facts['sas_interconnect'] = self.change_state(self.state)

return dict(changed=changed, msg=msg, ansible_facts=facts)

def __get_by_name(self, name):
sas_interconnects = self.resource_client.get_by('name', name)

if not sas_interconnects:
raise OneViewModuleResourceNotFound(self.MSG_NOT_FOUND)

return sas_interconnects[0]

def change_state(self, state_name, resource):
def change_state(self, state_name):
changed = False
state = self.states[state_name]
property_name = state['path'][1:]

if state_name in self.actions or resource[property_name] != state['value']:
resource = self.resource_client.patch(id_or_uri=resource["uri"], **state)
if state_name in self.actions or self.current_resource.data[property_name] != state['value']:
self.current_resource.patch(**state)
msg = self.states_success_message[state_name]
changed = True
else:
msg = self.MSG_NOTHING_TO_DO

return changed, msg, resource
return changed, msg, self.current_resource.data


def main():
Expand Down
14 changes: 7 additions & 7 deletions library/oneview_sas_interconnect_facts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
###
# Copyright (2016-2017) Hewlett Packard Enterprise Development LP
# Copyright (2016-2019) Hewlett Packard Enterprise Development LP
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
Expand All @@ -28,7 +28,7 @@
version_added: "2.3"
requirements:
- "python >= 2.7.9"
- "hpOneView >= 3.0.0"
- "hpOneView >= 5.0.0"
author: "Bruno Souza (@bsouza)"
options:
name:
Expand All @@ -48,14 +48,14 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
- name: Gather paginated, filtered and sorted facts about SAS Interconnects
oneview_sas_interconnect_facts:
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
params:
start: 0
count: 3
Expand All @@ -67,7 +67,7 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
name: "0000A66103, interconnect 1"
'''

Expand All @@ -78,10 +78,10 @@
type: list
'''

from ansible.module_utils.oneview import OneViewModuleBase
from ansible.module_utils.oneview import OneViewModule


class SasInterconnectFactsModule(OneViewModuleBase):
class SasInterconnectFactsModule(OneViewModule):
argument_spec = dict(
name=dict(required=False, type='str'),
params=dict(required=False, type='dict'),
Expand Down
16 changes: 8 additions & 8 deletions oneview-ansible.md
Original file line number Diff line number Diff line change
Expand Up @@ -7831,7 +7831,7 @@ Manage the OneView SAS Interconnect resources.

#### Requirements (on the host that executes the module)
* python >= 2.7.9
* hpOneView >= 3.0.0
* hpOneView >= 5.0.0

#### Options

Expand All @@ -7853,7 +7853,7 @@ Manage the OneView SAS Interconnect resources.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: powered_on
name: "0000A66101, interconnect 1"

Expand All @@ -7862,7 +7862,7 @@ Manage the OneView SAS Interconnect resources.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: refreshed
name: "0000A66101, interconnect 1"

Expand All @@ -7871,7 +7871,7 @@ Manage the OneView SAS Interconnect resources.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: hard_reset
name: "0000A66101, interconnect 1"

Expand Down Expand Up @@ -7901,7 +7901,7 @@ Retrieve facts about the OneView SAS Interconnects.

#### Requirements (on the host that executes the module)
* python >= 2.7.9
* hpOneView >= 3.0.0
* hpOneView >= 5.0.0

#### Options

Expand All @@ -7922,14 +7922,14 @@ Retrieve facts about the OneView SAS Interconnects.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800

- name: Gather paginated, filtered and sorted facts about SAS Interconnects
oneview_sas_interconnect_facts:
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
params:
start: 0
count: 3
Expand All @@ -7941,7 +7941,7 @@ Retrieve facts about the OneView SAS Interconnects.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
name: "0000A66103, interconnect 1"

```
Expand Down

0 comments on commit 37de44f

Please sign in to comment.