コード例 #1
0
ファイル: UCSServer.py プロジェクト: madpabz/KUBaM
def createBiosPolicy(handle, org):
    print "Creating Kube Bios policy"
    from ucsmsdk.mometa.bios.BiosVProfile import BiosVProfile
    from ucsmsdk.mometa.bios.BiosVfConsistentDeviceNameControl import BiosVfConsistentDeviceNameControl
    from ucsmsdk.mometa.bios.BiosVfFrontPanelLockout import BiosVfFrontPanelLockout
    from ucsmsdk.mometa.bios.BiosVfPOSTErrorPause import BiosVfPOSTErrorPause
    from ucsmsdk.mometa.bios.BiosVfQuietBoot import BiosVfQuietBoot
    from ucsmsdk.mometa.bios.BiosVfResumeOnACPowerLoss import BiosVfResumeOnACPowerLoss
    mo = BiosVProfile(parent_mo_or_dn=org,
                      policy_owner="local",
                      name="kube",
                      descr="KUBaM Bios settings",
                      reboot_on_update="yes")
    mo_1 = BiosVfConsistentDeviceNameControl(parent_mo_or_dn=mo,
                                             vp_cdn_control="enabled")
    mo_2 = BiosVfFrontPanelLockout(parent_mo_or_dn=mo,
                                   vp_front_panel_lockout="platform-default")
    mo_3 = BiosVfPOSTErrorPause(parent_mo_or_dn=mo,
                                vp_post_error_pause="platform-default")
    mo_4 = BiosVfQuietBoot(parent_mo_or_dn=mo,
                           vp_quiet_boot="platform-default")
    mo_5 = BiosVfResumeOnACPowerLoss(parent_mo_or_dn=mo,
                                     vp_resume_on_ac_power_loss="last-state")
    handle.add_mo(mo, modify_present=True)
    try:
        handle.commit()
    except UcsException as err:
        if err.error_code == "103":
            print "\talready exists"
コード例 #2
0
def bios_conf_quite_boot(handle,
                         name,
                         parent_org_dn,
                         vp_quite_boot="platform-default"):
    from ucsmsdk.mometa.bios.BiosVfQuietBoot import BiosVfQuietBoot

    profile_dn = parent_org_dn + "/bios-prof-" + name
    obj = handle.query_dn(profile_dn)
    if obj:
        mo = BiosVfQuietBoot(parent_mo_or_dn=obj, vp_quiet_boot=vp_quite_boot)
        handle.add_mo(mo, True)
        handle.commit()
    else:
        log.info("Bios policy '%s' not found." % profile_dn)
コード例 #3
0
def add_ucs_bios_policy():
    """ Add UCS BIOS Policy """
    handle = UcsHandle(UCS_HOST, UCS_USER, UCS_PASS)
    handle.login()

    mo_bios_policy = BiosVProfile(parent_mo_or_dn='org-root',
                                  name='test-bios-prof',
                                  reboot_on_update='yes')
    BiosVfQuietBoot(parent_mo_or_dn=mo_bios_policy, vp_quiet_boot='disabled')
    BiosVfResumeOnACPowerLoss(parent_mo_or_dn=mo_bios_policy,
                              vp_resume_on_ac_power_loss='stay-off')
    BiosVfConsoleRedirection(parent_mo_or_dn=mo_bios_policy,
                             vp_baud_rate='9600',
                             vp_console_redirection='com-0',
                             vp_terminal_type='pc-ansi')

    handle.add_mo(mo_bios_policy, modify_present=True)
    handle.commit()
コード例 #4
0
def bios_create(handle,
                parent_org_dn,
                name,
                descr="",
                reboot_on_update="no",
                vp_cdn_control="platform-default",
                vp_front_panel_lockout="platform-default",
                vp_post_error_pause="platform-default",
                vp_quiet_boot="platform-default",
                vp_resume_on_ac_power_loss="platform-default"):

    from ucsmsdk.mometa.bios.BiosVProfile import BiosVProfile
    from ucsmsdk.mometa.bios.BiosVfConsistentDeviceNameControl import \
        BiosVfConsistentDeviceNameControl
    from ucsmsdk.mometa.bios.BiosVfFrontPanelLockout import \
        BiosVfFrontPanelLockout
    from ucsmsdk.mometa.bios.BiosVfPOSTErrorPause import BiosVfPOSTErrorPause
    from ucsmsdk.mometa.bios.BiosVfQuietBoot import BiosVfQuietBoot
    from ucsmsdk.mometa.bios.BiosVfResumeOnACPowerLoss import \
        BiosVfResumeOnACPowerLoss

    mo = BiosVProfile(parent_mo_or_dn=parent_org_dn,
                      name=name,
                      descr=descr,
                      reboot_on_update=reboot_on_update)
    mo_1 = BiosVfConsistentDeviceNameControl(parent_mo_or_dn=mo,
                                             vp_cdn_control=vp_cdn_control)
    mo_2 = BiosVfFrontPanelLockout(
        parent_mo_or_dn=mo, vp_front_panel_lockout=vp_front_panel_lockout)
    mo_3 = BiosVfPOSTErrorPause(parent_mo_or_dn=mo,
                                vp_post_error_pause=vp_post_error_pause)
    mo_4 = BiosVfQuietBoot(parent_mo_or_dn=mo, vp_quiet_boot=vp_quiet_boot)
    mo_5 = BiosVfResumeOnACPowerLoss(
        parent_mo_or_dn=mo,
        vp_resume_on_ac_power_loss=vp_resume_on_ac_power_loss)
    handle.add_mo(mo)
    handle.commit()
