Ejemplo n.º 1
0
def add_vnx(spa_ip,
            spb_ip,
            array_user,
            array_pass,
            ecom_ip,
            ecom_user="******",
            ecom_pass="******"):

    ecom_url = "https://%s:5989" % ecom_ip
    ecom_conn = pywbem.WBEMConnection(ecom_url, (ecom_user, ecom_pass),
                                      default_namespace="/root/emc")
    ers = ecom_conn.EnumerateInstanceNames("EMC_SystemRegistrationService")
    o = ecom_conn.InvokeMethod("EMCAddSystem",
                               ers[0],
                               ArrayType=pywbem.Uint16(1),
                               Addresses=[spa_ip, spb_ip],
                               Types=[pywbem.Uint16(2),
                                      pywbem.Uint16(2)],
                               User=array_user,
                               Password=array_pass)

    results = [
        "Success", "Not Supported", "Unknown", "Timeout", "Failed",
        "Inavlid Parameter", "In Use", "Existing"
    ]
    print "Execution Ouput:"
    print o
    print "Result: %s" % results[o[0]]
Ejemplo n.º 2
0
    def cim_method_send_indication(self, env, object_name, method):
        """
        Method to test the upcalls to the cimom handle for export_indications.
        """
        global _indication_names, _indication_count
        cimtime = pywbem.CIMDateTime.now()
        ch = env.get_cimom_handle()
        ch.set_default_namespace("root/cimv2")
        logger = env.get_logger()

        for name in _indication_names:
            alert_ind = pywbem.CIMInstance("UpcallAtom_Indication")
            alert_ind['AlertType'] = pywbem.Uint16(2)
            alert_ind['Description'] = name
            alert_ind['PerceivedSeverity'] = pywbem.Uint16(1)
            alert_ind['PorbablyCause'] = pywbem.Uint16(1)
            alert_ind['IndicationTime'] = cimtime
            alert_ind['SystemName'] = socket.getfqdn()

            try:
                print '### Exporting indication. pid:', os.getpid()
                ch.export_indication(alert_ind)
                print '### Done exporting indication'
            except pywbem.CIMError, arg:
                print '### Caught exception exporting indication'
                raise
Ejemplo n.º 3
0
    def _create_test_instance(self, name_of_atom, number):
        """ Create a TestAtom instance.  """

        weight = _atomic_weights[name_of_atom]
        #new_instance['char16Prop']  = 
        #new_instance['char16Propa'] = Null
        new_instance = pywbem.CIMInstance('TestAtom')
        new_instance['Name'] = name_of_atom
        new_instance['boolProp']     = False
        new_instance['dateProp']     = self.time
        new_instance['real32Prop']   = pywbem.Real32(weight)
        new_instance['real32Propa']  = [pywbem.Real32(weight), \
                                        pywbem.Real32(weight), \
                                        pywbem.Real32(weight)]
        new_instance['real64Prop']   = pywbem.Real64(weight)
        new_instance['real64Propa']  = [pywbem.Real64(weight), \
                                        pywbem.Real64(weight), \
                                        pywbem.Real64(weight)]
        new_instance['sint16Prop']   = pywbem.Sint16(number)
        new_instance['sint16Propa']  = [pywbem.Sint16(number), \
                                        pywbem.Sint16(number), \
                                        pywbem.Sint16(number)]
        new_instance['sint32Prop']   = pywbem.Sint32(number)
        new_instance['sint32Propa']  = [pywbem.Sint32(number), \
                                        pywbem.Sint32(number), \
                                        pywbem.Sint32(number)]
        new_instance['sint64Prop']   = pywbem.Sint64(number)
        new_instance['sint64Propa']  = [pywbem.Sint64(number), \
                                        pywbem.Sint64(number), \
                                        pywbem.Sint64(number)]
        new_instance['sint8prop']    = pywbem.Sint8(number)
        new_instance['sint8Propa']   = [pywbem.Sint8(number), \
                                        pywbem.Sint8(number), \
                                        pywbem.Sint8(number)]
        new_instance['stringProp']   = name_of_atom
        new_instance['stringPropa']  = ['proton', 'electron', 'neutron']
        new_instance['uint16Prop']   = pywbem.Uint16(number)
        new_instance['uint16Propa']  = [pywbem.Uint16(number), \
                                        pywbem.Uint16(number), \
                                        pywbem.Uint16(number)]
        new_instance['uint32Prop']   = pywbem.Uint32(number)
        new_instance['uint32Propa']  = [pywbem.Uint32(number), \
                                        pywbem.Uint32(number), \
                                        pywbem.Uint32(number)]
        new_instance['uint64Prop']   = pywbem.Uint64(number)
        new_instance['uint64Propa']  = [pywbem.Uint64(number), \
                                        pywbem.Uint64(number), \
                                        pywbem.Uint64(number)]
        new_instance['uint8Prop']    = pywbem.Uint64(number)
        new_instance['uint8Propa']   = [pywbem.Uint64(number), \
                                        pywbem.Uint64(number), \
                                        pywbem.Uint64(number)]

        try:
            cipath = self.conn.CreateInstance(new_instance)
            new_instance.path = cipath
            self.inst_paths.append(cipath)

        except pywbem.CIMError, arg:
            return None, arg
