Highlighted
Absent Member.. Absent Member..
Absent Member..
1092 views

Retrieve CI information from SOAP API via Python

Jump to solution

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.

 

 

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Retrieve CI information from SOAP API via Python

Jump to solution

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)

View solution in original post

0 Likes
1 Reply
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Retrieve CI information from SOAP API via Python

Jump to solution

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)

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.