def remove_vnic_assignment_order(ucs, vnic, sp): from ucsmsdk.mometa.ls.LsVConAssign import LsVConAssign mo = LsVConAssign(parent_mo_or_dn=sp, admin_vcon='any', order='unspecified', transport=vnic['transport'], vnic_name=vnic['name']) ucs.login_handle.add_mo(mo, True) ucs.login_handle.commit()
def update_vnic_assignment_order(ucs, vnic, sp): from ucsmsdk.mometa.ls.LsVConAssign import LsVConAssign mo = LsVConAssign(parent_mo_or_dn=sp, admin_vcon=vnic['admin_vcon'], order=vnic['order'], transport=vnic['transport'], vnic_name=vnic['name']) ucs.login_handle.add_mo(mo, True) ucs.login_handle.commit()
def sp_vcon_assign_vnic(handle, sp_name, vnic_name, admin_vcon, order, transport="ethernet", parent_dn="org-root"): """ Assign vnic to service profile Args: handle (UcsHandle) sp_name (string): dn of service profile vnic_name (string): name of vnic admin_vcon (string): ["1", "2", "3", "4", "any"] order (string): ["unspecified"], ["0-256"] transport (string): transport medium parent_dn (string): org dn Returns: LsVConAssign Raises: ValueError: If LsServer is not present Example: sp_vcon_assign_vnic(handle, sp_name="testsp", vnic_name="testvnic", admin_vcon="1", order="100") """ from ucsmsdk.mometa.ls.LsVConAssign import LsVConAssign sp_dn = parent_dn + "/ls-" + sp_name obj = handle.query_dn(sp_dn) if not obj: raise ValueError("SP '%s' does not exist" % sp_dn) mo = LsVConAssign(parent_mo_or_dn=obj, admin_vcon=admin_vcon, order=order, transport=transport, vnic_name=vnic_name) handle.add_mo(mo, True) handle.commit() return mo
def sp_vcon_deassign_vnic(handle, sp_name, vnic_name, transport="ethernet", parent_dn="org-root"): """ Deassign vnic from service profile Args: handle (UcsHandle) sp_name (string): dn of service profile vnic_name (string): name of vnic transport (string): transport medium parent_dn (string): org dn Returns: LsVConAssign Raises: ValueError: If LsServer is not present Example: sp_vcon_deassign_vnic(handle, sp_name="testsp", vnic_name="testvnic", transport="ethernet") """ from ucsmsdk.mometa.ls.LsVConAssign import LsVConAssign sp_dn = parent_dn + "/ls-" + sp_name sp = handle.query_dn(sp_dn) if not sp: raise ValueError("SP '%s' does not exist" % sp_dn) mo = LsVConAssign(parent_mo_or_dn=sp, admin_vcon="any", order="unspecified", transport=transport, vnic_name=vnic_name) handle.add_mo(mo, True) handle.commit() return mo
def sp_vcon_assign_vnic(handle, sp_name, admin_vcon, vnic_name, order, transport="ethernet", org_dn="org-root"): from ucsmsdk.mometa.ls.LsVConAssign import LsVConAssign ls_dn = org_dn + "/ls-" + sp_name obj = handle.query_dn(ls_dn) if obj: mo = LsVConAssign(parent_mo_or_dn=ls_dn, admin_vcon=admin_vcon, order=order, transport=transport, vnic_name=vnic_name) handle.add_mo(mo, modify_present=True) handle.commit() else: log.info("SP not found.Can not add.")
def sp_vcon_remove_vnic(handle, org_name, sp_name, vnic_name, transport="ethernet", org_parent="org-root"): from ucsmsdk.mometa.ls.LsVConAssign import LsVConAssign if org_name != "": org_dn = org_parent + "/org-" + org_name + "/ls-" + sp_name else: org_dn = org_parent + "/ls-" + sp_name parent_mo = handle.query_dn(org_dn) if parent_mo: mo = LsVConAssign(parent_mo_or_dn=org_dn, admin_vcon="any", order="unspecified", transport=transport, vnic_name=vnic_name) handle.add_mo(mo, True) handle.commit() else: log.info("SP not found.")
def test_002_sp_expert(): ''' This case is generated based on SP expert mode creation wizard. ''' from ucsmsdk.mometa.ls.LsServer import LsServer from ucsmsdk.mometa.ls.LsVConAssign import LsVConAssign from ucsmsdk.mometa.vnic.VnicEther import VnicEther from ucsmsdk.mometa.vnic.VnicEtherIf import VnicEtherIf from ucsmsdk.mometa.vnic.VnicFc import VnicFc from ucsmsdk.mometa.vnic.VnicFcIf import VnicFcIf from ucsmsdk.mometa.vnic.VnicFcNode import VnicFcNode from ucsmsdk.mometa.storage.StorageIniGroup import StorageIniGroup from ucsmsdk.mometa.vnic.VnicFcGroupDef import VnicFcGroupDef from ucsmsdk.mometa.storage.StorageInitiator import StorageInitiator from ucsmsdk.mometa.ls.LsPower import LsPower from ucsmsdk.mometa.fabric.FabricVCon import FabricVCon mo = LsServer(parent_mo_or_dn="org-root", vmedia_policy_name="", ext_ip_state="none", bios_profile_name="SRIOV", mgmt_fw_policy_name="", agent_policy_name="", mgmt_access_policy_name="", dynamic_con_policy_name="", kvm_mgmt_policy_name="", sol_policy_name="", uuid="00000000-0000-0000-0000-0000000000bb", descr="", stats_policy_name="default", policy_owner="local", ext_ip_pool_name="ext-mgmt", boot_policy_name="default", usr_lbl="", host_fw_policy_name="", vcon_profile_name="", ident_pool_name="", src_templ_name="", local_disk_policy_name="default", scrub_policy_name="", power_policy_name="default", maint_policy_name="", name="test_sp", resolve_remote="yes") mo_1 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", order="1", transport="ethernet", vnic_name="eth0") mo_2 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", order="2", transport="fc", vnic_name="fc0") mo_3 = VnicEther(parent_mo_or_dn=mo, nw_ctrl_policy_name="", name="eth0", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", admin_cdn_name="", switch_id="A", pin_to_group_name="", mtu="1500", qos_policy_name="", adaptor_profile_name="", ident_pool_name="default", order="1", nw_templ_name="", addr="derived") mo_3_1 = VnicEtherIf(parent_mo_or_dn=mo_3, default_net="yes", name="default") mo_4 = VnicFc(parent_mo_or_dn=mo, addr="derived", name="fc0", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", admin_cdn_name="", switch_id="A", pin_to_group_name="", pers_bind="disabled", pers_bind_clear="no", qos_policy_name="", adaptor_profile_name="", ident_pool_name="", order="2", nw_templ_name="", max_data_field_size="2048") mo_4_1 = VnicFcIf(parent_mo_or_dn=mo_4, name="default") mo_5 = VnicFcNode(parent_mo_or_dn=mo, ident_pool_name="", addr="20:00:00:25:B5:00:00:00") mo_6 = StorageIniGroup(parent_mo_or_dn=mo, name="test", descr="", group_policy_name="", policy_name="", policy_owner="local", rmt_disk_cfg_name="") mo_6_1 = VnicFcGroupDef(parent_mo_or_dn=mo_6, storage_conn_policy_name="", policy_owner="local", name="", descr="", stats_policy_name="default") mo_6_2 = StorageInitiator(parent_mo_or_dn=mo_6, policy_owner="local", name="fc0", descr="") mo_7 = LsPower(parent_mo_or_dn=mo, state="admin-up") mo_8 = FabricVCon(parent_mo_or_dn=mo, placement="physical", fabric="NONE", share="shared", select="all", transport="ethernet,fc", id="1", inst_type="auto") mo_9 = FabricVCon(parent_mo_or_dn=mo, placement="physical", fabric="NONE", share="shared", select="all", transport="ethernet,fc", id="2", inst_type="auto") mo_10 = FabricVCon(parent_mo_or_dn=mo, placement="physical", fabric="NONE", share="shared", select="all", transport="ethernet,fc", id="3", inst_type="auto") mo_11 = FabricVCon(parent_mo_or_dn=mo, placement="physical", fabric="NONE", share="shared", select="all", transport="ethernet,fc", id="4", inst_type="auto") handle.add_mo(mo) handle.commit() obj = handle.query_dn("org-root/ls-test_sp") handle.remove_mo(obj) handle.commit()
mo = FabricEthLanPc(parent_mo_or_dn="fabric/lan/A", name="PC-50", descr="", flow_ctrl_policy="default", admin_speed="10gbps", auto_negotiate="yes", admin_state="enabled", oper_speed="10gbps", port_id="50", lacp_policy_name="default") mo_1 = FabricEthLanPcEp(parent_mo_or_dn=mo, eth_link_profile_name="default", name="", auto_negotiate="yes", slot_id="1", admin_state="enabled", port_id="3") mo_2 = FabricEthLanPcEp(parent_mo_or_dn=mo, eth_link_profile_name="default", name="", auto_negotiate="yes", slot_id="1", admin_state="enabled", port_id="4") handle.add_mo(mo) handle.commit() #PC-51 with FI-B P3 and FI-B P4 mo = FabricEthLanPc(parent_mo_or_dn="fabric/lan/B", name="PC-51", descr="", flow_ctrl_policy="default", admin_speed="10gbps", auto_negotiate="yes", admin_state="enabled", oper_speed="10gbps", port_id="51", lacp_policy_name="default") mo_1 = FabricEthLanPcEp(parent_mo_or_dn=mo, eth_link_profile_name="default", name="", auto_negotiate="yes", slot_id="1", admin_state="enabled", port_id="3") mo_2 = FabricEthLanPcEp(parent_mo_or_dn=mo, eth_link_profile_name="default", name="", auto_negotiate="yes", slot_id="1", admin_state="enabled", port_id="4") handle.add_mo(mo) handle.commit() #Create Service Profile Template if (FC and not iSCSI): mo = LsServer(parent_mo_or_dn=my_Full_Path_Org, vmedia_policy_name="", ext_ip_state="none", bios_profile_name="", mgmt_fw_policy_name="", agent_policy_name="", mgmt_access_policy_name="", dynamic_con_policy_name="", kvm_mgmt_policy_name="", sol_policy_name="", uuid="0", descr="SPT Description", stats_policy_name="default", policy_owner="local", ext_ip_pool_name="ext-mgmt", boot_policy_name="Boot_Policy", usr_lbl="", host_fw_policy_name="", vcon_profile_name="", ident_pool_name="UUID_POOL", src_templ_name="", type="initial-template", local_disk_policy_name="Local_Disk_CP", scrub_policy_name="", power_policy_name="default", maint_policy_name="User_Ack", name=my_SPT, resolve_remote="yes") mo_1 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", admin_host_port="ANY", order="1", transport="ethernet", vnic_name="MGMT-A") mo_2 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", admin_host_port="ANY", order="2", transport="ethernet", vnic_name="MGMT-B") mo_3 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", admin_host_port="ANY", order="3", transport="ethernet", vnic_name="VM-A") mo_4 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", admin_host_port="ANY", order="4", transport="ethernet", vnic_name="VM-B") mo_5 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", admin_host_port="ANY", order="5", transport="fc", vnic_name="fc-a") mo_6 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", admin_host_port="ANY", order="6", transport="fc", vnic_name="fc-b") mo_7 = VnicEther(parent_mo_or_dn=mo, cdn_prop_in_sync="yes", nw_ctrl_policy_name="", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", admin_cdn_name="", switch_id="A", pin_to_group_name="", name="MGMT-A", order="1", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", cdn_source="vnic-name", mtu="1500", nw_templ_name="MGMT-A", addr="derived") mo_8 = VnicEther(parent_mo_or_dn=mo, cdn_prop_in_sync="yes", nw_ctrl_policy_name="", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", admin_cdn_name="", switch_id="B", pin_to_group_name="", name="MGMT-B", order="2", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", cdn_source="vnic-name", mtu="1500", nw_templ_name="MGMT-B", addr="derived") mo_9 = VnicEther(parent_mo_or_dn=mo, cdn_prop_in_sync="yes", nw_ctrl_policy_name="", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", admin_cdn_name="", switch_id="A", pin_to_group_name="", name="VM-A", order="3", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", cdn_source="vnic-name", mtu="1500", nw_templ_name="VM-A", addr="derived") mo_10 = VnicEther(parent_mo_or_dn=mo, cdn_prop_in_sync="yes", nw_ctrl_policy_name="", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", admin_cdn_name="", switch_id="B", pin_to_group_name="", name="VM-B", order="4", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", cdn_source="vnic-name", mtu="1500", nw_templ_name="VM-B", addr="derived") mo_11 = VnicFc(parent_mo_or_dn=mo, cdn_prop_in_sync="yes", addr="derived", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", admin_cdn_name="", switch_id="A", pin_to_group_name="", pers_bind="disabled", order="5", pers_bind_clear="no", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", cdn_source="vnic-name", max_data_field_size="2048", nw_templ_name="fc-a", name="fc-a") mo_11_1 = VnicFcIf(parent_mo_or_dn=mo_11, name="") mo_12 = VnicFc(parent_mo_or_dn=mo, cdn_prop_in_sync="yes", addr="derived", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", admin_cdn_name="", switch_id="B", pin_to_group_name="", pers_bind="disabled", order="6", pers_bind_clear="no", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", cdn_source="vnic-name", max_data_field_size="2048", nw_templ_name="fc-b", name="fc-b") mo_12_1 = VnicFcIf(parent_mo_or_dn=mo_12, name="") mo_13 = VnicFcNode(parent_mo_or_dn=mo, ident_pool_name="WWNN_Pool", addr="pool-derived") mo_14 = LsRequirement(parent_mo_or_dn=mo, restrict_migration="no", name="Server_Pool", qualifier="")
#CREATE VHBA TEMPLATE mo = VnicSanConnTempl(parent_mo_or_dn="org-root", templ_type="updating-template", name="FC_A", descr="", stats_policy_name="default", switch_id="A", pin_to_group_name="", policy_owner="local", qos_policy_name="", ident_pool_name="WWPN_A", max_data_field_size="2048") mo_1 = VnicFcIf(parent_mo_or_dn=mo, name=vsananame) handle.add_mo(mo) mo = VnicSanConnTempl(parent_mo_or_dn="org-root", templ_type="updating-template", name="FC_B", descr="", stats_policy_name="default", switch_id="B", pin_to_group_name="", policy_owner="local", qos_policy_name="", ident_pool_name="WWPN_B", max_data_field_size="2048") mo_1 = VnicFcIf(parent_mo_or_dn=mo, name=vsanbname) handle.add_mo(mo) else : print "Last Step" #Create Service Profile Template ESX mo = LsServer(parent_mo_or_dn="org-root", vmedia_policy_name="", ext_ip_state="none", bios_profile_name="", mgmt_fw_policy_name="", agent_policy_name="", mgmt_access_policy_name="", dynamic_con_policy_name="", kvm_mgmt_policy_name="", sol_policy_name="", uuid="0", descr="", stats_policy_name="default", policy_owner="local", ext_ip_pool_name="ext-mgmt", boot_policy_name="default", usr_lbl="", host_fw_policy_name="", vcon_profile_name="", ident_pool_name="default", src_templ_name="", type="updating-template", local_disk_policy_name="default", scrub_policy_name="", power_policy_name="default", maint_policy_name="User-Ack", name="ESX", resolve_remote="yes") mo_1 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", order="1", transport="ethernet", vnic_name="VMDATA_A") mo_2 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", order="2", transport="ethernet", vnic_name="VMDATA_B") mo_3 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", order="3", transport="ethernet", vnic_name="vMotion_A") mo_4 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", order="4", transport="ethernet", vnic_name="vMotion_B") mo_5 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", order="5", transport="ethernet", vnic_name="mgmt_A") mo_6 = LsVConAssign(parent_mo_or_dn=mo, admin_vcon="any", order="6", transport="ethernet", vnic_name="mgmt_B") mo_7 = VnicDefBeh(parent_mo_or_dn=mo, name="", descr="", policy_owner="local", action="none", type="vhba", nw_templ_name="") mo_8 = VnicEther(parent_mo_or_dn=mo, nw_ctrl_policy_name="", name="VMDATA_A", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", switch_id="A", pin_to_group_name="", mtu="1500", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", order="1", nw_templ_name="VMDATA_A", addr="derived") mo_9 = VnicEther(parent_mo_or_dn=mo, nw_ctrl_policy_name="", name="VMDATA_B", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", switch_id="B", pin_to_group_name="", mtu="1500", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", order="2", nw_templ_name="VMDATA_B", addr="derived") mo_11 = VnicEther(parent_mo_or_dn=mo, nw_ctrl_policy_name="", name="vMotion_A", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", switch_id="A", pin_to_group_name="", mtu="1500", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", order="3", nw_templ_name="vMotion_A", addr="derived") mo_12 = VnicEther(parent_mo_or_dn=mo, nw_ctrl_policy_name="", name="vMotion_B", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", switch_id="B", pin_to_group_name="", mtu="1500", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", order="4", nw_templ_name="vMotion_B", addr="derived") mo_13 = VnicEther(parent_mo_or_dn=mo, nw_ctrl_policy_name="", name="mgmt_A", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", switch_id="A", pin_to_group_name="", mtu="1500", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", order="5", nw_templ_name="mgmt_A", addr="derived") mo_14 = VnicEther(parent_mo_or_dn=mo, nw_ctrl_policy_name="", name="mgmt_B", admin_host_port="ANY", admin_vcon="any", stats_policy_name="default", switch_id="B", pin_to_group_name="", mtu="1500", qos_policy_name="", adaptor_profile_name="VMWare", ident_pool_name="", order="6", nw_templ_name="mgmt_B", addr="derived") mo_15 = LsPower(parent_mo_or_dn=mo, state="admin-up") mo_16 = FabricVCon(parent_mo_or_dn=mo, placement="physical", fabric="NONE", share="shared", select="all", transport="ethernet,fc", id="1", inst_type="auto") mo_17 = FabricVCon(parent_mo_or_dn=mo, placement="physical", fabric="NONE", share="shared", select="all", transport="ethernet,fc", id="2", inst_type="auto")