Ejemplo n.º 4
0
def _typed_randrange(lo, hi, type):
    if type == 'sint8':
        return pywbem.Sint8(
            random.randrange(pywbem.Sint8(lo), pywbem.Sint8(hi)))
    elif type == 'sint16':
        return pywbem.Sint16(
            random.randrange(pywbem.Sint16(lo), pywbem.Sint16(hi)))
    elif type == 'sint32':
        return pywbem.Sint32(
            random.randrange(pywbem.Sint32(lo), pywbem.Sint32(hi)))
    elif type == 'sint64':
        return pywbem.Sint64(
            random.randrange(pywbem.Sint64(lo), pywbem.Sint64(hi)))
    elif type == 'uint8':
        return pywbem.Uint8(
            random.randrange(pywbem.Uint8(lo), pywbem.Uint8(hi)))
    elif type == 'uint16':
        return pywbem.Uint16(
            random.randrange(pywbem.Uint16(lo), pywbem.Uint16(hi)))
    elif type == 'uint32':
        return pywbem.Uint32(
            random.randrange(pywbem.Uint32(lo), pywbem.Uint32(hi)))
    elif type == 'uint64':
        return pywbem.Uint64(
            random.randrange(pywbem.Uint64(lo), pywbem.Uint64(hi)))
    elif type == 'real32':
        return pywbem.Real32(
            random.randrange(pywbem.Real32(lo), pywbem.Real32(hi)))
    elif type == 'real64':
        return pywbem.Real64(
            random.randrange(pywbem.Real64(lo), pywbem.Real64(hi)))
 class PrimaryStatus(object):
     Unknown = pywbem.Uint16(0)
     OK = pywbem.Uint16(1)
     Degraded = pywbem.Uint16(2)
     Error = pywbem.Uint16(3)
     # DMTF_Reserved = ..
     # Vendor_Reserved = 0x8000..
     _reverse_map = {0: 'Unknown', 1: 'OK', 2: 'Degraded', 3: 'Error'}
 class CommunicationStatus(object):
     Unknown = pywbem.Uint16(0)
     Not_Available = pywbem.Uint16(1)
     Communication_OK = pywbem.Uint16(2)
     Lost_Communication = pywbem.Uint16(3)
     No_Contact = pywbem.Uint16(4)
     # DMTF_Reserved = ..
     # Vendor_Reserved = 0x8000..
     _reverse_map = {0: 'Unknown', 1: 'Not Available', 2: 'Communication OK', 3: 'Lost Communication', 4: 'No Contact'}
 class ResetCapability(object):
     Other = pywbem.Uint16(1)
     Unknown = pywbem.Uint16(2)
     Disabled = pywbem.Uint16(3)
     Enabled = pywbem.Uint16(4)
     Not_Implemented = pywbem.Uint16(5)
     _reverse_map = {
         1: 'Other',
         2: 'Unknown',
         3: 'Disabled',
         4: 'Enabled',
         5: 'Not Implemented'
     }
