msiempy
msiempy copied to clipboard
Add datasource method should ensure it's well added
Describe
Like in the code snippet, the add()
method should call dsAddDataSourcesStatus
, make sure there is no error or raise an Exception if the Datasource were not added.
Only if special argument check_added=True
to keep compatibility.
** msiempy versions:**
- msiempy: 0.3.3
Additional context
if ds.get('client', None):
print("Adding Client Datasource: {}".format(ds))
resp = devtree.add_client(ds)
else:
print("Adding Datasource: {}".format(ds))
resp = devtree.add(ds)
if not resp:
print('Something went wrong, Datasource {} not added.')
continue
else:
# Wait for the add DS query to execuite ...
time.sleep(1)
ds_status = NitroSession().api_request('dsAddDataSourcesStatus', {"jobId": resp}, retry=0)
if not isinstance(ds_status, dict):
print('Something went wrong, Datasource {} not added.\n{}'.format(ds['name'], ds_status))
continue
while not ds_status['jobStatus'] == 'COMPLETE':
time.sleep(1)
ds_status = NitroSession().api_request('dsAddDataSourcesStatus', {"jobId": resp}, retry=0)
if len(ds_status['unsuccessfulDatasources'])>0:
print('Something went wrong, Datasource {} not added. {}'.format(ds['name'], ds_status['unsuccessfulDatasources'][0]))
continue
else:
ds_to_verify.append(ds['name'])
devtree.refresh()