pcoffey1
Contributor
Contributor

schema for vCBM 2.5.1 API - creating custom hierarchy from CSV

v2.5.1 removed from the GUI the ability to create a custom hierarchy by importing a CSV file -  must now be done through the API.  Any documentation on the schema for this?  code examples?  checked the API guide and the API_REF_2_5.

0 Kudos
5 Replies
dprabhakaran
Enthusiast
Enthusiast

pcoffery1,

  In the API reference guide, did you look into "Populate Hierarchy" API under Hierarchy management section? Is it not sufficient or what you are looking for?

Thanks

Diwakar

0 Kudos
pcoffey1
Contributor
Contributor

Hi - no, the documentation still references a CSV file but does not provide information on how that maps to the XML.  As far as I know, you can't get XML to "read" a CSV file....so i'm looking for the specific format of the XML needed to contain the contents of the CSV file. For example, it might look like.

<UniqueId>1</UniqueId>

 
<ChildName>pjc</ChildName>

 
<ParentID>01</ParentID>

 
<ChildEntityType>101</ChildEntityType>

This is obviously just a guess - but it illustrates the level of documentation about the API that i'm looking for.

0 Kudos
Lakshmi325
Enthusiast
Enthusiast

Hi,

Currently we support only CSV file for Populate Hierarchy API. you need to give CSV file only as input.

Please let us know if you need more information.

Thanks,

Lakshmi

0 Kudos
pcoffey1
Contributor
Contributor

This is exactly the problem.  In prior version of the CBM the ability to import via CSV file was provided through the UI....it has now been removed.  Documentation indicates use the API which is built on XML/XSD.  So HOW do you import/use a CSV file with the API?  the documentation doesn't give a clue other than provide the format of the CSV file which hasn't changed.  If you have a code snippet that shows how the populate hierarchy api call can be used to import or read a CSV file - that will solve this issue.

Thanks,

Pam

0 Kudos
Lakshmi325
Enthusiast
Enthusiast

Hi Pam,

Which client are you using to connect to the API ?. I used the apache http client and wrote a sample java program and i could able to populate the hierarchy from CSV file. you need the convert the given csv file to string format and send it in request. Please see below the code snippet.

//URL will be like https://10.112.58.103:443/vCenter-CB/api/hierarchy/41878/populate

PostMethod postMethod = new PostMethod(URL);

HttpClient client = new HttpClient();

             FileReader fr = new FileReader("HierarchyCSV.csv");

            BufferedReader br = new BufferedReader(fr);

            String s;

            StringBuffer sb = new StringBuffer();

            while((s=br.readLine())!=null)

            {

                sb.append(s);

                sb.append("\n");

            }

           

            postMethod.setRequestEntity(new StringRequestEntity(sb.toString(),null,null));

            client.executeMethod(postMethod);

The contents of the sample input CSV which i used is

#version 1.5.0

1,CB-folder,-1,101

2,CB-folder-1,1,101,vCenter Chargeback entity

3,Datacenters,1,0,10.112.58.52,group-d1,1

4,Datacenters,2,0,10.112.58.53,group-d1,2

Please let me know if you need more information.

Thanks,

Lakshmi

0 Kudos