def test_from_json_file(self, mock_open, mock_login):
        json_config_content = u"""{
          "ip": "172.16.102.59",
          "api_version": 800,
          "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())
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###

import os
from pprint import pprint
from hpeOneView.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()
deployment_plans = image_streamer_client.deployment_plans

# To run this example set a valid Build Plan URI
deployment_plan_information = {
    "name": "Demo Deployment Plan",
    "description": "",
    "hpProvided": "false",
    "oeBuildPlanURI": "/rest/build-plans/134b7e3f-4305-47c4-8d15-44d265697bf0",
}

if oneview_client.api_version >= 500:
    deployment_plan_information["type"] = "OEDeploymentPlanV5"

# Create a Deployment Plan
Exemple #3
0
from hpeOneView.oneview_client import OneViewClient
from hpeOneView.exceptions import HPEOneViewException
from config_loader import try_load_from_file
from pprint import pprint

config = {
    "ip": "<oneview_ip>",
    "credentials": {
        "userName": "******",
        "password": "******"
    }
}

# Try load config from a file (if there is a config file)
config = try_load_from_file(config)
oneview_client = OneViewClient.from_json_file('config.json')
storage_systems = oneview_client.storage_systems
storage_pools = oneview_client.storage_pools
scopes = oneview_client.scopes

# Find or add storage system
print("Find or add storage system")
s_systems = storage_systems.get_all()
if s_systems:
    s_system_data = s_systems[0]
    s_system = storage_systems.get_by_uri(s_system_data["uri"])
    storage_system_added = False
    print("Found storage system '{}' at uri: {}".format(
        s_system.data['name'], s_system.data['uri']))
else:
    options = {