����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# coding: utf-8 -*-
# (c) 2014, Hewlett-Packard Development Company, L.P.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
DOCUMENTATION = '''
---
module: baremetal_node
short_description: Create/Delete Bare Metal Resources from OpenStack
author: OpenStack Ansible SIG
description:
- Create or Remove Ironic nodes from OpenStack.
options:
state:
description:
- Indicates desired state of the resource
choices: ['present', 'absent']
default: present
type: str
uuid:
description:
- globally unique identifier (UUID) to be given to the resource. Will
be auto-generated if not specified, and name is specified.
- Definition of a UUID will always take precedence to a name value.
type: str
name:
description:
- unique name identifier to be given to the resource.
type: str
driver:
description:
- The name of the Ironic Driver to use with this node.
- Required when I(state=present)
type: str
chassis_uuid:
description:
- Associate the node with a pre-defined chassis.
type: str
ironic_url:
description:
- If noauth mode is utilized, this is required to be set to the
endpoint URL for the Ironic API. Use with "auth" and "auth_type"
settings set to None.
type: str
resource_class:
description:
- The specific resource type to which this node belongs.
type: str
bios_interface:
description:
- The bios interface for this node, e.g. "no-bios".
type: str
boot_interface:
description:
- The boot interface for this node, e.g. "pxe".
type: str
console_interface:
description:
- The console interface for this node, e.g. "no-console".
type: str
deploy_interface:
description:
- The deploy interface for this node, e.g. "iscsi".
type: str
inspect_interface:
description:
- The interface used for node inspection, e.g. "no-inspect".
type: str
management_interface:
description:
- The interface for out-of-band management of this node, e.g.
"ipmitool".
type: str
network_interface:
description:
- The network interface provider to use when describing
connections for this node.
type: str
power_interface:
description:
- The interface used to manage power actions on this node, e.g.
"ipmitool".
type: str
raid_interface:
description:
- Interface used for configuring raid on this node.
type: str
rescue_interface:
description:
- Interface used for node rescue, e.g. "no-rescue".
type: str
storage_interface:
description:
- Interface used for attaching and detaching volumes on this node, e.g.
"cinder".
type: str
vendor_interface:
description:
- Interface for all vendor-specific actions on this node, e.g.
"no-vendor".
type: str
driver_info:
description:
- Information for this server's driver. Will vary based on which
driver is in use. Any sub-field which is populated will be validated
during creation. For compatibility reasons sub-fields `power`,
`deploy`, `management` and `console` are flattened.
required: true
type: dict
nics:
description:
- 'A list of network interface cards, eg, " - mac: aa:bb:cc:aa:bb:cc"'
required: true
type: list
elements: dict
suboptions:
mac:
description: The MAC address of the network interface card.
type: str
required: true
properties:
description:
- Definition of the physical characteristics of this server, used for scheduling purposes
type: dict
suboptions:
cpu_arch:
description:
- CPU architecture (x86_64, i686, ...)
default: x86_64
cpus:
description:
- Number of CPU cores this machine has
default: 1
ram:
description:
- amount of RAM this machine has, in MB
default: 1
disk_size:
description:
- size of first storage device in this machine (typically /dev/sda), in GB
default: 1
capabilities:
description:
- special capabilities for the node, such as boot_option, node_role etc
(see U(https://docs.openstack.org/ironic/latest/install/advanced.html)
for more information)
default: ""
root_device:
description:
- Root disk device hints for deployment.
- See U(https://docs.openstack.org/ironic/latest/install/advanced.html#specifying-the-disk-for-deployment-root-device-hints)
for allowed hints.
default: ""
skip_update_of_masked_password:
description:
- Allows the code that would assert changes to nodes to skip the
update if the change is a single line consisting of the password
field.
- As of Kilo, by default, passwords are always masked to API
requests, which means the logic as a result always attempts to
re-assert the password field.
- C(skip_update_of_driver_password) is deprecated alias and will be removed in openstack.cloud 2.0.0.
type: bool
aliases:
- skip_update_of_driver_password
requirements:
- "python >= 3.6"
- "openstacksdk"
- "jsonpatch"
extends_documentation_fragment:
- openstack.cloud.openstack
'''
EXAMPLES = '''
# Enroll a node with some basic properties and driver info
- openstack.cloud.baremetal_node:
cloud: "devstack"
driver: "pxe_ipmitool"
uuid: "00000000-0000-0000-0000-000000000002"
properties:
cpus: 2
cpu_arch: "x86_64"
ram: 8192
disk_size: 64
capabilities: "boot_option:local"
root_device:
wwn: "0x4000cca77fc4dba1"
nics:
- mac: "aa:bb:cc:aa:bb:cc"
- mac: "dd:ee:ff:dd:ee:ff"
driver_info:
ipmi_address: "1.2.3.4"
ipmi_username: "admin"
ipmi_password: "adminpass"
chassis_uuid: "00000000-0000-0000-0000-000000000001"
'''
try:
import jsonpatch
HAS_JSONPATCH = True
except ImportError:
HAS_JSONPATCH = False
from ansible_collections.openstack.cloud.plugins.module_utils.ironic import (
IronicModule,
ironic_argument_spec,
)
from ansible_collections.openstack.cloud.plugins.module_utils.openstack import (
openstack_module_kwargs,
openstack_cloud_from_module
)
_PROPERTIES = {
'cpu_arch': 'cpu_arch',
'cpus': 'cpus',
'ram': 'memory_mb',
'disk_size': 'local_gb',
'capabilities': 'capabilities',
'root_device': 'root_device',
}
def _parse_properties(module):
"""Convert ansible properties into native ironic values.
Also filter out any properties that are not set.
"""
p = module.params['properties']
return {to_key: p[from_key] for (from_key, to_key) in _PROPERTIES.items()
if p.get(from_key) is not None}
def _parse_driver_info(sdk, module):
info = module.params['driver_info'].copy()
for deprecated in ('power', 'console', 'management', 'deploy'):
if deprecated in info:
info.update(info.pop(deprecated))
module.deprecate("Suboption %s of the driver_info parameter of "
"'openstack.cloud.baremetal_node' is deprecated"
% deprecated, version='2.0.0',
collection_name='openstack.cloud')
return info
def _choose_id_value(module):
if module.params['uuid']:
return module.params['uuid']
if module.params['name']:
return module.params['name']
return None
def _choose_if_password_only(module, patch):
if len(patch) == 1:
if 'password' in patch[0]['path'] and module.params['skip_update_of_masked_password']:
# Return false to abort update as the password appears
# to be the only element in the patch.
return False
return True
def _exit_node_not_updated(module, server):
module.exit_json(
changed=False,
result="Node not updated",
uuid=server['uuid'],
provision_state=server['provision_state']
)
def main():
argument_spec = ironic_argument_spec(
uuid=dict(required=False),
name=dict(required=False),
driver=dict(required=False),
resource_class=dict(required=False),
bios_interface=dict(required=False),
boot_interface=dict(required=False),
console_interface=dict(required=False),
deploy_interface=dict(required=False),
inspect_interface=dict(required=False),
management_interface=dict(required=False),
network_interface=dict(required=False),
power_interface=dict(required=False),
raid_interface=dict(required=False),
rescue_interface=dict(required=False),
storage_interface=dict(required=False),
vendor_interface=dict(required=False),
driver_info=dict(type='dict', required=True),
nics=dict(type='list', required=True, elements="dict"),
properties=dict(type='dict', default={}),
chassis_uuid=dict(required=False),
skip_update_of_masked_password=dict(
required=False,
type='bool',
aliases=['skip_update_of_driver_password'],
deprecated_aliases=[dict(
name='skip_update_of_driver_password',
version='2.0.0',
collection_name='openstack.cloud')]
),
state=dict(required=False, default='present', choices=['present', 'absent'])
)
module_kwargs = openstack_module_kwargs()
module = IronicModule(argument_spec, **module_kwargs)
if not HAS_JSONPATCH:
module.fail_json(msg='jsonpatch is required for this module')
node_id = _choose_id_value(module)
sdk, cloud = openstack_cloud_from_module(module)
try:
server = cloud.get_machine(node_id)
if module.params['state'] == 'present':
if module.params['driver'] is None:
module.fail_json(msg="A driver must be defined in order "
"to set a node to present.")
properties = _parse_properties(module)
driver_info = _parse_driver_info(sdk, module)
kwargs = dict(
driver=module.params['driver'],
properties=properties,
driver_info=driver_info,
name=module.params['name'],
)
optional_field_names = ('resource_class',
'bios_interface',
'boot_interface',
'console_interface',
'deploy_interface',
'inspect_interface',
'management_interface',
'network_interface',
'power_interface',
'raid_interface',
'rescue_interface',
'storage_interface',
'vendor_interface')
for i in optional_field_names:
if module.params[i]:
kwargs[i] = module.params[i]
if module.params['chassis_uuid']:
kwargs['chassis_uuid'] = module.params['chassis_uuid']
if server is None:
# Note(TheJulia): Add a specific UUID to the request if
# present in order to be able to re-use kwargs for if
# the node already exists logic, since uuid cannot be
# updated.
if module.params['uuid']:
kwargs['uuid'] = module.params['uuid']
server = cloud.register_machine(module.params['nics'],
**kwargs)
module.exit_json(changed=True, uuid=server['uuid'],
provision_state=server['provision_state'])
else:
# TODO(TheJulia): Presently this does not support updating
# nics. Support needs to be added.
#
# Note(TheJulia): This message should never get logged
# however we cannot realistically proceed if neither a
# name or uuid was supplied to begin with.
if not node_id:
module.fail_json(msg="A uuid or name value "
"must be defined")
# Note(TheJulia): Constructing the configuration to compare
# against. The items listed in the server_config block can
# be updated via the API.
server_config = dict(
driver=server['driver'],
properties=server['properties'],
driver_info=server['driver_info'],
name=server['name'],
)
# Add the pre-existing chassis_uuid only if
# it is present in the server configuration.
if hasattr(server, 'chassis_uuid'):
server_config['chassis_uuid'] = server['chassis_uuid']
# Note(TheJulia): If a password is defined and concealed, a
# patch will always be generated and re-asserted.
patch = jsonpatch.JsonPatch.from_diff(server_config, kwargs)
if not patch:
_exit_node_not_updated(module, server)
elif _choose_if_password_only(module, list(patch)):
# Note(TheJulia): Normally we would allow the general
# exception catch below, however this allows a specific
# message.
try:
server = cloud.patch_machine(
server['uuid'],
list(patch))
except Exception as e:
module.fail_json(msg="Failed to update node, "
"Error: %s" % e.message)
# Enumerate out a list of changed paths.
change_list = []
for change in list(patch):
change_list.append(change['path'])
module.exit_json(changed=True,
result="Node Updated",
changes=change_list,
uuid=server['uuid'],
provision_state=server['provision_state'])
# Return not updated by default as the conditions were not met
# to update.
_exit_node_not_updated(module, server)
if module.params['state'] == 'absent':
if not node_id:
module.fail_json(msg="A uuid or name value must be defined "
"in order to remove a node.")
if server is not None:
cloud.unregister_machine(module.params['nics'],
server['uuid'])
module.exit_json(changed=True, result="deleted")
else:
module.exit_json(changed=False, result="Server not found")
except sdk.exceptions.OpenStackCloudException as e:
module.fail_json(msg=str(e))
if __name__ == "__main__":
main()
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| __init__.py | File | 0 B | 0644 |
|
| address_scope.py | File | 5.98 KB | 0644 |
|
| auth.py | File | 1.33 KB | 0644 |
|
| baremetal_inspect.py | File | 4.19 KB | 0644 |
|
| baremetal_node.py | File | 15.53 KB | 0644 |
|
| baremetal_node_action.py | File | 12.65 KB | 0644 |
|
| baremetal_node_info.py | File | 21.74 KB | 0644 |
|
| baremetal_port.py | File | 11.64 KB | 0644 |
|
| baremetal_port_info.py | File | 6.83 KB | 0644 |
|
| catalog_service.py | File | 5.12 KB | 0644 |
|
| coe_cluster.py | File | 8.7 KB | 0644 |
|
| coe_cluster_template.py | File | 12.24 KB | 0644 |
|
| compute_flavor.py | File | 7.71 KB | 0644 |
|
| compute_flavor_info.py | File | 7.79 KB | 0644 |
|
| compute_service_info.py | File | 3.56 KB | 0644 |
|
| config.py | File | 1.97 KB | 0644 |
|
| container.py | File | 5.92 KB | 0644 |
|
| dns_zone.py | File | 6.98 KB | 0644 |
|
| dns_zone_info.py | File | 5.16 KB | 0644 |
|
| endpoint.py | File | 6.34 KB | 0644 |
|
| federation_idp.py | File | 6.31 KB | 0644 |
|
| federation_idp_info.py | File | 2.21 KB | 0644 |
|
| federation_mapping.py | File | 5.18 KB | 0644 |
|
| federation_mapping_info.py | File | 2.15 KB | 0644 |
|
| floating_ip.py | File | 12.14 KB | 0644 |
|
| floating_ip_info.py | File | 6.12 KB | 0644 |
|
| group_assignment.py | File | 2.29 KB | 0644 |
|
| host_aggregate.py | File | 7.21 KB | 0644 |
|
| identity_domain.py | File | 4.71 KB | 0644 |
|
| identity_domain_info.py | File | 3.13 KB | 0644 |
|
| identity_group.py | File | 4.18 KB | 0644 |
|
| identity_group_info.py | File | 4.1 KB | 0644 |
|
| identity_role.py | File | 2.66 KB | 0644 |
|
| identity_role_info.py | File | 2.23 KB | 0644 |
|
| identity_user.py | File | 7.86 KB | 0644 |
|
| identity_user_info.py | File | 4.27 KB | 0644 |
|
| image.py | File | 8.77 KB | 0644 |
|
| image_info.py | File | 5.72 KB | 0644 |
|
| keypair.py | File | 4.44 KB | 0644 |
|
| keypair_info.py | File | 3.8 KB | 0644 |
|
| keystone_federation_protocol.py | File | 5.1 KB | 0644 |
|
| keystone_federation_protocol_info.py | File | 2.57 KB | 0644 |
|
| lb_health_monitor.py | File | 11.11 KB | 0644 |
|
| lb_listener.py | File | 8.93 KB | 0644 |
|
| lb_member.py | File | 6.71 KB | 0644 |
|
| lb_pool.py | File | 8.1 KB | 0644 |
|
| loadbalancer.py | File | 24.92 KB | 0644 |
|
| network.py | File | 8.03 KB | 0644 |
|
| networks_info.py | File | 4 KB | 0644 |
|
| neutron_rbac_policies_info.py | File | 8.27 KB | 0644 |
|
| neutron_rbac_policy.py | File | 10.53 KB | 0644 |
|
| object.py | File | 3.4 KB | 0644 |
|
| object_container.py | File | 5.92 KB | 0644 |
|
| os_auth.py | File | 1.33 KB | 0644 |
|
| os_client_config.py | File | 1.97 KB | 0644 |
|
| os_coe_cluster.py | File | 8.7 KB | 0644 |
|
| os_coe_cluster_template.py | File | 12.24 KB | 0644 |
|
| os_flavor_info.py | File | 7.79 KB | 0644 |
|
| os_floating_ip.py | File | 12.14 KB | 0644 |
|
| os_group.py | File | 4.18 KB | 0644 |
|
| os_group_info.py | File | 4.1 KB | 0644 |
|
| os_image.py | File | 8.77 KB | 0644 |
|
| os_image_info.py | File | 5.72 KB | 0644 |
|
| os_ironic.py | File | 15.53 KB | 0644 |
|
| os_ironic_inspect.py | File | 4.19 KB | 0644 |
|
| os_ironic_node.py | File | 12.65 KB | 0644 |
|
| os_keypair.py | File | 4.44 KB | 0644 |
|
| os_keystone_domain.py | File | 4.71 KB | 0644 |
|
| os_keystone_domain_info.py | File | 3.13 KB | 0644 |
|
| os_keystone_endpoint.py | File | 6.34 KB | 0644 |
|
| os_keystone_federation_protocol.py | File | 5.1 KB | 0644 |
|
| os_keystone_federation_protocol_info.py | File | 2.57 KB | 0644 |
|
| os_keystone_identity_provider.py | File | 6.31 KB | 0644 |
|
| os_keystone_identity_provider_info.py | File | 2.21 KB | 0644 |
|
| os_keystone_mapping.py | File | 5.18 KB | 0644 |
|
| os_keystone_mapping_info.py | File | 2.15 KB | 0644 |
|
| os_keystone_role.py | File | 2.66 KB | 0644 |
|
| os_keystone_service.py | File | 5.12 KB | 0644 |
|
| os_listener.py | File | 8.93 KB | 0644 |
|
| os_loadbalancer.py | File | 24.92 KB | 0644 |
|
| os_member.py | File | 6.71 KB | 0644 |
|
| os_network.py | File | 8.03 KB | 0644 |
|
| os_networks_info.py | File | 4 KB | 0644 |
|
| os_nova_flavor.py | File | 7.71 KB | 0644 |
|
| os_nova_host_aggregate.py | File | 7.21 KB | 0644 |
|
| os_object.py | File | 3.4 KB | 0644 |
|
| os_pool.py | File | 8.1 KB | 0644 |
|
| os_port.py | File | 16.46 KB | 0644 |
|
| os_port_info.py | File | 6.78 KB | 0644 |
|
| os_project.py | File | 6.33 KB | 0644 |
|
| os_project_access.py | File | 6.08 KB | 0644 |
|
| os_project_info.py | File | 4.51 KB | 0644 |
|
| os_quota.py | File | 15.99 KB | 0644 |
|
| os_recordset.py | File | 7.73 KB | 0644 |
|
| os_router.py | File | 21.82 KB | 0644 |
|
| os_routers_info.py | File | 5.55 KB | 0644 |
|
| os_security_group.py | File | 4.25 KB | 0644 |
|
| os_security_group_rule.py | File | 12.07 KB | 0644 |
|
| os_server.py | File | 26.5 KB | 0644 |
|
| os_server_action.py | File | 8.84 KB | 0644 |
|
| os_server_group.py | File | 4.12 KB | 0644 |
|
| os_server_info.py | File | 2.66 KB | 0644 |
|
| os_server_metadata.py | File | 4.84 KB | 0644 |
|
| os_server_volume.py | File | 3.67 KB | 0644 |
|
| os_stack.py | File | 7.76 KB | 0644 |
|
| os_subnet.py | File | 12.55 KB | 0644 |
|
| os_subnets_info.py | File | 4.51 KB | 0644 |
|
| os_user.py | File | 7.86 KB | 0644 |
|
| os_user_group.py | File | 2.29 KB | 0644 |
|
| os_user_info.py | File | 4.27 KB | 0644 |
|
| os_user_role.py | File | 5.65 KB | 0644 |
|
| os_volume.py | File | 7.8 KB | 0644 |
|
| os_volume_snapshot.py | File | 4.86 KB | 0644 |
|
| os_zone.py | File | 6.98 KB | 0644 |
|
| port.py | File | 16.46 KB | 0644 |
|
| port_info.py | File | 6.78 KB | 0644 |
|
| project.py | File | 6.33 KB | 0644 |
|
| project_access.py | File | 6.08 KB | 0644 |
|
| project_info.py | File | 4.51 KB | 0644 |
|
| quota.py | File | 15.99 KB | 0644 |
|
| recordset.py | File | 7.73 KB | 0644 |
|
| role_assignment.py | File | 5.65 KB | 0644 |
|
| router.py | File | 21.82 KB | 0644 |
|
| routers_info.py | File | 5.55 KB | 0644 |
|
| security_group.py | File | 4.25 KB | 0644 |
|
| security_group_info.py | File | 5.8 KB | 0644 |
|
| security_group_rule.py | File | 12.07 KB | 0644 |
|
| security_group_rule_info.py | File | 7.71 KB | 0644 |
|
| server.py | File | 26.5 KB | 0644 |
|
| server_action.py | File | 8.84 KB | 0644 |
|
| server_group.py | File | 4.12 KB | 0644 |
|
| server_info.py | File | 2.66 KB | 0644 |
|
| server_metadata.py | File | 4.84 KB | 0644 |
|
| server_volume.py | File | 3.67 KB | 0644 |
|
| stack.py | File | 7.76 KB | 0644 |
|
| stack_info.py | File | 2.44 KB | 0644 |
|
| subnet.py | File | 12.55 KB | 0644 |
|
| subnet_pool.py | File | 10.99 KB | 0644 |
|
| subnets_info.py | File | 4.51 KB | 0644 |
|
| volume.py | File | 7.8 KB | 0644 |
|
| volume_backup.py | File | 6.26 KB | 0644 |
|
| volume_backup_info.py | File | 2.9 KB | 0644 |
|
| volume_info.py | File | 3.65 KB | 0644 |
|
| volume_snapshot.py | File | 4.86 KB | 0644 |
|
| volume_snapshot_info.py | File | 3.43 KB | 0644 |
|