コード例 #5
0
ファイル: bios_policy.py プロジェクト: CiscoUcs/puppet-ucsm
def bios_policy(input):
    name = input['name']
    descr = input['descr']
    consistent_device_naming = input['consistent_device_naming']
    state = input['state']
    ip = input['ip']
    username = input['username']
    password = input['password']
    results = {}
    ucs_handle = pickle.loads(str(ucs_login.main(ip, username, password)))
    ###-------CHECK IF MO EXISTS---------------------------------

    try:
        mo = ucs_handle.query_dn("org-root/bios-prof-" + name)
        mo_block = ucs_handle.query_dn("org-root/bios-prof-" + name +
                                       "/Consistent-Device-Name-Control")
    except:
        results['error'] = "Could not query children of bios_policy"
        return results
###----if expected state is "present"------------------------

    if state == "present":
        if mo:
            if (mo.name == name and mo.descr == descr
                    and mo_block.vp_cdn_control == consistent_device_naming):
                results['name'] = name
                results['expected'] = True
                results['changed'] = False
                results['present'] = True

            else:
                try:
                    mo = BiosVProfile(parent_mo_or_dn="org-root",
                                      name=name,
                                      descr=descr)
                    modified_mo = BiosVfConsistentDeviceNameControl(
                        parent_mo_or_dn=mo,
                        vp_cdn_control=consistent_device_naming)
                    results['name'] = name
                    results['expected'] = False
                    results['changed'] = True
                    results['present'] = True
                    ucs_handle.add_mo(mo, True)
                    ucs_handle.commit()
                    #results['mo_bootpolicy'] = json.dumps(json.loads(jsonpickle.encode(mo)));

                except Exception as e:
                    results[
                        'error'] = "Modification of bios policy mo failed" + str(
                            e)
                    return results