Ejemplo n.º 8
0
 class ElementSoftwareStatus(object):
     Unknown = pywbem.Uint16(0)
     Current = pywbem.Uint16(2)
     Next = pywbem.Uint16(3)
     FallBack = pywbem.Uint16(4)
     Default = pywbem.Uint16(5)
     Installed = pywbem.Uint16(6)
     Single_Use = pywbem.Uint16(7)
     Available = pywbem.Uint16(8)
     Supports = pywbem.Uint16(9)
 class RequestedState(object):
     Enabled = pywbem.Uint16(2)
     Disabled = pywbem.Uint16(3)
     Shut_Down = pywbem.Uint16(4)
     Offline = pywbem.Uint16(6)
     Test = pywbem.Uint16(7)
     Defer = pywbem.Uint16(8)
     Quiesce = pywbem.Uint16(9)
     Reboot = pywbem.Uint16(10)
     Reset = pywbem.Uint16(11)
Ejemplo n.º 10
0
 class AvailableRequestedStates(object):
     Enabled = pywbem.Uint16(2)
     Disabled = pywbem.Uint16(3)
     Shut_Down = pywbem.Uint16(4)
     Offline = pywbem.Uint16(6)
     Test = pywbem.Uint16(7)
     Defer = pywbem.Uint16(8)
     Quiesce = pywbem.Uint16(9)
     Reboot = pywbem.Uint16(10)
     Reset = pywbem.Uint16(11)
     # DMTF_Reserved = ..
     _reverse_map = {2: 'Enabled', 3: 'Disabled', 4: 'Shut Down', 6: 'Offline', 7: 'Test', 8: 'Defer', 9: 'Quiesce', 10: 'Reboot', 11: 'Reset'}
Ejemplo n.º 11
0
 def __AttachNicToNetwork(self, switch, nics):
     result = 0
     if switch != None:
         try:
             rasd = CIMInstance('Xen_HostNetworkPortSettingData')
             rasd['ResourceType'] = pywbem.Uint16(33)
             rasd['VlanTag'] = pywbem.Uint64(23)
             rasd['Connection'] = nics
             print 'adding resources %s' % rasd.items()
             vssd = CIMInstanceName('Xen_VirtualSwitchSettingData')
             vssd['InstanceID'] = 'Xen:' + switch['Name']
             nic_rasds = [rasd]
             in_params = {
                 'AffectedConfiguration': vssd,
                 'ResourceSettings': nic_rasds
             }
             (rval,
              out_params) = self.conn.InvokeMethod('AddResourceSettings',
                                                   self.vsms, **in_params)
             if rval == 0:
                 result = 1
                 try:
                     nics = self.__FindNicsAssociatedWithSwitch(switch)
                     if len(nics) == 0:
                         result = 0
                 except Exception, e:
                     print 'exception %s was received' % str(e)
                     result = 0
             else:
                 print 'Method returned error %d' % rval
Ejemplo n.º 12
0
def get_stats(array_serial,
              ecom_ip,
              instance_id,
              ecom_user="******",
              ecom_pass="******"):
    """ Collect performance statistics """

    ecom_conn = ecom_connect(ecom_ip, ecom_user, ecom_pass)

    # Check and set the sample interval
    interval = get_sample_interval(ecom_conn, array_serial)
    if interval != sample_interval:
        set_sample_interval(ecom_conn, array_serial, sample_interval)

    # Determine the sequence our Stats are coming in from the Manifest
    array = get_array_instancename(ecom_conn, array_serial)
    man_coll = ecom_conn.AssociatorNames(
        array, ResultClass="CIM_BlockStatisticsManifestCollection")[0]

    manifests = ecom_conn.Associators(
        man_coll, ResultClass="CIM_BlockStatisticsManifest")

    for i in manifests:
        if instance_id in i["InstanceID"]:
            header_row = i["CSVSequence"]

    # Grab our stats
    stats_service = ecom_conn.AssociatorNames(
        array, ResultClass="CIM_BlockStatisticsService")[0]

    stat_output = ecom_conn.InvokeMethod("GetStatisticsCollection",
                                         stats_service,
                                         StatisticsFormat=pywbem.Uint16(2))

    return (header_row, stat_output[1]["Statistics"])
