Esempio n. 1
0
    def cim_method_getdate(self, env, object_name, method, param_datestr):
        logger = env.get_logger()
        logger.log_debug('Entering %s.cim_method_getdate()' \
                % self.__class__.__name__)

        out_params = {}
        rval = pywbem.CIMDateTime(param_datestr)
        return (rval, out_params)
Esempio n. 2
0
    def get_instance(self, env, model):
        """Return an instance.

        Keyword arguments:
        env -- Provider Environment (pycimmb.ProviderEnvironment)
        model -- A template of the pywbem.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.  Only properties present in the model need to be
            given values.  If you prefer, you can set all of the 
            values, and the instance will be filtered for you. 

        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__)

        jobId, logEntryTimestamp = self.fromInstanceID(model['InstanceID'])
        concreteJob = concrete_job.AnyJob.load(jobId)
        cuJob = concreteJob.concreteJob
        logEntries = [
            x for x in cuJob.logs.enumerate()
            if x.timestamp == logEntryTimestamp
        ]
        if not logEntries:
            return
        logEntry = logEntries[0]

        created = utils.Time.format(logEntryTimestamp)

        #model['Caption'] = '' # TODO
        model['CreationTimeStamp'] = pywbem.CIMDateTime(created)
        #model['Description'] = '' # TODO
        #model['ElementName'] = '' # TODO
        #model['Generation'] = pywbem.Uint64() # TODO
        #model['Locale'] = '' # TODO
        model['LogInstanceID'] = self.createLogInstanceID(jobId)
        #model['LogName'] = '' # TODO
        #model['Message'] = logEntry.content
        #model['MessageArguments'] = [ logEntry.content ]
        #model['MessageID'] = '' # TODO
        #model['OwningEntity'] = '' # TODO
        model['PerceivedSeverity'] = self.Values.PerceivedSeverity.Information
        model['RecordData'] = logEntry.content
        model['RecordFormat'] = ''
        model['RecordID'] = model['InstanceID']
        return model
Esempio n. 3
0
    def cim_method_getdates(self, env, object_name, method, param_datestrs):

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

        out_params = {}
        elems = [pywbem.CIMDateTime(s) for s in param_datestrs]
        out_params['nelems'] = pywbem.Sint32(len(elems))
        out_params['elems'] = elems
        rval = True
        return (rval, out_params)
Esempio n. 4
0
    def test_getDates(self):
        dt = pywbem.CIMDateTime.now()
        s1 = str(dt)
        ra = [s1]
        dt = pywbem.CIMDateTime(pywbem.datetime.now() + \
                pywbem.timedelta(seconds=10))
        s2 = str(dt)
        ra.append(s2)
        dt = pywbem.CIMDateTime(pywbem.datetime.now() + \
                pywbem.timedelta(seconds=10))
        s3 = str(dt)
        ra.append(s3)

        rv, outs = self.conn.InvokeMethod('getDates',
                                          'TestMethod',
                                          datestrs=ra)
        self.assertTrue(rv)
        self.assertTrue(isinstance(rv, bool))
        self.assertEquals(outs['nelems'], len(ra))
        self.assertTrue(isinstance(outs['nelems'], pywbem.Sint32))

        for i in range(0, len(ra)):
            self.assertTrue(isinstance(outs['elems'][i], pywbem.CIMDateTime))
            self.assertEquals(str(outs['elems'][i]), ra[i])
Esempio n. 5
0
def set_sample_interval(ecom_conn, array_serial, sample_interval):

    array = get_array_instancename(ecom_conn, array_serial)

    SampleInterval = ecom_conn.Associators(
        array, ResultClass="CIM_StatisticsCollection",
        PropertyList=["SampleInterval"])

    new_interval = timedelta(minutes=sample_interval)

    SampleInterval[0]["SampleInterval"] = pywbem.CIMDateTime(new_interval)

    ecom_conn.ModifyInstance(SampleInterval[0],
                             PropertyList=["SampleInterval"])

    return
    def get_instance(self, env, model, withCleanup=True):
        """Return an instance.

        Keyword arguments:
        env -- Provider Environment (pycimmb.ProviderEnvironment)
        model -- A template of the pywbem.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.  Only properties present in the model need to be
            given values.  If you prefer, you can set all of the 
            values, and the instance will be filtered for you. 

        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 withCleanup:
            self._populateTroveCache()

        troveId = model['InstanceID']

        nvf, isInstalled = self._conarySoftwareMap[troveId]

        modelName = modelDescription = nvf[0]
        if isInstalled is self.installationService.SystemModelType:
            # We use the system model's file mtime as the version timestamp
            verTimestamp = int(nvf[2])
            operatingStatus = self.Values.OperatingStatus.In_Service
            productLabel = self.installationService.SystemModelElementName
            versionString = nvf[1]
        else:
            # Our timestamps are 32-bit, so we store the 2 MSB as buildNumber
            # and the 2LSB as the revision number.
            verTimestamp = int(nvf[1].trailingRevision().getTimestamp())
            operatingStatus = ((isInstalled
                                and self.Values.OperatingStatus.In_Service)
                               or self.Values.OperatingStatus.Dormant)

            productLabel = str(nvf[1].trailingLabel())
            versionString = "%s[%s]" % (nvf[1].freeze(), str(nvf[2]))

        buildNumber = verTimestamp & 0xFFFF
        revisionNumber = (verTimestamp & 0xFFFF0000) >> 16
        vendorURL = 'http://www.rpath.org/rbuilder'

        model['BuildNumber'] = pywbem.Uint16(buildNumber)
        #model['Caption'] = '' # TODO
        #model['ClassificationDescriptions'] = ['',] # TODO
        #model['Classifications'] = [self.Values.Classifications.<VAL>,] # TODO
        #model['CommunicationStatus'] = self.Values.CommunicationStatus.<VAL> # TODO
        model['Description'] = modelDescription
        #model['DetailedStatus'] = self.Values.DetailedStatus.<VAL> # TODO
        model['ElementName'] = modelName
        #model['ExtendedResourceType'] = self.Values.ExtendedResourceType.<VAL> # TODO
        #model['Generation'] = pywbem.Uint64() # TODO
        model['HealthState'] = self.Values.HealthState.OK
        # XXX Some of these have hard-coded values
        model['IdentityInfoType'] = [
            'VMware-VAMI:VendorUUID', 'VMware-VAMI:ProductRID',
            'VMware-VAMI:VendorURL', 'VMware-VAMI:ProductURL',
            'VMware-VAMI:SupportURL', 'VMware-VAMI:UpdateInfo'
        ]
        model['IdentityInfoValue'] = [
            'com.rpath', productLabel, vendorURL,
            'http://www.rpath.org/project/remote-update', vendorURL, ''
        ]
        #model['InstallDate'] = pywbem.CIMDateTime() # TODO
        model['IsEntity'] = True
        model['IsLargeBuildNumber'] = True
        #model['Languages'] = ['',] # TODO
        model['LargeBuildNumber'] = pywbem.Uint64(verTimestamp)
        model['MajorVersion'] = pywbem.Uint16(0)
        model['Manufacturer'] = 'rPath, Inc.'
        #model['MinExtendedResourceTypeBuildNumber'] = pywbem.Uint16() # TODO
        #model['MinExtendedResourceTypeMajorVersion'] = pywbem.Uint16() # TODO
        #model['MinExtendedResourceTypeMinorVersion'] = pywbem.Uint16() # TODO
        #model['MinExtendedResourceTypeRevisionNumber'] = pywbem.Uint16() # TODO
        model['MinorVersion'] = pywbem.Uint16(0)
        model['Name'] = modelName
        model['OperatingStatus'] = operatingStatus
        #model['OperationalStatus'] = [self.Values.OperationalStatus.<VAL>,] # TODO
        #model['OtherExtendedResourceTypeDescription'] = '' # TODO
        model['PrimaryStatus'] = self.Values.PrimaryStatus.OK
        model['ReleaseDate'] = pywbem.CIMDateTime(
            utils.Time.format(verTimestamp))
        model['RevisionNumber'] = pywbem.Uint16(revisionNumber)
        #model['SerialNumber'] = '' # TODO
        #model['Status'] = self.Values.Status.<VAL> # TODO
        #model['StatusDescriptions'] = ['',] # TODO
        #model['TargetOperatingSystems'] = ['',] # TODO
        model['TargetOSTypes'] = [
            self.Values.TargetOSTypes.LINUX,
        ]
        #model['TargetTypes'] = ['',] # TODO
        model['VersionString'] = versionString
        if withCleanup:
            self._conarySoftwareMap.clear()
        return model