{"id":1615,"date":"2023-03-21T13:29:14","date_gmt":"2023-03-21T13:29:14","guid":{"rendered":"https:\/\/community.5gasp.eu\/?page_id=1615"},"modified":"2023-03-21T13:29:15","modified_gmt":"2023-03-21T13:29:15","slug":"build-your-vnf-from-scratch","status":"publish","type":"page","link":"https:\/\/community.5gasp.eu\/index.php\/build-your-vnf-from-scratch\/","title":{"rendered":"Build your VNF from scratch"},"content":{"rendered":"\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Basic Architecture<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open Source MANO (OSM &#8211; version 10.0.3)<\/li>\n\n\n\n<li>OpenStack (version wallaby stable)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-5.png\" alt=\"\" class=\"wp-image-1621\" width=\"575\" height=\"254\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-5.png 691w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-5-300x132.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-5-611x270.png 611w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">OSM requirements<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>2CPUs<\/li>\n\n\n\n<li>6GB RAM (8 recommended)<\/li>\n\n\n\n<li>40GB Disk space<\/li>\n\n\n\n<li>Single interface with internet access<\/li>\n\n\n\n<li>Ubuntu20.04 (64-bit)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Installing OSM<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wget https:\/\/osm-download.etsi.org\/ftp\/osm-10.0-ten\/install_osm.sh\r\n$ chmod +x install_osm.sh\r\n$ .\/install_osm.sh\r\n$ .\/install_osm.sh --k8s_monitor (install OSM with an add-on to monitor the Kubernetes cluster)\r<\/code><\/pre>\n\n\n\n<p>Check the installation in the browser by accessing your host IP (by default user and password are admin).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Adding a VIM account<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ osm vim-create --name openstack-site --user admin --password userpwd \\\r\n--auth_url http:\/\/10.10.10.11:5000\/v2.0 --tenant admin --account_type openstack\r<\/code><\/pre>\n\n\n\n<p>It is also possible to add the VIm through the OSM GUI:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Dashboard > Projects > admin > VIM Accounts > New VIM<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">What is a Virtual Deployment Unit (VDU)<\/h3>\n\n\n\n<p>VDU is a basic part of a VNF. It is the VM that hosts the network function and its properties are described in the VNF descriptor.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating the VNF<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Create VNF packages<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ osm package-create --base-directory ~\/tutorial vnf tutorial<\/code><\/pre>\n\n\n\n<p>This command creates the base package for our VNF. We are defining the <strong>directory<\/strong>, package <strong>type<\/strong> and package <strong>name<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Change the VNF descriptor (VNFD)<\/h3>\n\n\n\n<p>You can find the descriptor in:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~\/tutorial\/tutorial_vnf\/tutorial_vnfd.yaml<\/code><\/pre>\n\n\n\n<p>We will start by adding the basic info tou our desciptor:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vnfd:\r\n   id: tutorial_vnf\r\n   description: A basic VNF descriptor with one VDU\n   product-name: tutorial_vnf\r\n   version: \"1.0\"\r<\/code><\/pre>\n\n\n\n<p>As you can see, we are defining an <strong>id<\/strong>, <strong>description<\/strong>, <strong>product name<\/strong> and <strong>version<\/strong>.<\/p>\n\n\n\n<p>Next, we want to add our deployment flavour:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df:\r\n   - id: default-df\ninstantiation-level:\r\n   - id: default-instantiation-level\nvdu-level:\r\n   - number-of-instances: \"1\"\n      vdu-id: tutorial\r\nvdu-profile:\r\n   - id: tutorial\r\n     min-number-of-instances: \"1\"\r<\/code><\/pre>\n\n\n\n<p>This block of code defines a default instantiation level, with <strong>1 VDU instance<\/strong> and with id as tutorial.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ext-cpd:\r\n- id: vnf-cp0-ext\r\n   int-cpd:\r\n      cpd: vdu-eth0-int\r\n      vdu-id: tutorial\r\nmgmt-cp: vnf-cp0-ext<\/code><\/pre>\n\n\n\n<p>Here we are defining the connection points:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>external<\/strong> will connect the VNF to the exterior, so it can be accessible by the Network Service.<\/li>\n\n\n\n<li>The <strong>internal<\/strong> will create the connection point to the VDU.<\/li>\n<\/ul>\n\n\n\n<p>Next, we will define the <strong>image<\/strong> to be used. Keep in mind that it <strong>needs to exist in your VIM account<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sw-image-desc:\r\n- id: \"Ubuntu Server 20.04\"\r\n   image: \"Ubuntu Server 20.04\"\r\n   name: \"Ubuntu Server 20.04\"<\/code><\/pre>\n\n\n\n<p>Now, we have the <strong>VDU specifications<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>virtual-compute-desc:\r\n- id: tutorial-compute\r\n   virtual-cpu:\r\n      num-virtual-cpu: \"1\"\r\n   virtual-memory:\r\n      size: \"1.0\"\r\nvirtual-storage-desc:\r\n- id: tutorial-storage\r\n   size-of-storage: \"10\"<\/code><\/pre>\n\n\n\n<p>As you can see, we are defining the CPU, memory and storage for the VDU.<\/p>\n\n\n\n<p>Finally, the VDU configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vdu:\r\n- cloud-init-file: cloud-init.cfg\r\n   id: tutorial\r\n   int-cpd:\r\n   - id: vdu-eth0-int\r\n      virtual-network-interface-requirement:\r\n      - name: vdu-eth0\r\n         virtual-interface:\r\n            type: PARAVIRT\r\n   name: tutorial\r\n   sw-image-desc: \"Ubuntu Server 20.04\"\r\n   virtual-compute-desc: tutorial-compute\r\n   virtual-storage-desc: tutorial-storage<\/code><\/pre>\n\n\n\n<p>We are giving it a <strong>cloud-init<\/strong> file that will be explained later.<br>We also referring the <strong>already created<\/strong> connection points, image, storage and IDs.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Cloud-init file<\/h3>\n\n\n\n<p>You can find it in:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~\/tutorial\/tutorial_vnf\/cloud_init\/cloud_init.cfg<\/code><\/pre>\n\n\n\n<p>This file has the basic initial configurations in the VM:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#cloud-config\npassword: tutorial\nchpasswd: { expire: False }\nssh_pwauth: True\npackage_update: true\npackages:\n   - nmap<\/code><\/pre>\n\n\n\n<p>We are <strong>changing the password<\/strong>, allowing <strong>ssh connections<\/strong> with credentials and installing the <strong>nmap<\/strong> package.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Validate and Upload the VNF package<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ osm nfpkg-create ~\/tutorial\/tutorial_vnf<\/code><\/pre>\n\n\n\n<p>This command validates and uploads the package to OSM. Make sure you input the correct VNF directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating the NS<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Create NS packages<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ osm package-create --base-directory ~\/tutorial ns tutorial<\/code><\/pre>\n\n\n\n<p>This command creates the base package for our NS.<\/p>\n\n\n\n<p>We are defining the <strong>directory<\/strong>, package <strong>type<\/strong> and package <strong>name<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Change the NS descriptor (NSD)<\/h3>\n\n\n\n<p>You can find the descriptor in:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>~\/tutorial\/tutorial_ns\/tutorial_nsd.yaml<\/code><\/pre>\n\n\n\n<p>We will start by adding the basic info tou our desciptor:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nsd:\r\n   nsd:\r\n   - id: tutorial_ns\r\n      name: tutorial_ns\r\n      version: \"1.0\"\r\n      description: Simple NS with one VNF and a single Virtual Link<\/code><\/pre>\n\n\n\n<p>As you can see, we are defining an <strong>id<\/strong>, <strong>name<\/strong>, <strong>version<\/strong> and <strong>description<\/strong>.<\/p>\n\n\n\n<p>Next, we need to create a <strong>Virtual Link<\/strong>. This link will connect our Network Service to our VIM Network:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>     virtual-link-desc:\r\n     - id: mgmtnet_2\r\n       mgmt-network: true\r\n       vim-network-name: proj_net<\/code><\/pre>\n\n\n\n<p>In our case, the VIM Network is called <strong>proj_net<\/strong>.<\/p>\n\n\n\n<p>We also need to connect the NS to our VNF created before:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   vnfd-id:\r\n   - tutorial_vnf<\/code><\/pre>\n\n\n\n<p>Make sure that the id is the same as the VNF.<\/p>\n\n\n\n<p>Next, we need to establish the connections between the VNF and the VIM:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>   df:\r\n   - id: default-df\r\n     vnf-profile:\r\n     - id: \"1\"\r\n       virtual-link-connectivity:\r\n     - constituent-cpd-id:\r\n        - constituent-base-element-id: \"1\"\r\n          constituent-cpd-id: vnf-cp0-ext\r\n        virtual-link-profile-id: mgmtnet_2\r\n    vnfd-id: tutorial_vnf<\/code><\/pre>\n\n\n\n<p>Notice that the <strong>constituent-cpd-id<\/strong> is the same as the <strong>external connection point<\/strong> defined in the <strong>VNF descriptor<\/strong>.<\/p>\n\n\n\n<p>Also, the <strong>virtual-link-profile-id<\/strong> has to be the same as the one created.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Validate and Upload the NS package<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ osm nspkg-create ~\/tutorial\/tutorial_ns<\/code><\/pre>\n\n\n\n<p>This command validates and uploads the package to OSM. Make sure you input the correct NS directory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">NS instantiation<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>$ osm ns-create --ns_name tutorial_ns --nsd_name tutorial_ns --vim_account Tron<\/code><\/pre>\n\n\n\n<p>This command creates the instance of the network service. Notice that the <strong>&#8211;nsd_name<\/strong> option has to be the name of the ns package. In our case, the VIM account is<br>called <strong>Tron<\/strong>. Make sure that you input <strong>your VIM account<\/strong>.<\/p>\n\n\n\n<p>If all goes accordingly, you should be able to see in the OSM interface that your instance is running and active.<\/p>\n\n\n\n<p>You can also check if your instance is running in the VIM account.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check the cloud init file<\/h3>\n\n\n\n<p>With the VMup and running, you can check if the cloud-init file worked:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ssh ubuntu@&lt;your_machine_ip>\r\n$ nmap<\/code><\/pre>\n\n\n\n<p>By connecting to your machine using ssh and checking the nmap package, you ensure that it worked as expected.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Video<\/h2>\n\n\n\n<p>For a better description of the tutorial, you can check our video <a href=\"http:\/\/youtube.com\/watch?v=GIjamEItXAQ\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Basic Architecture OSM requirements Installing OSM Check the installation in the browser by accessing your host IP (by default user and password are admin). Adding a VIM account It is also possible to add the VIm through the OSM GUI: What is a Virtual Deployment Unit (VDU) VDU is a [\u2026]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"pg_page_styles":[],"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"footnotes":""},"class_list":["post-1615","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/pages\/1615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/comments?post=1615"}],"version-history":[{"count":6,"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/pages\/1615\/revisions"}],"predecessor-version":[{"id":1623,"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/pages\/1615\/revisions\/1623"}],"wp:attachment":[{"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/media?parent=1615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}