aboutsummaryrefslogtreecommitdiffstats
path: root/docs/usage/usage/cds.rst
blob: b516c73fcf8114dc84ba4211e59a0b6c2d8d5336 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
CDS
###

Preparation for CDS tests
-------------------------

To enable CDS Enrichment in an ONAP Frankfurt environment the NodePort 30449
for the CDS Blueprint Processor API service needs to be opened

#. Check existing CDS Services:

   .. code-block:: sh

      ubuntu@control01:~$ kubectl get service -n onap|grep cds-blueprints-processor-http
      cds-blueprints-processor-http      ClusterIP  10.43.101.198   <none>  8080/TCP

#. Change NodePort to CDS cds-blueprints-processor-http

   Add the "nodePort" under "ports" section
   and change "type" from "ClusterIP" to "NodePort"

   .. code-block:: sh

      ubuntu@control01:~$ kubectl edit service cds-blueprints-processor-http -n onap

      apiVersion: v1
      kind: Service
      metadata:
        creationTimestamp: "2020-07-23T02:57:36Z"
        labels:
          app: cds-blueprints-processor
          chart: cds-blueprints-processor-6.0.0
          heritage: Tiller
          release: onap
        name: cds-blueprints-processor-http
        namespace: onap
        resourceVersion: "10256"
        selfLink: /api/v1/namespaces/onap/services/cds-blueprints-processor-http
        uid: 6f065c03-4563-4d64-b6f5-a8892226c909
      spec:
        clusterIP: 10.43.101.198
        ports:
        - name: blueprints-processor-http
          nodePort: 30449	-> add line
          port: 8080
          protocol: TCP
          targetPort: 8080
        selector:
          app: cds-blueprints-processor
          release: onap
        sessionAffinity: None
        type: ClusterIP -> change to NodePort
      status:
        loadBalancer: {}

#. Verify NodePort to CDS cds-blueprints-processor-http

   .. code-block:: sh

      ubuntu@control01:~$ kubectl get service -n onap|grep cds-blueprints-processor-http
      cds-blueprints-processor-http      NodePort    10.43.101.198   <none> 8080:30449/TCP

#. Load ModelType via Bootstrap

   .. code-block:: sh

      curl --location --request POST 'http://<k8s-host>:30449/api/v1/blueprint-model/bootstrap' \
      --header 'Content-Type: application/json' \
      --header 'Authorization: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==' \
      --data-raw '{
      "loadModelType" : true,
      "loadResourceDictionary" : false,
      "loadCBA" : false
      }'


Load blueprint from file
------------------------

.. code:: Python

    from onapsdk.cds import Blueprint
    blueprint = Blueprint.load_from_file("<< path to CBA file >>")

Enrich blueprint and save
-------------------------

.. code:: Python

    enriched_blueprint = blueprint.enrich()
    enriched_blueprint.save("<< path to dest file >>")

Publish blueprint
-----------------

.. code:: Python

    enriched_blueprint.publish()

Generate data dictionary from blueprint
---------------------------------------

The method to generate data dictionaries based on the blueprint mappings. As the result it returns a data dictionaries set
with valid structure, but some additional actions may be needed. Data dictionary input has to be filled by the user
if the type is neither "source-input" nor "source-default". Things, which are needed to be filled are marked by `<< FILL >>` mark.
If the blueprint you are using has only "source-input" or "source-default" input types, the generated data dictionary set is
ready to upload to CDS.

.. code:: Python

    generated_dd: DataDictionarySet = blueprint.get_data_dictionaries()
    generated_dd.save_to_file("<< path to dest file >>")

Load data dictionary set from file
----------------------------------

.. code:: Python

    from onapsdk.cds import DataDictionarySet
    dd_set = DataDictionarySet.load_from_file("<< path to dd file >>")

Upload data dictionary set
--------------------------

.. code:: Python

    dd_set.upload()

Retrieve Blueprint Models from CDS
--------------------------

#. All

.. code:: Python

    from onapsdk.cds import BlueprintModel
    all_blueprint_models = BlueprintModel.get_all()

#. Selected by id of Blueprint Model

.. code:: Python

    blueprint_model = BlueprintModel.get_by_id(blueprint_model_id='11111111-1111-1111-1111-111111111111')

#. Selected by name and version of Blueprint Model

.. code:: Python

    blueprint_model = BlueprintModel.get_by_name_and_version(blueprint_name='test_name', blueprint_version='1.0.0')

Delete Blueprint Model
--------------------------

.. code:: Python

    blueprint_model.delete()

Download Blueprint Model
--------------------------

.. code:: Python

    blueprint_model.save(dst_file_path='/tmp/blueprint.zip')


Get Blueprint object for Blueprint Model
--------------------------

After that, all operation for blueprint object, like execute blueprint workflow etc. can be executed.

.. code:: Python

    blueprint = blueprint_model.get_blueprint()