Newer
Older
# ANNEX 2: Reference of OSM Client commands and library
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
**Usage:**
```bash
osm [OPTIONS] COMMAND [ARGS]...
```
**Options:**
```bash
--hostname TEXT hostname of server. Also can set OSM_HOSTNAME in
environment
--user TEXT user (defaults to admin). Also can set OSM_USER in
environment
--password TEXT password (defaults to admin). Also can set OSM_PASSWORD in
environment
--project TEXT project (defaults to admin). Also can set OSM_PROJECT in
environment
--help Show this message and exit.
```
**Commands:**
```bash
netslice-instance-create creates a new Network Slice Instance
netslice-instance-delete deletes a Network Slice Instance (NSI)
netslice-instance-list list all Network Slice Instances (NSI)
netslice-instance-op-list shows the history of operations over a...
netslice-instance-op-show shows the info of an operation over a Network
Slice Instance(NSI)
netslice-instance-show shows the content of a Network Slice Instance
(NSI)
netslice-template-create creates a new Network Slice Template (NST)
netslice-template-delete deletes a Network Slice Template (NST)
netslice-template-list list all Network Slice Templates (NST) in the...
netslice-template-show shows the content of a Network Slice Template
(NST)
netslice-template-update updates a Network Slice Template (NST)
nf-list list all NF instances Options: --ns TEXT NS...
nfpkg-create creates a new NFpkg
nfpkg-delete deletes a NFpkg
nfpkg-list list all NF pkg (VNF pkg, PNF pkg, HNF pkg)...
nfpkg-show shows the content of a NF Descriptor
nfpkg-update updates a NFpkg
ns-action executes an action/primitive over a NS...
ns-alarm-create creates a new alarm for a NS instance
ns-create creates a new Network Service instance
ns-delete deletes a NS instance
ns-list list all NS instances Options: --filter...
ns-metric-export exports a metric to the internal OSM bus,...
ns-op-list shows the history of operations over a NS...
ns-op-show shows the info of an operation
ns-show shows the info of a NS instance
nsd-create creates a new NSD/NSpkg
nsd-delete deletes a NSD/NSpkg
nsd-list list all NSD/NS pkg in the system
nsd-show shows the content of a NSD
nsd-update updates a NSD/NSpkg
nsi-create creates a new Network Slice Instance
nsi-delete deletes a Network Slice Instance (NSI)
nsi-list list all Network Slice Instances (NSI)
nsi-op-list shows the history of operations over a...
nsi-op-show shows the info of an operation over a Network
Slice Instance(NSI)
nsi-show shows the content of a Network Slice Instance
(NSI)
nspkg-create creates a new NSD/NSpkg
nspkg-delete deletes a NSD/NSpkg
nspkg-list list all NSD/NS pkg in the system
nspkg-show shows the content of a NSD
nspkg-update updates a NSD/NSpkg
nst-create creates a new Network Slice Template (NST)
nst-delete deletes a Network Slice Template (NST)
nst-list list all Network Slice Templates (NST) in the...
nst-show shows the content of a Network Slice Template
(NST)
nst-update updates a Network Slice Template (NST)
pdu-create adds a new Physical Deployment Unit to the
catalog
pdu-delete deletes a Physical Deployment Unit (PDU)
pdu-list list all Physical Deployment Units (PDU)
pdu-show shows the content of a Physical Deployment Unit
(PDU)
project-create Creates a new project NAME: name of the...
project-delete deletes a project NAME: name or ID of the...
project-list list all projects
project-show shows the details of a project NAME: name or...
project-update Update a project name :param ctx: :param...
role-create creates a role
role-delete deletes a role
role-list list all roles
role-show show specific role
role-update updates a role
sdnc-create creates a new SDN controller
sdnc-delete deletes an SDN controller NAME: name or ID of...
sdnc-list list all SDN controllers
sdnc-show shows the details of an SDN controller NAME:...
sdnc-update updates an SDN controller
upload-package uploads a VNF package or NS package FILENAME:...
user-create Creates a new user USERNAME: name of the...
user-delete deletes a user NAME: name or ID of the user...
user-list list all users
user-show shows the details of a user NAME: name or ID...
user-update Update a user information USERNAME: name of...
vim-create creates a new VIM account
vim-delete deletes a VIM account NAME: name or ID of the...
vim-list list all VIM accounts
vim-show shows the details of a VIM account NAME: name...
vim-update updates a VIM account
vnf-list list all NF instances
vnf-scale Executes a VNF scale (adding/removing VDUs)...
vnf-show shows the info of a VNF instance
vnfd-create creates a new VNFD/VNFpkg
vnfd-delete deletes a VNFD/VNFpkg
vnfd-list list all VNFD/VNF pkg in the system
vnfd-show shows the content of a VNFD
vnfd-update updates a new VNFD/VNFpkg
vnfpkg-create creates a new VNFD/VNFpkg
vnfpkg-delete deletes a VNFD/VNFpkg
vnfpkg-list list all VNFD/VNF pkg in the system
vnfpkg-show shows the content of a VNFD
vnfpkg-update updates a VNFD/VNFpkg
wim-create creates a new WIM account
wim-delete deletes a WIM account NAME: name or ID of the...
wim-list list all WIM accounts
wim-show shows the details of a WIM account NAME: name...
wim-update updates a WIM account
```
## Enable autocompletion
You can enable autocompletion in OSM client by creating a file osm-complete.sh in the following way:
```bash
mkdir -p $HOME/.bash_completion.d
_OSM_COMPLETE=source osm > $HOME/.bash_completion.d/osm-complete.sh
```
Then you can add the following to your $HOME/.bashrc file:
```bash
. .bash_completion.d/osm-complete.sh
```
## Other installation methods
### Installing from git repo
```bash
# Ubuntu pre-requirements
sudo apt install python-pip libcurl4-gnutls-dev libgnutls-dev
# CentOS pre-requirements
# sudo yum install python-pip libcurl-devel gnutls-devel
sudo -H pip install python-magic
# Install OSM client from the git repo.
# You can install the latest client from master branch in this way:
sudo -H pip install git+https://osm.etsi.org/gerrit/osm/osmclient
# You could also install a specific tag/version in this way
sudo -H pip install git+https://osm.etsi.org/gerrit/osm/osmclient@v6.0.1
```
### Installing from cloned repo (for developers)
```bash
# Ubuntu pre-requirements
sudo apt install python-pip libcurl4-gnutls-dev libgnutls-dev
# Make sure that
# sudo yum install python-pip libcurl-devel gnutls-devel
sudo -H pip install python-magic
# Clone the osmclient repo and install OSM client from the git repo.
git clone https://osm.etsi.org/gerrit/osm/osmclient
sudo -H pip install osmclient
```
## Using osmclient as a library to interact with OSM
Assuming that you have installed python-osmclient package, it's pretty simple to write some Python code to interact with OSM.
### Simple Python code to get the list of NS packages
```python
from osmclient import client
from osmclient.common.exceptions import ClientException
hostname = "127.0.0.1"
myclient = client.Client(host=hostname, sol005=True)
resp = myclient.nsd.list()
print yaml.safe_dump(resp)
```
### Simple Python code to get the list of VNF packages from a specific user and project
The code will print for each package a pretty table, then the full details in yaml
```python
from osmclient import client
from osmclient.common.exceptions import ClientException
import yaml
from prettytable import PrettyTable
hostname = "127.0.0.1"
user = admin
password = admin
project = admin
kwargs = {}
if user is not None:
kwargs['user']=user
if password is not None:
kwargs['password']=password
if project is not None:
kwargs['project']=project
myclient = client.Client(host=hostname, sol005=True, **kwargs)
resp = myclient.vnfd.list()
print yaml.safe_dump(resp)
```