Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
  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/java/resources/oxm/aai_oxm_v11.xml
    Image Modified

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

    <xml-element java-attribute="complexName" name="complex-name" type="java.lang.String">
    <xml-properties>
    <xml-property name="description" value="complex name for cloud-region instance. NOTE - THIS FIELD IS NOT CORRECTLY POPULATED." />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="newAttributeForDemo" name="new-attribute-for-demo" required="true" type="java.lang.String">
    <xml-properties>
    <xml-property name="description" value="Example new attribute for cloud-region instance. " />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="numberAttributeForDemo" name="number-attribute-for-demo" required="true" type="java.lang.Integer">
    <xml-properties>
    <xml-property name="description" value="Example number attribute for cloud-region instance. " />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="resourceVersion" name="resource-version" type="java.lang.String">
    <xml-properties>
    <xml-property name="description" value="Used for optimistic concurrency. Must be empty on create, valid on update and delete." />
    </xml-properties>
    </xml-element>


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

    here's my example file: aai_oxm_v11.xml
    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 -o-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 -oShould result in BUILD SUCCESS

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

    $ cd ~/LF/AAI; java -DAJSC_HOME=/home/jimmy/LF/AAI/resources/aai-resources/target/swm/package/nix/dist_files/opt/app/aai-resources -DBUNDLECONFIG_DIR="bundleconfig" -cp aai-common/aai-core/target/aai-core-1.1.0-SNAPSHOT.jar:resources/aai-resources/target/aai-resources.jar:resources/aai-resources/target/userjars/* org.openecomp.aai.dbgen.GenTester

    There will be lots of output, you should see the following which indicates that resources has picked up the new OXM file:

    Creating PropertyKey: [new-attribute-for-demo], [String], [SINGLE]

    [DEV: 2017-Jul-27 13:07:26,856][INFO ][main ]Creating PropertyKey: [new-attribute-for-demo], [String], [SINGLE]
    No index added for PropertyKey: [new-attribute-for-demo]
    [DEV: 2017-Jul-27 13:07:27,902][INFO ][main ]No index added for PropertyKey: [new-attribute-for-demo]
    Creating PropertyKey: [number-attribute-for-demo], [Integer], [SINGLE]
    [DEV: 2017-Jul-27 13:07:27,904][INFO ][main ]Creating PropertyKey: [number-attribute-for-demo], [Integer], [SINGLE]
    No index added for PropertyKey: [number-attribute-for-demo]
    [DEV: 2017-Jul-27 13:07:27,912][INFO ][main ]No index added for PropertyKey: [number-attribute-for-demo]
  8. Start the "resources" microservice
  9. Resources runs on port 8446.  Go to the resources directory
    $ cd ~/LF/AAI/resources
  10. 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"
  11. Start the microservice
    $ mvn -P runAjsc
    Start the "traversal" microservice
  12. Traversal runs on port 8447.  Go to the traversal directory
    $ cd ~/LF/AAI/traversal
  13. 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"
  14. Start the microservice
    $ mvn -P runAjsc 
    Should see something like this: 2017-07-26 12:46:35.524:INFO:oejs.Server:com.att.ajsc.runner.Runner.main(): Started @25827ms
  15. Get an example cloud-region object, postman: Cloud-Region Example.postman_collection.json

    Image Removed

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

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

    Image Removed

    1. Check the object by doing a GET: GET Cloud-Region (no depth param) in postman collection
      Image Removed
    1. Daai.core.version=0.0.1-TEST-SNAPSHOT -Daai.schema.version=0.0.1-TEST-SNAPSHOT
    2. Should result in BUILD SUCCESS

      Note

      From https://lists.onap.org/g/onap-discuss/message/11507:


      The html and yaml gets automatically generated when you run install but the xsd was never part of the autogenerate maven profile.
      For Beijing and earlier release, we never auto generated it. In order to run the generation of the xsd, here is the command:

      cd ~/LF/aai/aai-common/aai-core/
      mvn -PgenerateXsd install -DskipTests -Dgendoc.version=v14

      I have actually noticed that recently within the internal release and realized that it makes sense for xsd to be also auto generated.
      I am not sure why it was left out from the autogenerate profile but when developing the model driven feature, I ensured that the auto generate also does xsd generation.
      Once that feature gets delivered to Casablanca, there wouldn't be a need to run the profile manually.



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

    $ cd ~/LF/AAI/graphadmin;

    java -DAJSC_HOME=. -DBUNDLECONFIG_DIR=src/main/resources/ -Dloader.main=org.onap.aai.schema.GenTester -Dloader.path=./src/main/resources -Dschema.ingest.file=src/main/resources/application.properties -jar target/aai-graphadmin-*.jar

    You should see the following output:

        ---- NOTE --- about to open graph (takes a little while)--------;

    -- loading schema into JanusGraph

    -- loading schema into JanusGraph

    -- Loading new schema elements into JanusGraph --

    -- graph commit

    -- graph shutdown


    You can check the logs to see if the graph elements were created successfully and grep for your property
    cd logs/createDBSchema/;
    grep 'complex-name' metrics.log

    2018-12-06T04:43:18.061+0000|2018-12-06T04:43:42.960+0000|449b8583-54c1-42bf-8ada-5b75c52d7a13||main      ||AAI|AAI-TOOLS|AAI|main|COMPLETE|0|||INFO||127.0.1.1|24899|localhost||org.onap.a
    ai.dbgen.SchemaGenerator||||||||co=DBGenTester:Creating PropertyKey: [complex-name], [String], [SINGLE]
    2018-12-06T04:43:18.061+0000|2018-12-06T04:43:42.960+0000|449b8583-54c1-42bf-8ada-5b75c52d7a13||main      ||AAI|AAI-TOOLS|AAI|main|COMPLETE|0|||INFO||127.0.1.1|24899|localhost||org.onap.a
    ai.dbgen.SchemaGenerator||||||||co=DBGenTester:Add index for PropertyKey: [complex-name]


  18. 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

  19. 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

  20. Get an example cloud-region object, postman: Cloud-Region Example.postman_collection.json

    Image Added

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

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

    Image Added

  22. Check the object by doing a GET: GET Cloud-Region (no depth param) in postman collection
    Image Added
  23. Add the depth parameter: GET Cloud-Region (depth = all) in postman collection

    Image Added

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

  24. 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

  25. 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:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Fault>
    <requestError>
    <serviceException>
    <messageId>SVC3000</messageId>
    <text>Invalid input performing %1 on %2 (msg=%3) (ec=%4)</text>
    <variables>
    <variable>PUT</variable>
    <variable>v11/cloud-infrastructure/cloud-regions/cloud-region/example-cloud-owner-val-44086/example-cloud-region-id-val-67393</variable>
    <variable>Invalid input performing %1 on %2:Missing required property: new-attribute-for-demo</variable>
    <variable>ERR.5.2.3000</variable>
    </variables>
    </serviceException>
    </requestError>
    </Fault>


  26. 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}"

    <java-type name="Network">
    <xml-properties>
    <xml-property name="description" value="Namespace for network inventory resources." />
    </xml-properties>
    <xml-root-element name="network" />
    <java-attributes>
    <xml-element java-attribute="logicalLinks" name="logical-links" type="inventory.aai.onap.org.v11.LogicalLinks" />
    <xml-element java-attribute="sitePairSets" name="site-pair-sets" type="inventory.aai.onap.org.v11.SitePairSets" />
    <xml-element java-attribute="vpnBindings" name="vpn-bindings" type="inventory.aai.onap.org.v11.VpnBindings" />
    <xml-element java-attribute="vplsPes" name="vpls-pes" type="inventory.aai.onap.org.v11.VplsPes" />
    <xml-element java-attribute="multicastConfigurations" name="multicast-configurations" type="inventory.aai.onap.org.v11.MulticastConfigurations" />
    <xml-element java-attribute="vces" name="vces" type="inventory.aai.onap.org.v11.Vces" />
    <xml-element java-attribute="vpes" name="vpes" type="inventory.aai.onap.org.v11.Vpes" />
    <xml-element java-attribute="vnfcs" name="vnfcs" type="inventory.aai.onap.org.v11.Vnfcs" />
    <xml-element java-attribute="l3Networks" name="l3-networks" type="inventory.aai.onap.org.v11.L3Networks" />
    <xml-element java-attribute="networkPolicies" name="network-policies" type="inventory.aai.onap.org.v11.NetworkPolicies" />
    <xml-element java-attribute="genericVnfs" name="generic-vnfs" type="inventory.aai.onap.org.v11.GenericVnfs" />
    <xml-element java-attribute="lagLinks" name="lag-links" type="inventory.aai.onap.org.v11.LagLinks" />
    <xml-element java-attribute="newvces" name="newvces" type="inventory.aai.onap.org.v11.Newvces" />
    <xml-element java-attribute="pnfs" name="pnfs" type="inventory.aai.onap.org.v11.Pnfs" />
    <xml-element java-attribute="physicalLinks" name="physical-links" type="inventory.aai.onap.org.v11.PhysicalLinks" />
    <xml-element java-attribute="newWidgets" name="new-widgets" type="inventory.aai.onap.org.v11.NewWidgets" />
    <xml-element java-attribute="ipsecConfigurations" name="ipsec-configurations" type="inventory.aai.onap.org.v11.IpsecConfigurations" />
    <xml-element java-attribute="routeTableReferences" name="route-table-references" type="inventory.aai.onap.org.v11.RouteTableReferences" />
    <xml-element java-attribute="instanceGroups" name="instance-groups" type="inventory.aai.onap.org.v11.InstanceGroups" />
    <xml-element java-attribute="zones" name="zones" type="inventory.aai.onap.org.v11.Zones" />
    </java-attributes>
    </java-type>



  27. Set up the "NewWidgets" java type:

    <java-type name="NewWidgets">
    <xml-properties>
    <xml-property name="description" value="Collection of new Widgets" />
    </xml-properties>
    <xml-root-element name="new-widgets" />
    <java-attributes>
    <xml-element container-type="java.util.ArrayList" java-attribute="newWidget" name="new-widget" type="inventory.aai.onap.org.v11.NewWidget" />
    </java-attributes>
    </java-type>


  28. Set up the NewWidget java type:

    <java-type name="NewWidget">
    <xml-root-element name="new-widget

    Add the depth parameter: GET Cloud-Region (depth = all) in postman collection
    Image Removed
    This indicates that the schema has been updated with the new attributes and they are making it to the database
    Clear the cloud region and then delete it by using "Clear Cloud-Region" and "Delete Cloud-Region"
    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
    Run PUT Cloud-Region - missing attr.  This will try to PUT the object without the required attribute we defined in the schema, and the respoonse will look like this:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Fault>
    <requestError>
    <serviceException>
    <messageId>SVC3000</messageId>
    <text>Invalid input performing %1 on %2 (msg=%3) (ec=%4)</text>
    <variables>
    <variable>PUT</variable>
    <variable>v11/cloud-infrastructure/cloud-regions/cloud-region/example-cloud-owner-val-44086/example-cloud-region-id-val-67393</variable>
    <variable>Invalid input performing %1 on %2:Missing required property: new-attribute-for-demo</variable>
    <variable>ERR.5.2.3000</variable>
    </variables>
    </serviceException>
    </requestError>
    </Fault>

    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"

    <java-type name="Network">
    <xml-properties>
    <xml-property name="description" value="Namespace for network inventory resources." />
    </xml-properties>
    <xml-root-element name="network" />
    <java-attributes>
    <xml-element java-attribute="logicalLinksnewWidgetName" name="logical-linksnew-widget-name" required="true" type="inventory.aai.onap.org.v11.LogicalLinks" /java.lang.String" xml-key="true">
    <xml-element java-attribute="sitePairSets" properties>
    <xml-property name="site-pair-sets" typedescription" value="inventorye.aai.onap.org.v11.SitePairSets" />g.,awesome-new-widget, terrific-new-widget" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="vpnBindingsnewWidgetType" name="vpn-bindingsnew-widget-type" required="true" type="inventoryjava.aai.onap.org.v11.VpnBindings" /lang.String">
    <xml-element java-attribute="vplsPes" properties>
    <xml-property name="vpls-pesdescription" typevalue="inventory.aai.onap.org.v11.VplsPes" />Type of new Widget, e.g., fantastic, amazing" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="multicastConfigurationsresourceVersion" name="multicastresource-configurationsversion" type="inventoryjava.aai.onap.org.v11.MulticastConfigurations" /lang.String">
    <xml-element java-attribute="vces" properties>
    <xml-property name="vcesdescription" typevalue="inventory.aai.onap.org.v11.VcesUsed for optimistic concurrency. Must be empty on create, valid on update and delete." />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="vpesmodelInvariantId" name="vpesmodel-invariant-id" type="inventoryjava.aai.onap.org.v11.Vpes" /lang.String">
    <xml-element java-attribute="vnfcs" properties>
    <xml-property name="vnfcsdescription" type="inventory.aai.onap.org.v11.Vnfcsvalue="the ASDC model id for this resource or service model." />
    <xml-element java-attributeproperty name="visibility" value="l3Networks" deployment" />
    <xml-property name="l3-networksrequires" type="inventory.aai.onap.org.v11.L3Networksvalue="model-version-id" />
    <xml-element java-attributeproperty name="networkPoliciesdbAlias" namevalue="network-policies" type="inventory.aai.onap.org.v11.NetworkPolicies" />model-invariant-id-local" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="genericVnfsmodelVersionId" name="genericmodel-version-vnfsid" type="inventoryjava.aai.onap.org.v11.GenericVnfs" /lang.String">
    <xml-element java-attribute="lagLinks" properties>
    <xml-property name="lag-linksdescription" type="inventory.aai.onap.org.v11.LagLinksvalue="the ASDC model version for this resource or service model." />
    <xml-element java-attribute="newvces" property name="newvcesvisibility" typevalue="inventory.aai.onap.org.v11.Newvcesdeployment" />
    <xml-element java-attribute="pnfs" property name="pnfsrequires" type="inventory.aai.onap.org.v11.Pnfsvalue="model-invariant-id" />
    <xml-element java-attribute="physicalLinks" -property name="physical-linksdbAlias" type="inventory.aai.onap.org.v11.PhysicalLinksvalue="model-version-id-local" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="newWidgetsnewWidgetId" name="new-widgetswidget-id" type="inventoryjava.aai.onap.org.v11.NewWidgets" /lang.String">
    <xml-element java-attribute="ipsecConfigurations" properties>
    <xml-property name="ipsec-configurationsdescription" typevalue="inventory.aai.onap.org.v11.IpsecConfigurationsID of the newWidget" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="routeTableReferencesrelationshipList" name="routerelationship-table-referenceslist" type="inventory.aai.onap.org.v11.RouteTableReferencesRelationshipList" />
    </java-attributes>
    <xml-element java-attribute="instanceGroups" properties>
    <xml-property name="instance-groupsdescription" typevalue="inventory.aai.onap.org.v11.InstanceGroupsNew widgets are the best widgets. Our new widgets are really, really great."/>
    <xml-element java-attribute="zones" property name="zonesindexedProps" type="inventory.aai.onap.org.v11.Zonesvalue="new-widget-id,new-widget-name,model-invariant-id,model-version-id" />
    </java-attributes>
    </java-type>

    Set up the "NewWidgets" java type:

    <java-type name="NewWidgets"<xml-property name="uniqueProps" value="new-widget-id" />
    <xml-properties>
    <xml-property name="descriptioncontainer" value="Collection of new Widgets-widgets" />
    </xml-properties>
    <xml-root-element property name="new-widgetsnamespace" value="network" />
    <java-attributes>
    <xml-element container-typeproperty name="java.util.ArrayList" java-attribute="newWidget" name="new-widget" type="inventory.aai.onap.org.v11.NewWidget" searchable" value="new-widget-name,new-widget-id" />
    </javaxml-attributes>properties>
    </java-type>

    Set up the NewWidget java type:

    <java-type name="NewWidget">
    <xml-root-element name="new-widget" />
    <java-attributes>
    <xml-element java-attribute="newWidgetName" name="new-widget-name" required="true" type="java.lang.String" xml-key="true">
    <xml-properties>
    <xml-property name="description" value="e.g.,awesome-new-widget, terrific-new-widget" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="newWidgetType" name="new-widget-type" required="true" type="java.lang.String">
    <xml-properties>
    <xml-property name="description" value="Type of new Widget, e.g., fantastic, amazing" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="resourceVersion" name="resource-version" type="java.lang.String">
    <xml-properties>
    <xml-property name="description" value="Used for optimistic concurrency. Must be empty on create, valid on update and delete." />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="modelInvariantId" name="model-invariant-id" type="java.lang.String">
    <xml-properties>
    <xml-property name="description" value="the ASDC model id for this resource or service model." />
    <xml-property name="visibility" value="deployment" />
    <xml-property name="requires" value="model-version-id" />
    <xml-property name="dbAlias" value="model-invariant-id-local" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="modelVersionId" name="model-version-id" type="java.lang.String">
    <xml-properties>
    <xml-property name="description" value="the ASDC model version for this resource or service model." />
    <xml-property name="visibility" value="deployment" />
    <xml-property name="requires" value="model-invariant-id" />
    <xml-property name="dbAlias" value="model-version-id-local" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="newWidgetId" name="new-widget-id" type="java.lang.String">
    <xml-properties>
    <xml-property name="description" value="ID of the newWidget" />
    </xml-properties>
    </xml-element>
    <xml-element java-attribute="relationshipList" name="relationship-list" type="inventory.aai.onap.org.v11.RelationshipList" />
    </java-attributes>
    <xml-properties>
    <xml-property name="description" value="New widgets are the best widgets. Our new widgets are really, really great."/>
    <xml-property name="indexedProps" value="new-widget-id,new-widget-name,model-invariant-id,model-version-id" />
    <xml-property name="uniqueProps" value="new-widget-id" />
    <xml-property name="container" value="new-widgets" />
    <xml-property name="namespace" value="network" />
    <xml-property name="searchable" value="new-widget-name,new-widget-id" />
    </xml-properties>
    </java-type>

    Save the file, and rebuild the libraries and microservices:

    here's my example file: aai_oxm_v11.xml
  29. Rebuild aai-common first:
  30. $ cd ~/LF/AAI/aai-common
  31. $ mvn clean install
    Should result in BUILD SUCCESS
  32. $ cd ~/LF/AAI/resources
  33. $ mvn clean install -o
    Should result in BUILD SUCCESS
  34. $ cd ~/LF/AAI/traversal
    mvn clean install -o
  35. Should result in BUILD SUCCESS

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

    $ cd ~/LF/AAI; java -DAJSC_HOME=/home/jimmy/LF/AAI/resources/aai-resources/target/swm/package/nix/dist_files/opt/app/aai-resources -DBUNDLECONFIG_DIR="bundleconfig" -cp aai-common/aai-core/target/aai-core-1.1.0-SNAPSHOT.jar:resources/aai-resources/target/aai-resources.jar:resources/aai-resources/target/userjars/* org.openecomp.aai.dbgen.GenTester

    There will be lots of output, you should see the following which indicates that resources has picked up the new OXM file:

  36. Start the "resources" microservice
  37. Resources runs on port 8446.  Go to the resources directory
    $ cd ~/LF/AAI/resources
  38. 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"
  39. Start the microservice
    $ mvn -P runAjsc
    Start the "traversal" microservice
  40. Traversal runs on port 8447.  Go to the traversal directory
    $ cd ~/LF/AAI/traversal
  41. 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"
  42. Start the microservice
    $ mvn -P runAjsc 
    Should see something like this: 2017-07-26 12:46:35.524:INFO:oejs.Server:com.att.ajsc.runner.Runner.main(): Started @25827ms
  43. Get an example newWidget  (find these example in this postman collection: New-Widget Example.postman_collection.json
    Image Removed
  44. Copy the new widget and PUT it: 
    Image RemovedSuccess!  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
  45. Open DbEdgeRules.java (this is currently the way to change edge rules, but will be changing to updating a json file in the very near future)
    File is aai-common/aai-core/src/main/java/org/openecomp/aai/dbmodel/DbEdgeRules.java
    Image Removed
  46. Add a new EdgeRule, allowing an edge between the CloudRegion and NewWidget:

    public static final Multimap<String, String> EdgeRules = new ImmutableSetMultimap.Builder<String, String>()
    .putAll("availability-zone|complex",
    "groupsResourcesIn,OUT,Many2Many,false,false,false,false")
    .putAll("availability-zone|service-capability",
    "supportsServiceCapability,OUT,Many2Many,false,false,false,false")
    .putAll("cloud-region|complex",
    "locatedIn,OUT,Many2One,false,false,false,false")
    .putAll("cloud-region|l3-network",
    "uses,OUT,Many2Many,false,false,false,false")
    .putAll("cloud-region|tenant",
    "has,OUT,One2Many,true,false,false,reverse")
    .putAll("cloud-region|new-widget",
    "has,OUT,One2Many,true,false,false,false")

    This means cloud-region connects to new-widget, edge label is "has", it's an OUT edge, one cloud region can have multiple edges to new-widgets,

    multiplicity rule is true, cloud-region is not parent to new-widget, has-del-target is false, and it is not SVC_INFRA typeSave the file, and rebuild aai-common, resources, and traversal.  Start resources and traversal microservices.

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

    here's my example file: aai_oxm_v11.xml
    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

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

    $ cd ~/LF/AAI/graphadmin;

    java -DAJSC_HOME=. -DBUNDLECONFIG_DIR=src/main/resources/ -Dloader.main=org.onap.aai.schema.GenTester -Dloader.path=./src/main/resources -Dschema.ingest.file=src/main/resources/application.properties -jar target/aai-graphadmin-*.jar

    You should see the following output:

        ---- NOTE --- about to open graph (takes a little while)--------;

    -- loading schema into JanusGraph

    -- loading schema into JanusGraph

    -- Loading new schema elements into JanusGraph --

    -- graph commit

    -- graph shutdown

    You can check the logs to see if the graph elements were created successfully and grep for your propertycd logs/createDBSchema/;
    grep 'new-widget-name' metrics.log

    Creating PropertyKey: [new-widget-name], [String], [SINGLE]
    [DEV: 2017-Jul-28 08:44:12,287][INFO ][main ]Creating PropertyKey: [new-widget-name], [String], [SINGLE]
    Add index for PropertyKey: [new-widget-name]
    [DEV: 2017-Jul-28 08:44:12,289][INFO ][main ]Add index for PropertyKey: [new-widget-name]
    Creating PropertyKey: [new-widget-type], [String], [SINGLE]
    [DEV: 2017-Jul-28 08:44:12,291][INFO ][main ]Creating PropertyKey: [new-widget-type], [String], [SINGLE]
    No index added for PropertyKey: [new-widget-type]
    [DEV: 2017-Jul-28 08:44:12,501][INFO ][main ]No index added for PropertyKey: [new-widget-type]
    PropertyKey [resource-version] already existed in the DB.
    PropertyKey [model-invariant-id] already existed in the DB.
    PropertyKey [model-version-id] already existed in the DB.
    Creating PropertyKey: [new-widget-id], [String], [SINGLE]
    [DEV: 2017-Jul-28 08:44:12,501][INFO ][main ]Creating PropertyKey: [new-widget-id], [String], [SINGLE]


  49. 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

  50. 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
  51. Get an example newWidget using "New Widget Example" (find these examples in this postman collection: New-Widget Example.postman_collection.json)
    Image Added
  52. Copy the new widget and PUT it: (PUT New Widget)

    Image Added
  53. 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

  54. Open DbEdgeRules_v11.json
    File is aai-common/aai-core/src/main/resources/dbedgerules/DbEdgeRules_v11.json
    Image Added
  55. Add a new EdgeRule, allowing an edge between the CloudRegion and NewWidget:

            {

                "from": "cloud-region",

                "to": "tenant",

                "label": "has",

                "direction": "OUT",

                "multiplicity": "One2Many",

                "contains-other-v": "${direction}",

                "delete-other-v": "NONE",

                "SVC-INFRA": "!${direction}",

                "prevent-delete": "${direction}"

            },

            {

                "from": "cloud-region",

                "to": "new-widget",

                "label": "has",

                "direction": "OUT",

                "multiplicity": "One2Many",

                "contains-other-v": "NONE",

                "delete-other-v": "NONE",

                "SVC-INFRA": "NONE",

                "prevent-delete": "NONE"

            },


    This means cloud-region connects to new-widget, edge label is "has", it's an OUT edge, one cloud region can have multiple edges to new-widgets,

    cloud-region does not contain new-widget, new-widget will not be deleted when the cloud-region connected to it is deleted, it is not SVC_INFRA type, and having an edge to a new-widget will not prevent deletion of the cloud-region.



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

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

    Image Added
  58. GET the new-widget object: (GET New Widget)

    Image Added

  59. 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.  


Attachments

Attachments