def createServiceProfileTemplate(handle, org): print "Creating Kubernetes Service Profile Template" from ucsmsdk.mometa.ls.LsServer import LsServer from ucsmsdk.mometa.vnic.VnicConnDef import VnicConnDef from ucsmsdk.mometa.ls.LsRequirement import LsRequirement from ucsmsdk.mometa.lstorage.LstorageProfileBinding import LstorageProfileBinding mo = LsServer(parent_mo_or_dn=org, policy_owner="local", name="Kubernetes", descr="Kubernetes Service Profile", type="updating-template", # Boot using Kubernetes Boot policy: local Disk, then Remote DVD boot_policy_name="kube", # Default Maintenance Policy maint_policy_name="default", # scrub policy scrub_policy_name="kube", # Bios Policy bios_profile_name="kube", # UUID Pool ident_pool_name="kube", # disks we use. #local_disk_policy_name="kube", #storage_profile_name="kube", # virtual media policy vmedia_policy_name="kube" ) # create vNIC Connection Policy VnicConnDef(parent_mo_or_dn=mo, lan_conn_policy_name="kube") # create server pool and add to template. LsRequirement(parent_mo_or_dn=mo, name="Kubernetes") # add storage profile. mo_1 = LstorageProfileBinding(parent_mo_or_dn=mo, storage_profile_name="kube") handle.add_mo(mo, True) try: handle.commit() except UcsException as err: if err.error_code == "103": print "\talready exists" else: return 1, err.error_descr except Exception: return 1, "%s" % Exception return 0, ""
def configure_service_profile_template(ucs, module): from ucsmsdk.mometa.ls.LsServer import LsServer from ucsmsdk.mometa.vnic.VnicConnDef import VnicConnDef from ucsmsdk.mometa.vnic.VnicIScsiNode import VnicIScsiNode from ucsmsdk.mometa.ls.LsRequirement import LsRequirement from ucsmsdk.mometa.ls.LsPower import LsPower from ucsmsdk.mometa.lstorage.LstorageProfileBinding import LstorageProfileBinding from ucsmsdk.mometa.mgmt.MgmtInterface import MgmtInterface from ucsmsdk.mometa.mgmt.MgmtVnet import MgmtVnet from ucsmsdk.mometa.vnic.VnicIpV4MgmtPooledAddr import VnicIpV4MgmtPooledAddr if not module.check_mode: try: # create if mo does not already exist mo = LsServer( parent_mo_or_dn=module.params['org_dn'], bios_profile_name=module.params['bios_policy'], boot_policy_name=module.params['boot_policy'], descr=module.params['description'], ext_ip_state='pooled', ext_ip_pool_name=module.params['mgmt_ip_pool'], # graphics_card_policy_name=module.params['graphics_card_policy'], host_fw_policy_name=module.params['host_firmware_package'], ident_pool_name=module.params['uuid_pool'], kvm_mgmt_policy_name=module.params['kvm_mgmt_policy'], local_disk_policy_name=module.params['local_disk_policy'], maint_policy_name=module.params['maintenance_policy'], mgmt_access_policy_name=module.params['ipmi_access_profile'], name=module.params['name'], power_policy_name=module.params['power_control_policy'], power_sync_policy_name=module.params['power_sync_policy'], scrub_policy_name=module.params['scrub_policy'], sol_policy_name=module.params['sol_policy'], stats_policy_name=module.params['threshold_policy'], type=module.params['template_type'], usr_lbl=module.params['user_label'], vmedia_policy_name=module.params['vmedia_policy'], ) if module.params['storage_profile']: # Storage profile mo_1 = LstorageProfileBinding( parent_mo_or_dn=mo, storage_profile_name=module.params['storage_profile'], ) if module.params['mgmt_interface_mode']: # Management Interface mo_1 = MgmtInterface( parent_mo_or_dn=mo, mode=module.params['mgmt_interface_mode'], ip_v4_state='pooled', ) mo_2 = MgmtVnet( parent_mo_or_dn=mo_1, id='1', name=module.params['mgmt_vnet_name'], ) VnicIpV4MgmtPooledAddr( parent_mo_or_dn=mo_2, name=module.params['mgmt_inband_pool_name'], ) # LAN/SAN connectivity policy mo_1 = VnicConnDef( parent_mo_or_dn=mo, lan_conn_policy_name=module.params['lan_connectivity_policy'], san_conn_policy_name=module.params['san_connectivity_policy'], ) if module.params['iqn_pool']: # IQN pool mo_1 = VnicIScsiNode( parent_mo_or_dn=mo, iqn_ident_pool_name=module.params['iqn_pool'] ) # power state admin_state = 'admin-' + module.params['power_state'] mo_1 = LsPower( parent_mo_or_dn=mo, state=admin_state, ) if module.params['server_pool']: # server pool mo_1 = LsRequirement( parent_mo_or_dn=mo, name=module.params['server_pool'], qualifier=module.params['server_pool_qualification'], ) ucs.login_handle.add_mo(mo, True) ucs.login_handle.commit() except Exception as e: # generic Exception handling because SDK can throw a variety of exceptions ucs.result['msg'] = "setup error: %s " % str(e) module.fail_json(**ucs.result) ucs.result['changed'] = True
def sp_template_modify(ucs_handle, name, type=None, resolve_remote=None, descr=None, usr_lbl=None, src_templ_name=None, ext_ip_state="pooled", ext_ip_pool_name=None, ident_pool_name=None, vcon_profile_name=None, agent_policy_name=None, bios_profile_name=None, boot_policy_name=None, dynamic_con_policy_name=None, host_fw_policy_name=None, kvm_mgmt_policy_name=None, local_disk_policy_name=None, maint_policy_name=None, mgmt_access_policy_name=None, mgmt_fw_policy_name=None, power_policy_name=None, scrub_policy_name=None, sol_policy_name=None, stats_policy_name=None, vmedia_policy_name=None,storage_profile_name=None,vnic_name=None, vnic_template_name=None,vnic_order=None,adapter_profile_name=None, server_pool_name=None,parent_dn="org-root"): """ This method Modifies Service profile template. Args: ucs_handle (ucs_handle) name(string): Name of SP template type : "initial-template", "updating-template" resolve_remote : "no", "yes" descr (string): Basic description src_templ_name (string): Name of Source template ext_ip_state= :none", "pooled", "static" ext_ip_pool_name (string): Name of IP Pool ident_pool_name (string): Name of Ident pool agent_policy_name (string): Name of agent policy bios_profile_name (string): Name of bios profile boot_policy_name (string): Name of boot policy dynamic_con_policy_name (string): Name of dynamic connection policy host_fw_policy_name (string): Name of Host firmware. kvm_mgmt_policy_name (string): KVM management policy lan_conn_policy_name (string): LAN connection policy local_disk_policy_name (string): Local disk policy maint_policy_name (string): Maintenance policy mgmt_access_policy_name(string): Access Management policy mgmt_fw_policy_name (string): Firmware management policy power_policy_name (string): Power policy san_conn_policy_name (string): SAN connection policy scrub_policy_name (string): Scrub policy sol_policy_name (string): SOL policy stats_policy_name (string): Statistics Policy vcon_profile_name (string): Virtual Connection profile policy vmedia_policy_name (string): Virtual media policy parent_dn= Parent DN Returns: LsServer: Managed Object Raises: ValueError: If LsServer is not present Example: sp_template_modify(ucs_handle, name="sample_temp", local_disk_policy="sample_local1") """ dn = parent_dn + "/ls-" + name mo = ucs_handle.query_dn(dn) if not mo: raise ValueError("SP '%s' does not exist" % dn) if resolve_remote is not None: mo.resolve_remote = resolve_remote if descr is not None: mo.descr = descr if usr_lbl is not None: mo.usr_lbl = usr_lbl if src_templ_name is not None: mo.src_templ_name = src_templ_name if ext_ip_state is not None: mo.ext_ip_state = ext_ip_state if ext_ip_pool_name is not None: mo.ext_ip_pool_name = ext_ip_pool_name if ident_pool_name is not None: mo.ident_pool_name = ident_pool_name if vcon_profile_name is not None: mo.vcon_profile_name = vcon_profile_name if agent_policy_name is not None: mo.agent_policy_name = agent_policy_name if bios_profile_name is not None: mo.bios_profile_name = bios_profile_name if boot_policy_name is not None: mo.boot_policy_name = boot_policy_name if dynamic_con_policy_name is not None: mo.dynamic_con_policy_name = dynamic_con_policy_name if host_fw_policy_name is not None: mo.host_fw_policy_name = host_fw_policy_name if kvm_mgmt_policy_name is not None: mo.kvm_mgmt_policy_name = kvm_mgmt_policy_name if local_disk_policy_name is not None: mo.local_disk_policy_name = local_disk_policy_name if maint_policy_name is not None: mo.maint_policy_name = maint_policy_name if mgmt_access_policy_name is not None: mo.mgmt_access_policy_name = mgmt_access_policy_name if mgmt_fw_policy_name is not None: mo.mgmt_fw_policy_name = mgmt_fw_policy_name if power_policy_name is not None: mo.power_policy_name = power_policy_name if scrub_policy_name is not None: mo.scrub_policy_name = scrub_policy_name if sol_policy_name is not None: mo.sol_policy_name = sol_policy_name if stats_policy_name is not None: mo.stats_policy_name = stats_policy_name if vmedia_policy_name is not None: mo.vmedia_policy_name = vmedia_policy_name if server_pool_name is not None: mo_1 = LsRequirement(parent_mo_or_dn=mo, name=server_pool_name) if storage_profile_name is not None: mo_1 = LstorageProfileBinding(parent_mo_or_dn=mo, storage_profile_name=storage_profile_name) if(vnic_name <> '' and vnic_template_name <> ''): mo_1 = VnicEther(parent_mo_or_dn=mo, adaptor_profile_name=adapter_profile_name, order=vnic_order, name=vnic_name, nw_templ_name=vnic_template_name) ucs_handle.set_mo(mo) ucs_handle.commit() return mo
def sp_template_create(ucs_handle, name, type, resolve_remote, descr="", usr_lbl="", src_templ_name="", ext_ip_state="pooled", ext_ip_pool_name="", ident_pool_name="", agent_policy_name="", bios_profile_name="", boot_policy_name="", dynamic_con_policy_name="", host_fw_policy_name="", kvm_mgmt_policy_name="", lan_conn_policy_name="", local_disk_policy_name="", maint_policy_name="", mgmt_access_policy_name="", mgmt_fw_policy_name="", power_policy_name="", san_conn_policy_name="", scrub_policy_name="", sol_policy_name="", stats_policy_name="", vcon_profile_name="", vmedia_policy_name="", server_pool_name="", adapter_profile_name="", vnic_template_name="", vnic_name="", vnic_order="", storage_profile_name="", parent_dn="org-root"): """ This method creates Service profile template. Args: ucs_handle (ucs_handle) name(string): Name of SP template type : "initial-template", "updating-template" resolve_remote : "no", "yes" descr (string): Basic description src_templ_name (string): Name of Source template ext_ip_state= :none", "pooled", "static" ext_ip_pool_name (string): Name of IP Pool ident_pool_name (string): Name of Ident pool agent_policy_name (string): Name of agent policy bios_profile_name (string): Name of bios profile boot_policy_name (string): Name of boot policy dynamic_con_policy_name (string): Name of dynamic connection policy host_fw_policy_name (string): Name of Host firmware. kvm_mgmt_policy_name (string): KVM management policy lan_conn_policy_name (string): LAN connection policy local_disk_policy_name (string): Local disk policy maint_policy_name (string): Maintenance policy mgmt_access_policy_name(string): Access Management policy mgmt_fw_policy_name (string): Firmware management policy power_policy_name (string): Power policy san_conn_policy_name (string): SAN connection policy scrub_policy_name (string): Scrub policy sol_policy_name (string): SOL policy stats_policy_name (string): Statistics Policy vcon_profile_name (string): Virtual Connection profile policy vmedia_policy_name (string): Virtual media policy server_pool_name (string): Server Pool parent_dn= Parent DN Returns: Service Profile: Managed Object Raises: ValueError: If OrgOrg is not present Example: sp_template_create(ucs_handle, name="sample_temp", type="initial-template", resolve_remote="yes",local_disk_policy="sample_local") """ from ucsmsdk.mometa.ls.LsServer import LsServer from ucsmsdk.mometa.vnic.VnicConnDef import VnicConnDef from ucsmsdk.mometa.ls.LsRequirement import LsRequirement from ucsmsdk.mometa.lstorage.LstorageProfileBinding import LstorageProfileBinding from ucsmsdk.mometa.vnic.VnicEther import VnicEther from ucsmsdk.mometa.vnic.VnicFcNode import VnicFcNode from ucsmsdk.mometa.vnic.VnicFc import VnicFc from ucsmsdk.mometa.vnic.VnicFcIf import VnicFcIf from ucsmsdk.mometa.fabric.FabricVCon import FabricVCon from ucsmsdk.mometa.ls.LsPower import LsPower obj = ucs_handle.query_dn(parent_dn) if not obj: raise ValueError("org '%s' does not exist." % parent_dn) mo = LsServer(parent_mo_or_dn=obj, name=name, type=type, resolve_remote=resolve_remote, descr=descr, usr_lbl=usr_lbl, src_templ_name=src_templ_name, ext_ip_state=ext_ip_state, ext_ip_pool_name=ext_ip_pool_name, ident_pool_name=ident_pool_name, vcon_profile_name=vcon_profile_name, agent_policy_name=agent_policy_name, bios_profile_name=bios_profile_name, boot_policy_name=boot_policy_name, dynamic_con_policy_name=dynamic_con_policy_name, host_fw_policy_name=host_fw_policy_name, kvm_mgmt_policy_name=kvm_mgmt_policy_name, local_disk_policy_name=local_disk_policy_name, maint_policy_name=maint_policy_name, mgmt_access_policy_name=mgmt_access_policy_name, mgmt_fw_policy_name=mgmt_fw_policy_name, power_policy_name=power_policy_name, scrub_policy_name=scrub_policy_name, sol_policy_name=sol_policy_name, stats_policy_name=stats_policy_name, vmedia_policy_name=vmedia_policy_name ) if(storage_profile_name <> ""): mo_1 = LstorageProfileBinding(parent_mo_or_dn=mo, storage_profile_name=storage_profile_name) if(vnic_name <> "" and vnic_template_name <> ""): mo_1 = VnicEther(parent_mo_or_dn=mo, adaptor_profile_name=adapter_profile_name, order=vnic_order, name=vnic_name, nw_templ_name=vnic_template_name) if(server_pool_name <> ""): mo_1 = LsRequirement(parent_mo_or_dn=mo, name=server_pool_name) # Add vNIC Connection Policy to template VnicConnDef(parent_mo_or_dn=mo, lan_conn_policy_name=lan_conn_policy_name, san_conn_policy_name=san_conn_policy_name) ucs_handle.add_mo(mo, True) ucs_handle.commit() return mo
def setup_spt(server, module): from ucsmsdk.mometa.ls.LsServer import LsServer from ucsmsdk.mometa.ls.LsRequirement import LsRequirement from ucsmsdk.mometa.lstorage.LstorageProfileBinding import LstorageProfileBinding from ucsmsdk.mometa.vnic.VnicEther import VnicEther from ucsmsdk.mometa.vnic.VnicConnDef import VnicConnDef ansible = module.params args_mo = _get_mo_params(ansible) changed = False for spt in args_mo['spt_list']: mo = server.query_dn(args_mo['org_dn'] + '/ls-' + spt['name']) if mo: exists = True else: exists = False if ansible['state'] == 'absent': if exists: changed = True if not module.check_mode: server.remove_mo(mo) server.commit() else: if not exists: changed = True if not module.check_mode: # create if mo does not already exist if not 'vmedia_policy' in spt: spt['vmedia_policy'] = '' if not 'scrub_policy' in spt: spt['scrub_policy'] = '' mo = LsServer(parent_mo_or_dn=args_mo['org_dn'], name=spt['name'], type=spt['template_type'], resolve_remote='yes', descr='', usr_lbl='', src_templ_name='', ext_ip_state='pooled', ext_ip_pool_name='ext-mgmt', ident_pool_name=spt['uuid_pool'], vcon_profile_name='', agent_policy_name='', bios_profile_name=spt['bios_policy'], boot_policy_name=spt['boot_policy'], dynamic_con_policy_name='', host_fw_policy_name=spt['host_fw_package'], kvm_mgmt_policy_name='', local_disk_policy_name='', maint_policy_name='', mgmt_access_policy_name='', mgmt_fw_policy_name='', power_policy_name='', scrub_policy_name=spt['scrub_policy'], sol_policy_name='', stats_policy_name='', vmedia_policy_name=spt['vmedia_policy']) if 'server_pool' in spt: mo_1 = LsRequirement(parent_mo_or_dn=mo, name=spt['server_pool']) if 'storage_profile' in spt: mo_1 = LstorageProfileBinding( parent_mo_or_dn=mo, storage_profile_name=spt['storage_profile']) if 'san_connectivity_policy' in spt: mo_1 = VnicConnDef( parent_mo_or_dn=mo, san_conn_policy_name=spt['san_connectivity_policy'] ) if 'vnic_list' in spt: for vnic in spt['vnic_list']: if (vnic['vnic_name'] <> '' and vnic['vnic_template'] <> ''): mo_1 = VnicEther( parent_mo_or_dn=mo, adaptor_profile_name=vnic[ 'vnic_adapter_policy'], order=vnic['vnic_order'], name=vnic['vnic_name'], nw_templ_name=vnic['vnic_template']) if 'lan_connectivity_policy' in spt: mo_x = VnicConnDef( parent_mo_or_dn=mo, lan_conn_policy_name=spt['lan_connectivity_policy'] ) # create server pool and add to template. server.add_mo(mo, True) server.commit() return changed
def main(): argument_spec = ucs_argument_spec argument_spec.update( org_dn=dict(type='str', default='org-root'), name=dict(type='str', required=True), bios_policy=dict(type='str', default=''), boot_policy=dict(type='str', default='default'), description=dict(type='str', aliases=['descr'], default=''), mgmt_ip_pool=dict(type='str', default='ext-mgmt'), graphics_card_policy=dict(type='str', default=''), host_firmware_package=dict(type='str', default=''), uuid_pool=dict(type='str', default='default'), kvm_mgmt_policy=dict(type='str', default=''), local_disk_policy=dict(type='str', default=''), maintenance_policy=dict(type='str', default=''), ipmi_access_profile=dict(type='str', default=''), power_control_policy=dict(type='str', default='default'), power_sync_policy=dict(type='str', default=''), scrub_policy=dict(type='str', default=''), sol_policy=dict(type='str', default=''), threshold_policy=dict(type='str', default='default'), template_type=dict(type='str', default='initial-template', choices=['initial-template', 'updating-template']), user_label=dict(type='str', default=''), vmedia_policy=dict(type='str', default=''), storage_profile=dict(type='str', default=''), lan_connectivity_policy=dict(type='str', default=''), san_connectivity_policy=dict(type='str', default=''), server_pool=dict(type='str', default=''), server_pool_qualification=dict(type='str', default=''), power_state=dict(type='str', default='up', choices=['up', 'down']), mgmt_interface_mode=dict(type='str', default='', choices=['', 'in-band']), mgmt_vnet_name=dict(type='str', default=''), mgmt_inband_pool_name=dict(type='str', default=''), state=dict(type='str', default='present', choices=['present', 'absent']), ) module = AnsibleModule( argument_spec, supports_check_mode=True, ) ucs = UCSModule(module) err = False # UCSModule creation above verifies ucsmsdk is present and exits on failure. Additional imports are done below. from ucsmsdk.mometa.ls.LsServer import LsServer from ucsmsdk.mometa.vnic.VnicConnDef import VnicConnDef from ucsmsdk.mometa.ls.LsRequirement import LsRequirement from ucsmsdk.mometa.ls.LsPower import LsPower from ucsmsdk.mometa.lstorage.LstorageProfileBinding import LstorageProfileBinding from ucsmsdk.mometa.mgmt.MgmtInterface import MgmtInterface from ucsmsdk.mometa.mgmt.MgmtVnet import MgmtVnet from ucsmsdk.mometa.vnic.VnicIpV4MgmtPooledAddr import VnicIpV4MgmtPooledAddr changed = False try: mo_exists = False props_match = False dn = module.params['org_dn'] + '/ls-' + module.params['name'] mo = ucs.login_handle.query_dn(dn) if mo: mo_exists = True if module.params['state'] == 'absent': # mo must exist but all properties do not have to match if mo_exists: if not module.check_mode: ucs.login_handle.remove_mo(mo) ucs.login_handle.commit() changed = True else: if mo_exists: # check top-level mo props kwargs = dict(bios_profile_name=module.params['bios_policy']) kwargs['boot_policy_name'] = module.params['boot_policy'] kwargs['descr'] = module.params['description'] kwargs['ext_ip_pool_name'] = module.params['mgmt_ip_pool'] # kwargs['graphics_card_policy_name'] = module.params['graphics_card_policy'] kwargs['host_fw_policy_name'] = module.params[ 'host_firmware_package'] kwargs['ident_pool_name'] = module.params['uuid_pool'] kwargs['kvm_mgmt_policy_name'] = module.params[ 'kvm_mgmt_policy'] kwargs['local_disk_policy_name'] = module.params[ 'local_disk_policy'] kwargs['maint_policy_name'] = module.params[ 'maintenance_policy'] kwargs['mgmt_access_policy_name'] = module.params[ 'ipmi_access_profile'] kwargs['power_policy_name'] = module.params[ 'power_control_policy'] kwargs['power_sync_policy_name'] = module.params[ 'power_sync_policy'] kwargs['scrub_policy_name'] = module.params['scrub_policy'] kwargs['sol_policy_name'] = module.params['sol_policy'] kwargs['stats_policy_name'] = module.params['threshold_policy'] kwargs['type'] = module.params['template_type'] kwargs['usr_lbl'] = module.params['user_label'] kwargs['vmedia_policy_name'] = module.params['vmedia_policy'] if mo.check_prop_match(**kwargs): # top-level props match, check next level mo/props # code below should discontinue checks once any mismatch is found # check storage profile 1st child_dn = dn + '/profile-binding' mo_1 = ucs.login_handle.query_dn(child_dn) if mo_1: kwargs = dict(storage_profile_name=module. params['storage_profile']) if mo_1.check_prop_match(**kwargs): props_match = True elif not module.params['storage_profile']: # no stroage profile mo or desired state props_match = True if props_match: props_match = False # LAN/SAN connectivity policies child_dn = dn + '/conn-def' mo_1 = ucs.login_handle.query_dn(child_dn) if mo_1: kwargs = dict(lan_conn_policy_name=module. params['lan_connectivity_policy']) kwargs['san_conn_policy_name'] = module.params[ 'san_connectivity_policy'] if mo_1.check_prop_match(**kwargs): props_match = True elif not module.params[ 'lan_connectivity_policy'] and not module.params[ 'san_connectivity_policy']: # no mo and no desired state props_match = True if props_match: props_match = False # inband management policies child_dn = dn + '/iface-in-band' mo_1 = ucs.login_handle.query_dn(child_dn) if mo_1: kwargs = dict( mode=module.params['mgmt_interface_mode']) if mo_1.check_prop_match(**kwargs): child_dn = child_dn + '/network' mo_2 = ucs.login_handle.query_dn(child_dn) if mo_2: kwargs = dict( name=module.params['mgmt_vnet_name']) if mo_2.check_prop_match(**kwargs): child_dn = child_dn + '/ipv4-pooled-addr' mo_3 = ucs.login_handle.query_dn( child_dn) if mo_3: kwargs = dict( name=module. params['mgmt_inband_pool_name'] ) if mo_3.check_prop_match(**kwargs): props_match = True elif not module.params['mgmt_interface_mode']: # no mo and no desired state props_match = True if props_match: props_match = False # power state child_dn = dn + '/power' mo_1 = ucs.login_handle.query_dn(child_dn) if mo_1: kwargs = dict(state=module.params['power_state']) if mo_1.check_prop_match(**kwargs): props_match = True elif not module.params['power_state']: # no mo and no desired state props_match = True if props_match: props_match = False # server pool child_dn = dn + '/pn-req' mo_1 = ucs.login_handle.query_dn(child_dn) if mo_1: kwargs = dict(name=module.params['server_pool']) kwargs['qualifier'] = module.params[ 'server_pool_qualification'] if mo_1.check_prop_match(**kwargs): props_match = True elif not module.params['server_pool']: # no pn-req object and no server pool name provided props_match = True if not props_match: if not module.check_mode: # create if mo does not already exist mo = LsServer( parent_mo_or_dn=module.params['org_dn'], bios_profile_name=module.params['bios_policy'], boot_policy_name=module.params['boot_policy'], descr=module.params['description'], ext_ip_state='pooled', ext_ip_pool_name=module.params['mgmt_ip_pool'], # graphics_card_policy_name=module.params['graphics_card_policy'], host_fw_policy_name=module. params['host_firmware_package'], ident_pool_name=module.params['uuid_pool'], kvm_mgmt_policy_name=module.params['kvm_mgmt_policy'], local_disk_policy_name=module. params['local_disk_policy'], maint_policy_name=module.params['maintenance_policy'], mgmt_access_policy_name=module. params['ipmi_access_profile'], name=module.params['name'], power_policy_name=module. params['power_control_policy'], power_sync_policy_name=module. params['power_sync_policy'], scrub_policy_name=module.params['scrub_policy'], sol_policy_name=module.params['sol_policy'], stats_policy_name=module.params['threshold_policy'], type=module.params['template_type'], usr_lbl=module.params['user_label'], vmedia_policy_name=module.params['vmedia_policy'], ) if module.params['storage_profile']: # Storage profile mo_1 = LstorageProfileBinding( parent_mo_or_dn=mo, storage_profile_name=module. params['storage_profile'], ) if module.params['mgmt_interface_mode']: # Management Interface mo_1 = MgmtInterface( parent_mo_or_dn=mo, mode=module.params['mgmt_interface_mode'], ip_v4_state='pooled', ) mo_2 = MgmtVnet( parent_mo_or_dn=mo_1, id='1', name=module.params['mgmt_vnet_name'], ) mo_3 = VnicIpV4MgmtPooledAddr( parent_mo_or_dn=mo_2, name=module.params['mgmt_inband_pool_name'], ) # LAN/SAN connectivity policy mo_1 = VnicConnDef( parent_mo_or_dn=mo, lan_conn_policy_name=module. params['lan_connectivity_policy'], san_conn_policy_name=module. params['san_connectivity_policy'], ) # power state admin_state = 'admin-' + module.params['power_state'] mo_1 = LsPower( parent_mo_or_dn=mo, state=admin_state, ) if module.params['server_pool']: # server pool mo_1 = LsRequirement( parent_mo_or_dn=mo, name=module.params['server_pool'], qualifier=module. params['server_pool_qualification'], ) ucs.login_handle.add_mo(mo, True) ucs.login_handle.commit() changed = True except Exception as e: err = True ucs.result['msg'] = "setup error: %s " % str(e) ucs.result['changed'] = changed if err: module.fail_json(**ucs.result) module.exit_json(**ucs.result)