TOOLS_DIR := $(TOPDIR)/tools
SUBDIRS_CLEAN = $(addsuffix .clean, $(SUBDIRS))
+SUBDIRS_TEST = $(addsuffix .test, $(SUBDIRS))
.PHONY: $(SUBDIRS) $(SUBDIRS_CLEAN) clean
clean: $(SUBDIRS_CLEAN)
+test: $(SUBDIRS_TEST)
+
$(SUBDIRS_CLEAN): %.clean:
@$(MAKE) --no-print-directory -C $* clean
+$(SUBDIRS_TEST): %.test:
+ @$(MAKE) --no-print-directory -C $* test
+
$(SUBDIRS):
@$(MAKE) --no-print-directory -C $@
GEN_VNFD_PKG := $(TOOLS_DIR)/gen_vnfd_pkg.sh
GEN_NSD_PKG := $(TOOLS_DIR)/gen_nsd_pkg.sh
GEN_PKG := $(TOOLS_DIR)/generate_descriptor_pkg.sh
+TEST_PKG := $(TOOLS_DIR)/upgrade_descriptor_version.py
BUILD_VNFD := $(shell readlink -f .|sed -e 's/\/.*descriptor-packages//' | grep vnfd)
DEP_FILES = $(wildcard src/*)
$(Q)rm -rf $(BUILD_DIR)
$(Q)rm -rf $(CHARM_BUILD_DIR)
+test:
+ $(Q)echo -n testing $(shell readlink -f src/*.yaml) " "
+ $(Q)$(TEST_PKG) --test src/*.yaml
+ $(Q)echo OK
+
.DEFAULT_GOAL := all
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- id: VyOS
name: VyOS
short-name: data
type: ELAN
vim-network-name: net-corp
- provider-network:
- overlay-type: VLAN
vnfd-connection-point-ref:
- member-vnf-index-ref: '1'
vnfd-connection-point-ref: eth1
mgmt-network: 'true'
type: ELAN
vim-network-name: net-mgmtOS
- provider-network:
- overlay-type: VLAN
vnfd-connection-point-ref:
- member-vnf-index-ref: '1'
vnfd-connection-point-ref: eth0
vnfd-name: VyOS
primitive:
- index: '1'
- name: ping
+ name: ping
\ No newline at end of file
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- id: cirros_2vnf_nsd
name: cirros_2vnf_ns
mgmt-network: 'true'
# vim-network-name: <update>
# provider-network:
- # overlay-type: VLAN
# segmentation_id: <update>
vnfd-connection-point-ref:
# Specify the constituent VNFs
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- id: cirros_noportsecurity_2vnf_nsd
name: cirros_noportsecurity_2vnf_ns
mgmt-network: 'true'
# vim-network-name: <update>
# provider-network:
- # overlay-type: VLAN
# segmentation_id: <update>
vnfd-connection-point-ref:
# Specify the constituent VNFs
# member-vnf-index-ref - entry from constituent vnf
# vnfd-id-ref - VNFD id
# vnfd-connection-point-ref - connection point name in the VNFD
- - nsd:member-vnf-index-ref: 1
- nsd:vnfd-id-ref: cirros_noportsecurity_vnfd
- nsd:vnfd-connection-point-ref: eth0
- - nsd:member-vnf-index-ref: 2
- nsd:vnfd-id-ref: cirros_noportsecurity_vnfd
- nsd:vnfd-connection-point-ref: eth0
+ - member-vnf-index-ref: 1
+ vnfd-id-ref: cirros_noportsecurity_vnfd
+ vnfd-connection-point-ref: eth0
+ - member-vnf-index-ref: 2
+ vnfd-id-ref: cirros_noportsecurity_vnfd
+ vnfd-connection-point-ref: eth0
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- id: cirros_nsd
name: cirros_ns
mgmt-network: 'true'
# vim-network-name: <update>
# provider-network:
- # overlay-type: VLAN
# segmentation_id: <update>
vnfd-connection-point-ref:
# Specify the constituent VNFs
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- id: cirros_set_vim_network_ns
name: cirros_set_vim_network_ns
mgmt-network: 'true'
# vim-network-name: <update>
# provider-network:
- # overlay-type: VLAN
# segmentation_id: <update>
vim-network-name: mgmt
vnfd-connection-point-ref:
# member-vnf-index-ref - entry from constituent vnf
# vnfd-id-ref - VNFD id
# vnfd-connection-point-ref - connection point name in the VNFD
- - nsd:member-vnf-index-ref: 1
- nsd:vnfd-id-ref: cirros_vnfd
+ - member-vnf-index-ref: 1
+ vnfd-id-ref: cirros_vnfd
# NOTE: Validate the entry below
- nsd:vnfd-connection-point-ref: eth0
+ vnfd-connection-point-ref: eth0
nsd:nsd-catalog:
- nsd:nsd:
- - nsd:constituent-vnfd:
- - nsd:member-vnf-index: '1'
- nsd:start-by-default: 'true'
- nsd:vnfd-id-ref: dns_forwarder
- nsd:id: dns_forwarder_ns
- nsd:logo: dns.jpg
- nsd:name: dns_forwarder_ns
- nsd:vld:
- - nsd:id: management
- nsd:mgmt-network: 'true'
- nsd:name: management
- nsd:vim-network-name: subnet-8a91b2c0
- nsd:vnfd-connection-point-ref:
- - nsd:member-vnf-index-ref: '1'
- nsd:vnfd-connection-point-ref: eth0
- nsd:vnfd-id-ref: dns_forwarder
- rw-nsd:meta: '{"containerPositionMap":{"1":{"top":210.5,"left":248,"right":498,"bottom":265.5,"width":250,"height":55},"ada27681-7f3e-4768-8be8-41973f849066":{"top":30,"left":135,"right":385,"bottom":85,"width":250,"height":55},"vld-1":{"top":60,"left":495,"right":745,"bottom":98,"width":250,"height":38},"management":{"top":90,"left":480,"right":730,"bottom":128,"width":250,"height":38}}}'
+ nsd:
+ - constituent-vnfd:
+ - member-vnf-index: '1'
+ start-by-default: 'true'
+ vnfd-id-ref: dns_forwarder
+ id: dns_forwarder_ns
+ logo: dns.jpg
+ name: dns_forwarder_ns
+ vld:
+ - id: management
+ mgmt-network: 'true'
+ name: management
+ vim-network-name: subnet-8a91b2c0
+ vnfd-connection-point-ref:
+ - member-vnf-index-ref: '1'
+ vnfd-connection-point-ref: eth0
+ vnfd-id-ref: dns_forwarder
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- id: IMS-corpA
name: IMS-corpA
type: ELAN
vim-network-name: net-corp:108
provider-network:
- overlay-type: VLAN
physical-network: net-corp
segmentation_id: '108'
vnfd-connection-point-ref:
short-name: management
type: ELAN
vim-network-name: net-mgmtOS
- provider-network:
- overlay-type: VLAN
vnfd-connection-point-ref:
- member-vnf-index-ref: '1'
vnfd-connection-point-ref: eth1
vnfd-name: cwims_vnfd
primitive:
- index: '1'
- name: delete-user
+ name: delete-user
\ No newline at end of file
#
#
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- id: rift_ping_pong_ns
logo: rift_logo.png
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- constituent-vnfd:
- member-vnf-index: '1'
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- constituent-vnfd:
- member-vnf-index: '1'
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- id: ubuntu_cirros_multidisk_nsd
name: ubuntu_cirros_multidisk_nsd
-nsd:nsd-catalog:
- nsd:nsd:
- - nsd:constituent-vnfd:
- - nsd:member-vnf-index: '1'
- nsd:start-by-default: 'true'
- nsd:vnfd-id-ref: ubuntu_1iface_cloudinit_newfile_vnfd
- nsd:id: ubuntu_cloudinit
- nsd:name: ubuntu_cloudinit
- nsd:short-name: ubuntu_cloudinit
- nsd:vld:
- - nsd:id: mgmt
- nsd:mgmt-network: 'false'
- nsd:name: mgmt
- nsd:short-name: mgmt
+nsd-catalog:
+ nsd:
+ - constituent-vnfd:
+ - member-vnf-index: '1'
+ start-by-default: 'true'
+ vnfd-id-ref: ubuntu_1iface_cloudinit_newfile_vnfd
+ id: ubuntu_cloudinit
+ name: ubuntu_cloudinit
+ short-name: ubuntu_cloudinit
+ vld:
+ - id: mgmt
+ mgmt-network: 'false'
+ name: mgmt
+ short-name: mgmt
mgmt-network: 'true'
- nsd:vnfd-connection-point-ref:
- - nsd:member-vnf-index-ref: '1'
- nsd:vnfd-connection-point-ref: eth0
- nsd:vnfd-id-ref: ubuntu_1iface_cloudinit_newfile_vnfd
+ vnfd-connection-point-ref:
+ - member-vnf-index-ref: '1'
+ vnfd-connection-point-ref: eth0
+ vnfd-id-ref: ubuntu_1iface_cloudinit_newfile_vnfd
-nsd:nsd-catalog:
+nsd-catalog:
nsd:
- id: ubuntu_epa_virtio_ns
name: ubuntu_epa_virtio_ns
-#!/usr/bin/env python3
+#!/usr/bin/env python2
# -*- coding: utf-8 -*-
##
# under the License.
#
##
-
+from __future__ import print_function
import json
import yaml
# import logging
import sys
import getopt
-
"""
Converts OSM VNFD, NSD descriptor from release TWO to release THREE format
"""
-__author__ = "Alfonso Tierno"
+__author__ = "Alfonso Tierno, Guillermo Calvino"
__date__ = "2017-10-14"
-__version__ = "0.0.1"
+__version__ = "0.0.2"
version_date = "Nov 2017"
print(" -h|--help: shows this help")
print(" -i|--input FILE: (same as param FILE) descriptor file to be upgraded")
print(" -o|--output FILE: where to write generated descriptor. By default stdout")
- # print(" --test: Content is tested to check wrong format or unknown keys")
+ print(" --test: Content is tested to check wrong format or unknown keys")
return
input_file_name = None
output_file_name = None
test_file = None
+ file_name = None
try:
# load parameters and configuration
opts, args = getopt.getopt(sys.argv[1:], "hvi:o:", ["input=", "help", "version", "output=", "test",])
output = open(file_name, 'w')
else:
output = sys.stdout
+ file_name = None
if input_file_name.endswith('.yaml') or input_file_name.endswith('.yml') or not \
(input_file_name.endswith('.json') or '\t' in descriptor_str):
data = json.loads(descriptor_str)
format_output_yaml = False
+ if test_file:
+ import osm_im.vnfd as vnfd_catalog
+ import osm_im.nsd as nsd_catalog
+ from pyangbind.lib.serialise import pybindJSONDecoder
+
+ if "vnfd:vnfd-catalog" in data or "vnfd-catalog" in data:
+ descriptor = "VNF"
+ myvnfd = vnfd_catalog.vnfd()
+ pybindJSONDecoder.load_ietf_json(data, None, None, obj=myvnfd)
+ elif "nsd:nsd-catalog" in data or "nsd-catalog" in data:
+ descriptor = "NS"
+ mynsd = nsd_catalog.nsd()
+ pybindJSONDecoder.load_ietf_json(data, None, None, obj=mynsd)
+ else:
+ descriptor = None
+ raise KeyError("This is not neither nsd-catalog nor vnfd-catalog descriptor")
+ exit(0)
+
# Convert version
if "vnfd:vnfd-catalog" in data or "vnfd-catalog" in data:
remove_prefix(data, "vnfd:")
error_position.append("vnfd-catalog")
vnfd_descriptor = data["vnfd-catalog"]
-
vnfd_list = vnfd_descriptor["vnfd"]
error_position.append("vnfd")
for vnfd in vnfd_list:
error_position[-1] = "vnfd[{}]".format(vnfd["id"])
-
# Remove vnf-configuration:config-attributes
if "vnf-configuration" in vnfd and "config-attributes" in vnfd["vnf-configuration"]:
del vnfd["vnf-configuration"]["config-attributes"]
+ # Remove interval-vld:vendor
+ if "internal-vld" in vnfd:
+ internal_vld_list = vnfd.get("internal-vld", ())
+ for internal_vld in internal_vld_list:
+ if "vendor" in internal_vld:
+ del internal_vld["vendor"]
+ # Remove "rw-nsd:meta"
+ if "rw-vnfd:meta" in vnfd:
+ del vnfd["rw-vnfd:meta"]
+ # Change vnf-configuration:service-primitive into vnf-configuration:config-primitive
+ if "vnf-configuration" in vnfd and "service-primitive" in vnfd["vnf-configuration"]:
+ vnfd["vnf-configuration"]["config-primitive"] = vnfd["vnf-configuration"].pop("service-primitive")
+
+ #Convert to capital letters vnf-configuration:service-primitive:parameter:data-type
+ if "vnf-configuration" in vnfd and "config-primitive" in vnfd["vnf-configuration"]:
+ error_position.append("vnf-configuration")
+ error_position.append("config-primitive")
+ primitive_list = vnfd["vnf-configuration"].get("config-primitive", ())
+ for primitive in primitive_list:
+ if "parameter" in primitive:
+ parameter_list = primitive.get("parameter", ())
+ for parameter in parameter_list:
+ parameter["data-type"] = str(parameter["data-type"]).upper()
+
+ vnfd["vnf-configuration"]["config-primitive"] = primitive_list
+ error_position.pop()
+ error_position.pop()
# Iterate with vdu:interfaces
vdu_list = vnfd["vdu"]
error_position.append("vdu")
for vdu in vdu_list:
error_position[-1] = "vdu[{}]".format(vdu["id"])
-
- # Change exernal/internal interface
+ # Change external/internal interface
interface_list = []
external_interface_list = vdu.pop("external-interface", ())
error_position.append("external-interface")
external_interface.pop("vnfd-connection-point-ref")
interface_list.append(external_interface)
error_position.pop()
-
internal_interface_list = vdu.pop("internal-interface", ())
error_position.append("internal-interface")
for internal_interface in internal_interface_list:
internal_interface.pop("vdu-internal-connection-point-ref")
interface_list.append(internal_interface)
error_position.pop()
-
if interface_list:
vdu["interface"] = interface_list
error_position.pop()
# Change initial-config-primitive into initial-service-primitive
if "initial-config-primitive" in nsd:
nsd['initial-service-primitive'] = nsd.pop("initial-config-primitive")
+ # Remove "rw-nsd:meta"
+ if "rw-nsd:meta" in nsd:
+ del nsd["rw-nsd:meta"]
+ # Remove "rw-meta"
+ if "rw-meta" in nsd:
+ del nsd["rw-meta"]
+ # Iterate with vld:id
+ error_position.append("vld")
+ vld_list = nsd.get("vld",())
+ for vld in vld_list:
+ error_position[-1] = "vld[{}]".format(vld["id"])
+ if "provider-network" in vld and "overlay-type" in vld["provider-network"]:
+ del vld["provider-network"]["overlay-type"]
+ error_position.pop()
+ if vld_list:
+ nsd["vld"] = vld_list
error_position = []
else:
error_position = ["global"]
yaml.dump(data, output, indent=4, default_flow_style=False)
else:
json.dump(data, output)
+ exit(0)
except yaml.YAMLError as exc:
error_pos = ""
error_pos = "at line:%s column:%s" % (mark.line + 1, mark.column + 1)
print("Error loading file '{}'. yaml format error {}".format(input_file_name, error_pos), file=sys.stderr)
- except json.decoder.JSONDecodeError as e:
- print("Invalid field at configuration file '{file}' {message}".format(file=input_file_name, message=str(e)),
- file=sys.stderr)
+# except json.decoder.JSONDecodeError as e:
+# print("Invalid field at configuration file '{file}' {message}".format(file=input_file_name, message=str(e)),
+# file=sys.stderr)
except ArgumentParserError as e:
print(str(e), file=sys.stderr)
except IOError as e:
- print("Error loading file '{}': {}".format(file_name, e), file=sys.stderr)
+ print("Error loading file '{}': {}".format(file_name, e), file=sys.stderr)
+ except ImportError as e:
+ print ("Package python-osm-im not installed: {}".format(e), file=sys.stderr)
except Exception as e:
- if error_position:
+ if test_file:
+ if descriptor:
+ print("Error. Invalid {} descriptor format in '{}': {}".format(descriptor, input_file_name, str(e)), file=sys.stderr)
+ else:
+ print("Error. Invalid descriptor format in '{}': {}".format(input_file_name, str(e)),
+ file=sys.stderr)
+ elif error_position:
print("Descriptor error at '{}': {}".format(":".join(error_position), e), file=sys.stderr)
+ elif file_name:
+ print ("Error loading file '{}': {}".format(file_name, str(e)), file=sys.stderr)
else:
raise
# print("Unexpected exception {}".format(e), file=sys.stderr)
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: VyOS
name: VyOS
mgmt-interface:
cp: eth0
vnf-configuration:
- service-primitive:
+ config-primitive:
- name: config
parameter:
- name: user
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: cirros_noportsecurity_vnfd
name: cirros_noportsecurity_vnf
storage-gb: 2
# Image/checksum or image including the full path
- image: 'CirrOS 0.3.4 64-bit'
+ image: 'cirros034'
#checksum:
interface:
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: cirros_vnfd
name: cirros_vnf
storage-gb: 2
# Image/checksum or image including the full path
- image: 'cirros-0.3.5-x86_64-disk.img'
+ image: 'cirros034'
#checksum:
interface:
-vnfd:vnfd-catalog:
- vnfd:vnfd:
- - rw-vnfd:meta: '{"containerPositionMap":{"dns_forwarder":{"top":30,"left":260,"right":510,"bottom":85,"width":250,"height":55},"dns_forwarder/dns_forwarder-VM":{"top":130,"left":260,"right":510,"bottom":185,"width":250,"height":55}}}'
- vnfd:connection-point:
- - vnfd:name: eth0
- vnfd:type: VPORT
- vnfd:description: Simple VNF example with a DNS forwarder
- vnfd:id: dns_forwarder
- vnfd:logo: dns.jpg
- vnfd:mgmt-interface:
- vnfd:cp: eth0
- vnfd:name: dns_forwarder
- vnfd:service-function-chain: UNAWARE
- vnfd:short-name: dns_forwarder
- vnfd:vdu:
- - vnfd:count: '1'
- vnfd:description: dns_forwarder-VM
- vnfd:interface:
- - vnfd:name: eth0
- vnfd:type: EXTERNAL
- vnfd:virtual-interface:
- vnfd:bandwidth: '0'
- vnfd:type: VIRTIO
- vnfd:vpci: 0000:00:0a.0
- vnfd:external-connection-point-ref: eth0
- vnfd:guest-epa:
- vnfd:cpu-pinning-policy: ANY
- vnfd:id: dns_forwarder-VM
- vnfd:image: ubuntu/images/hvm-ssd/ubuntu-zesty-17.04-amd64-server-20170619.1
- vnfd:cloud-init-file: cloud_init.cfg
- vnfd:name: dns_forwarder-VM
- vnfd:supplemental-boot-data:
- vnfd:boot-data-drive: 'false'
- vnfd:vm-flavor:
- vnfd:memory-mb: '1024'
- vnfd:storage-gb: '1'
- vnfd:vcpu-count: '1'
- vnfd:vendor: OSM
- vnfd:version: '1.0'
+vnfd-catalog:
+ vnfd:
+ - connection-point:
+ - name: eth0
+ type: VPORT
+ description: Simple VNF example with a DNS forwarder
+ id: dns_forwarder
+ logo: dns.jpg
+ mgmt-interface:
+ cp: eth0
+ name: dns_forwarder
+ service-function-chain: UNAWARE
+ short-name: dns_forwarder
+ vdu:
+ - count: '1'
+ description: dns_forwarder-VM
+ interface:
+ - name: eth0
+ type: EXTERNAL
+ virtual-interface:
+ bandwidth: '0'
+ type: VIRTIO
+ vpci: 0000:00:0a.0
+ external-connection-point-ref: eth0
+ guest-epa:
+ cpu-pinning-policy: ANY
+ id: dns_forwarder-VM
+ image: ubuntu/images/hvm-ssd/ubuntu-zesty-17.04-amd64-server-20170619.1
+ cloud-init-file: cloud_init.cfg
+ name: dns_forwarder-VM
+ supplemental-boot-data:
+ boot-data-drive: 'false'
+ vm-flavor:
+ memory-mb: '1024'
+ storage-gb: '1'
+ vcpu-count: '1'
+ vendor: OSM
+ version: '1.0'
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: IMS-ALLIN1_2p
name: IMS-ALLIN1_2p
mgmt-interface:
cp: eth1
vnf-configuration:
- service-primitive:
+ config-primitive:
- name: config
parameter:
- name: home_domain
mandatory: 'true'
default-value: ims.com
- name: password
- data-type: string
+ data-type: STRING
mandatory: 'true'
default-value: cw-aio
- name: create-update-user
#
#
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: rift_ping_vnf
name: ping_vnf
port: '18888'
port: '18888'
cp: ping_vnfd/cp0
- # placement-groups:
- # - member-vdus:
- # - member-vdu-ref: iovdu_0
- # name: Eris
- # requirement: Place this VM on the Kuiper belt object Eris
- # strategy: COLOCATION
+ placement-groups:
+ - member-vdus:
+ - member-vdu-ref: iovdu_0
+ name: Eris
+ requirement: Place this VM on the Kuiper belt object Eris
+ strategy: COLOCATION
vdu:
- cloud-init-file: ping_cloud_init.cfg
count: '1'
#
#
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: rift_pong_vnf
name: pong_vnf
port: '18889'
port: '18889'
cp: pong_vnfd/cp0
- # placement-groups:
- # - member-vdus:
- # - member-vdu-ref: iovdu_0
- # name: Weywot
- # requirement: Place this VM on the Kuiper belt object Weywot
- # strategy: COLOCATION
+ placement-groups:
+ - member-vdus:
+ - member-vdu-ref: iovdu_0
+ name: Weywot
+ requirement: Place this VM on the Kuiper belt object Weywot
+ strategy: COLOCATION
vdu:
- cloud-init-file: pong_cloud_init.cfg
count: '1'
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- connection-point:
- name: mgmt0
name: VL12
short-name: VL12
type: ELAN
- vendor: ETSI
internal-connection-point:
- id-ref: 'iface11'
- id-ref: 'iface21'
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- connection-point:
- name: mgmt0
name: VL34
short-name: VL34
type: ELAN
- vendor: ETSI
internal-connection-point:
- id-ref: 'iface31'
- id-ref: 'iface41'
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- connection-point:
- name: mgmt
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- connection-point:
- name: mgmt
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: ubuntu_1iface_cloudinit_newfile_vnfd
name: ubuntu_1iface_cloudinit_newfile_vnf
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: ubuntu_cirros_multidisk_vnfd
name: ubuntu_cirros_multidisk_vnfd
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: ubuntu_epa_virtio_vnf
name: ubuntu_epa_virtio_vnf
-vnfd:vnfd-catalog:
+vnfd-catalog:
vnfd:
- id: ubuntu_xenial_vnfd
name: ubuntu_xenial_vnf
echo -e "usage: $0 [OPTIONS]"
echo -e "Install OSM from binaries or source code (by default, from binaries)"
echo -e " OPTIONS"
- echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
- echo -e " --source: install OSM from source code using the latest stable tag"
+ echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
+ echo -e " --source: install OSM from source code using the latest stable tag"
echo -e " -r <repo>: use specified repository name for osm packages"
- echo -e " -R <release>: use specified release for osm packages"
+ echo -e " -R <release>: use specified release for osm binaries (deb packages, lxd images, ...)"
echo -e " -u <repo base>: use specified repository url for osm packages"
echo -e " -k <repo key>: use specified repository public key url"
- echo -e " -b <refspec>: install OSM from source code using a specific branch (master, v2.0, ...) or tag"
- echo -e " -b master (main dev branch)"
- echo -e " -b v2.0 (v2.0 branch)"
- echo -e " -b tags/v1.1.0 (a specific tag)"
- echo -e " ..."
- echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
- echo -e " --nat: install only NAT rules"
-# echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch"
- echo -e " --showopts: print chosen options and exit (only for debugging)"
- echo -e " -y: do not prompt for confirmation, assumes yes"
- echo -e " -h / --help: print this help"
+ echo -e " -b <refspec>: install OSM from source code using a specific branch (master, v2.0, ...) or tag"
+ echo -e " -b master (main dev branch)"
+ echo -e " -b v2.0 (v2.0 branch)"
+ echo -e " -b tags/v1.1.0 (a specific tag)"
+ echo -e " ..."
+ echo -e " --lxdimages: download lxd images from OSM repository instead of creating them from scratch"
+ echo -e " -l <lxd_repo>: use specified repository url for lxd images"
+ echo -e " --vimemu: additionally fetch, build, and deploy the VIM emulator as a docker container"
+ echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
+# echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)"
+ echo -e " --nat: install only NAT rules"
+ echo -e " --noconfigure: DO NOT install osmclient, DO NOT install NAT rules, DO NOT configure modules"
+# echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch"
+ echo -e " --showopts: print chosen options and exit (only for debugging)"
+ echo -e " -y: do not prompt for confirmation, assumes yes"
+ echo -e " -h / --help: print this help"
}
#Uninstall OSM: remove containers
}
function so_is_up() {
- SO_IP=$1
+ if [ -n "$1" ]; then
+ SO_IP=$1
+ else
+ SO_IP=`lxc list SO-ub -c 4|grep eth0 |awk '{print $2}'`
+ fi
time=0
step=5
timelength=300
time=$((time+step))
done
- FATAL "OSM Failed to startup"
+ FATAL "OSM Failed to startup. SO failed to startup"
}
-#Configure VCA, SO and RO with the initial configuration:
-# RO -> tenant:osm, logs to be sent to SO
-# VCA -> juju-password
-# SO -> route to Juju Controller, add RO account, add VCA account
-function configure(){
- #Configure components
- echo -e "\nConfiguring components"
- . $OSM_DEVOPS/installers/export_ips
+function vca_is_up() {
+ if [[ `lxc exec VCA -- juju status | grep "osm" | wc -l` -eq 1 ]]; then
+ echo "VCA is up and running"
+ return 0
+ fi
+
+ FATAL "OSM Failed to startup. VCA failed to startup"
+}
+
+function ro_is_up() {
+ if [ -n "$1" ]; then
+ RO_IP=$1
+ else
+ RO_IP=`lxc list RO -c 4|grep eth0 |awk '{print $2}'`
+ fi
+ time=0
+ step=2
+ timelength=20
+ while [ $time -le $timelength ]; do
+ if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
+ echo "RO is up and running"
+ return 0
+ fi
+ sleep $step
+ echo -n "."
+ time=$((time+step))
+ done
+ FATAL "OSM Failed to startup. RO failed to startup"
+}
+
+
+function configure_RO(){
+ . $OSM_DEVOPS/installers/export_ips
echo -e " Configuring RO"
lxc exec RO -- sed -i -e "s/^\#\?log_socket_host:.*/log_socket_host: $SO_CONTAINER_IP/g" /etc/osm/openmanod.cfg
lxc exec RO -- service osm-ro restart
- time=0; step=2; timelength=20; while [ $time -le $timelength ]; do sleep $step; echo -n "."; time=$((time+step)); done; echo
+ ro_is_up
lxc exec RO -- openmano tenant-delete -f osm >/dev/null
- RO_TENANT_ID=`lxc exec RO -- openmano tenant-create osm |awk '{print $1}'`
+ lxc exec RO -- openmano tenant-create osm > /dev/null
lxc exec RO -- sed -i '/export OPENMANO_TENANT=osm/d' .bashrc
lxc exec RO -- sed -i '$ i export OPENMANO_TENANT=osm' .bashrc
- #lxc exec RO -- sh -c 'echo "export OPENMANO_TENANT=osm" >> .bashrc'
+ lxc exec RO -- sh -c 'echo "export OPENMANO_TENANT=osm" >> .bashrc'
+}
+function configure_VCA(){
echo -e " Configuring VCA"
JUJU_PASSWD=`date +%s | sha256sum | base64 | head -c 32`
echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc exec VCA -- juju change-user-password
+}
+
+function configure_SOUI(){
+ . $OSM_DEVOPS/installers/export_ips
JUJU_CONTROLLER_IP=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
+ RO_TENANT_ID=`lxc exec RO -- openmano tenant-list osm |awk '{print $1}'`
echo -e " Configuring SO"
sudo route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP
sudo sed -i "$ i route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP" /etc/rc.local
-
# make journaling persistent
lxc exec SO-ub -- mkdir -p /var/log/journal
lxc exec SO-ub -- systemd-tmpfiles --create --prefix /var/log/journal
netmask 255.255.255.255
EOF
lxc exec SO-ub ifup lo:1
+}
+#Configure RO, VCA, and SO with the initial configuration:
+# RO -> tenant:osm, logs to be sent to SO
+# VCA -> juju-password
+# SO -> route to Juju Controller, add RO account, add VCA account
+function configure(){
+ #Configure components
+ echo -e "\nConfiguring components"
+ configure_RO
+ configure_VCA
+ configure_SOUI
}
function install_lxd() {
+ sudo apt-get update
+ sudo apt-get install -y lxd
+ newgrp lxd
lxd init --auto
lxd waitready
- systemctl stop lxd-bridge
- systemctl --system daemon-reload
- systemctl enable lxd-bridge
- systemctl start lxd-bridge
+ lxc network create lxdbr0 ipv4.address=auto ipv4.nat=true ipv6.address=none ipv6.nat=false
+ DEFAULT_INTERFACE=$(route -n | awk '$1~/^0.0.0.0/ {print $8}')
+ DEFAULT_MTU=$( ip addr show $DEFAULT_INTERFACE | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
+ lxc profile device set default eth0 mtu $DEFAULT_MTU
+ #sudo systemctl stop lxd-bridge
+ #sudo systemctl --system daemon-reload
+ #sudo systemctl enable lxd-bridge
+ #sudo systemctl start lxd-bridge
}
function ask_user(){
done
}
+function launch_container_from_lxd(){
+ export OSM_MDG=$1
+ OSM_load_config
+ export OSM_BASE_IMAGE=$2
+ if ! container_exists $OSM_BUILD_CONTAINER; then
+ CONTAINER_OPTS=""
+ [[ "$OSM_BUILD_CONTAINER_PRIVILEGED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.privileged=true"
+ [[ "$OSM_BUILD_CONTAINER_ALLOW_NESTED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.nesting=true"
+ create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER $CONTAINER_OPTS
+ wait_container_up $OSM_BUILD_CONTAINER
+ fi
+}
+
+function install_osmclient(){
+ CLIENT_RELEASE=${RELEASE#"-R "}
+ CLIENT_REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
+ CLIENT_REPOSITORY="stable"
+ [ -z "$REPOSITORY_BASE" ] && REPOSITORY_BASE="-u https://osm-download.etsi.org/repository/osm/debian"
+ CLIENT_REPOSITORY_BASE=${REPOSITORY_BASE#"-u "}
+ key_location=$CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE/$CLIENT_REPOSITORY_KEY
+ curl $key_location | sudo apt-key add -
+ sudo add-apt-repository -y "deb [arch=amd64] $CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE $CLIENT_REPOSITORY osmclient"
+ sudo apt-get update
+ sudo apt-get install -y python-osmclient
+ export OSM_HOSTNAME=`lxc list | awk '($2=="SO-ub"){print $6}'`
+ export OSM_RO_HOSTNAME=`lxc list | awk '($2=="RO"){print $6}'`
+ echo -e "\nOSM client installed"
+ echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
+ echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
+ echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
+}
+
+function install_from_lxdimages(){
+ LXD_RELEASE=${RELEASE#"-R "}
+ LXD_IMAGE_DIR="$(mktemp -d -q --tmpdir "osmimages.XXXXXX")"
+ trap 'rm -rf "$LXD_IMAGE_DIR"' EXIT
+ wget -O $LXD_IMAGE_DIR/osm-ro.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-ro.tar.gz
+ lxc image import $LXD_IMAGE_DIR/osm-ro.tar.gz --alias osm-ro
+ rm -f $LXD_IMAGE_DIR/osm-ro.tar.gz
+ wget -O $LXD_IMAGE_DIR/osm-vca.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-vca.tar.gz
+ lxc image import $LXD_IMAGE_DIR/osm-vca.tar.gz --alias osm-vca
+ rm -f $LXD_IMAGE_DIR/osm-vca.tar.gz
+ wget -O $LXD_IMAGE_DIR/osm-soui.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-soui.tar.gz
+ lxc image import $LXD_IMAGE_DIR/osm-soui.tar.gz --alias osm-soui
+ rm -f $LXD_IMAGE_DIR/osm-soui.tar.gz
+ launch_container_from_lxd RO osm-ro
+ ro_is_up && track RO
+ launch_container_from_lxd VCA osm-vca
+ vca_is_up && track VCA
+ launch_container_from_lxd SO osm-soui
+ #so_is_up && track SOUI
+ track SOUI
+}
+
+function install_docker_ce() {
+ # installs and configures Docker CE
+ echo "Installing Docker CE ..."
+ sudo apt-get -qq update
+ sudo apt-get install -y apt-transport-https ca-certificates software-properties-common
+ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
+ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
+ sudo apt-get -qq update
+ sudo apt-get install -y docker-ce
+ echo "Adding user to group 'docker'"
+ sudo groupadd -f docker
+ sudo usermod -aG docker $USER
+ echo "... Docker CE installation done"
+ sleep 2
+ sudo service docker restart
+ echo "... restarted Docker service"
+}
+
+function install_vimemu() {
+ # install Docker
+ install_docker_ce
+ # clone vim-emu repository (attention: branch is currently master only)
+ echo "Cloning vim-emu repository ..."
+ git clone https://osm.etsi.org/gerrit/osm/vim-emu.git
+ # build vim-emu docker
+ echo "Building vim-emu Docker container..."
+ sudo docker build -t vim-emu-img -f vim-emu/Dockerfile vim-emu/
+ # start vim-emu container as daemon
+ echo "Starting vim-emu Docker container 'vim-emu' ..."
+ sudo docker run --name vim-emu -t -d --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py
+ echo "Waiting for 'vim-emu' container to start ..."
+ sleep 5
+ export VIMEMU_HOSTNAME=$(sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu)
+ echo "vim-emu running at $VIMEMU_HOSTNAME ..."
+ echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
+ echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
+ echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
+ echo -e "You might be interested in adding the following vim-emu env variables to your .bashrc file:"
+ echo " export VIMEMU_HOSTNAME=${VIMEMU_HOSTNAME}"
+ echo -e "\nTo add the emulated VIM to OSM you should do:"
+ echo " osm vim-create --name emu-vim1 --user username --password password --auth_url http://$VIMEMU_HOSTNAME:6001/v2.0 --tenant tenantName --account_type openstack"
+}
+
+function dump_vars(){
+ echo "DEVELOP=$DEVELOP"
+ echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
+ echo "UNINSTALL=$UNINSTALL"
+ echo "NAT=$NAT"
+ echo "UPDATE=$UPDATE"
+ echo "RECONFIGURE=$RECONFIGURE"
+ echo "TEST_INSTALLER=$TEST_INSTALLER"
+ echo "INSTALL_VIMEMU=$INSTALL_VIMEMU"
+ echo "INSTALL_LXD=$INSTALL_LXD"
+ echo "INSTALL_FROM_LXDIMAGES=$INSTALL_FROM_LXDIMAGES"
+ echo "LXD_REPOSITORY_BASE=$LXD_REPOSITORY_BASE"
+ echo "RELEASE=$RELEASE"
+ echo "REPOSITORY=$REPOSITORY"
+ echo "REPOSITORY_BASE=$REPOSITORY_BASE"
+ echo "REPOSITORY_KEY=$REPOSITORY_KEY"
+ echo "NOCONFIGURE=$NOCONFIGURE"
+ echo "SHOWOPTS=$SHOWOPTS"
+ echo "Install from specific refspec (-b): $COMMIT_ID"
+}
+
+function track(){
+ ctime=`date +%s`
+ duration=$((ctime - SESSION_ID))
+ url="http://www.woopra.com/track/ce?project=osm.etsi.org&cookie=${SESSION_ID}"
+ #url="${url}&ce_campaign_name=${CAMPAIGN_NAME}"
+ event_name="bin"
+ [ -n "$INSTALL_FROM_SOURCE" ] && event_name="src"
+ [ -n "$INSTALL_FROM_LXDIMAGES" ] && event_name="lxd"
+ event_name="${event_name}_$1"
+ url="${url}&event=${event_name}&ce_duration=${duration}"
+ wget -q -O /dev/null $url
+}
+
UNINSTALL=""
DEVELOP=""
NAT=""
UPDATE=""
RECONFIGURE=""
TEST_INSTALLER=""
-LXD=""
+INSTALL_LXD=""
SHOWOPTS=""
COMMIT_ID=""
ASSUME_YES=""
INSTALL_FROM_SOURCE=""
RELEASE="-R ReleaseTHREE"
-
-while getopts ":hy-:b:r:k:u:R:" o; do
+INSTALL_VIMEMU=""
+INSTALL_FROM_LXDIMAGES=""
+LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
+NOCONFIGURE=""
+RELEASE_DAILY=""
+SESSION_ID=`date +%s`
+
+while getopts ":hy-:b:r:k:u:R:l:" o; do
case "${o}" in
h)
usage && exit 0
u)
REPOSITORY_BASE="-u ${OPTARG}"
;;
+ l)
+ LXD_REPOSITORY_BASE="${OPTARG}"
+ ;;
-)
[ "${OPTARG}" == "help" ] && usage && exit 0
[ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && continue
[ "${OPTARG}" == "update" ] && UPDATE="y" && continue
[ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue
[ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
- [ "${OPTARG}" == "lxd" ] && LXD="y" && continue
+ [ "${OPTARG}" == "lxdinstall" ] && INSTALL_LXD="y" && continue
+ [ "${OPTARG}" == "lxdimages" ] && INSTALL_FROM_LXDIMAGES="y" && continue
+ [ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
+ [ "${OPTARG}" == "noconfigure" ] && NOCONFIGURE="y" && continue
[ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue
+ [ "${OPTARG}" == "daily" ] && RELEASE_DAILY="y" && continue
echo -e "Invalid option: '--$OPTARG'\n" >&2
usage && exit 1
;;
done
if [ -n "$SHOWOPTS" ]; then
- echo "DEVELOP=$DEVELOP"
- echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
- echo "UNINSTALL=$UNINSTALL"
- echo "NAT=$NAT"
- echo "UPDATE=$UPDATE"
- echo "RECONFIGURE=$RECONFIGURE"
- echo "TEST_INSTALLER=$TEST_INSTALLER"
- echo "LXD=$LXD"
- echo "SHOWOPTS=$SHOWOPTS"
- echo "Install from specific refspec (-b): $COMMIT_ID"
+ dump_vars
exit 0
fi
+[ -n "$RELEASE_DAILY" ] && echo -e "\nInstalling from daily build repo" && RELEASE="-R ReleaseTHREE-daily" && REPOSITORY="-r testing" && COMMIT_ID="master"
+
# if develop, we force master
[ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
[ -z "$COMMIT_ID" ] && [ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not find the current latest stable release" && exit 0
echo "Latest tag in devops repo: $LATEST_STABLE_DEVOPS"
[ -z "$COMMIT_ID" ] && [ -n "$LATEST_STABLE_DEVOPS" ] && COMMIT_ID="tags/$LATEST_STABLE_DEVOPS"
-[ -z "$TEST_INSTALLER" ] && git -C $TEMPDIR checkout tags/$LATEST_STABLE_DEVOPS
+
+if [ -n "$RELEASE_DAILY" ]; then
+ echo "Using master/HEAD devops"
+ git -C $TEMPDIR checkout master
+elif [ -z "$TEST_INSTALLER" ]; then
+ git -C $TEMPDIR checkout tags/$LATEST_STABLE_DEVOPS
+fi
OSM_DEVOPS=$TEMPDIR
OSM_JENKINS="$TEMPDIR/jenkins"
echo -e "Checking required packages: lxd"
lxd --version &>/dev/null || FATAL "lxd not present, exiting."
-[ -n "$LXD" ] && echo -e "\nConfiguring lxd" && install_lxd
+[ -n "$INSTALL_LXD" ] && echo -e "\nInstalling and configuring lxd" && install_lxd
wget -q -O- https://osm-download.etsi.org/ftp/osm-3.0-three/README.txt &> /dev/null
+track start
# use local devops for containers
export OSM_USE_LOCAL_DEVOPS=true
-if [ -z "$INSTALL_FROM_SOURCE" ]; then
- echo -e "\nCreating the containers and installing from binaries ..."
- $OSM_DEVOPS/jenkins/host/install RO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "RO install failed"
- $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA install failed"
- $OSM_DEVOPS/jenkins/host/install SO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "SO install failed"
- $OSM_DEVOPS/jenkins/host/install UI $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "UI install failed"
-else #install from source
+if [ -n "$INSTALL_FROM_SOURCE" ]; then #install from source
echo -e "\nCreating the containers and building from source ..."
$OSM_DEVOPS/jenkins/host/start_build RO --notest checkout $COMMIT_ID || FATAL "RO container build failed (refspec: '$COMMIT_ID')"
+ ro_is_up && track RO
$OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA container build failed"
+ vca_is_up && track VCA
$OSM_DEVOPS/jenkins/host/start_build SO checkout $COMMIT_ID || FATAL "SO container build failed (refspec: '$COMMIT_ID')"
$OSM_DEVOPS/jenkins/host/start_build UI checkout $COMMIT_ID || FATAL "UI container build failed (refspec: '$COMMIT_ID')"
+ #so_is_up && track SOUI
+ track SOUI
+elif [ -n "$INSTALL_FROM_LXDIMAGES" ]; then #install from LXD images stored in OSM repo
+ echo -e "\nInstalling from lxd images ..."
+ install_from_lxdimages
+else #install from binaries
+ echo -e "\nCreating the containers and installing from binaries ..."
+ $OSM_DEVOPS/jenkins/host/install RO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "RO install failed"
+ ro_is_up && track RO
+ $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA install failed"
+ vca_is_up && track VCA
+ $OSM_DEVOPS/jenkins/host/install SO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "SO install failed"
+ $OSM_DEVOPS/jenkins/host/install UI $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "UI install failed"
+ #so_is_up && track SOUI
+ track SOUI
fi
#Install iptables-persistent and configure NAT rules
-nat
+[ -z "$NOCONFIGURE" ] && nat
#Configure components
-configure
+[ -z "$NOCONFIGURE" ] && configure
+
+#Install osmclient
+[ -z "$NOCONFIGURE" ] && install_osmclient
+
+#Install vim-emu (optional)
+if [ -n "$INSTALL_VIMEMU" ]; then
+ echo -e "\nInstalling vim-emu ..."
+ install_vimemu
+fi
wget -q -O- https://osm-download.etsi.org/ftp/osm-3.0-three/README2.txt &> /dev/null
+track end
echo -e "\nDONE"
+
--- /dev/null
+#!/bin/bash
+# Copyright 2017 Telefónica Investigación y Desarrollo S.A.U.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+function usage(){
+ echo -e "usage: $0 [OPTIONS]"
+ echo -e "Install OSM from binaries or source code (by default, from binaries)"
+ echo -e " OPTIONS"
+ echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
+ echo -e " --source: install OSM from source code using the latest stable tag"
+ echo -e " -r <repo>: use specified repository name for osm packages"
+ echo -e " -R <release>: use specified release for osm binaries (deb packages, lxd images, ...)"
+ echo -e " -u <repo base>: use specified repository url for osm packages"
+ echo -e " -k <repo key>: use specified repository public key url"
+ echo -e " -b <refspec>: install OSM from source code using a specific branch (master, v2.0, ...) or tag"
+ echo -e " -b master (main dev branch)"
+ echo -e " -b v2.0 (v2.0 branch)"
+ echo -e " -b tags/v1.1.0 (a specific tag)"
+ echo -e " ..."
+ echo -e " --lxdimages: download lxd images from OSM repository instead of creating them from scratch"
+ echo -e " -l <lxd_repo>: use specified repository url for lxd images"
+ echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
+# echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)"
+ echo -e " --nat: install only NAT rules"
+ echo -e " --noconfigure: DO NOT install osmclient, DO NOT install NAT rules, DO NOT configure modules"
+# echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch"
+ echo -e " --showopts: print chosen options and exit (only for debugging)"
+ echo -e " -y: do not prompt for confirmation, assumes yes"
+ echo -e " -h / --help: print this help"
+}
+
+function FATAL() {
+ echo -e $1
+ exit 1
+}
+
+TEST_INSTALLER=""
+LATEST_STABLE_DEVOPS=""
+
+while getopts ":h" o; do
+ case "${o}" in
+ h)
+ usage && exit 0
+ ;;
+ -)
+ [ "${OPTARG}" == "help" ] && usage && exit 0
+ [ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
+ ;;
+ esac
+done
+
+if [ -n "$TEST_INSTALLER" ]; then
+ echo -e "\nUsing local devops repo for OSM installation"
+ TEMPDIR="$(dirname $(realpath $(dirname $0)))"
+else
+ echo -e "\nCreating temporary dir for OSM installation"
+ TEMPDIR="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
+ trap 'rm -rf "$TEMPDIR"' EXIT
+fi
+
+if [ -z "$TEST_INSTALLER" ]; then
+ need_packages="git"
+ for package in $need_packages; do
+ echo -e "Checking required packages: $package"
+ dpkg -l $package &>/dev/null \
+ || ! echo -e " $package not installed.\nInstalling $package requires root privileges" \
+ || sudo apt-get install -y $package \
+ || FATAL "failed to install $package"
+ done
+ echo -e "\nCloning devops repo temporarily"
+ git clone https://osm.etsi.org/gerrit/osm/devops.git $TEMPDIR
+ echo -e "\nGuessing the current stable release"
+ LATEST_STABLE_DEVOPS=`git -C $TEMPDIR tag -l v[0-9].* | sort -V | tail -n1`
+ [ -z "$LATEST_STABLE_DEVOPS" ] && FATAL "Could not find the current latest stable release"
+ echo "Using latest tag in devops repo: $LATEST_STABLE_DEVOPS"
+ git -C $TEMPDIR checkout tags/$LATEST_STABLE_DEVOPS || FATAL "Could not checkout latest tag"
+fi
+
+$TEMPDIR/installers/install_osm.sh --test $*
+
#Release TWO
+DEBIAN_FRONTEND=noninteractive add-apt-repository -y cloud-archive:ocata
apt-get update
apt-get -y install python-osm-ro
# Install libjuju
apt-get install -y python3-pip python3-setuptools
-pip3 install juju
+pip3 install juju==0.6.1
# Wait for the container to get an IP address
lxc exec $container -- bash -c "for i in {1..60}; do sleep 1; ping -c1 10.44.127.1 &> /dev/null && break; done"
+ # Wait for cloud-init to finish
+ lxc exec $container -- bash -c "while [ ! -f /var/lib/cloud/instance/boot-finished ]; do sleep 1; done"
+
lxc exec $container -- apt-get update -y
lxc exec $container -- apt-get upgrade -y
lxc exec $container -- apt-get install -y $PACKAGES $2
booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'),
booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'),
booleanParam(defaultValue: false, description: '', name: 'DO_STAGE_4'),
+ booleanParam(defaultValue: false, description: '', name: 'SAVE_ARTIFACTS_OVERRIDE'),
])
])
ci_helper = load "jenkins/ci-pipelines/ci_helper.groovy"
def upstream_main_job = params.UPSTREAM_SUFFIX
- def save_artifacts = false
// upstream jobs always use merged artifacts
upstream_main_job += '-merge'
container_name_prefix = "osm-${tag_or_branch}"
container_name = "${container_name_prefix}"
if ( JOB_NAME.contains('merge') ) {
- save_artifacts = true
- println("merge job, saving artifacts")
container_name += "-merge"
}
container_name += "-${BUILD_NUMBER}"
junit '*.xml'
}
+ stage_4_archive = false
if ( params.DO_STAGE_4 ) {
stage("stage_4") {
def downstream_params = [
string(name: 'NODE', value: NODE_NAME.split()[0]),
]
stage_4_result = build job: "${params.DOWNSTREAM_STAGE_NAME}/${GERRIT_BRANCH}", parameters: downstream_params, propagate: false
-
currentBuild.result = stage_4_result.result
+
+ if ( stage_4_result.getResult().equals('SUCCESS') ) {
+ stage_4_archive = true;
+ }
}
}
- // save the artifacts of this build if this is a merge job
- if ( save_artifacts ) {
+ // override to save the artifacts
+ if ( params.SAVE_ARTIFACTS_OVERRIDE || stage_4_archive ) {
stage("Archive") {
sh "echo ${container_name} > build_version.txt"
archiveArtifacts artifacts: "build_version.txt", fingerprint: true
Verify that the charm has been configured
"""
- status_set('maintenance', 'Verifying configuration data...')
- (validated, output) = charms.sshproxy.verify_ssh_credentials()
- if not validated:
- status_set('blocked', 'Unable to verify SSH credentials: {}'.format(
- output
- ))
- return
- if all(k in cfg for k in ['mode']):
- if cfg['mode'] in ['ping', 'pong']:
- set_flag('pingpong.configured')
- status_set('active', 'ready!')
+
+ try:
+ status_set('maintenance', 'Verifying configuration data...')
+
+ (validated, output) = charms.sshproxy.verify_ssh_credentials()
+ if not validated:
+ status_set('blocked', 'Unable to verify SSH credentials: {}'.format(
+ output
+ ))
return
- status_set('blocked', 'Waiting for configuration')
+
+ if all(k in cfg for k in ['mode']):
+ if cfg['mode'] in ['ping', 'pong']:
+ set_flag('pingpong.configured')
+ status_set('active', 'ready!')
+ return
+ status_set('blocked', 'Waiting for configuration')
+
+ except Exception as err:
+ status_set('blocked', 'Waiting for valid configuration ({})'.format(err))
@when('config.changed')
assert not osm.get_api().vim.delete(vim_name)
@pytest.mark.vmware
- @pytest.mark.smoke
+ #@pytest.mark.smoke
def test_add_vim_account_vmware(self,osm,vmware,cleanup_test_add_vim_account):
os_access = {}
vim_name = 'helloworld-vmware'
assert not osm.get_api().vim.delete(vim_name)
- @pytest.mark.smoke
+ #@pytest.mark.smoke
def test_add_multiple_accounts(self,osm,cleanup_test_add_vim_account):
os_access = {}
vims = [ {'name': 'testvim1', 'vim-type': 'openstack'}, {'name': 'testvim2','vim-type': 'vmware'} ]
--- /dev/null
+#!/bin/bash
+
+function usage() {
+ echo -e "usage: $0 [OPTIONS]"
+ echo -e " OPTIONS"
+ echo -e " -c <COMPONENT>: the component whose lxd image has to be generated. Allowed values: RO, VCA, SOUI, MON"
+ echo -e " -R <RELEASE>: push images to specific RELEASE folder"
+}
+
+GEN_ALL="y"
+GEN_RO=""
+GEN_VCA=""
+GEN_SOUI=""
+GEN_MON=""
+RELEASE="ReleaseTHREE"
+
+while getopts ":h" o; do
+ case "${o}" in
+ h)
+ usage
+ exit 0
+ ;;
+ R)
+ RELEASE="${OPTARG}"
+ ;;
+ c)
+ [ "${OPTARG}" == "RO" ] && GEN_ALL="" && GEN_RO="y" && continue
+ [ "${OPTARG}" == "VCA" ] && GEN_ALL="" && GEN_VCA="y" && continue
+ [ "${OPTARG}" == "SOUI" ] && GEN_ALL="" && GEN_SOUI="y" && continue
+ [ "${OPTARG}" == "MON" ] && GEN_ALL="" && GEN_MON="y" && continue
+ echo -e "Invalid option: '--$OPTARG'\n" >&2
+ usage && exit 1
+ ;;
+ *)
+ usage && exit 1
+ ;;
+ esac
+done
+
+[ "$GEN_ALL" == "y" ] && GEN_RO="y" && GEN_VCA="y" && GEN_SOUI="y" && GEN_MON="y"
+
+echo "Stopping containers"
+lxc stop RO
+lxc stop VCA
+lxc stop SO-ub
+#lxc stop MON
+
+echo "Saving containers as images in local lxd server"
+OSM_RO_IMAGE="osm-ro"
+OSM_VCA_IMAGE="osm-vca"
+OSM_SOUI_IMAGE="osm-soui"
+OSM_MON_IMAGE="osm-mon"
+
+[ -n "$GEN_RO" ] && lxc publish --public RO --alias ${OSM_RO_IMAGE}
+[ -n "$GEN_VCA" ] && lxc publish --public VCA --alias ${OSM_VCA_IMAGE}
+[ -n "$GEN_SOUI" ] && lxc publish --public SO-ub --alias ${OSM_SOUI_IMAGE}
+#[ -n "$GEN_MON" ] && lxc publish --public MON --alias ${OSM_MON_IMAGE}
+#lxc image list
+
+#echo "Copying images to a remote lxd server"
+#[ -n "$GEN_RO" ] && lxc image copy ${OSM_RO_IMAGE} remote:
+#[ -n "$GEN_VCA" ] && lxc image copy ${OSM_VCA_IMAGE} remote:
+#[ -n "$GEN_SOUI" ] && lxc image copy ${OSM_SOUI_IMAGE} remote:
+#[ -n "$GEN_MON" ] && lxc image copy ${OSM_MON_IMAGE} remote:
+
+echo "Exporting images as targz"
+mkdir -p "${RELEASE}"
+#trap 'rm -rf "$RELEASE"' EXIT
+
+[ -n "$GEN_RO" ] && lxc image export "${OSM_RO_IMAGE}" "${RELEASE}"/"${OSM_RO_IMAGE}"
+[ -n "$GEN_VCA" ] && lxc image export "${OSM_VCA_IMAGE}" "${RELEASE}"/"${OSM_VCA_IMAGE}"
+[ -n "$GEN_SOUI" ] && lxc image export "${OSM_SOUI_IMAGE}" "${RELEASE}"/"${OSM_SOUI_IMAGE}"
+#[ -n "$GEN_MON" ] && lxc image export "${OSM_MON_IMAGE}" "${RELEASE}"/"${OSM_MON_IMAGE}"
+
+echo "Pushing images to ETSI FTP server"
+RSYNC_USER_HOST=osmusers@osm-download.etsi.org
+RSYNC_OPTIONS="--delete --progress"
+rsync -avR "$RSYNC_OPTIONS" "$RELEASE" rsync://$RSYNC_USER_HOST/repos/osm/lxd
+
+
cp -R $BUILD_NUMBER/dists/$IN_REPO $BASE_DIR/dists/$OUT_REPO
cp -R $BUILD_NUMBER/pool $BASE_DIR/
-[ -d "$BUILD_NUMBER/changelog" ] && cp -R $BUILD_NUMBER/changelog $BASE_DIR/
+
+echo "copy changelog from $BUILD_NUMBER/changelog to $BASE_DIR/"
+cp -R $BUILD_NUMBER/changelog $BASE_DIR/
cd $BASE_DIR
BRANCH=$2
fi
-modules="juju-charms devops descriptor-packages openvim RO SO UI osmclient"
+modules="juju-charms devops descriptor-packages openvim RO SO UI osmclient IM N2VC MON vim-emu"
list=""
for i in $modules; do
if [ "$1" == "$i" -o "$1" == "all" ]; then