Tutorial: Making and Testing a Schema Change in A&AI in Beijing Release

Tutorial: Making and Testing a Schema Change in A&AI in Beijing Release

  1. Set up a development environment as described in A&AI Developer Environment Setup - Updated for Beijing!

  2. This document will show editing schema files with Eclipse, but Eclipse is not required.

  3. In this example, we will add 2 new attributes to the cloud-region node type and a new node type called "new-widget" which will be a child node of "cloud-region"

  4. Adding a new attribute to "cloud-region"

  5. Open aai/aai-common, aai-schema/src/main/resources/oxm/aai_oxm_v11.xml



  6. Add the following attributes between "complexName" and "resourceVersion":

  7. Save the file, and rebuild the libraries and microservices:

    here's my example file: 

    1. Rebuild aai-common first:

    2. $ cd ~/LF/AAI/aai-common

    3. $ mvn versions:set -DnewVersion=0.0.1-TEST-SNAPSHOT

    4. $ mvn clean install
      Should result in BUILD SUCCESS

    5. $ cd ~/LF/AAI/resources

    6. $ mvn clean install -Daai.core.version=0.0.1-TEST-SNAPSHOT -Daai.schema.version=0.0.1-TEST-SNAPSHOT
      Should result in BUILD SUCCESS

    7. $ cd ~/LF/AAI/traversal
      mvn clean install -Daai.core.version=0.0.1-TEST-SNAPSHOT -Daai.schema.version=0.0.1-TEST-SNAPSHOT

    8. Should result in BUILD SUCCESS

  8. Run GenTester, using the target dir under aai-resources:

  9. Start the "resources" microservice

    1. Resources runs on port 8447.  Go to the resources directory
      $ cd ~/LF/AAI/resources

    2. Set the debug port to 9447
      $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9447,server=y,suspend=n"

    3. Start the microservice
      $ mvn -pl aai-resources -P runAjsc -Daai.core.version=0.0.1-TEST-SNAPSHOT -Daai.schema.version=0.0.1-TEST-SNAPSHOT

  10. Start the "traversal" microservice

    1. Traversal runs on port 8446.  Go to the traversal directory
      $ cd ~/LF/AAI/traversal

    2. Set the debug port to 9446
      $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9446,server=y,suspend=n"

    3. Start the microservice
      $ mvn -pl aai-traversal -PrunAjsc -Daai.core.version=0.0.1-TEST-SNAPSHOT -Daai.schema.version=0.0.1-TEST-SNAPSHOT
      Should see something like this: Traversal Microservice Started

  11. Get an example cloud-region object, postman: 

    You should see the new attributes on the example object, as highlighted in the red rectangle above

  12. Copy and paste the example object and PUT it to persist the new attributes.  Use this postman collection thru step 15

  13. Check the object by doing a GET: GET Cloud-Region (no depth param) in postman collection

  14. Add the depth parameter: GET Cloud-Region (depth = all) in postman collection



    1. This indicates that the schema has been updated with the new attributes and they are making it to the database

  15. Clear the cloud region and then delete it by using "Clear Cloud-Region" and "Delete Cloud-Region"

    1. note: you will need to perform a GET each time and update the resource version of the cloud-region in the XML payload for the clear, and do the GET again and update the resource-version QueryParam to perform
      the delete

  16. Run PUT Cloud-Region - missing attr.  This will try to PUT the object without the required attribute we defined in the schema, and the response will look like this:

  17. Adding a new node type.  First, add the container under the top-level inventory category.  Adding "newWidgets" to "Network" so the URI will be "aai/v11/network/new-widgets/new-widget/{new-widget-name}"



  18. Set up the "NewWidgets" java type:

  19. Set up the NewWidget java type:

  20. Save the file, and rebuild the libraries and microservices:

    here's my example file: 

    1. Rebuild aai-common first:

    2. $ cd ~/LF/AAI/aai-common

    3. $ mvn versions:set -DnewVersion=0.0.1-TEST-SNAPSHOT

    4. $ mvn clean install
      Should result in BUILD SUCCESS

    5. $ cd ~/LF/AAI/resources

    6. $ mvn clean install -Daai.core.version=0.0.1-TEST-SNAPSHOT -Daai.schema.version=0.0.1-TEST-SNAPSHOT
      Should result in BUILD SUCCESS

    7. $ cd ~/LF/AAI/traversal
      mvn clean install -Daai.core.version=0.0.1-TEST-SNAPSHOT -Daai.schema.version=0.0.1-TEST-SNAPSHOT

    8. Should result in BUILD SUCCESS

  21. Run GenTester, using the target dir under aai-resources:

  22. Start the "resources" microservice

    1. Resources runs on port 8447.  Go to the resources directory
      $ cd ~/LF/AAI/resources

    2. Set the debug port to 9447
      $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9447,server=y,suspend=n"

    3. Start the microservice
      $ mvn -pl aai-resources -P runAjsc -Daai.core.version=0.0.1-TEST-SNAPSHOT -Daai.schema.version=0.0.1-TEST-SNAPSHOT
      Should see something like this: Resources Microservice Started

  23. Start the "traversal" microservice

    1. Traversal runs on port 8446.  Go to the traversal directory
      $ cd ~/LF/AAI/traversal

    2. Set the debug port to 9446
      $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9447,server=y,suspend=n"

    3. Start the microservice
      $ mvn -pl aai-traversal -P runAjsc -Daai.core.version=0.0.1-TEST-SNAPSHOT -Daai.schema.version=0.0.1-TEST-SNAPSHOT
      Should see something like this: Traversal Microservice Started

  24. Get an example newWidget using "New Widget Example" (find these examples in this postman collection: )

  25. Copy the new widget and PUT it: (PUT New Widget)

  26. Success!  We have updated an existing object type and added a new object type.  Next, we will set up an edge between the CloudRegion and the NewWidget

  27. Open DbEdgeRules_v11.json
    File is aai-common/aai-core/src/main/resources/dbedgerules/DbEdgeRules_v11.json

  28. Add a new EdgeRule, allowing an edge between the CloudRegion and NewWidget:



  29. Save the file, and rebuild aai-common, resources, and traversal.  Start resources and traversal microservices.

  30. Create a cloud region with a relationship to the new-widget that was created earlier: (PUT Cloud-Region related to New-Widget)

  31. GET the new-widget object: (GET New Widget)



  32. Notice that when GETting the new-widget object it shows the relationship to the cloud-region.

    We have successfully modified the schema and edge rules to update an existing type, create a new type, and define an edge relationship which allows for a new-widget type to be connected to a cloud-region.