Commit 6c0fbd80 authored by Hugo Nicodemos's avatar Hugo Nicodemos
Browse files

Create new repo for cleaning server profile

parent f523b58e
# Copyright (2016-2017) Hewlett Packard Enterprise Development LP
# Copyright (2016-2017) 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("TESTANDO: Powering off Server Hardware %s" % (
node_info.get('server_hardware_uri')
))
if sp_uri:
sp_uuid = sp_uri.split('/')[-1]
print("TESTANDO: Deleting server profile %s" % (sp_uuid))
else:
print("TESTANDO: No applied Server Profile to delete")
except exceptions.OneViewResourceNotFoundError:
print("TESTANDO: 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)
[tox]
minversion = 1.6
envlist = clean
skipsdist = True
[testenv]
setenv = VIRTUAL_ENV={envdir}
LANGUAGE=en_US
# .testr.conf uses TESTS_DIR
TESTS_DIR=./integration_tests
usedevelop = True
install_command = pip install -U {opts} {packages}
deps =
-r{toxinidir}/requirements.txt
commands =
python integration_tests/clean.py
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