Ejemplo n.º 13
0
 class PerceivedSeverity(object):
     Unknown = pywbem.Uint16(0)
     Other = pywbem.Uint16(1)
     Information = pywbem.Uint16(2)
     Degraded_Warning = pywbem.Uint16(3)
     Minor = pywbem.Uint16(4)
     Major = pywbem.Uint16(5)
     Critical = pywbem.Uint16(6)
     Fatal_NonRecoverable = pywbem.Uint16(7)
Ejemplo n.º 14
0
    def test_create_KVP (self):
        #in_params = {'RequestedState':'2'}
        #ChangeVMState(self.conn, self.test_vm, in_params, True, '2')
        key = "testkey2"
        value = "testvalue2"

        kvp_rasd = CIMInstance('Xen_KVP')
        kvp_rasd['ResourceType'] = pywbem.Uint16(40000)
        kvp_rasd['Key'] = key
        kvp_rasd['Value'] = value

        print "KVP RASD = %s" % kvp_rasd
        print "PV: %s" % self.test_vm

        in_params = {'ResourceSetting': kvp_rasd, 'AffectedSystem': self.test_vm}
        AddVMResource(self.conn, self.vsms[0], in_params)

        rasds_to_delete = []
        # Enumerate the created RASD
        instances = self.conn.EnumerateInstanceNames("Xen_KVP")

        for instance in instances:
            print "Instance: %s" % instance
            tmp1 = CIMInstance("Xen_KVP")
            tmp1['DeviceID'] = instance['DeviceID']
            tmp1['ResourceType'] = pywbem.Uint16(40000)
            tmp1['InstanceID'] = instance['DeviceID']
            #tmp1['Key'] = "testkey2"
            #tmp1['Value'] = "testvalue2"
            #tmp1['Value'] = instance['Value']
            rasds_to_delete.append(tmp1)

        vssds = GetVSSDsForVM(self.conn, self.test_vm)
        rasds = GetRASDsFromVSSD(self.conn, vssds[0])

        print "Rasds: %s" % rasds
        print "Keys 1: %s" % rasds[0].keys()

        print "Keys 2: %s" % rasds_to_delete[0].keys()
        print "About to delete %s" % rasds_to_delete
        in_params = {'ResourceSettings': rasds_to_delete}
        rc = DeleteVMResources(self.conn, self.vsms[0], in_params)
        print rc
        
        print "done"
Ejemplo n.º 15
0
 def CreateBondedNetwork(self):
     self.TestBegin()
     # eth1 and eth2 PIFs are bonded and a network is created out of them
     rasd1 = CIMInstance('Xen_HostNetworkPortSettingData')
     rasd1['ResourceType'] = pywbem.Uint16(33)
     rasd1['Connection'] = ["eth1"]
     rasd1['VlanTag'] = pywbem.Uint64(2)
     rasd2 = CIMInstance('Xen_NetworkPortSettingData')
     rasd2['ResourceType'] = pywbem.Uint16(33)
     rasd2['Connection'] = ["eth2"]
     rasd2['VlanTag'] = pywbem.Uint64(2)
     rasds = [rasd1, rasd2]
     result = 0
     bonded_network = self.__CreateNetwork(rasds)
     if bonded_network != None:
         result = 1
     self.TestEnd(result)
     return bonded_network
