def test_from_environment_variables_is_passing_right_arguments_to_the_constructor(self, mock_cls): mock_cls.return_value = None OneViewClient.from_environment_variables() mock_cls.assert_called_once_with({'api_version': 201, 'proxy': '172.16.100.195:9999', 'ip': '172.16.100.199', 'image_streamer_ip': '172.172.172.172', 'credentials': {'password': '******', 'authLoginDomain': 'authdomain', 'userName': '******'}})
def test_from_environment_variables_is_passing_right_arguments_to_the_constructor_with_only_sessionID(self, mock_cls): mock_cls.return_value = None OneViewClient.from_environment_variables() mock_cls.assert_called_once_with({'api_version': 300, 'proxy': '', 'timeout': None, 'ip': '172.16.100.199', 'image_streamer_ip': '', 'ssl_certificate': '', 'credentials': {'userName': '', 'password': '', 'authLoginDomain': '', 'sessionID': '123'}})
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 test_from_minimal_environment_variables(self, mock_set_proxy, mock_login): oneview_client = OneViewClient.from_environment_variables() mock_login.assert_called_once_with( dict(userName='******', password='******', authLoginDomain='')) mock_set_proxy.assert_not_called() self.assertEqual(300, oneview_client.connection._apiVersion)
def test_from_minimal_environment_variables(self, mock_set_proxy, mock_login): oneview_client = OneViewClient.from_environment_variables() mock_login.assert_called_once_with(dict(userName='******', password='******', authLoginDomain='')) mock_set_proxy.assert_not_called() self.assertEqual(300, oneview_client.connection._apiVersion)
def test_from_full_environment_variables(self, mock_set_proxy, mock_login): oneview_client = OneViewClient.from_environment_variables() mock_login.assert_called_once_with( dict(userName='******', password='******', authLoginDomain='authdomain')) mock_set_proxy.assert_called_once_with('172.16.100.195', 9999) self.assertEqual(201, oneview_client.connection._apiVersion)
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'])
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'])
def test_from_full_environment_variables(self, mock_set_proxy, mock_login): oneview_client = OneViewClient.from_environment_variables() mock_login.assert_called_once_with(dict(userName='******', password='******', authLoginDomain='authdomain')) mock_set_proxy.assert_called_once_with('172.16.100.195', 9999) self.assertEqual(201, oneview_client.connection._apiVersion) self.assertEqual(oneview_client.create_image_streamer_client().connection.get_host(), OS_ENVIRON_CONFIG_FULL['ONEVIEWSDK_IMAGE_STREAMER_IP'])
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, )
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'])
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'])
from hpOneView.oneview_client import OneViewClient from hpOneView.exceptions import HPOneViewException import json import sys import re import logging import os ov_client = OneViewClient.from_environment_variables() server_hw = ov_client.server_hardware.get_all() # Iterate through each server and validate info in ES for server in server_hw: # Update each ES record with data from Server H/W and keep track print("Name : %s Serial#: %s Model %s" % (server['name'], server['serialNumber'], server['shortModel']))