Skip to content

Commit

Permalink
Merge 8f86230 into 73379c2
Browse files Browse the repository at this point in the history
  • Loading branch information
sijeesh committed Apr 12, 2019
2 parents 73379c2 + 8f86230 commit c5729ea
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 55 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ This release extends the planned support of the modules to OneView REST API vers
- oneview_sas_interconnect
- oneview_sas_interconnect_facts
- oneview_sas_interconnect_type_facts
- oneview_sas_logical_interconnect_group
- oneview_sas_logical_interconnect_group_facts
- oneview_switch_type_facts

## v5.2.0
Expand Down
10 changes: 5 additions & 5 deletions endpoints-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@
|<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: |
|<sub>/rest/sas-logical-interconnect-groups/{id}</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-logical-interconnect-groups/{id}</sub> | PUT | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-logical-interconnect-groups/{id}</sub> | DELETE | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-logical-interconnect-groups</sub> | POST | :heavy_minus_sign: | :white_check_mark: | :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: | :white_check_mark: |
|<sub>/rest/sas-logical-interconnect-groups/{id}</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-logical-interconnect-groups/{id}</sub> | PUT | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-logical-interconnect-groups/{id}</sub> | DELETE | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| **SAS Logical Interconnects** |
|<sub>/rest/sas-logical-interconnects</sub> | GET | :heavy_minus_sign: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|<sub>/rest/sas-logical-interconnects/{id}</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_logical_interconnect_group.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 Expand Up @@ -76,4 +76,4 @@
data:
name: 'Updated SAS Logical Interconnect Group'
delegate_to: localhost
register: deleted
register: deleted
4 changes: 2 additions & 2 deletions examples/oneview_sas_logical_interconnect_group_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 All @@ -19,7 +19,7 @@
vars:
config: "{{ playbook_dir }}/oneview_config.json"
# Set the name of a SAS Logical Interconnect Group to run the playbook
sas_logical_interconnect_group_name: "sas-LIG"
sas_logical_interconnect_group_name: "SYN_SAS_1"
scope_uris: "/rest/scopes/be263683-b147-4818-8bbe-c5a5629b9bfe"