Ejemplo n.º 16
0
def createCIMXMLVM(password = None,
                   hostIPAddr = None,
                   vmName = None):
    cimxmlConn = cimxmlConnection(password,hostIPAddr)

    # Virtual System setting data for an HVM type
    hvmVssd = CIMInstance("Xen_ComputerSystemSettingData")
    hvmVssd['Description'] = vmName
    hvmVssd['ElementName'] = vmName
    hvmVssd['VirtualSystemType'] = 'DMTF:xen:HVM'
    hvmVssd['HVM_Boot_Params'] = ['order=dc']
    hvmVssd['HVM_Boot_Policy'] = 'BIOS order'
    hvmVssd['Platform'] = ['acpi=true','apic=true','pae=true']

    # RASD to specify processor allocation for the VM
    # Processor RASD
    procRasd = CIMInstance('CIM_ResourceAllocationSettingData')
    procRasd['ResourceType'] = pywbem.Uint16(3)
    procRasd['VirtualQuantity'] = pywbem.Uint64(1)
    procRasd['AllocationUnits'] = 'count'

    # memory RASD to specify memory allocation settings for a VM
    memRasd = CIMInstance('Xen_MemorySettingData')
    memRasd['ResourceType'] = pywbem.Uint16(4)
    memRasd['VirtualQuantity'] = pywbem.Uint64(512)
    memRasd['AllocationUnits'] = 'byte*2^20'

    vsms = cimxmlConn.EnumerateInstanceNames("Xen_VirtualSystemManagementService")

    rasds = [procRasd, memRasd]
    hvmParams = {'SystemSettings': hvmVssd, 'ResourceSettings': rasds}

    newVM = None
    try:
        (rval, outParams) = cimxmlConn.InvokeMethod('DefineSystem', vsms[0], **hvmParams)

        if((rval != 4096) and (rval != 0)):
            raise xenrt.XRTError("Following error occured while invoking DefineSystem %s" % (rval))

        newVM = outParams['ResultingSystem']
        xenrt.sleep(10)

    except  Exception, e:
        raise xenrt.XRTError("Caught exception while invoking DefineSystem")
 class HealthState(object):
     Unknown = pywbem.Uint16(0)
     OK = pywbem.Uint16(5)
     Degraded_Warning = pywbem.Uint16(10)
     Minor_failure = pywbem.Uint16(15)
     Major_failure = pywbem.Uint16(20)
     Critical_failure = pywbem.Uint16(25)
     Non_recoverable_error = pywbem.Uint16(30)
 class HealthState(object):
     Unknown = pywbem.Uint16(0)
     OK = pywbem.Uint16(5)
     Degraded_Warning = pywbem.Uint16(10)
     Minor_failure = pywbem.Uint16(15)
     Major_failure = pywbem.Uint16(20)
     Critical_failure = pywbem.Uint16(25)
     Non_recoverable_error = pywbem.Uint16(30)
     # DMTF_Reserved = ..
     _reverse_map = {0: 'Unknown', 5: 'OK', 10: 'Degraded/Warning', 15: 'Minor failure', 20: 'Major failure', 25: 'Critical failure', 30: 'Non-recoverable error'}
Ejemplo n.º 19
0
    def get_instance(self, env, model, cim_class, stat=None):
        """Return an instance.

        Keyword arguments:
        env -- Provider Environment
        model -- A template of the CIMInstance to be returned.  The key 
            properties are set on this instance to correspond to the 
            instanceName that was requested.  The properties of the model
            are already filtered according to the PropertyList from the 
            request.
        cim_class -- The CIMClass

        Possible Errors:
        CIM_ERR_ACCESS_DENIED
        CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized 
            or otherwise incorrect parameters)
        CIM_ERR_NOT_FOUND (the CIM Class does exist, but the requested CIM 
            Instance does not exist in the specified namespace)
        CIM_ERR_FAILED (some other unspecified error occurred)

        """

        logger = env.get_logger()
        logger.log_debug('Entering %s.get_instance()' %
                         self.__class__.__name__)

        if stat is None:
            stat = os.lstat(model['name'])

        mode = stat[ST_MODE]
        model['Writeable'] = bool(mode & S_IWUSR)
        model['HealthState'] = pywbem.Uint16(5)
        #model['StatusDescriptions'] = # TODO (type = string[])
        model['Executable'] = bool(mode & S_IXUSR)
        model['Readable'] = bool(mode & S_IRUSR)
        #model['OperationalStatus'] = # TODO (type = uint16[])
        model['FileSize'] = pywbem.Uint64(stat[ST_SIZE])
        #model['CompressionMethod'] = # TODO (type = string)
        #model['Status'] = # TODO (type = string)
        #model['Description'] = # TODO (type = string)
        #model['InstallDate'] = # TODO (type = datetime)
        model['LastModified'] = pywbem.CIMDateTime.fromtimestamp(
            stat[ST_MTIME])
        #model['InUseCount'] = # TODO (type = uint64)
        #model['EncryptionMethod'] = # TODO (type = string)
        model['LastAccessed'] = pywbem.CIMDateTime.fromtimestamp(
            stat[ST_ATIME])
        model['ElementName'] = model['name'] == '/' and '/' or \
                    os.path.basename(model['name'])
        #model['Caption'] = # TODO (type = string)
        model['CreationDate'] = pywbem.CIMDateTime.fromtimestamp(
            stat[ST_CTIME])
        return model
 class EnabledDefault(object):
     Enabled = pywbem.Uint16(2)
     Disabled = pywbem.Uint16(3)
     Not_Applicable = pywbem.Uint16(5)
     Enabled_but_Offline = pywbem.Uint16(6)
     No_Default = pywbem.Uint16(7)
     Quiesce = pywbem.Uint16(9)
