Commit f523b58e authored by Hugo Nicodemos's avatar Hugo Nicodemos
Browse files

Create new repo for cleaning server profile

parent b99bcfdc
# -*- encoding: utf-8 -*-
#
# Copyright 2016 Hewlett Packard Enterprise Development LP.
# Copyright 2016 Universidade Federal de Campina Grande
# All Rights Reserved.
#
# 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.
from oneview_client import client
from oneview_client import exceptions
import os
import six.moves.configparser as config_parser
def clean_server_profile(node_info):
try:
server_hardware = oneview_client.get_server_hardware(node_info)
sp_uri = server_hardware.server_profile_uri
print("Powering off Server Hardware %s" % (
node_info.get('server_hardware_uri')
))
oneview_client.power_off(node_info)
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:
print("Error deleting Server Profile")
else:
print("No applied Server Profile to delete")
except exceptions.OneViewResourceNotFoundError:
print("Check server hardware URI")
if __name__ == "__main__":
config_file = os.path.join(os.path.dirname(__file__), 'test.conf')
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')
)
node_info = {
'server_hardware_uri': config.get('node', 'server_hardware_uri')
}
clean_server_profile(node_info)
#!/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
#!/bin/bash
# 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.
CONFIG_FILE=./test.conf
SERVER_HARDWARE_URI=$(awk '{print $1}' ${IRONIC_HWINFO_FILE})
cat <<END >>$CONFIG_FILE
[node]
server_hardware_uri=$SERVER_HARDWARE_URI
[oneview]
manager_url=$ONEVIEW_MANAGER_URL
username=$ONEVIEW_USERNAME
password=$ONEVIEW_PASSWORD
END
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