###----------if not, create boot policy with desired config ----------------

        else:
            try:
                mo = BiosVProfile(parent_mo_or_dn="org-root",
                                  name=name,
                                  descr=descr)
                mo_1 = BiosVfQuietBoot(parent_mo_or_dn=mo,
                                       vp_quiet_boot="platform-default")
                mo_2 = BiosVfPOSTErrorPause(
                    parent_mo_or_dn=mo, vp_post_error_pause="platform-default")
                mo_3 = BiosVfResumeOnACPowerLoss(
                    parent_mo_or_dn=mo,
                    vp_resume_on_ac_power_loss="platform-default")
                mo_4 = BiosVfFrontPanelLockout(
                    parent_mo_or_dn=mo,
                    vp_front_panel_lockout="platform-default")
                mo_5 = BiosVfConsistentDeviceNameControl(
                    parent_mo_or_dn=mo,
                    vp_cdn_control=consistent_device_naming)
                mo_6 = BiosVfIntelTurboBoostTech(
                    parent_mo_or_dn=mo,
                    vp_intel_turbo_boost_tech="platform-default")
                mo_7 = BiosVfEnhancedIntelSpeedStepTech(
                    parent_mo_or_dn=mo,
                    vp_enhanced_intel_speed_step_tech="platform-default")
                mo_8 = BiosVfIntelHyperThreadingTech(
                    parent_mo_or_dn=mo,
                    vp_intel_hyper_threading_tech="platform-default")
                mo_9 = BiosVfCoreMultiProcessing(
                    parent_mo_or_dn=mo,
                    vp_core_multi_processing="platform-default")
                mo_10 = BiosVfExecuteDisableBit(
                    parent_mo_or_dn=mo,
                    vp_execute_disable_bit="platform-default")
                mo_11 = BiosVfIntelVirtualizationTechnology(
                    parent_mo_or_dn=mo,
                    vp_intel_virtualization_technology="platform-default")
                mo_12 = BiosVfProcessorPrefetchConfig(
                    parent_mo_or_dn=mo,
                    vp_dcuip_prefetcher="platform-default",
                    vp_adjacent_cache_line_prefetcher="platform-default",
                    vp_hardware_prefetcher="platform-default",
                    vp_dcu_streamer_prefetch="platform-default")
                mo_13 = BiosVfDirectCacheAccess(
                    parent_mo_or_dn=mo,
                    vp_direct_cache_access="platform-default")
                mo_14 = BiosVfProcessorCState(
                    parent_mo_or_dn=mo,
                    vp_processor_c_state="platform-default")
                mo_15 = BiosVfProcessorC1E(
                    parent_mo_or_dn=mo, vp_processor_c1_e="platform-default")
                mo_16 = BiosVfProcessorC3Report(
                    parent_mo_or_dn=mo,
                    vp_processor_c3_report="platform-default")
                mo_17 = BiosVfProcessorC6Report(
                    parent_mo_or_dn=mo,
                    vp_processor_c6_report="platform-default")
                mo_18 = BiosVfProcessorC7Report(
                    parent_mo_or_dn=mo,
                    vp_processor_c7_report="platform-default")
                mo_19 = BiosVfProcessorCMCI(
                    parent_mo_or_dn=mo, vp_processor_cmci="platform-default")
                mo_20 = BiosVfCPUPerformance(
                    parent_mo_or_dn=mo, vp_cpu_performance="platform-default")
                mo_21 = BiosVfMaxVariableMTRRSetting(
                    parent_mo_or_dn=mo, vp_processor_mtrr="platform-default")
                mo_22 = BiosVfLocalX2Apic(parent_mo_or_dn=mo,
                                          vp_local_x2_apic="platform-default")
                mo_23 = BiosVfProcessorEnergyConfiguration(
                    parent_mo_or_dn=mo,
                    vp_power_technology="platform-default",
                    vp_energy_performance="platform-default")
                mo_24 = BiosVfFrequencyFloorOverride(
                    parent_mo_or_dn=mo,
                    vp_frequency_floor_override="platform-default")
                mo_25 = BiosVfPSTATECoordination(
                    parent_mo_or_dn=mo,
                    vp_pstate_coordination="platform-default")
                mo_26 = BiosVfDRAMClockThrottling(
                    parent_mo_or_dn=mo,
                    vp_dram_clock_throttling="platform-default")
                mo_27 = BiosVfInterleaveConfiguration(
                    parent_mo_or_dn=mo,
                    vp_channel_interleaving="platform-default",
                    vp_rank_interleaving="platform-default",
                    vp_memory_interleaving="platform-default")
                mo_28 = BiosVfScrubPolicies(parent_mo_or_dn=mo,
                                            vp_patrol_scrub="platform-default",
                                            vp_demand_scrub="platform-default")
                mo_29 = BiosVfAltitude(parent_mo_or_dn=mo,
                                       vp_altitude="platform-default")
                mo_30 = BiosVfPackageCStateLimit(
                    parent_mo_or_dn=mo,
                    vp_package_c_state_limit="platform-default")
                mo_31 = BiosVfCPUHardwarePowerManagement(
                    parent_mo_or_dn=mo,
                    vp_cpu_hardware_power_management="platform-default")
                mo_32 = BiosVfEnergyPerformanceTuning(
                    parent_mo_or_dn=mo, vp_pwr_perf_tuning="platform-default")
                mo_33 = BiosVfWorkloadConfiguration(
                    parent_mo_or_dn=mo,
                    vp_workload_configuration="platform-default")
                ucs_handle.add_mo(mo)
                ucs_handle.commit()
                results['name'] = name
                results['present'] = False
                results['created'] = True
                results['changed'] = True
            #results['mo_bootpolicy'] = json.dumps(json.loads(jsonpickle.encode(mo)));

            except Exception as e:
                results['error'] = "Bios Policy creation failed" + str(e)
                return results


###------if expected state is "absent"----------------------------

    if state == "absent":

        if mo:

            try:
                ucs_handle.remove_mo(mo)
                results['name'] = name
                results['present'] = False
                results['removed'] = True
                ucs_handle.commit()

            except Exception as e:
                results['error'] = "Remove of bios policy mo failed" + str(e)
                return results
        else:
            results['name'] = name
            results['removed'] = False
            results['present'] = False
    ucs_handle = pickle.dumps(ucs_handle)
    ucs_logout.main(ucs_handle)
    return results