Ejemplo n.º 21
0
 class ClassType(object):
     Unknown = pywbem.Uint16(0)
     Other = pywbem.Uint16(1)
     CIM = pywbem.Uint16(2)
     DMI_Recast = pywbem.Uint16(200)
     SNMP_Recast = pywbem.Uint16(201)
     CMIP_Recast = pywbem.Uint16(202)
 class DetailedStatus(object):
     Not_Available = pywbem.Uint16(0)
     No_Additional_Information = pywbem.Uint16(1)
     Stressed = pywbem.Uint16(2)
     Predictive_Failure = pywbem.Uint16(3)
     Non_Recoverable_Error = pywbem.Uint16(4)
     Supporting_Entity_in_Error = pywbem.Uint16(5)
Ejemplo n.º 23
0
 class UpgradeCondition(object):
     Unknown = pywbem.Uint16(0)
     Other = pywbem.Uint16(1)
     Resides_off_device = pywbem.Uint16(2)
     Owner_Upgradeable = pywbem.Uint16(3)
     Factory_Upgradeable = pywbem.Uint16(4)
     Not_Upgradeable = pywbem.Uint16(5)
def getnum(num, datatype):
    try:
        result = {
            '8': pywbem.Uint8(num),
            '16': pywbem.Uint16(num),
            '32': pywbem.Uint32(num),
            '64': pywbem.Uint64(num)
        }
        result = result.get(datatype, num)
    except NameError:
        result = num

    return result
Ejemplo n.º 25
0
 def CreateInvalidBondedNetwork2(self):
     self.TestBegin()
     # one invalid pif is bonded with an valid pif
     rasd1 = CIMInstance('Xen_HostNetworkPortSettingData')
     rasd1['ResourceType'] = pywbem.Uint16(33)
     rasd1['Connection'] = ["eth11234", "eth1"]
     rasd1['VlanTag'] = pywbem.Uint64(2)
     rasds = [rasd1]
     result = 0
     bonded_network = self.__CreateNetwork(rasds)
     if bonded_network == None:
         result = 1
     self.TestEnd(result)
Ejemplo n.º 26
0
 def CreateInvalidBondedNetwork(self):
     self.TestBegin()
     # 2 invalid pifs (with the wrong interfaces specified) are bonded
     rasd1 = CIMInstance('Xen_NetworkPortSettingData')
     rasd1['ResourceType'] = pywbem.Uint16(33)
     rasd1['Connection'] = ["eth11234", "eth2345"]
     rasd1['VlanTag'] = pywbem.Uint64(2)
     rasds = [rasd1]
     result = 0
     bonded_network = self.__CreateNetwork(rasds)
     if bonded_network == None:
         result = 1
     self.TestEnd(result)
Ejemplo n.º 27
0
def start():
    tester = IntelWbemTester(IntelWbemTester.NAMESPACE_INTEL)
    processes = tester.connection.EnumerateInstances('Intel_BaseServer')
    process = processes[0]
    print("Value: ", process.items())
    process['LogLevel'] = pywbem.Uint16(0)
    process['LogMax'] = pywbem.Uint32(800)
    print("Process: ", process.items())
    tester.connection.ModifyInstance(process, PropertyList=['LogLevel','LogMax'])
    print("Modifying done")
    processes1 = tester.connection.EnumerateInstances('Intel_BaseServer')
    process1 = processes1[0]
    print("Modified LogMax: ", process1.items()) 
 class RecoveryAction(object):
     Unknown = pywbem.Uint16(0)
     Other = pywbem.Uint16(1)
     Do_Not_Continue = pywbem.Uint16(2)
     Continue_With_Next_Job = pywbem.Uint16(3)
     Re_run_Job = pywbem.Uint16(4)
     Run_Recovery_Job = pywbem.Uint16(5)
     _reverse_map = {0: 'Unknown', 1: 'Other', 2: 'Do Not Continue', 3: 'Continue With Next Job', 4: 'Re-run Job', 5: 'Run Recovery Job'}
