�
�Udac @` s d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
Z
d Z y d d l
m Z e Z Wn# e k
r� e
j � Z e Z n Xd d
l m Z d d l Z d d l m Z m Z d d l m Z m Z d d � Z d � Z e d k re � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bysi
---
module: ucs_managed_objects
short_description: Configures Managed Objects on Cisco UCS Manager
description:
- Configures Managed Objects on Cisco UCS Manager.
- The Python SDK module, Python class within the module (UCSM Class), and all properties must be directly specified.
- More information on the UCSM Python SDK and how to directly configure Managed Objects is available at L(UCSM Python SDK,http://ucsmsdk.readthedocs.io/).
- Examples can be used with the UCS Platform Emulator U(https://communities.cisco.com/ucspe).
extends_documentation_fragment: ucs
options:
state:
description:
- If C(present), will verify that the Managed Objects are present and will create if needed.
- If C(absent), will verify that the Managed Objects are absent and will delete if needed.
choices: [ absent, present ]
default: present
objects:
description:
- List of managed objects to configure. Each managed object has suboptions the specify the Python SDK module, class, and properties to configure.
suboptions:
module:
description:
- Name of the Python SDK module implementing the required class.
required: yes
class_name:
description:
- Name of the Python class that will be used to configure the Managed Object.
required: yes
properties:
description:
- List of properties to configure on the Managed Object. See the UCSM Python SDK for information on properties for each class.
required: yes
children:
description:
- Optional list of child objects. Each child has its own module, class, and properties suboptions.
- The parent_mo_or_dn property for child objects is automatically set as the list of children is configured.
required: yes
requirements:
- ucsmsdk
author:
- David Soper (@dsoper2)
- CiscoUcs (@CiscoUcs)
version_added: '2.8'
s�
- name: Configure Network Control Policy
ucs_managed_objects:
hostname: 172.16.143.150
username: admin
password: password
objects:
- module: ucsmsdk.mometa.nwctrl.NwctrlDefinition
class: NwctrlDefinition
properties:
parent_mo_or_dn: org-root
cdp: enabled
descr: ''
lldp_receive: enabled
lldp_transmit: enabled
name: Enable-CDP-LLDP
- name: Remove Network Control Policy
ucs_managed_objects:
hostname: 172.16.143.150
username: admin
password: password
objects:
- module: ucsmsdk.mometa.nwctrl.NwctrlDefinition
class: NwctrlDefinition
properties:
parent_mo_or_dn: org-root
name: Enable-CDP-LLDP
state: absent
- name: Configure Boot Policy Using JSON objects list with children
ucs_managed_objects:
hostname: 172.16.143.150
username: admin
password: password
objects:
- {
"module": "ucsmsdk.mometa.lsboot.LsbootPolicy",
"class": "LsbootPolicy",
"properties": {
"parent_mo_or_dn": "org-root",
"name": "Python_SDS",
"enforce_vnic_name": "yes",
"boot_mode": "legacy",
"reboot_on_update": "no"
},
"children": [
{
"module": "ucsmsdk.mometa.lsboot.LsbootVirtualMedia",
"class": "LsbootVirtualMedia",
"properties": {
"access": "read-only-local",
"lun_id": "0",
"order": "2"
}
},
{
"module": "ucsmsdk.mometa.lsboot.LsbootStorage",
"class": "LsbootStorage",
"properties": {
"order": "1"
},
"children": [
{
"module": "ucsmsdk.mometa.lsboot.LsbootLocalStorage",
"class": "LsbootLocalStorage",
"properties": {},
"children": [
{
"module": "ucsmsdk.mometa.lsboot.LsbootDefaultLocalImage",
"class": "LsbootDefaultLocalImage",
"properties": {
"order": "1"
}
}
]
}
]
}
]
}
- name: Remove Boot Policy Using JSON objects list
ucs_managed_objects:
hostname: 172.16.143.150
username: admin
password: password
objects:
- {
"module": "ucsmsdk.mometa.lsboot.LsbootPolicy",
"class": "LsbootPolicy",
"properties": {
"parent_mo_or_dn": "org-root",
"name": "Python_SDS"
}
}
state: absent
s
#
N( t
import_module( t deepcopy( t
AnsibleModulet missing_required_lib( t UCSModulet ucs_argument_spect c C` s� t } t | d � } t | | d � } | d j d � sM | | d d <n | | d � } | j j | j � } | j d d k r� | r�| j s� | j j | � | j j
� n t | j d <q�n� | r(t
| d � } | j d d � | j d d � | j d d � | j | � r(t } q(n | s�| j s�y'