tasks:
Expand Down
23 changes: 10 additions & 13 deletions library/oneview_sas_logical_interconnect_group.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 @@ -29,7 +29,7 @@
version_added: "2.3"
requirements:
- "python >= 2.7.9"
- "hpOneView >= 3.1.0"
- "hpOneView >= 5.0.0"
author: "Camila Balestrin (@balestrinc)"
options:
state:
Expand All @@ -56,7 +56,7 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: present
data:
name: "Test SAS Logical Interconnect Group"
Expand Down Expand Up @@ -88,7 +88,7 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: present
data:
name: 'New SAS Logical Interconnect Group'
Expand All @@ -99,7 +99,7 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: absent
data:
name: 'New SAS Logical Interconnect Group'
Expand All @@ -112,10 +112,10 @@
type: dict
'''

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


class SasLogicalInterconnectGroupModule(OneViewModuleBase):
class SasLogicalInterconnectGroupModule(OneViewModule):
MSG_CREATED = 'SAS Logical Interconnect Group created successfully.'
MSG_UPDATED = 'SAS Logical Interconnect Group updated successfully.'
MSG_DELETED = 'SAS Logical Interconnect Group deleted successfully.'
Expand All @@ -135,16 +135,13 @@ def __init__(self):
super(SasLogicalInterconnectGroupModule, self).__init__(additional_arg_spec=self.argument_spec,
validate_etag_support=True)

self.resource_client = self.oneview_client.sas_logical_interconnect_groups
self.set_resource_object(self.oneview_client.sas_logical_interconnect_groups)

def execute_module(self):

resource = self.get_by_name(self.data.get('name'))

if self.state == 'present':
return self.resource_present(resource, self.RESOURCE_FACT_NAME)
return self.resource_present(self.RESOURCE_FACT_NAME)
elif self.state == 'absent':
return self.resource_absent(resource)
return self.resource_absent()


def main():
Expand Down
21 changes: 11 additions & 10 deletions library/oneview_sas_logical_interconnect_group_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 Down Expand Up @@ -29,7 +29,7 @@
version_added: "2.3"
requirements:
- "python >= 2.7.9"
- "hpOneView >= 4.5.0"
- "hpOneView >= 5.0.0"
author: "Camila Balestrin (@balestrinc)"
options:
name:
Expand All @@ -50,15 +50,15 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
- debug: var=sas_logical_interconnect_groups
- name: Gather paginated, filtered and sorted facts about SAS Logical Interconnect Groups
oneview_sas_logical_interconnect_group_facts:
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
params:
start: 0
count: 5
Expand All @@ -71,7 +71,7 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
params:
scope_uris: "/rest/scopes/be263683-b147-4818-8bbe-c5a5629b9bfe"
- debug: var=sas_logical_interconnect_groups
Expand All @@ -81,7 +81,7 @@
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
name: "LIG-SLJA-1"
- debug: var=sas_logical_interconnect_groups
'''
Expand All @@ -93,24 +93,25 @@
type: dict
'''

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


class SasLogicalInterconnectGroupFactsModule(OneViewModuleBase):
class SasLogicalInterconnectGroupFactsModule(OneViewModule):
argument_spec = dict(
name=dict(required=False, type='str'),
params=dict(required=False, type='dict')
)

def __init__(self):
super(SasLogicalInterconnectGroupFactsModule, self).__init__(additional_arg_spec=self.argument_spec)
self.resource_client = self.oneview_client.sas_logical_interconnect_groups

def execute_module(self):
if self.module.params['name']:
name = self.module.params['name']
resources = self.oneview_client.sas_logical_interconnect_groups.get_by('name', name)
resources = self.resource_client.get_by('name', name)
else:
resources = self.oneview_client.sas_logical_interconnect_groups.get_all(**self.facts_params)
resources = self.resource_client.get_all(**self.facts_params)

return dict(changed=False,
ansible_facts=dict(sas_logical_interconnect_groups=resources))
Expand Down
18 changes: 9 additions & 9 deletions oneview-ansible.md
Original file line number Diff line number Diff line change
Expand Up @@ -8266,7 +8266,7 @@ Manage OneView SAS Logical Interconnect Group resources.

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

#### Options

Expand All @@ -8288,7 +8288,7 @@ Manage OneView SAS Logical Interconnect Group resources.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: present
data:
name: "Test SAS Logical Interconnect Group"
Expand Down Expand Up @@ -8320,7 +8320,7 @@ Manage OneView SAS Logical Interconnect Group resources.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: present
data:
name: 'New SAS Logical Interconnect Group'
Expand All @@ -8331,7 +8331,7 @@ Manage OneView SAS Logical Interconnect Group resources.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
state: absent
data:
name: 'New SAS Logical Interconnect Group'
Expand Down Expand Up @@ -8369,7 +8369,7 @@ Retrieve facts about one or more of the OneView SAS Logical Interconnect Groups.

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

#### Options

Expand All @@ -8390,15 +8390,15 @@ Retrieve facts about one or more of the OneView SAS Logical Interconnect Groups.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
- debug: var=sas_logical_interconnect_groups

- name: Gather paginated, filtered and sorted facts about SAS Logical Interconnect Groups
oneview_sas_logical_interconnect_group_facts:
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
params:
start: 0
count: 5
Expand All @@ -8411,7 +8411,7 @@ Retrieve facts about one or more of the OneView SAS Logical Interconnect Groups.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
params:
scope_uris: "/rest/scopes/be263683-b147-4818-8bbe-c5a5629b9bfe"
- debug: var=sas_logical_interconnect_groups
Expand All @@ -8421,7 +8421,7 @@ Retrieve facts about one or more of the OneView SAS Logical Interconnect Groups.
hostname: 172.16.101.48
username: administrator
password: my_password
api_version: 600
api_version: 800
name: "LIG-SLJA-1"
- debug: var=sas_logical_interconnect_groups

Expand Down
29 changes: 16 additions & 13 deletions test/test_oneview_sas_logical_interconnect_group.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 @@ -17,6 +17,7 @@
###

import pytest
import mock

from hpe_test_utils import OneViewBaseTest
from oneview_module_loader import SasLogicalInterconnectGroupModule
Expand Down Expand Up @@ -68,9 +69,10 @@ class TestSasLogicalInterconnectGroupModule(OneViewBaseTest):
"""

def test_should_create(self):
self.resource.get_by.return_value = []
self.resource.create.return_value = DEFAULT_SAS_LIG_TEMPLATE

self.resource.get_by_name.return_value = None
obj = mock.Mock()
obj.data = DEFAULT_SAS_LIG_TEMPLATE
self.resource.create.return_value = obj
self.mock_ansible_module.params = PARAMS_FOR_PRESENT

SasLogicalInterconnectGroupModule().run()
Expand All @@ -86,8 +88,10 @@ def test_create_with_newName_when_resource_not_exists(self):
data_merged['name'] = RENAMED_SAS_LIG
params_to_rename = PARAMS_TO_RENAME.copy()

self.resource.get_by.return_value = []
self.resource.create.return_value = DEFAULT_SAS_LIG_TEMPLATE
self.resource.get_by_name.return_value = None
obj = mock.Mock()
obj.data = DEFAULT_SAS_LIG_TEMPLATE
self.resource.create.return_value = obj

self.mock_ansible_module.params = params_to_rename

Expand All @@ -96,7 +100,7 @@ def test_create_with_newName_when_resource_not_exists(self):
self.resource.create.assert_called_once_with(PARAMS_TO_RENAME['data'])

def test_should_not_update_when_data_is_equals(self):
self.resource.get_by.return_value = [DEFAULT_SAS_LIG_TEMPLATE]
self.resource.data = DEFAULT_SAS_LIG_TEMPLATE

self.mock_ansible_module.params = PARAMS_FOR_PRESENT

Expand All @@ -112,8 +116,7 @@ def test_update_when_data_has_modified_attributes(self):
data_merged = DEFAULT_SAS_LIG_TEMPLATE.copy()
data_merged['description'] = 'New description'

self.resource.get_by.return_value = [DEFAULT_SAS_LIG_TEMPLATE]
self.resource.update.return_value = data_merged
self.resource.data = DEFAULT_SAS_LIG_TEMPLATE

self.mock_ansible_module.params = PARAMS_WITH_CHANGES

Expand All @@ -122,15 +125,15 @@ def test_update_when_data_has_modified_attributes(self):
self.mock_ansible_module.exit_json.assert_called_once_with(
changed=True,
msg=SasLogicalInterconnectGroupModule.MSG_UPDATED,
ansible_facts=dict(sas_logical_interconnect_group=data_merged)
ansible_facts=dict(sas_logical_interconnect_group=self.resource.data)
)

def test_rename_when_resource_exists(self):
data_merged = DEFAULT_SAS_LIG_TEMPLATE.copy()
data_merged['name'] = RENAMED_SAS_LIG
params_to_rename = PARAMS_TO_RENAME.copy()

self.resource.get_by.return_value = [DEFAULT_SAS_LIG_TEMPLATE]
self.resource.data = DEFAULT_SAS_LIG_TEMPLATE
self.resource.update.return_value = data_merged

self.mock_ansible_module.params = params_to_rename
Expand All @@ -140,7 +143,7 @@ def test_rename_when_resource_exists(self):
self.resource.update.assert_called_once_with(data_merged)

def test_should_remove(self):
self.resource.get_by.return_value = [DEFAULT_SAS_LIG_TEMPLATE]
self.resource.data = DEFAULT_SAS_LIG_TEMPLATE

self.mock_ansible_module.params = PARAMS_FOR_ABSENT

Expand All @@ -152,7 +155,7 @@ def test_should_remove(self):
)

def test_should_do_nothing_when_resource_not_exist(self):
self.resource.get_by.return_value = []
self.resource.get_by_name.return_value = None
self.mock_ansible_module.params = PARAMS_FOR_ABSENT

SasLogicalInterconnectGroupModule().run()
Expand Down

0 comments on commit c5729ea

Please sign in to comment.