QuestionQ139

Cisco Platforms

Question Image

Refer to the exhibit. Drag the code snippets from the bottom to the blanks in the code to provision a new UCS server. Not all options are used.

Drag & Drop
STATE_ERROR
STATE_FAILED
LsServerConsts
event_handle
from ucsmsdk.ucseventhandler import UcsEventHandle
from ucsmsdk.mometa.ls.LsServer import 

end_script = False

def_sp_associate_callback(mce):
    global end_script
    if mce.mo.assoc_state == LsServerConsts.ASSOC_STATE_ASSOCIATED:
        log.debug("SP:" + mce.mo.dn + " Assoc Successful. assoc_state: "+
                  mce.mo.assoc_state)
    elif mce.mo.assoc_state == LsServerConsts.ASSIGN_STATE_FAILED:
        log.error("SP:" + mce.mo.dn + "Assoc Failed. assoc_state: " +
                  mce.mo.assoc_state)
    end_script = True

def _sp_associate_monitor(event_handle, mo):
    .add(managed_object=mo, prop= "assoc_state",
                 success_value=[LsServerConsts.ASSOC_STATE_ASSOCIATED],
                 failure_value=[LsServerConsts.ASSOC_],
                 timeout_sec=600, call_back=_sp_associate_callback)
Explanation

LsServerConsts provides the UCS service-profile state constants. Monitoring the assoc_state property through the supplied event handle completes successfully at ASSOC_STATE_ASSOCIATED and reports failure at ASSOC_STATE_FAILED; thus the final token completes the ASSOC_ prefix as ASSOC_STATE_FAILED.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!