def __init__(self):
        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    supports_check_mode=False)
        if not HAS_HPE_ONEVIEW:
            self.module.fail_json(msg=HPE_ONEVIEW_SDK_REQUIRED)
        if not self.module.params['config']:
            logical_interconnects = OneViewClient.from_environment_variables(
            ).logical_interconnects
        else:
            logical_interconnects = OneViewClient.from_json_file(
                self.module.params['config']).logical_interconnects

        self.resource_client = logical_interconnects
        self.options = dict(
            qos_aggregated_configuration=logical_interconnects.
            get_qos_aggregated_configuration,
            snmp_configuration=logical_interconnects.get_snmp_configuration,
            port_monitor=logical_interconnects.get_port_monitor,
            internal_vlans=logical_interconnects.get_internal_vlans,
            forwarding_information_base=logical_interconnects.
            get_forwarding_information_base,
            firmware=logical_interconnects.get_firmware,
            unassigned_uplink_ports=logical_interconnects.
            get_unassigned_uplink_ports,
            telemetry_configuration=logical_interconnects.
            get_telemetry_configuration,
        )
 def __init__(self):
     self.module = AnsibleModule(argument_spec=self.argument_spec,
                                 supports_check_mode=False)
     if not self.module.params['config']:
         self.oneview_client = OneViewClient.from_environment_variables()
     else:
         self.oneview_client = OneViewClient.from_json_file(
             self.module.params['config'])
    def __init__(self):
        self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=False)
        if not HAS_HPE_ONEVIEW:
            self.module.fail_json(msg=HPE_ONEVIEW_SDK_REQUIRED)

        if not self.module.params['config']:
            self.oneview_client = OneViewClient.from_environment_variables()
        else:
            self.oneview_client = OneViewClient.from_json_file(self.module.params['config'])
Exemplo n.º 4
0
    def __init__(self):
        self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=False)
        if not HAS_HPE_ONEVIEW:
            self.module.fail_json(msg=HPE_ONEVIEW_SDK_REQUIRED)

        if not self.module.params['config']:
            self.oneview_client = OneViewClient.from_environment_variables()
        else:
            self.oneview_client = OneViewClient.from_json_file(self.module.params['config'])
Exemplo n.º 5
0
 def _create_oneview_client(self):
     if self.module.params.get('hostname'):
         config = dict(ip=self.module.params['hostname'],
                       credentials=dict(userName=self.module.params['username'], password=self.module.params['password']),
                       api_version=self.module.params['api_version'],
                       image_streamer_ip=self.module.params['image_streamer_hostname'])
         self.oneview_client = OneViewClient(config)
     elif not self.module.params['config']:
         self.oneview_client = OneViewClient.from_environment_variables()
     else:
         self.oneview_client = OneViewClient.from_json_file(self.module.params['config'])
Exemplo n.º 6
0
 def _create_oneview_client(self):
     if self.module.params.get('hostname'):
         config = dict(ip=self.module.params['hostname'],
                       credentials=dict(userName=self.module.params['username'], password=self.module.params['password']),
                       api_version=self.module.params['api_version'],
                       image_streamer_ip=self.module.params['image_streamer_hostname'])
         self.oneview_client = OneViewClient(config)
     elif not self.module.params['config']:
         self.oneview_client = OneViewClient.from_environment_variables()
     else:
         self.oneview_client = OneViewClient.from_json_file(self.module.params['config'])
Exemplo n.º 7
0
    def test_from_json_file_with_only_sessionID(self, mock_open, mock_login):
        json_config_content = u"""{
          "ip": "172.16.102.59",
          "credentials": {
            "sessionID": "123"
          }
        }"""
        mock_open.return_value = self.__mock_file_open(json_config_content)
        oneview_client = OneViewClient.from_json_file("config.json")

        self.assertIsInstance(oneview_client, OneViewClient)
        self.assertEqual("172.16.102.59", oneview_client.connection.get_host())
    def test_from_json_file_with_only_sessionID(self, mock_open, mock_login):
        json_config_content = u"""{
          "ip": "172.16.102.59",
          "credentials": {
            "sessionID": "123"
          }
        }"""
        mock_open.return_value = self.__mock_file_open(json_config_content)
        oneview_client = OneViewClient.from_json_file("config.json")

        self.assertIsInstance(oneview_client, OneViewClient)
        self.assertEqual("172.16.102.59", oneview_client.connection.get_host())
Exemplo n.º 9
0
    def test_default_api_version(self, mock_open, mock_login):
        json_config_content = u"""{
          "ip": "172.16.102.59",
          "credentials": {
            "userName": "******",
            "authLoginDomain": "",
            "password": ""
          }
        }"""
        mock_open.return_value = self.__mock_file_open(json_config_content)
        oneview_client = OneViewClient.from_json_file("config.json")

        self.assertEqual(200, oneview_client.connection._apiVersion)
    def test_default_api_version(self, mock_open, mock_login):
        json_config_content = u"""{
          "ip": "172.16.102.59",
          "credentials": {
            "userName": "******",
            "authLoginDomain": "",
            "password": ""
          }
        }"""
        mock_open.return_value = self.__mock_file_open(json_config_content)
        oneview_client = OneViewClient.from_json_file("config.json")

        self.assertEqual(200, oneview_client.connection._apiVersion)
Exemplo n.º 11
0
    def test_from_json_file(self, mock_open, mock_login):
        json_config_content = u"""{
          "ip": "172.16.102.59",
          "credentials": {
            "userName": "******",
            "authLoginDomain": "",
            "password": ""
          }
        }"""
        mock_open.return_value = self.__mock_file_open(json_config_content)
        oneview_client = OneViewClient.from_json_file("config.json")

        self.assertIsInstance(oneview_client, OneViewClient)
        self.assertEqual("172.16.102.59", oneview_client.connection.get_host())
