UCMDB and UD Practitioners Forum (Previously CMS)
cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve CI information from SOAP API via Python

SOLVED
Go to solution
Highlighted
JamesNewman
Occasional Advisor

Retrieve CI information from SOAP API via Python

I'm trying to pull CI information from uCMDB via the SOAP/Web Services API using Python.

I can successfully return appropriate CIs, but I only seem to get the CI id, rather than any other properties.

My code;

 

import suds
from suds.client import Client
from suds.sudsobject import Property
from suds.transport.https import HttpAuthenticated

ucmdb = None

def connect(wsdl, username, password):
    global ucmdb
    credentials = dict(username=username, password=password)
    t = HttpAuthenticated(**credentials)
    ucmdb = Client(wsdl, cache=None, transport=t)

connect("http://ucmdbserver:8080/axis2/services/UcmdbService?wsdl", "username", "password")

cmdbContext = ucmdb.factory.create('ns17:CmdbContext')
cmdbContext.callerApplication = 'DoesThisMatter'

ucmdb.service.getCIsByType(cmdbContext, "digital_certificate")

 

This returns a list of CI information that looks like;

(reply){
    CIs =
        (CIs){
            CI[] =
                (CI){
                    ID = "d3ed06d7f193fd826ba63f5e29fbe07e"
                    type = "digital_certificate"
                    props = ""
                    },
                (CI){
                    ID = "ebed21cf9663d31ffe421d285a9f7edd"
                    type = "digital_certificate"
                    props = ""
                    },

        }
chunkInfo =
     (ChunkInfo){
        numberOfChunks = 0
        chunksKey =
    (ChunkKey){
        key1 = None
        key2 = None
        }
    }
}

 

What I'm having trouble with is actually getting all the properties of the CI, not just its ID.  If I can get all the properties that would be fine.  If I can limit the request to specfic properties that would be even better.  But even if I specify an additional attribute in the getCIsByType method, for example;

ucmdb.service.getCIsByType(cmdbContext=cmdbContext, type='digital_certificate', properties='Organization')

I don't get any additional properties, including Organization.

 

 

 

 

1 REPLY
JamesNewman
Occasional Advisor
Solution

Re: Retrieve CI information from SOAP API via Python

Future me will google this and then rather than scratch my head,  this is how I did it;

 

 

import suds
from suds.client import Client
from suds.sudsobject import Property
from suds.transport.https import HttpAuthenticated


t = HttpAuthenticated(username='username', password='password')
client = Client('http://ucmdbserver:8080/axis2/services/UcmdbService?wsdl', cache=None, transport=t)

cmdbContext = client.factory.create('ns17:CmdbContext')
cmdbContext.callerApplication = 'JimForTheWin'


propertieslist = client.factory.create('ns21:PropertiesList')
propertieslist.propertyName.extend(['actual_deletion_period',
'allow_ci_update',
'common_ame',
'container',
'create_time',
'create_on',
'created_by',
'deletion_candidate_period',
'description',
'display_label',
'enable_aging',
'global_id',
'is_candidate_for_deletion',
'is_self_signed',
'issuer',
'issuer_name',
'last_access_time',
'last_modified_time',
'name',
'note',
'organization',
'organizationunit',
'origin',
'serial_number',
'signature_algorithm',
'subject',
'type',
'updated_by',
'user_label',
'valid_to',
'version',
])


props = client.factory.create('ns21:CustomProperties')
props.propertiesList = propertieslist

response = client.service.getCIsByType(cmdbContext=cmdbContext, type='digital_certificate', properties=props)

//Add this to "OnDomLoad" event