4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 See the License for the specific language governing permissions and
15 limitations under the License
19 OSM client library and console script
26 # Ubuntu 18.04 pre-requirements
27 sudo apt-get install python3-pip libcurl4-openssl-dev libssl-dev
28 # CentOS pre-requirements
29 # sudo yum install python3-pip libcurl-devel gnutls-devel
30 sudo -H python3 -m pip install python-magic
31 # Install OSM Information model
32 sudo -H python3 -m pip install git+https://osm.etsi.org/gerrit/osm/IM --upgrade
33 # Install OSM client from the git repo.
34 # You can install the latest client from master branch in this way:
35 sudo -H python3 -m pip install git+https://osm.etsi.org/gerrit/osm/osmclient
36 # You could also install a specific tag/version in this way
37 # sudo -H python3 -m pip install git+https://osm.etsi.org/gerrit/osm/osmclient@v7.0.0rc1
40 ### From cloned repo (for developers)
43 # Ubuntu 18.04 pre-requirements
44 sudo apt-get install python3-pip libcurl4-openssl-dev libssl-dev
45 # Centos pre-requirements
46 # sudo yum install python3-pip libcurl-devel gnutls-devel
47 sudo -H python3 -m pip install python-magic
48 # Install OSM Information model
49 sudo -H python3 -m pip install git+https://osm.etsi.org/gerrit/osm/IM --upgrade
50 # Clone the osmclient repo and install OSM client from the git repo.
51 git clone https://osm.etsi.org/gerrit/osm/osmclient
53 python3 -m pip install --user -e .
54 # logout and login so that PATH can be updated. Executable osm will be found in /home/ubuntu/.local/bin
59 Set the OSM_HOSTNAME variable to the host of the OSM server (default: localhost).
62 localhost$ export OSM_HOSTNAME=<hostname>
70 localhost$ osm upload-package ubuntu_xenial_vnf.tar.gz
71 {'transaction_id': 'ec12af77-1b91-4c84-b233-60f2c2c16d14'}
72 localhost$ osm vnfd-list
73 +--------------------+--------------------+
75 +--------------------+--------------------+
76 | ubuntu_xenial_vnfd | ubuntu_xenial_vnfd |
77 +--------------------+--------------------+
83 localhost$ osm upload-package ubuntu_xenial_ns.tar.gz
84 {'transaction_id': 'b560c9cb-43e1-49ef-a2da-af7aab24ce9d'}
85 localhost$ osm nsd-list
86 +-------------------+-------------------+
88 +-------------------+-------------------+
89 | ubuntu_xenial_nsd | ubuntu_xenial_nsd |
90 +-------------------+-------------------+
96 localhost$ osm vim-list
97 +-------------+-----------------+--------------------------------------+
98 | ro-account | datacenter name | uuid |
99 +-------------+-----------------+--------------------------------------+
100 | osmopenmano | openstack-site | 2ea04690-0e4a-11e7-89bc-00163e59ff0c |
101 +-------------+-----------------+--------------------------------------+
107 localhost$ osm ns-create ubuntu_xenial_nsd testns openstack-site
109 localhost$ osm ns-list
110 +------------------+--------------------------------------+-------------------+--------------------+---------------+
111 | ns instance name | id | catalog name | operational status | config status |
112 +------------------+--------------------------------------+-------------------+--------------------+---------------+
113 | testns | 6b0d2906-13d4-11e7-aa01-b8ac6f7d0c77 | ubuntu_xenial_nsd | running | configured |
114 +------------------+--------------------------------------+-------------------+--------------------+---------------+
117 ## Using osmclient as a library to interact with OSM
119 Assuming that you have installed python-osmclient package, it's pretty simple to write some Python code to interact with OSM.
121 ### Simple Python code to get the list of NS packages
124 from osmclient import client
125 from osmclient.common.exceptions import ClientException
126 hostname = "127.0.0.1"
127 myclient = client.Client(host=hostname, sol005=True)
128 resp = myclient.nsd.list()
129 print yaml.safe_dump(resp, indent=4, default_flow_style=False)
132 ### Simple Python code to get the list of VNF packages from a specific user and project
134 The code will print for each package a pretty table, then the full details in yaml
137 from osmclient import client
138 from osmclient.common.exceptions import ClientException
140 from prettytable import PrettyTable
141 hostname = "127.0.0.1"
148 if password is not None:
149 kwargs['password']=password
150 if project is not None:
151 kwargs['project']=project
152 myclient = client.Client(host=hostname, sol005=True, **kwargs)
153 resp = myclient.vnfd.list()
154 print yaml.safe_dump(resp, indent=4, default_flow_style=False)
157 ## Enable autocompletion
159 You can enable autocompletion in OSM client by creating a file osm-complete.sh in the following way:
162 mkdir -p $HOME/.bash_completion.d
163 _OSM_COMPLETE=source osm > $HOME/.bash_completion.d/osm-complete.sh
166 Then you can add the following to your $HOME/.bashrc file:
169 . .bash_completion.d/osm-complete.sh