Exemplo n.º 12
0
    def test_from_json_file(self, mock_open, mock_login):
        json_config_content = u"""{
          "ip": "172.16.102.59",
          "credentials": {
            "userName": "******",
            "authLoginDomain": "",
            "password": ""
          }
        }"""
        mock_open.return_value = self.__mock_file_open(json_config_content)
        oneview_client = OneViewClient.from_json_file("config.json")

        self.assertIsInstance(oneview_client, OneViewClient)
        self.assertEqual("172.16.102.59", oneview_client.connection.get_host())
    def __init__(self):
        self.module = AnsibleModule(argument_spec=self.argument_spec,
                                    supports_check_mode=False)
        if not HAS_HPE_ONEVIEW:
            self.module.fail_json(msg=HPE_ONEVIEW_SDK_REQUIRED)

        if not self.module.params['config']:
            self.oneview_client = OneViewClient.from_environment_variables()
        else:
            self.oneview_client = OneViewClient.from_json_file(
                self.module.params['config'])

        resource_uri = self.oneview_client.storage_volume_attachments.URI
        self.__search_attachment_uri = str(
            resource_uri
        ) + "?filter=storageVolumeUri='{}'&filter=hostName='{}'"
    def __init__(self):
        self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=False)
        if not HAS_HPE_ONEVIEW:
            self.module.fail_json(msg=HPE_ONEVIEW_SDK_REQUIRED)
        if not self.module.params['config']:
            logical_interconnects = OneViewClient.from_environment_variables().logical_interconnects
        else:
            logical_interconnects = OneViewClient.from_json_file(self.module.params['config']).logical_interconnects

        self.resource_client = logical_interconnects
        self.options = dict(
            qos_aggregated_configuration=logical_interconnects.get_qos_aggregated_configuration,
            snmp_configuration=logical_interconnects.get_snmp_configuration,
            port_monitor=logical_interconnects.get_port_monitor,
            internal_vlans=logical_interconnects.get_internal_vlans,
            forwarding_information_base=logical_interconnects.get_forwarding_information_base,
            firmware=logical_interconnects.get_firmware,
            unassigned_uplink_ports=logical_interconnects.get_unassigned_uplink_ports,
            telemetry_configuration=logical_interconnects.get_telemetry_configuration,
        )
Exemplo n.º 15
0
###
# Pull down configuration information from an HPE OneView instance
#
# Implemented so far:
# ethernet_networks, fc_networks, fcoe_networks, network_sets, server_profile_templates, firmware_drivers
#
###

from hpOneView.oneview_client import OneViewClient

import json

oneview_client = OneViewClient.from_json_file('config.json')
configuration = {}
nw_resources = ['ethernet_networks', 'fc_networks', 'fcoe_networks']
excluded_keys = [
    'connectionTemplateUri', 'fabricUri', 'managedSanUri', 'scopesUri',
    'status', 'state', 'created', 'modified', 'eTag', 'category', 'uri',
    'subnetUri', 'nativeNetworkUri', 'networkUris', 'serverHardwareTypeUri'
]


# Define functions
def remove_keys(resource, dict):
    configuration[resource][dict['name']] = {
        k: v
        for k, v in dict.items() if k not in excluded_keys
    }


def get_networks(resource):
 def __init__(self):
     self.module = AnsibleModule(argument_spec=self.argument_spec, supports_check_mode=False)
     if not self.module.params['config']:
         self.oneview_client = OneViewClient.from_environment_variables()
     else:
         self.oneview_client = OneViewClient.from_json_file(self.module.params['config'])
Exemplo n.º 17
0
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###

import os
from pprint import pprint
from hpOneView.oneview_client import OneViewClient

EXAMPLE_CONFIG_FILE = os.path.join(os.path.dirname(__file__), '../config.json')

oneview_client = OneViewClient.from_json_file(EXAMPLE_CONFIG_FILE)

image_streamer_client = oneview_client.create_image_streamer_client()

build_plan_information = {
    "name": "Demo Build Plan",
    "oeBuildPlanType": "deploy"
}

# Create a Build Plan
print("Create an OS Build Plan")
build_plan_created = image_streamer_client.build_plans.create(build_plan_information)
pprint(build_plan_created)

# Update the Build Plan
print("\nUpdate the OS Build Plan")
Exemplo n.º 18
0
 def __create_oneview_client(self):
     if not self.module.params['config']:
         self.oneview_client = OneViewClient.from_environment_variables()
     else:
         self.oneview_client = OneViewClient.from_json_file(self.module.params['config'])
Exemplo n.º 19
0
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
###

import os
from pprint import pprint
from hpOneView.oneview_client import OneViewClient

EXAMPLE_CONFIG_FILE = os.path.join(os.path.dirname(__file__), '../config.json')

oneview_client = OneViewClient.from_json_file(EXAMPLE_CONFIG_FILE)

image_streamer_client = oneview_client.create_image_streamer_client()

# To run this example set a valid Build Plan URI
deployment_plan_information = {
    "name": "Demo Deployment Plan",
    "description": "",
    "hpProvided": "false",
    "oeBuildPlanURI": "/rest/build-plans/1beb9333-66a8-48d5-82b6-1bda1a81582a",
}

# Create a Deployment Plan
print("Create a Deployment Plan")
deployment_plan_created = image_streamer_client.deployment_plans.create(
    deployment_plan_information)
Exemplo n.º 20
0
 def __create_oneview_client(self):
     if not self.module.params['config']:
         self.oneview_client = OneViewClient.from_environment_variables()
     else:
         self.oneview_client = OneViewClient.from_json_file(self.module.params['config'])