Ejemplo n.º 29
0
    def set_instance(self, env, instance, previous_instance, cim_class):
        """Return a newly created or modified instance.

        Keyword arguments:
        env -- Provider Environment (pycimmb.ProviderEnvironment)
        instance -- The new pywbem.CIMInstance.  If modifying an existing 
            instance, the properties on this instance have been filtered by 
            the PropertyList from the request.
        previous_instance -- The previous pywbem.CIMInstance if modifying 
            an existing instance.  None if creating a new instance. 
        cim_class -- The pywbem.CIMClass

        Return the new instance.  The keys must be set on the new instance. 

        Possible Errors:
        CIM_ERR_ACCESS_DENIED
        CIM_ERR_NOT_SUPPORTED
        CIM_ERR_INVALID_PARAMETER (including missing, duplicate, unrecognized 
            or otherwise incorrect parameters)
        CIM_ERR_ALREADY_EXISTS (the CIM Instance already exists -- only 
            valid if previous_instance is None, indicating that the operation
            was CreateInstance)
        CIM_ERR_NOT_FOUND (the CIM Instance does not exist -- only valid 
            if previous_instance is not None, indicating that the operation
            was ModifyInstance)
        CIM_ERR_FAILED (some other unspecified error occurred)

        """

        logger = env.get_logger()
        logger.log_debug('Entering %s.set_instance()' \
                % self.__class__.__name__)

        if previous_instance is None:
            _PyFooInsts[model['TheKey']] = instance['TheValue']
        else:
            if 'TheValue' in instance:
                try:
                    _PyFooInsts[instance['TheKey']] = instance['TheValue']
                except KeyError:
                    raise pywbem.CIMError(pywbem.CIM_ERR_NOT_FOUND)
                ci = pywbem.CIMInstance('CIM_InstModification')
                ci['PreviousInstance'] = previous_instance
                ci['SourceInstance'] = instance
                ci['SourceInstanceModelPath'] = instance.path
                ci['IndicationIdentifier'] = 'PyTestInd:%s' % 'one'
                ci['IndicationTime'] = pywbem.CIMDateTime.now()
                ci['PerceivedSeverity'] = pywbem.Uint16(2)
                ch = env.get_cimom_handle()
                ch.export_indication(ci, 'root/cimv2')
        return instance
Ejemplo n.º 30
0
    def run(self):
        log = self.env.get_logger()
        log.log_debug('##### IndicationThread.run entered...')
        self.shuttingdown = False
        ch = self.env.get_cimom_handle()
        while not self.shuttingdown:
            # Acquire the lock on the condition variable before we wait on it
            self._cond.acquire()
            # We'll wait on the condition for 5 seconds. Then we'll
            # wake up and generate an indication
            l = self._cond.wait(5.0)
            self._cond.release()
            # If we're shutting down, just break out of this loop
            if self.shuttingdown:
                break

            self.count += 1

            ci = pywbem.CIMInstance('Py_TestAlert')
            ci['SystemName'] = self.sysname
            ci['MessageID'] = 'PyTestInd:%s' % self.count
            ci['Message'] = 'Hello. This is a python alert indication'
            ci['SystemCreationClassName'] = 'OMC_UnitaryComputerSystem'
            ci['EventID'] = str(self.count)
            ci['EventTime'] = pywbem.CIMDateTime.now()
            ci['AlertType'] = pywbem.Uint16(1)
            ci['Description'] = 'This is a test indication from the provider interface'
            ci['ProviderName'] = 'AlertIndication.py'
            ci['PerceivedSeverity'] = pywbem.Uint16(2)
            ci['OwningEntity'] = 'mine. mine. all mine'
            ci['RecommendedActions'] = ['Have fun', 'Ignore crap like this']
            ci['IndicationTime'] = pywbem.CIMDateTime.now()
            ci['IndicationIdentifier'] = 'Little redundant'
            log.log_debug('##### IndicationThread.run exporting indication')

            ch.export_indication(ci, 'root/cimv2')

        log.log_debug('##### IndicationThread.run returning')