Remove usage of glanceclient
... because Glance was already removed from Undercloud. This also removes the module and the playbook which require glanceclient because these are useless. Note that the playbook removed by this change is not actually used by tripleoclient. Change-Id: I7b482e5a03878baf42ef2c2c72bbdb0637cb204d
This commit is contained in:
parent
a322b62217
commit
2c7ad26454
@ -14,7 +14,6 @@ mock_roles:
|
||||
- ceph-facts
|
||||
mock_modules:
|
||||
- baremetal_nodes_validate
|
||||
- baremetal_register_or_update_nodes
|
||||
- ceph_crush_rule
|
||||
- ceph_dashboard_user
|
||||
- ceph_key
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The ``baremetal_register_or_update_nodes`` module has been removed,
|
||||
because it is useless since Glance was removed from Undercloud.
|
@ -1,6 +1,5 @@
|
||||
pbr>=1.6
|
||||
tripleo-common>=16.0.0 # Apache-2.0
|
||||
python-glanceclient>=2.8.0 # Apache-2.0
|
||||
python-heatclient # Apache-2.0
|
||||
python-ironicclient!=2.5.2,!=2.7.1,!=3.0.0,>=2.3.0,<4.0.0;python_version=='2.7' # Apache-2.0
|
||||
python-ironicclient!=2.5.2,!=2.7.1,!=3.0.0,>=2.3.0;python_version>='3.6' # Apache-2.0
|
||||
|
@ -21,7 +21,6 @@
|
||||
# should revise this.
|
||||
import os
|
||||
|
||||
from glanceclient import client as glanceclient
|
||||
from heatclient.v1 import client as heatclient
|
||||
from ironicclient import client as ironicclient
|
||||
from novaclient import client as novaclient
|
||||
@ -128,28 +127,6 @@ class TripleOCommon(object):
|
||||
)
|
||||
return self.client_cache['ironicclient']
|
||||
|
||||
def get_image_client(self):
|
||||
"""Return the image (glance) client.
|
||||
|
||||
This method will return a client object using the legacy library. Upon
|
||||
the creation of a successful client creation, the client object will
|
||||
be stored in the `self.client_cache object`, should this method be
|
||||
called more than once, the cached object will automatically return,
|
||||
resulting in fewer authentications and faster API interactions.
|
||||
|
||||
:returns: Object
|
||||
"""
|
||||
|
||||
if 'glanceclient' in self.client_cache:
|
||||
return self.client_cache['glanceclient']
|
||||
else:
|
||||
self.client_cache['glanceclient'] = \
|
||||
glanceclient.Client(
|
||||
2,
|
||||
session=self.sess
|
||||
)
|
||||
return self.client_cache['glanceclient']
|
||||
|
||||
def return_introspected_node_data(self, node_id):
|
||||
"""Return baremetal data from the ironic inspector.
|
||||
|
||||
|
@ -1,134 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2018 OpenStack Foundation
|
||||
# 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.
|
||||
|
||||
import yaml
|
||||
|
||||
from ansible.module_utils import tripleo_common_utils as tc
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_full_argument_spec
|
||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_module_kwargs
|
||||
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import openstack_cloud_from_module
|
||||
|
||||
from tripleo_common.utils import nodes
|
||||
|
||||
ANSIBLE_METADATA = {
|
||||
'metadata_version': '1.1',
|
||||
'status': ['preview'],
|
||||
'supported_by': 'community'
|
||||
}
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: baremetal_register_or_update_nodes
|
||||
|
||||
short_description: Register, update or remove baremetal nodes
|
||||
|
||||
version_added: "2.8"
|
||||
|
||||
description:
|
||||
- "It registers, updates or removes baremetal nodes of Ironic"
|
||||
|
||||
options:
|
||||
nodes_json:
|
||||
description:
|
||||
- Description of the nodes to be added, removed, changed
|
||||
type: list
|
||||
required: true
|
||||
remove:
|
||||
required: false
|
||||
type: bool
|
||||
kernel_name:
|
||||
required: false
|
||||
ramdisk_name:
|
||||
required: false
|
||||
instance_boot_option:
|
||||
required: false
|
||||
|
||||
author:
|
||||
- Adriano Petrich (@frac)
|
||||
requirements: ["openstacksdk", "tripleo-common"]
|
||||
'''
|
||||
|
||||
|
||||
def run_module():
|
||||
result = dict(
|
||||
success=False,
|
||||
error="",
|
||||
nodes=[]
|
||||
)
|
||||
|
||||
argument_spec = openstack_full_argument_spec(
|
||||
**yaml.safe_load(DOCUMENTATION)['options']
|
||||
)
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec,
|
||||
supports_check_mode=True,
|
||||
**openstack_module_kwargs()
|
||||
)
|
||||
|
||||
_, conn = openstack_cloud_from_module(module)
|
||||
tripleo = tc.TripleOCommon(session=conn.session)
|
||||
|
||||
# if the user is working with this module in only check mode we do not
|
||||
# want to make any changes to the environment, just return the current
|
||||
# state with no modifications
|
||||
if module.check_mode:
|
||||
module.exit_json(**result)
|
||||
|
||||
nodes_json = module.params['nodes_json']
|
||||
|
||||
for node in nodes_json:
|
||||
caps = node.get('capabilities', {})
|
||||
caps = nodes.capabilities_to_dict(caps)
|
||||
if module.params['instance_boot_option'] is not None:
|
||||
caps.setdefault('boot_option',
|
||||
module.params['instance_boot_option'])
|
||||
node['capabilities'] = nodes.dict_to_capabilities(caps)
|
||||
|
||||
baremetal_client = tripleo.get_baremetal_client()
|
||||
image_client = tripleo.get_image_client()
|
||||
|
||||
try:
|
||||
registered_nodes = nodes.register_all_nodes(
|
||||
nodes_json,
|
||||
client=baremetal_client,
|
||||
remove=module.params['remove'],
|
||||
glance_client=image_client,
|
||||
kernel_name=module.params['kernel_name'],
|
||||
ramdisk_name=module.params['ramdisk_name'])
|
||||
result['success'] = True
|
||||
result['nodes'] = [
|
||||
dict(uuid=node.uuid, provision_state=node.provision_state)
|
||||
for node in registered_nodes
|
||||
]
|
||||
except Exception as exc:
|
||||
# LOG.exception("Error registering nodes with ironic.")
|
||||
result['error'] = str(exc)
|
||||
module.fail_json(msg='Validation Failed', **result)
|
||||
|
||||
# in the event of a successful module execution, you will want to
|
||||
# simple AnsibleModule.exit_json(), passing the key/value results
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
def main():
|
||||
run_module()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,98 +0,0 @@
|
||||
---
|
||||
# Copyright 2019 Red Hat, Inc.
|
||||
#
|
||||
# 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.
|
||||
|
||||
- name: TripleO register or update nodes
|
||||
connection: "{{ (tripleo_target_host is defined) | ternary('ssh', 'local') }}"
|
||||
hosts: "{{ tripleo_target_host | default('localhost') }}"
|
||||
remote_user: "{{ tripleo_target_user | default(lookup('env', 'USER')) }}"
|
||||
gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}"
|
||||
any_errors_fatal: true
|
||||
vars:
|
||||
nodes_json: []
|
||||
remove: false
|
||||
kernel_name: null
|
||||
ramdisk_name: null
|
||||
instance_boot_option: null
|
||||
initial_state: 'manageable'
|
||||
tasks:
|
||||
- name: "Check if temp_file is set"
|
||||
fail:
|
||||
msg: the option temp_file is undefined
|
||||
when:
|
||||
- temp_file is undefined
|
||||
|
||||
- name: Validate nodes
|
||||
baremetal_nodes_validate:
|
||||
nodes_list: "{{ nodes_json }}"
|
||||
register: result
|
||||
|
||||
- name: Register or Update nodes
|
||||
baremetal_register_or_update_nodes:
|
||||
nodes_json: "{{ nodes_json }}"
|
||||
remove: "{{ remove }}"
|
||||
kernel_name: "{{ kernel_name }}"
|
||||
ramdisk_name: "{{ ramdisk_name }}"
|
||||
instance_boot_option: "{{ instance_boot_option }}"
|
||||
register: registered_nodes
|
||||
|
||||
- name: "Registered nodes during enroll"
|
||||
debug:
|
||||
msg: "{{ registered_nodes }}"
|
||||
|
||||
- name: "Save registered nodes"
|
||||
copy:
|
||||
content: "{{ registered_nodes.nodes | to_json }}"
|
||||
dest: "{{ temp_file }}"
|
||||
|
||||
- name: Register nodes failed
|
||||
fail:
|
||||
msg: "{{ registered_nodes.error }}"
|
||||
when: result.failed
|
||||
|
||||
- name: "Exit early if initial state for enroll only"
|
||||
block:
|
||||
- name: "Registered nodes during enroll"
|
||||
debug:
|
||||
msg: "{{ registered_nodes }}"
|
||||
|
||||
- meta: end_play
|
||||
when:
|
||||
- initial_state == "enroll"
|
||||
|
||||
- name: "Set new nodes fact"
|
||||
set_fact:
|
||||
new_nodes: "{{ registered_nodes.nodes | selectattr('provision_state', 'eq', 'enroll') | list }}"
|
||||
|
||||
- name: Make nodes available
|
||||
command: >-
|
||||
openstack --os-cloud undercloud baremetal node manage {{ item.uuid }} --wait 1200
|
||||
loop: "{{ new_nodes }}"
|
||||
async: 2400
|
||||
poll: 0
|
||||
register: node_manageable
|
||||
|
||||
- name: poll for completion
|
||||
async_status:
|
||||
jid: "{{ item.ansible_job_id }}"
|
||||
loop: "{{ node_manageable.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.item }}"
|
||||
register: wait
|
||||
until: wait.finished
|
||||
retries: 120
|
||||
|
||||
- name: "Registered nodes during enroll"
|
||||
debug:
|
||||
msg: "{{ new_nodes | length }} node(s) successfully moved to the 'manageable' state."
|
Loading…
Reference in New Issue
Block a user