From 1bc5690a09462237d48e5ed409e985597681898f Mon Sep 17 00:00:00 2001 From: Sylvain Desbureaux Date: Wed, 30 Jan 2019 14:36:14 +0100 Subject: reduce ccsdk-ansible-server image footprint Project "CIA" scope is to provide smaller and multi architecture docker images. This proposition aims to do that for ccsdk-ansible-server. The current size of this proposal is 139mb compared to the 618Mb image proposed before (and before actual ansible installation). Principles used are the following: 1. a "basic" `docker build .` should provide a working image; 2. use the smallest (and multi arch) base image possibe; 3. install necessary stuff only; 4. leverage python best practices for installation; 5. remove installation stuff occuring at run level and move them to build level. * Dockerfile is now at the root part; * ansible configuration file `ansible.cfg` is created and put in `configuration` folder; * ansible configuration file `ansible.cfg` is pushed during the build part with a reproductible process; * `python` files are on `ansible-server" folder so copying during build works out of the box; * yml files are put directly on `ansible-server/Playbooks` so copying during build works out the box; * Dockerfile base image is now alpine:3.8; * `timeout` executable being now from busybox, change in the command-line call has been made (`--signal` is now `-s` and `-t` is set before setting the timeout value). * Only install python and python-pip as alpine package and remove build dependencies package after use. * put all python requirements in `requirements.txt` package and launch pip installation command with this file. * call directly python main script (`RestServer.py`) as entrypoint and do the python installation stuff at build time. - [x] change pom.xml so building parts works - [ ] consider changing destination folder (`/opt/ansible-server/`) to the ancient one (`/opt/onap/ccsdk/`) if this is problematic Change-Id: I5c66f29ca40d9224aef3d230593735b8e0aa1f3b Issue-ID: INT-816 Signed-off-by: Sylvain Desbureaux --- ansible-server/src/main/scripts/BuildHostFile.py | 112 ----------------------- 1 file changed, 112 deletions(-) delete mode 100755 ansible-server/src/main/scripts/BuildHostFile.py (limited to 'ansible-server/src/main/scripts/BuildHostFile.py') diff --git a/ansible-server/src/main/scripts/BuildHostFile.py b/ansible-server/src/main/scripts/BuildHostFile.py deleted file mode 100755 index 20bbc904..00000000 --- a/ansible-server/src/main/scripts/BuildHostFile.py +++ /dev/null @@ -1,112 +0,0 @@ -''' -/*- -* ============LICENSE_START======================================================= -* ONAP : APPC -* ================================================================================ -* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. -* ================================================================================ -* Copyright (C) 2019 Amdocs -* ============================================================================= -* 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. -* -* ECOMP is a trademark and service mark of AT&T Intellectual Property. -* ============LICENSE_END========================================================= -*/ -''' - -import os, subprocess -import sys -from collections import namedtuple -import json - -import uuid -import cherrypy -from cherrypy.lib.httputil import parse_query_string -from cherrypy.lib import auth_basic - -def buildHostsSysCall(JsonInput, run_path, inventory_type): - - cherrypy.log( "***> in BuildHostFile.buildHostSysCall") - - # Build host file in run dir - output_file = open(run_path + "/host_file.txt","w") - - # - # host vm will be formated based on the inventory_type value passed - # - cherrypy.log( "*** buildHostsSysCall -> Inventory_type: " + inventory_type) - - # print standard header stuff to file - output_file.write ("[host]\n") - output_file.write ("localhost ansible_connection=local\n") - - TypeList=[] - - # print vm type then vm & ips - for NodeList in JsonInput['NodeList']: - #print( "" ) - #print ("Node: ") - #print NodeList - - #need to add check that vnfc-type is present in request - if not ('vnfc-type' in NodeList): - cherrypy.log( "*** buildHostsSysCall -> vnfc-type Not in NodeList: ") - return(-1) - - Type = NodeList['vnfc-type'] - TypeList.append(Type) - - - # Optional Floating Address & VIP Element - FloatingIP="" - NE_ID_VIP="" - if ('floating_ip_address-vip' in NodeList) & ('ne_id_vip' in NodeList): - FloatingIP = NodeList['floating_ip_address-vip'] - NE_ID_VIP = NodeList['ne_id_vip'] - #print ("FloatingIP: " + FloatingIP) - #print ("ne_id_vip: " + NE_ID_VIP) - output_file.write ("\n[%svip]\n" % Type ) - if inventory_type == "None": - output_file.write ("%s\n" % (FloatingIP) ) - elif inventory_type == "VNFC": - output_file.write ("%s ansible_host=%s\n" % (NE_ID_VIP, FloatingIP) ) - elif inventory_type == "VM": - output_file.write ("%s ansible_host=%s\n" % (NE_ID_VIP[0:13], FloatingIP) ) - - output_file.write ("\n[%s]\n" % Type ) - Site = NodeList['site'] - - #print ("Type: " + Type) - #print ("Site: " + Site) - - for vm in NodeList['vm-info']: - #print ("VM: " ) - #print (vm) - Name = vm['ne_id'] - IpAddr = vm['fixed_ip_address'] - #print ("vm: " + Name + ": " + IpAddr) - if inventory_type == "None": - output_file.write ("%s\n" % (IpAddr) ) - elif inventory_type == "VNFC": - output_file.write ("%s ansible_host=%s\n" % (Name, IpAddr) ) - elif inventory_type == "VM": - output_file.write ("%s ansible_host=%s\n" % (Name[0:13], IpAddr) ) - - # print site list - output_file.write ("\n[%s:children]\n" % Site ) - for child_type in TypeList: - output_file.write ("%s\n" % child_type) - - - output_file.close() - return(0) -- cgit 1.2.3-korg