Commit e3394784 authored by Ricardo Araujo's avatar Ricardo Araujo
Browse files

Merge branch 'feature/hponeview' into 'master'

Change python-oneviewclient to hpOneView

See merge request !2
parents 96081e72 758500ce
# -*- encoding: utf-8 -*-
#
# Copyright 2016 Hewlett Packard Enterprise Development LP.
# Copyright 2016 Universidade Federal de Campina Grande
# All Rights Reserved.
# Copyright (2016-2017) Hewlett Packard Enterprise Development LP.
# Copyright (2016-2017) Universidade Federal de Campina Grande
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
......@@ -16,34 +13,39 @@
# License for the specific language governing permissions and limitations
# under the License.
from oneview_client import client
from oneview_client import exceptions
import os
import six.moves.configparser as config_parser
from six.moves.urllib import parse
from hpOneView import exceptions
from hpOneView import oneview_client as Client
def clean_server_profile(node_info):
try:
server_hardware = oneview_client.get_server_hardware(node_info)
sp_uri = server_hardware.server_profile_uri
sh_uri = node_info.get('server_hardware_uri')
server_hardware = oneview_client.server_hardware.get(sh_uri)
sp_uri = server_hardware.get('serverProfileUri')
print("Powering off Server Hardware %s" % (
node_info.get('server_hardware_uri')
))
print("Powering off Server Hardware %s" % sh_uri)
oneview_client.power_off(node_info)
configuration = {
"powerState": "Off",
"powerControl": "MomentaryPress"
}
oneview_client.server_hardware.update_power_state(
configuration, sh_uri)
if sp_uri:
sp_uuid = sp_uri.split('/')[-1]
print("Deleting server profile %s" % (sp_uuid))
try:
oneview_client.delete_server_profile(sp_uuid)
except exceptions.OneViewServerProfileDeletionError:
oneview_client.server_profiles.delete(sp_uuid)
except exceptions.HPOneViewException:
print("Error deleting Server Profile")
else:
print("No applied Server Profile to delete")
except exceptions.OneViewResourceNotFoundError:
except exceptions.HPOneViewException:
print("Check server hardware URI")
......@@ -52,15 +54,25 @@ if __name__ == "__main__":
config = config_parser.SafeConfigParser()
config.read(config_file)
oneview_client = client.Client(
manager_url=config.get('oneview', 'manager_url'),
username=config.get('oneview', 'username'),
password=config.get('oneview', 'password'),
allow_insecure_connections=config.get(
'oneview',
'allow_insecure_connections'),
tls_cacert_file=config.get('oneview', 'tls_cacert_file')
)
def prepare_manager_url(manager_url):
# NOTE(mrtenio) python-oneviewclient uses https or http in the
# manager_url while python-hpOneView does not. This will not be
# necessary when python-hpOneView client is the only OneView library.
if manager_url:
url_parse = parse.urlparse(manager_url)
manager_url = url_parse.netloc
return manager_url
manager_url = prepare_manager_url(config.get('oneview', 'manager_url'))
credentials = {
"ip": manager_url,
"credentials": {
"userName": config.get('oneview', 'username'),
"password": config.get('oneview', 'password')
}
}
oneview_client = Client.OneViewClient(credentials)
node_info = {
'server_hardware_uri': config.get('node', 'server_hardware_uri')
......
#!/bin/bash -xe
# Copyright (2016-2017) Hewlett Packard Enterprise Development LP
# Copyright (2016-2017) Universidade Federal de Campina Grande
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# 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.
# This script is executed inside post_test_hook function in devstack gate.
function generate_testr_results {
if [ -f .testrepository/0 ]; then
sudo .tox/py27/bin/testr last --subunit > $WORKSPACE/testrepository.subunit
sudo mv $WORKSPACE/testrepository.subunit $BASE/logs/testrepository.subunit
sudo /usr/os-testr-env/bin/subunit2html $BASE/logs/testrepository.subunit $BASE/logs/testr_results.html
sudo gzip -9 $BASE/logs/testrepository.subunit
sudo gzip -9 $BASE/logs/testr_results.html
sudo chown jenkins:jenkins $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
sudo chmod a+r $BASE/logs/testrepository.subunit.gz $BASE/logs/testr_results.html.gz
fi
}
# Run tests
echo "Running oneview functional test suite"
set +e
# Only admin credentials needed for ironic api
source $BASE/new/devstack/openrc admin admin
# Preserve env for OS_ credentials
sudo -E -H -u jenkins ./run_integration.sh
EXIT_CODE=$?
set -e
# Collect and parse result
generate_testr_results
exit $EXIT_CODE
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hpOneView<4.0.0,>=3.2.1
six>=1.9.0 # MIT
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment