Docs: Move RTP to INF, make sure most of the O-Cloud word change to INF O2 service
[pti/o2.git] / docs / user-guide.rst
1 O-Cloud O2 Service User Guide
2 =============================
3
4 This guide will introduce the process that make O2 interface work with
5 SMO.
6
7 -  Assume you have an O-Cloud O2 environment
8
9    .. code:: bash
10
11       export OAM_IP=<INF_OAM_IP>
12
13 -  Discover O-Cloud inventory
14
15    -  O-Cloud auto discovery
16
17       After you installed the O-Cloud service, it will automatically
18       discover the INF through the parameters that you give from the
19       “*o2service-override.yaml*”
20
21       Below command can get the O-Cloud information
22
23       .. code:: shell
24
25          curl -X 'GET' \
26            "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/" \
27            -H 'accept: application/json'
28
29    -  Resource pool
30
31       One O-Cloud have one resource pool, all the resources that belong
32       to this O-Cloud will be organized into this resource pool
33
34       Get the resource pool information through this interface
35
36       .. code:: shell
37
38          curl -X 'GET' \
39            "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/resourcePools" \
40            -H 'accept: application/json'
41
42          # export resource pool id
43          export resourcePoolId=`curl -X 'GET'   "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/resourcePools"   -H 'accept: application/json' -H 'X-Fields: resourcePoolId' 2>/dev/null | jq .[].resourcePoolId | xargs echo`
44
45          echo ${resourcePoolId} # check the exported resource pool id
46
47    -  Resource type
48
49       Resource type defined what type is the specified resource, like a
50       physical machine, memory, or CPU
51
52       Show all resource type
53
54       .. code:: shell
55
56          curl -X 'GET' \
57            "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/resourceTypes" \
58            -H 'accept: application/json'
59
60    -  Resource
61
62       Get the list of all resources, the value of *resourcePoolId* from
63       the result of resource pool interface
64
65       .. code:: shell
66
67          curl -X 'GET' \
68            "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/resourcePools/${resourcePoolId}/resources" \
69            -H 'accept: application/json'
70
71       Get detail of one resource, need to export one specific resource
72       id that wants to check
73
74       .. code:: shell
75
76          curl -X 'GET' \
77            "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/resourcePools/${resourcePoolId}/resources/${resourceId}" \
78            -H 'accept: application/json'
79
80    -  Deployment manager services endpoint
81
82       The Deployment Manager Service (DMS) that related to this IMS
83       information you can use below API to check
84
85       .. code:: shell
86
87          curl -X 'GET' \
88            "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/deploymentManagers" \
89            -H 'accept: application/json'
90
91 -  Provisioning O-Cloud with SMO endpoint configuration
92
93    Assume you have an SMO, then configure O-Cloud with SMO endpoint
94    address. This provisioning of O-Cloud will make a request from
95    O-Cloud to SMO, that make SMO know the O2 service is working.
96
97    It needs SMO to have an API like
98    “*http(s)://SMO_HOST:SMO_PORT/registration*”, which can accept JSON
99    format data.
100
101    .. code:: bash
102
103       curl -X 'POST' \
104         'http://'${OAM_IP}':30205/provision/v1/smo-endpoint' \
105         -H 'accept: application/json' \
106         -H 'Content-Type: application/json' \
107         -d '{
108         "endpoint": "http://<SMO_HOST>:<SMO_PORT>/registration"
109       }'
110
111 -  Subscribe to the O-Cloud resource change notification
112
113    Assume you have an SMO, and the SMO have an API can be receive
114    callback request
115
116    -  Create subscription in O-Cloud IMS
117
118       .. code:: bash
119
120          curl -X 'POST' \
121            "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/subscriptions" \
122            -H 'accept: application/json' \
123            -H 'Content-Type: application/json' \
124            -d '{
125            "callback": "http://SMO/address/to/callback",
126            "consumerSubscriptionId": "<ConsumerIdHelpSmoToIdentify>",
127            "filter": "<ResourceTypeNameSplitByComma,EmptyToGetAll>"
128          }'
129
130    -  Handle resource change notification
131
132       When the SMO callback API get the notification that the resource
133       of O-Cloud changing, use the URL to get the latest resource
134       information to update its database
135
136 -  Orchestrate CNF in helm chart
137
138    On this sample, we prepare a firewall chart to test the
139    orchestration.
140
141    We need to do some preparation to make the helm repo work and include
142    our firewall chart inside of the repository.
143
144       Get the DMS Id in the O-Cloud, and set it into bash environment
145
146       .. code:: bash
147
148          curl --location --request GET "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/deploymentManagers"
149
150          export dmsId=`curl --location --request GET "http://${OAM_IP}:30205/o2ims_infrastructureInventory/v1/deploymentManagers" 2>/dev/null | jq .[].deploymentManagerId | xargs echo`
151
152          echo ${dmsId} # check the exported DMS id
153
154       Using helm to deploy a chartmuseum to the INF
155
156       .. code:: bash
157
158          helm repo add chartmuseum https://chartmuseum.github.io/charts
159          helm repo update
160          helm pull chartmuseum/chartmuseum # download chartmuseum-3.4.0.tgz to local
161          tar zxvf chartmuseum-3.4.0.tgz
162          cat <<EOF>chartmuseum-override.yaml
163          env:
164            open:
165              DISABLE_API: false
166          service:
167            type: NodePort
168            nodePort: 30330
169          EOF
170
171          helm install chartmuseumrepo chartmuseum/chartmuseum -f chartmuseum-override.yaml
172          kubectl get pods
173          Kubectl get services
174
175       Update the helm repo and add the chartmusem into the repository
176
177       .. code:: bash
178
179          helm repo add o2imsrepo http://${NODE_IP}:30330
180          helm repo update
181
182       Download the firewall chart and push it into the repository
183
184       .. code:: bash
185
186          git clone https://github.com/biny993/firewall-host-netdevice.git
187          tar -zcvf firewall-host-netdevice-1.0.0.tgz firewall-host-netdevice/
188          helm plugin install https://github.com/chartmuseum/helm-push.git
189          helm cm-push firewall-host-netdevice-1.0.0.tgz o2imsrepo
190          helm repo update
191          helm search repo firewall
192
193       Setup host net device over INF
194
195       .. code:: bash
196
197          ssh sysadmin@<INF OAM IP>
198          sudo ip link add name veth11 type veth peer name veth12
199          sudo ip link add name veth21 type veth peer name veth22
200          sudo ip link |grep veth
201          exit
202
203    -  Create NfDeploymentDescriptor
204
205       .. code:: bash
206
207          curl --location --request POST "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor" \
208          --header 'Content-Type: application/json' \
209          --data-raw '{
210            "name": "cfwdesc1",
211            "description": "demo nf deployment descriptor",
212            "artifactRepoUrl": "http://'${NODE_IP}':30330",
213            "artifactName": "firewall-host-netdevice",
214            "inputParams": 
215            "{\n  \"image\": {\n    \"repository\": \"ubuntu\",\n    \"tag\": 18.04,\n    \"pullPolicy\": \"IfNotPresent\"\n  },\n  \"resources\": {\n    \"cpu\": 2,\n    \"memory\": \"2Gi\",\n    \"hugepage\": \"0Mi\",\n    \"unprotectedNetPortVpg\": \"veth11\",\n    \"unprotectedNetPortVfw\": \"veth12\",\n    \"unprotectedNetCidr\": \"10.10.1.0/24\",\n    \"unprotectedNetGwIp\": \"10.10.1.1\",\n    \"protectedNetPortVfw\": \"veth21\",\n    \"protectedNetPortVsn\": \"veth22\",\n    \"protectedNetCidr\": \"10.10.2.0/24\",\n    \"protectedNetGwIp\": \"10.10.2.1\",\n    \"vfwPrivateIp0\": \"10.10.1.1\",\n    \"vfwPrivateIp1\": \"10.10.2.1\",\n    \"vpgPrivateIp0\": \"10.10.1.2\",\n    \"vsnPrivateIp0\": \"10.10.2.2\"\n  }\n}",
216            "outputParams": "{\"output1\": 100}"
217          }'
218
219          curl --location --request GET "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor"
220
221          export descId=` curl -X 'GET'   "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeploymentDescriptor"   -H 'accept: application/json'   -H 'X-Fields: id' 2>/dev/null | jq .[].id | xargs echo`
222
223          echo ${descId} # check the exported descriptor id
224
225    -  Create NfDeployment
226
227       When you have an descriptor of deployment, you can create a
228       NfDeployment, it will trigger an event inside of the IMS/DMS, and
229       use the K8S API to create a real pod of the firewall sample
230
231       .. code:: bash
232
233          curl --location --request POST "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment" \
234          --header 'Content-Type: application/json' \
235          --data-raw '{
236            "name": "cfw100",
237            "description": "demo nf deployment",
238            "descriptorId": "'${descId}'",
239            "parentDeploymentId": ""
240          }'
241
242          curl --location --request GET "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment"
243
244    -  Check pods of the firewall sample
245
246       .. code:: bash
247
248          kubectl get pods
249
250    -  Delete the deployment we just created
251
252       .. code:: shell
253
254          export NfDeploymentId=`curl --location --request GET "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment" 2>/dev/null | jq .[].id | xargs echo`
255
256          echo ${NfDeploymentId} # Check the exported deployment id
257
258          curl --location --request DELETE "http://${OAM_IP}:30205/o2dms/${dmsId}/O2dms_DeploymentLifecycle/NfDeployment/${NfDeploymentId}"