def server_pool_add_rack_unit(handle, rack_id, parent_dn="org-root"): """ This method adds a rack server to a ComputePool. Args: handle (UcsHandle) rack_id (string): ID of rack server to add parent_dn (string): Parent of Org. Returns: ComputePooledRackUnit: Managed Object Example: server_pool_add_rack_unit(handle, rack_id=1, parent_dn="org-root/org-sub/compute-pool-sample_compute_pool") """ obj = handle.query_dn(parent_dn) if not obj: raise ValueError("org '%s' does not exist" % parent_dn) if not isinstance(obj, ComputePool): raise TypeError("Object {0} is not a ComputePool".format(obj.dn)) mo = ComputePooledRackUnit(parent_mo_or_dn=parent_dn, id=str(rack_id)) handle.add_mo(mo) handle.commit() return mo
def addServersToKubePool(handle, servers, org): print "Adding servers to Kubernetes Pool" from ucsmsdk.mometa.compute.ComputePool import ComputePool from ucsmsdk.mometa.compute.ComputePooledSlot import ComputePooledSlot from ucsmsdk.mometa.compute.ComputePooledRackUnit import ComputePooledRackUnit from ucsmsdk.mometa.compute.ComputeRackUnit import ComputeRackUnit from ucsmsdk.mometa.fabric.FabricComputeSlotEp import FabricComputeSlotEp mo = ComputePool(parent_mo_or_dn=org, policy_owner="local", name="Kubernetes", descr="") for s in servers: reset_disks(handle, s) if type(s) is FabricComputeSlotEp: ComputePooledSlot(parent_mo_or_dn=mo, slot_id=re.sub("slot-", "", s.slot_id), chassis_id=str(s.chassis_id)) if type(s) is ComputeRackUnit: ComputePooledRackUnit(parent_mo_or_dn=mo, id=re.sub("rack-unit-", "", s.rn)) handle.add_mo(mo, True) try: handle.commit() except UcsException as err: if err.error_code == "103": print "\talready exists"
def add_servers_to_pool(handle, servers, org): from ucsmsdk.mometa.compute.ComputePool import ComputePool from ucsmsdk.mometa.compute.ComputePooledSlot import ComputePooledSlot from ucsmsdk.mometa.compute.ComputePooledRackUnit import ComputePooledRackUnit print "Adding servers to KUBAM Pool" mo = ComputePool(parent_mo_or_dn=org, policy_owner="local", name="kubam", descr="") handle.query_classid("computeBlade") if "blades" in servers: for s in servers["blades"]: # Don't reset disks, leave them the way they are. # reset_disks(handle, s) chassis, slot = s.split("/") ComputePooledSlot(parent_mo_or_dn=mo, slot_id=str(slot), chassis_id=str(chassis)) if "rack_servers" in servers: for r in servers["rack_servers"]: ComputePooledRackUnit(parent_mo_or_dn=mo, id=r) 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 return 0, None
def setup_serverpool(server, module): from ucsmsdk.mometa.compute.ComputePool import ComputePool from ucsmsdk.mometa.compute.ComputePooledSlot import ComputePooledSlot from ucsmsdk.mometa.compute.ComputePooledRackUnit import ComputePooledRackUnit from ucsmsdk.mometa.compute.ComputeRackUnit import ComputeRackUnit from ucsmsdk.mometa.fabric.FabricComputeSlotEp import FabricComputeSlotEp ansible = module.params args_mo = _get_mo_params(ansible) changed = False exists = False for pool in args_mo['pool_list']: mo = server.query_dn(args_mo['org_dn'] + '/compute-pool-' + pool['name']) if mo: exists = True 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 "descr" in pool: pool["descr"] = "" nmo = ComputePool(parent_mo_or_dn=args_mo['org_dn'], name=pool["name"], descr=pool["descr"]) if "servers" in pool: for ser in pool["servers"]: ComputePooledRackUnit(parent_mo_or_dn=nmo, id=str(ser)) if "blades" in pool: for b in pool["blades"]: ComputePooledSlot(parent_mo_or_dn=nmo, slot_id=re.sub("\/\d", "", b), chassis_id=re.sub("\d\/", "", b)) server.add_mo(nmo, True) server.commit() return changed
def addServersToKubePool(handle, servers, org): print "Adding servers to Kubernetes Pool" from ucsmsdk.mometa.compute.ComputePool import ComputePool from ucsmsdk.mometa.compute.ComputePooledSlot import ComputePooledSlot from ucsmsdk.mometa.compute.ComputePooledRackUnit import ComputePooledRackUnit mo = ComputePool(parent_mo_or_dn=org, policy_owner="local", name="Kubernetes", descr="") blades = handle.query_classid("computeBlade") if "blades" in servers: for s in servers["blades"]: reset_disks(handle, s) chassis, slot = s.split("/") ComputePooledSlot(parent_mo_or_dn=mo, slot_id=str(slot), chassis_id=str(chassis)) if "rack_servers" in servers: for r in servers["rack_servers"]: ComputePooledRackUnit(parent_mo_or_dn=mo, id=r) 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 return 0, ""
chassis_id=pool_parms['chassis'], slot_id=pool_parms['slot']) handle.add_mo(mo) handle.commit() ##### End-Of-PythonScript ##### ##### Start-Of-PythonScript ##### from ucsmsdk.mometa.compute.ComputePooledRackUnit import ComputePooledRackUnit mo = ComputePool(parent_mo_or_dn="org-root", policy_owner="local", name="Openstack_Installer_Pool", descr="") for pool_parms in settings_file['installer_pool']: mo_1 = ComputePooledRackUnit(parent_mo_or_dn=mo, id=pool_parms['rack_id']) handle.add_mo(mo) handle.commit() ##### End-Of-PythonScript ##### ##### Start-Of-PythonScript ##### from ucsmsdk.mometa.fabric.FabricVConProfile import FabricVConProfile from ucsmsdk.mometa.fabric.FabricVCon import FabricVCon mo = FabricVConProfile(parent_mo_or_dn="org-root", policy_owner="local", name="Host_Infra", descr="", mezz_mapping="round-robin") mo_1 = FabricVCon(parent_mo_or_dn=mo,