├── MANIFEST.in ├── src ├── server_manager │ ├── __init__.py │ ├── reprepro │ │ ├── dpdk_depends_conf │ │ │ ├── override │ │ │ └── distributions │ │ └── conf │ │ │ ├── override │ │ │ └── distributions │ ├── ansible │ │ ├── playbooks │ │ │ ├── README │ │ │ ├── files │ │ │ │ └── pip.conf │ │ │ └── requirements.yml │ │ └── README.md │ ├── tags.ini │ ├── contrail_defaults.py │ ├── server_mgr_exception.py │ ├── server_mgr_err.py │ ├── utils │ │ ├── puppet_manifest_replace_deb.sh │ │ ├── smgr_upgrade_script.sh │ │ ├── provision_test_script.sh │ │ ├── sm-cleanup.sh │ │ └── ipmi_reboot.py │ ├── sm-config.ini │ ├── logger.conf │ ├── smgr_dhcp_event.py │ ├── server_mgr_ssh_client.py │ ├── send_mail.py │ └── server_mgr_defaults.py ├── scons │ ├── monitoring │ │ └── ipmi │ │ │ ├── MANIFEST.in │ │ │ ├── setup.py │ │ │ ├── SConscript │ │ │ └── monitoring.sandesh │ ├── inventory │ │ ├── inventory-daemon │ │ │ ├── __init__.py │ │ │ ├── MANIFEST.in │ │ │ ├── setup.py │ │ │ ├── SConscript │ │ │ └── server_inventory.sandesh │ │ └── SConscript │ └── SConscript ├── unit_tests │ ├── monitoring │ │ ├── __init__.py │ │ ├── test-data │ │ │ ├── sensor │ │ │ │ ├── noipmi_output.txt │ │ │ │ ├── supermicro_sensor_expected_output.txt │ │ │ │ ├── sensor_wrongoutput.txt │ │ │ │ └── quanta_sensor_expected_output.txt │ │ │ ├── disk_info │ │ │ │ ├── disk_info_wrong_output.txt │ │ │ │ ├── disk_info_expected_output.txt │ │ │ │ └── disk_info_diff_expected_output.txt │ │ │ └── chassis │ │ │ │ ├── chassis_wrongoutput.txt │ │ │ │ └── chassis_expected_output.txt │ │ └── verify_result.py │ ├── puppet │ │ └── manifests │ │ │ └── site.pp │ ├── test_sm_rest_api │ │ └── __init__.py │ ├── run_tests.sh │ ├── test_tag.json │ ├── tags.ini │ ├── cluster.json │ ├── code_coverage.sh │ ├── setup_utenv.sh │ ├── test-requirements.txt │ ├── sm-config.ini │ ├── README.txt │ ├── sm_unit_test.py │ ├── logger.conf │ ├── fake-logger.conf │ ├── test_cluster.json │ ├── test_sm_mgr_main │ │ └── verfiy_server_cfg.py │ └── server.json ├── smgr_cliff_client │ ├── version.txt │ ├── smgrcliapp │ │ ├── __init__.py │ │ ├── sm-client-config.ini │ │ ├── smgr_monitoring.py │ │ ├── smgr_inventory.py │ │ └── commandmanager.py │ ├── servermanagerclient │ ├── requirements.txt │ ├── MANIFEST.in │ ├── setup.cfg │ ├── setup_server_manager_client.sh │ └── setup.py ├── contrail_smgr │ ├── puppet │ │ ├── autosign.conf │ │ ├── auth.conf.rpmsave │ │ ├── environments │ │ │ └── production │ │ │ │ └── modules │ │ │ │ └── smgr_report │ │ │ │ ├── manifests │ │ │ │ └── init.pp │ │ │ │ └── lib │ │ │ │ └── puppet │ │ │ │ └── reports │ │ │ │ └── smgr_report.rb │ │ ├── node_mapping.json │ │ ├── hiera.yaml │ │ ├── fileserver.conf │ │ ├── puppet.conf.rpmsave │ │ ├── puppet.conf │ │ ├── node_classifier.py │ │ ├── auth.conf.rpmnew │ │ ├── auth.conf │ │ └── puppet_init_rd │ ├── cobbler │ │ ├── auth.conf │ │ ├── auth.conf.sample │ │ ├── named.template.u │ │ ├── named.template.u.sample │ │ ├── named.template │ │ ├── cobbler.conf │ │ ├── cobbler.conf.sample │ │ ├── named.conf.options.u │ │ ├── bootup_dhcp.template.u │ │ └── dhcp.template.u.sample │ ├── ntp.conf.sample │ ├── hiera.yaml │ ├── smgr.conf │ ├── kickstarts │ │ └── contrail-esxi.ks │ ├── role_sequence.json │ └── contrail-defaults.yaml ├── ntp.conf ├── ntp.conf.sample ├── cobbler │ ├── var_lib_cobbler │ │ └── loaders │ │ │ ├── yaboot │ │ │ ├── menu.c32 │ │ │ ├── grub-x86.efi │ │ │ ├── pxelinux.0 │ │ │ ├── elilo-ia64.efi │ │ │ ├── grub-x86_64.efi │ │ │ ├── COPYING.yaboot │ │ │ ├── COPYING.elilo │ │ │ └── README │ ├── etc_cobbler │ │ ├── pxe │ │ │ ├── pxesystem_esxi.template │ │ │ └── bootcfg_esxi65.template │ │ ├── named.template │ │ ├── tftpd.template │ │ └── modules.conf │ ├── etc_bind │ │ └── named.conf.options │ └── python_cobbler │ │ ├── server_pre_install.py │ │ └── server_post_install.py ├── pxesystem_esxi.template ├── repos │ └── contrail-centos-repo │ │ ├── wget-1.12-1.8.el6.x86_64.rpm │ │ ├── facter-1.5.8-1.el6.rf.noarch.rpm │ │ ├── ruby-1.8.7.352-10.el6_4.x86_64.rpm │ │ ├── ntp-4.2.4p8-3.el6.centos.x86_64.rpm │ │ ├── puppet-2.7.20-1308300027.noarch.rpm │ │ ├── ntpdate-4.2.4p8-3.el6.centos.x86_64.rpm │ │ ├── ruby-libs-1.8.7.352-10.el6_4.x86_64.rpm │ │ ├── compat-readline5-5.2-17.1.el6.x86_64.rpm │ │ ├── puppet-server-2.7.20-1308300027.noarch.rpm │ │ └── repodata │ │ ├── 231b4689c9cf577f66845b4de859ae8e1bd3f75933bbcddabea043e235c2aefb-other.xml.gz │ │ ├── d24d50fe8fb38188b064f135e4956105f8d01ab91f9274ef422a740f12f4baf8-primary.xml.gz │ │ ├── 20d387fec8b9bac544a259ec672ab9e5e6e918f99f15f8eceb82fe9792011fa5-filelists.xml.gz │ │ ├── 81049688865d7515ec93026456c3bfa00569ff6f607bb204475643416b275fbd-primary.sqlite.bz2 │ │ ├── b7a568f368fe9d4540554d64b8be9d9e379cad23f13ac02ae0fbbaa9e28ba0c1-other.sqlite.bz2 │ │ ├── b8f129511cb4d852708ea6e9ee66a7b7e19890b0c42ecad5ed32dc88a3b73a46-filelists.sqlite.bz2 │ │ └── repomd.xml ├── client │ ├── storage_keys.ini │ ├── tag.json │ ├── sm-client-config.ini │ ├── provision.json │ ├── smgr_client_def.py │ ├── image.json │ ├── cluster-5-node-interface.json │ ├── new-package.json │ ├── testbed-format-translator.json │ ├── image_json_schema.txt │ ├── server_esxi.json │ ├── smgr_monitoring.py │ ├── smgr_inventory.py │ └── server-manager ├── contrail-server-manager-ansible.start.u ├── contrail-server-manager-lite.start.u ├── contrail-server-manager.start ├── smgr.conf ├── contrail-server-manager.start.u ├── SConscript ├── Makefile ├── bootcfg_esxi55.template ├── contrail-server-manager ├── contrail │ ├── server.xml │ └── server_xmltoserver.py ├── contrail-server-manager-client.spec ├── role_sequence.json └── contrail-defaults.yaml ├── SConscript ├── ansible ├── ansible.cfg ├── playbooks │ ├── roles │ │ ├── common-docker-setup.yml │ │ ├── cobbler-docker │ │ │ └── setup.yml │ │ ├── contrail-docker │ │ │ └── setup.yml │ │ ├── create_inventory │ │ │ └── tasks │ │ │ │ └── main.yml │ │ └── create_configs │ │ │ ├── tasks │ │ │ └── main.yml │ │ │ ├── defaults │ │ │ └── main.yml │ │ │ └── templates │ │ │ └── sm.config.ini.j2 │ ├── deploy.yml │ ├── build_setup.yaml │ └── build.yml └── config │ └── server_manager_server.yml ├── docker ├── cobbler │ ├── entrypoint.sh │ └── Dockerfile └── contrail-sm │ └── Dockerfile ├── setup.py ├── .gitreview ├── Makefile └── README.md /MANIFEST.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/server_manager/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/scons/monitoring/ipmi/MANIFEST.in: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/version.txt: -------------------------------------------------------------------------------- 1 | 5.0.1 2 | -------------------------------------------------------------------------------- /src/unit_tests/puppet/manifests/site.pp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/unit_tests/test_sm_rest_api/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/autosign.conf: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /src/scons/inventory/inventory-daemon/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/smgrcliapp/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/server_manager/reprepro/dpdk_depends_conf/override: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/auth.conf.rpmsave: -------------------------------------------------------------------------------- 1 | path / 2 | auth yes 3 | allow * 4 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/auth.conf: -------------------------------------------------------------------------------- 1 | [xmlrpc_service_users] 2 | admin = DISABLED 3 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/environments/production/modules/smgr_report/manifests/init.pp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/auth.conf.sample: -------------------------------------------------------------------------------- 1 | [xmlrpc_service_users] 2 | admin = DISABLED 3 | -------------------------------------------------------------------------------- /src/server_manager/ansible/playbooks/README: -------------------------------------------------------------------------------- 1 | playbooks used from contrail-ansible repo 2 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/servermanagerclient: -------------------------------------------------------------------------------- 1 | export SMGR_IP=1.1.1.1 2 | export SMGR_PORT=9001 3 | -------------------------------------------------------------------------------- /src/unit_tests/run_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source bin/activate 3 | python sm_unit_test.py 4 | -------------------------------------------------------------------------------- /src/unit_tests/test_tag.json: -------------------------------------------------------------------------------- 1 | { 2 | "tag6": "test_tag_1", 3 | "tag7": "test_tag_2" 4 | } 5 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/node_mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "sample-host-fqdn" : "sample_environment" 3 | } 4 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/requirements.txt: -------------------------------------------------------------------------------- 1 | pbr>=0.7.0 2 | cliff>=1.4.5 3 | configparser>=3.3 4 | pyparsing>=2 5 | -------------------------------------------------------------------------------- /src/ntp.conf: -------------------------------------------------------------------------------- 1 | server 127.127.1.0 iburst maxpoll 9 2 | fudge 127.127.1.0 stratum 10 3 | restrict 127.0.0.1 nomodify 4 | -------------------------------------------------------------------------------- /src/scons/inventory/inventory-daemon/MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include inventory_daemon/server_inventory *.html *.xml *.css 2 | -------------------------------------------------------------------------------- /src/ntp.conf.sample: -------------------------------------------------------------------------------- 1 | server 127.127.1.0 iburst maxpoll 9 2 | fudge 127.127.1.0 stratum 10 3 | restrict 127.0.0.1 nomodify 4 | -------------------------------------------------------------------------------- /src/unit_tests/tags.ini: -------------------------------------------------------------------------------- 1 | [TAGS] 2 | tag1 = datacenter 3 | tag2 = floor 4 | tag3 = hall 5 | tag4 = rack 6 | tag5 = user_tag 7 | -------------------------------------------------------------------------------- /src/server_manager/tags.ini: -------------------------------------------------------------------------------- 1 | [TAGS] 2 | tag1 = datacenter 3 | tag2 = floor 4 | tag3 = hall 5 | tag4 = rack 6 | tag5 = user_tag 7 | -------------------------------------------------------------------------------- /src/contrail_smgr/ntp.conf.sample: -------------------------------------------------------------------------------- 1 | server 127.127.1.0 iburst maxpoll 9 2 | fudge 127.127.1.0 stratum 10 3 | restrict 127.0.0.1 nomodify 4 | -------------------------------------------------------------------------------- /src/cobbler/var_lib_cobbler/loaders/yaboot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/cobbler/var_lib_cobbler/loaders/yaboot -------------------------------------------------------------------------------- /src/cobbler/var_lib_cobbler/loaders/menu.c32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/cobbler/var_lib_cobbler/loaders/menu.c32 -------------------------------------------------------------------------------- /src/server_manager/ansible/playbooks/files/pip.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | trusted-host = HOSTIP 3 | index-url = http://HOSTIP/thirdparty_packages/pip_repo/simple 4 | -------------------------------------------------------------------------------- /src/server_manager/ansible/playbooks/requirements.yml: -------------------------------------------------------------------------------- 1 | - src: https://github.com/hkumarmk/ansible-docker 2 | name: docker 3 | - src: andrewrothstein.curl 4 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/test-data/sensor/noipmi_output.txt: -------------------------------------------------------------------------------- 1 | Error obtaining SDR info: Insufficient privilege level 2 | Unable to open SDR for reading 3 | -------------------------------------------------------------------------------- /src/cobbler/var_lib_cobbler/loaders/grub-x86.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/cobbler/var_lib_cobbler/loaders/grub-x86.efi -------------------------------------------------------------------------------- /src/cobbler/var_lib_cobbler/loaders/pxelinux.0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/cobbler/var_lib_cobbler/loaders/pxelinux.0 -------------------------------------------------------------------------------- /SConscript: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. 3 | # 4 | 5 | env = DefaultEnvironment() 6 | 7 | SConscript(dirs=['src']) 8 | 9 | -------------------------------------------------------------------------------- /src/cobbler/var_lib_cobbler/loaders/elilo-ia64.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/cobbler/var_lib_cobbler/loaders/elilo-ia64.efi -------------------------------------------------------------------------------- /src/pxesystem_esxi.template: -------------------------------------------------------------------------------- 1 | default linux 2 | prompt 0 3 | timeout 1 4 | label linux 5 | kernel $kernel_path 6 | ipappend 2 7 | append -c $img_path/cobbler-boot.cfg 8 | -------------------------------------------------------------------------------- /ansible/ansible.cfg: -------------------------------------------------------------------------------- 1 | [defaults] 2 | inventory = ./inventory/hosts 3 | host_key_checking = False 4 | log_path = /var/log/ansible.log 5 | jinja2_extensions=jinja2.ext.do 6 | -------------------------------------------------------------------------------- /src/cobbler/var_lib_cobbler/loaders/grub-x86_64.efi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/cobbler/var_lib_cobbler/loaders/grub-x86_64.efi -------------------------------------------------------------------------------- /src/server_manager/contrail_defaults.py: -------------------------------------------------------------------------------- 1 | DEFAULT_KERNEL_UPGRADE = "Yes" 2 | DEFAULT_KERNEL_VERSION = "" 3 | 4 | 5 | DEFAULT_HUGE_PAGES = "" 6 | DEFAULT_CORE_MASK = "" 7 | -------------------------------------------------------------------------------- /src/server_manager/reprepro/conf/override: -------------------------------------------------------------------------------- 1 | galera Section utils 2 | galera Priority standard 3 | mysql-server-wsrep Section utils 4 | mysql-server-wsrep Priority standard 5 | -------------------------------------------------------------------------------- /src/unit_tests/cluster.json: -------------------------------------------------------------------------------- 1 | { 2 | "cluster": [ 3 | { 4 | "id": "test-cluster", 5 | "parameters" : {} 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /src/unit_tests/code_coverage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source bin/activate 3 | rm .figleaf 4 | figleaf monitoring/monitoring.py 5 | figleaf2html -d /var/www/figleafhtml .figleaf 6 | -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/wget-1.12-1.8.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/wget-1.12-1.8.el6.x86_64.rpm -------------------------------------------------------------------------------- /src/cobbler/etc_cobbler/pxe/pxesystem_esxi.template: -------------------------------------------------------------------------------- 1 | default linux 2 | prompt 0 3 | timeout 1 4 | label linux 5 | kernel $kernel_path 6 | ipappend 2 7 | append -c $img_path/cobbler-boot.cfg 8 | -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/facter-1.5.8-1.el6.rf.noarch.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/facter-1.5.8-1.el6.rf.noarch.rpm -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/ruby-1.8.7.352-10.el6_4.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/ruby-1.8.7.352-10.el6_4.x86_64.rpm -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/ntp-4.2.4p8-3.el6.centos.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/ntp-4.2.4p8-3.el6.centos.x86_64.rpm -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/puppet-2.7.20-1308300027.noarch.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/puppet-2.7.20-1308300027.noarch.rpm -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/ntpdate-4.2.4p8-3.el6.centos.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/ntpdate-4.2.4p8-3.el6.centos.x86_64.rpm -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/ruby-libs-1.8.7.352-10.el6_4.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/ruby-libs-1.8.7.352-10.el6_4.x86_64.rpm -------------------------------------------------------------------------------- /src/smgr_cliff_client/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include requirements.txt 2 | include setup_server_manager_client.sh 3 | include smgrcliapp/sm-client-config.ini 4 | include version.txt 5 | include servermanagerclient 6 | -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/compat-readline5-5.2-17.1.el6.x86_64.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/compat-readline5-5.2-17.1.el6.x86_64.rpm -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/puppet-server-2.7.20-1308300027.noarch.rpm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/puppet-server-2.7.20-1308300027.noarch.rpm -------------------------------------------------------------------------------- /src/client/storage_keys.ini: -------------------------------------------------------------------------------- 1 | [STORAGE-KEYS] 2 | storage_mon_secret = AQBM78tTEMz+GhAA3WiOXQI7UVdIy0YFFuTGdw== 3 | osd_bootstrap_key = AQCq7NFTeJUoBhAAlTVpxwWQJtBej/JDNhT6+Q== 4 | admin_key = AQDIgtNTgPLWARAAK6gs/fj8m88LnY9DwxJdYA== -------------------------------------------------------------------------------- /docker/cobbler/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # enable tftp 6 | touch /etc/xinetd.d/rsync 7 | 8 | #systemctl restart xinetd 9 | #systemctl restart tftp 10 | 11 | # Execute Dockerfile CMD 12 | exec "$@" 13 | -------------------------------------------------------------------------------- /src/client/tag.json: -------------------------------------------------------------------------------- 1 | { 2 | "tag1" : "data-center", 3 | "tag2" : "floor", 4 | "tag3" : "room", 5 | "tag4" : "pod", 6 | "tag5" : "rack", 7 | "tag6" : "user-defined-1", 8 | "tag7" : "user-defined-2" 9 | } 10 | 11 | -------------------------------------------------------------------------------- /src/server_manager/reprepro/conf/distributions: -------------------------------------------------------------------------------- 1 | Origin: Debian 2 | Label: Debian-All 3 | Suite: contrail-install-repo 4 | Codename: contrail 5 | Version: 1.0 6 | Architectures: amd64 7 | DebOverride: override 8 | Components: main 9 | Description: Contrail Install Repo 10 | -------------------------------------------------------------------------------- /src/client/sm-client-config.ini: -------------------------------------------------------------------------------- 1 | [SERVER-MANAGER] 2 | ; ip address of the server manager 3 | ; replace the following with proper server manager address 4 | listen_ip_addr = 1.1.1.1 5 | ; server manager listening port 6 | listen_port = 9001 7 | 8 | [CLUSTER] 9 | 10 | [SERVER] 11 | -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/repodata/231b4689c9cf577f66845b4de859ae8e1bd3f75933bbcddabea043e235c2aefb-other.xml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/repodata/231b4689c9cf577f66845b4de859ae8e1bd3f75933bbcddabea043e235c2aefb-other.xml.gz -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/repodata/d24d50fe8fb38188b064f135e4956105f8d01ab91f9274ef422a740f12f4baf8-primary.xml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/repodata/d24d50fe8fb38188b064f135e4956105f8d01ab91f9274ef422a740f12f4baf8-primary.xml.gz -------------------------------------------------------------------------------- /src/server_manager/reprepro/dpdk_depends_conf/distributions: -------------------------------------------------------------------------------- 1 | Origin: Debian 2 | Label: Debian-All 3 | Suite: contrail-dpdk-depends 4 | Codename: contrail-dpdk-depends 5 | Version: 1.0 6 | Architectures: amd64 7 | DebOverride: override 8 | Components: main 9 | Description: Contrail DPDK depends 10 | -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/repodata/20d387fec8b9bac544a259ec672ab9e5e6e918f99f15f8eceb82fe9792011fa5-filelists.xml.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/repodata/20d387fec8b9bac544a259ec672ab9e5e6e918f99f15f8eceb82fe9792011fa5-filelists.xml.gz -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/repodata/81049688865d7515ec93026456c3bfa00569ff6f607bb204475643416b275fbd-primary.sqlite.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/repodata/81049688865d7515ec93026456c3bfa00569ff6f607bb204475643416b275fbd-primary.sqlite.bz2 -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/repodata/b7a568f368fe9d4540554d64b8be9d9e379cad23f13ac02ae0fbbaa9e28ba0c1-other.sqlite.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/repodata/b7a568f368fe9d4540554d64b8be9d9e379cad23f13ac02ae0fbbaa9e28ba0c1-other.sqlite.bz2 -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/repodata/b8f129511cb4d852708ea6e9ee66a7b7e19890b0c42ecad5ed32dc88a3b73a46-filelists.sqlite.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-server-manager/HEAD/src/repos/contrail-centos-repo/repodata/b8f129511cb4d852708ea6e9ee66a7b7e19890b0c42ecad5ed32dc88a3b73a46-filelists.sqlite.bz2 -------------------------------------------------------------------------------- /src/server_manager/server_mgr_exception.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import pdb 3 | 4 | 5 | class ServerMgrException(Exception): 6 | def __init__(self, msg, ret_code = 0): 7 | self.msg = msg 8 | self.ret_code = ret_code 9 | 10 | def __str__(self): 11 | return repr(self.msg) 12 | 13 | 14 | -------------------------------------------------------------------------------- /ansible/playbooks/roles/common-docker-setup.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: "Install docker-py" 3 | yum: 4 | name: python-docker-py 5 | state: present 6 | become: yes 7 | become_user: root 8 | 9 | - name: Disable selinux for the build 10 | selinux: 11 | state: disabled 12 | become: yes 13 | become_user: root 14 | -------------------------------------------------------------------------------- /src/client/provision.json: -------------------------------------------------------------------------------- 1 | { 2 | "roles" : { 3 | "database" : ["demo2-server"], 4 | "openstack" : ["demo2-server"], 5 | "config" : ["demo2-server"], 6 | "control" : ["demo2-server"], 7 | "collector" : ["demo2-server"], 8 | "webui" : ["demo2-server"], 9 | "compute" : ["demo2-server"] 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/smgrcliapp/sm-client-config.ini: -------------------------------------------------------------------------------- 1 | [SERVER-MANAGER] 2 | ; ip address of the server manager 3 | ; replace the following with proper server manager address 4 | listen_ip_addr = 1.1.1.1 5 | ; server manager listening port 6 | listen_port = 9001 7 | 8 | [CLUSTER] 9 | 10 | [SERVER] 11 | 12 | [TAG] 13 | [IMAGE] 14 | [DHCP_HOST] 15 | [DHCP_SUBNET] 16 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 | # 4 | 5 | from setuptools import setup 6 | import setuptools 7 | 8 | setup( 9 | name='contrail-server-manager', 10 | version='0.1dev', 11 | packages=setuptools.find_packages(exclude=["*.pyc"]), 12 | zip_safe=False, 13 | long_description="Server Manager package", 14 | ) 15 | -------------------------------------------------------------------------------- /src/cobbler/etc_cobbler/pxe/bootcfg_esxi65.template: -------------------------------------------------------------------------------- 1 | bootstate=0 2 | title=Loading ESXi installer 3 | prefix=$img_path 4 | kernel=tboot.b00 5 | #if $getVar('system_name','') != '' 6 | #set $what = "system" 7 | #else 8 | #set $what = "profile" 9 | #end if 10 | kernelopt=runweasel ks=http://$server:$http_port/cblr/svc/op/ks/$what/$name 11 | modules=$esx_modules 12 | build= 13 | updated=0 14 | -------------------------------------------------------------------------------- /src/scons/monitoring/ipmi/setup.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 | # 4 | 5 | from setuptools import setup 6 | import setuptools 7 | 8 | setup( 9 | name='contrail-sm-monitoring', 10 | version='0.1dev', 11 | packages=setuptools.find_packages(), 12 | zip_safe=False, 13 | long_description="SM Monitoring Statistics", 14 | ) 15 | -------------------------------------------------------------------------------- /src/unit_tests/setup_utenv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pip install virtualenv 4 | cd .. 5 | virtualenv --system-site-packages unit_tests 6 | cd unit_tests 7 | source ./bin/activate 8 | FILE=test-requirements.txt 9 | easy_install http://darcs.idyll.org/~t/projects/figleaf-latest.tar.gz 10 | while read line; do 11 | pip install $line 12 | done < $FILE 13 | mkdir fake-logs 14 | deactivate 15 | -------------------------------------------------------------------------------- /src/unit_tests/test-requirements.txt: -------------------------------------------------------------------------------- 1 | gevent 2 | pycurl 3 | requests 4 | xmltodict 5 | netaddr 6 | flexmock 7 | mock 8 | bottle 9 | ../../../../build/debug/server-manager/monitoring/ipmi/dist/contrail-sm-monitoring-0.1dev.tar.gz 10 | ../../../../build/debug/tools/sandesh/library/python/dist/sandesh-0.1dev.tar.gz 11 | ../../../../build/debug/sandesh/common/dist/sandesh-common-0.1dev.tar.gz 12 | -------------------------------------------------------------------------------- /src/scons/inventory/SConscript: -------------------------------------------------------------------------------- 1 | # -*- mode: python; -*- 2 | # 3 | # Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 4 | # 5 | # src directory 6 | 7 | Import('BuildEnv') 8 | 9 | BuildEnv.SConscript('inventory-daemon/SConscript', 10 | exports='BuildEnv', 11 | variant_dir='#build/noarch/inventory-daemon', 12 | duplicate=1) 13 | -------------------------------------------------------------------------------- /src/contrail-server-manager-ansible.start.u: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | setenforce 0 &> /dev/null 4 | 5 | mkdir -p /var/run/contrail-server-manager-ansible/ 6 | echo "" 7 | echo "Starting SMgr Ansible" 8 | echo "" 9 | nohup /opt/contrail/server_manager/ansible/sm_ansible_server.py -c /opt/contrail/server_manager/sm-config.ini 0<&- &> var/run/contrail-server-manager-ansible/contrail-server-manager-ansible.log& 10 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/named.template.u: -------------------------------------------------------------------------------- 1 | include "/etc/bind/named.conf.options"; 2 | include "/etc/bind/named.conf.local"; 3 | 4 | #for $zone in $forward_zones 5 | zone "${zone}." { 6 | type master; 7 | file "/etc/bind/db.$zone"; 8 | }; 9 | 10 | #end for 11 | #for $zone, $arpa in $reverse_zones 12 | zone "${arpa}." { 13 | type master; 14 | file "/etc/bind/db.$zone"; 15 | }; 16 | 17 | #end for 18 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/named.template.u.sample: -------------------------------------------------------------------------------- 1 | include "/etc/bind/named.conf.options"; 2 | include "/etc/bind/named.conf.local"; 3 | 4 | #for $zone in $forward_zones 5 | zone "${zone}." { 6 | type master; 7 | file "/etc/bind/db.$zone"; 8 | }; 9 | 10 | #end for 11 | #for $zone, $arpa in $reverse_zones 12 | zone "${arpa}." { 13 | type master; 14 | file "/etc/bind/db.$zone"; 15 | }; 16 | 17 | #end for 18 | -------------------------------------------------------------------------------- /ansible/playbooks/deploy.yml: -------------------------------------------------------------------------------- 1 | - name: Create dynamic inventory 2 | hosts: deployer 3 | gather_facts: no 4 | vars_files: 5 | - "{{ config_file }}" 6 | roles: 7 | - create_inventory 8 | 9 | - name: Deploy containers 10 | hosts: command_servers 11 | gather_facts: yes 12 | vars_files: 13 | - "{{ hostvars['localhost'].config_file }}" 14 | roles: 15 | - create_configs 16 | - launch_containers 17 | -------------------------------------------------------------------------------- /src/scons/inventory/inventory-daemon/setup.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 | # 4 | 5 | import setuptools 6 | 7 | setuptools.setup( 8 | name='server-inventory-collector', 9 | version='0.1dev', 10 | packages=setuptools.find_packages(), 11 | package_data={'': ['*.html', '*.css', '*.xml']}, 12 | zip_safe=False, 13 | long_description="Server Inventory", 14 | ) 15 | -------------------------------------------------------------------------------- /src/server_manager/server_mgr_err.py: -------------------------------------------------------------------------------- 1 | ERR_SVR_NOT_FOUND = 1 2 | ERR_CLSTR_NOT_FOUND = 2 3 | ERR_IMG_NOT_FOUND = 3 4 | 5 | 6 | ERR_SVR_EXISTS = 4 7 | ERR_CLSTR_EXISTS = 5 8 | ERR_IMG_EXISTS = 6 9 | 10 | ERR_IMG_TYPE_INVALID = 7 11 | 12 | ERR_OPR_ERROR = 8 13 | ERR_GENERAL_ERROR = 9 14 | 15 | ERR_MATCH_KEY_NOT_PRESENT = 10 16 | ERR_MATCH_VALUE_NOT_PRESENT = 11 17 | ERR_INVALID_MATCH_KEY = 12 18 | 19 | ERR_IMG_CATEGORY_ERROR = 13 20 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/test-data/disk_info/disk_info_wrong_output.txt: -------------------------------------------------------------------------------- 1 | Linux 3.13.0-32-generic (host05) 07/07/2015 _x86_64_ (40 CPU) 2 | 3 | avg-cpu: %user %nice %system %iowait %steal %idle 4 | 0.03 0.00 0.03 0.00 0.00 99.94 5 | 6 | Device: tps MB_read/s MB_wrtn/s MB_read 7 | sda 0.42 0.00 0.00 3165 8 | dm-0 0.73 0.00 0.02 1025 9 | -------------------------------------------------------------------------------- /src/scons/SConscript: -------------------------------------------------------------------------------- 1 | # -*- mode: python; -*- 2 | # 3 | # Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 4 | # 5 | # src directory 6 | 7 | Import('BuildEnv') 8 | 9 | BuildEnv.SConscript('monitoring/ipmi/SConscript', 10 | exports='BuildEnv', 11 | duplicate=0) 12 | 13 | BuildEnv.SConscript('inventory/SConscript', 14 | exports='BuildEnv', 15 | duplicate=0) 16 | -------------------------------------------------------------------------------- /ansible/playbooks/roles/cobbler-docker/setup.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: "Run cobbler container" 3 | docker_container: 4 | name: cobbler 5 | image: cobbler 6 | state: started 7 | network_mode: host 8 | volumes: 9 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 10 | - /dist/images:/mnt:ro 11 | exposed_ports: 12 | - 69 13 | - 80 14 | - 443 15 | - 25151 16 | privileged: yes 17 | become: yes 18 | become_user: root 19 | 20 | -------------------------------------------------------------------------------- /src/contrail_smgr/hiera.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - yaml 4 | :hierarchy: 5 | - "%{::clientcert}-contrail" 6 | - "%{::clientcert}-openstack" 7 | - "contrail-defaults" 8 | 9 | :yaml: 10 | # datadir is empty here, so hiera uses its defaults: 11 | # - /var/lib/hiera on *nix 12 | # - %CommonAppData%\PuppetLabs\hiera\var on Windows 13 | # When specifying a datadir, make sure the directory exists. 14 | :datadir: /etc/puppet/environments/%{environment}/hieradata 15 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/test-data/chassis/chassis_wrongoutput.txt: -------------------------------------------------------------------------------- 1 | System Power : on 2 | Power Overload : false 3 | Power Interlock : inactive 4 | Main Power Fault : false 5 | Power Control Fault : false 6 | Power Restore Policy : always-off 7 | Last Power Event : command 8 | Chassis Intrusion : inactive 9 | Front-Panel Lockout : inactive 10 | Drive Fault : false 11 | Cooling/Fan Fault : false 12 | Front Panel Control : none 13 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/hiera.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | :backends: 3 | - yaml 4 | :hierarchy: 5 | - "%{::clientcert}-contrail" 6 | - "%{::clientcert}-openstack" 7 | - "contrail-defaults" 8 | 9 | :yaml: 10 | # datadir is empty here, so hiera uses its defaults: 11 | # - /var/lib/hiera on *nix 12 | # - %CommonAppData%\PuppetLabs\hiera\var on Windows 13 | # When specifying a datadir, make sure the directory exists. 14 | :datadir: /etc/puppet/environments/%{environment}/hieradata 15 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/test-data/chassis/chassis_expected_output.txt: -------------------------------------------------------------------------------- 1 | System Power : on 2 | Power Overload : false 3 | Power Interlock : inactive 4 | Main Power Fault : false 5 | Power Control Fault : false 6 | Power Restore Policy : always-off 7 | Last Power Event : command 8 | Chassis Intrusion : inactive 9 | Front-Panel Lockout : inactive 10 | Drive Fault : false 11 | Cooling/Fan Fault : false 12 | Front Panel Control : none 13 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/test-data/disk_info/disk_info_expected_output.txt: -------------------------------------------------------------------------------- 1 | Linux 3.13.0-32-generic (host05) 07/07/2015 _x86_64_ (40 CPU) 2 | 3 | avg-cpu: %user %nice %system %iowait %steal %idle 4 | 0.03 0.00 0.03 0.00 0.00 99.94 5 | 6 | Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn 7 | sda 0.42 0.00 0.00 3165 10788 8 | dm-0 0.73 0.00 0.02 1025 58147 9 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/test-data/disk_info/disk_info_diff_expected_output.txt: -------------------------------------------------------------------------------- 1 | Linux 3.13.0-32-generic (host05) 07/07/2015 _x86_64_ (40 CPU) 2 | 3 | avg-cpu: %user %nice %system %iowait %steal %idle 4 | 0.03 0.00 0.03 0.00 0.00 99.94 5 | 6 | Device: tps MB_read/s MB_wrtn/s MB_read MB_wrtn 7 | sda 0.42 0.00 0.00 3165 10788 8 | dm-0 0.73 0.00 0.02 1025 58147 9 | -------------------------------------------------------------------------------- /.gitreview: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. 3 | # 4 | # OpenContrail Code Review System 5 | # 6 | # Please visit opencontrail.org additional information. 7 | # 8 | # e.g. After changes are complete and commited to a local branch, do 9 | # 'git review' to submit changeset to review.opencontrail.org Code Review 10 | # (gerrit) System. 11 | # 12 | [gerrit] 13 | host=review.opencontrail.org 14 | port=29418 15 | project=Juniper/contrail-server-manager.git 16 | defaultbranch=master 17 | -------------------------------------------------------------------------------- /src/contrail-server-manager-lite.start.u: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | setenforce 0 4 | 5 | echo "" 6 | echo "Restarting Apache2" 7 | echo "" 8 | service apache2 restart 9 | 10 | echo "" 11 | echo "Restarting Xinetd" 12 | echo "" 13 | service xinetd restart 14 | 15 | mkdir -p /var/run/contrail-server-manager/ 16 | echo "" 17 | echo "Starting SMgr" 18 | echo "" 19 | nohup /opt/contrail/server_manager/server_mgr_main.py -c /opt/contrail/server_manager/sm-config.ini 0<&- &> /var/run/contrail-server-manager/contrail-server-manager.log& 20 | 21 | -------------------------------------------------------------------------------- /src/client/smgr_client_def.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 4 | 5 | import os 6 | import json 7 | 8 | _DEF_SMGR_PORT = 9001 9 | _DEF_SMGR_CFG_FILE = os.path.dirname(__file__) + "/sm-client-config.ini" 10 | 11 | def print_rest_response(resp): 12 | if resp: 13 | try: 14 | resp_str = json.loads(resp) 15 | resp = json.dumps(resp_str, sort_keys=True, indent=4) 16 | except ValueError: 17 | pass 18 | print resp 19 | 20 | #end print_rest_resp 21 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/fileserver.conf: -------------------------------------------------------------------------------- 1 | # This file consists of arbitrarily named sections/modules 2 | # defining where files are served from and to whom 3 | 4 | # Define a section 'files' 5 | # Adapt the allow/deny settings to your needs. Order 6 | # for allow/deny does not matter, allow always takes precedence 7 | # over deny 8 | # [files] 9 | # path /var/lib/puppet/files 10 | # allow *.example.com 11 | # deny *.evil.example.com 12 | # allow 192.168.0.0/24 13 | [ssl_certs] 14 | path /etc/contrail_smgr/puppet/ssl 15 | allow * 16 | -------------------------------------------------------------------------------- /ansible/playbooks/roles/contrail-docker/setup.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: "Run server-manager container" 3 | docker_container: 4 | name: server-manager 5 | image: contrail-server-manager 6 | state: started 7 | network_mode: host 8 | volumes: 9 | - /sys/fs/cgroup:/sys/fs/cgroup:ro 10 | - /dist/:/dist/ 11 | volumes_from: 12 | - cobbler 13 | exposed_ports: 14 | - 9001 15 | privileged: yes 16 | become: yes 17 | become_user: root 18 | 19 | # Implement postinst stuff 20 | 21 | # Restart Xinetd and Cobbler containers 22 | -------------------------------------------------------------------------------- /ansible/playbooks/roles/create_inventory/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Add server manager server to inventory 4 | add_host: 5 | hostname: "{{ item.value.ip }}" 6 | groupname: server_manager 7 | ansible_user: "{{ item.value.ssh_user|default('root') }}" 8 | ansible_ssh_pass: "{{ item.value.ssh_pass|default('c0ntrail123') }}" 9 | ansible_become: true 10 | ansible_become_pass: "{{ item.value.sudo_pass|default('sudoPassword') }}" 11 | server_name: "{{ item.key }}" 12 | server_ip: "{{ item.value.ip }}" 13 | with_dict: "{{ server_manager_server }}" 14 | -------------------------------------------------------------------------------- /src/unit_tests/sm-config.ini: -------------------------------------------------------------------------------- 1 | [SERVER-MANAGER] 2 | listen_ip_addr = 127.0.0.1 3 | listen_port = 9001 4 | database_name = smgr_data.db 5 | server_manager_base_dir = ./ 6 | html_root_dir = ./html 7 | cobbler_ip_address = 127.0.0.1 8 | cobbler_port = 9 | cobbler_username = cobbler 10 | cobbler_password = cobbler 11 | ipmi_username = ADMIN 12 | ipmi_password = ADMIN 13 | ipmi_type = ipmilan 14 | puppet_dir = ./puppet/ 15 | 16 | [CLUSTER] 17 | 18 | [SERVER] 19 | 20 | [IMAGE] 21 | -------------------------------------------------------------------------------- /src/server_manager/utils/puppet_manifest_replace_deb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ $# -ne 2 ] 4 | then 5 | echo "Usage $0 " 6 | exit 7 | fi 8 | 9 | deb_file=$1 10 | puppet_manifest=$2 11 | 12 | rm -rf ~/debmodify 13 | mkdir ~/debmodify 14 | echo "Contrail package : $deb_file" 15 | echo "Puppet manifest to replace : $puppet_manifest" 16 | dpkg-deb -x $deb_file ~/debmodify 17 | dpkg-deb -e $deb_file ~/debmodify/DEBIAN 18 | cp $puppet_manifest ~/debmodify/opt/contrail/puppet/contrail-puppet-manifest.tgz 19 | cp $deb_file $deb_file.old 20 | dpkg -b ~/debmodify $deb_file 21 | -------------------------------------------------------------------------------- /src/cobbler/var_lib_cobbler/loaders/COPYING.yaboot: -------------------------------------------------------------------------------- 1 | Cobbler deploys a yaboot binary over TFTP to enable network booting of PowerPC 2 | machines. 3 | 4 | Yaboot is GPL and is being distributed in binary form persuant to this section 5 | of the GPL license: 6 | 7 | c) Accompany it with the information you received as to the offer 8 | to distribute corresponding source code. (This alternative is 9 | allowed only for noncommercial distribution and only if you 10 | received the program in object code or executable form with such 11 | an offer, in accord with Subsection b above.) 12 | 13 | Source code to yaboot is available on http://yaboot.ozlabs.org. 14 | 15 | A full copy of the GPL is available in "COPYING". 16 | -------------------------------------------------------------------------------- /src/cobbler/var_lib_cobbler/loaders/COPYING.elilo: -------------------------------------------------------------------------------- 1 | Cobbler deploys elilo.efi over TFTP to enable network booting of 2 | Itanium machines. 3 | 4 | ELILO is GPL and is being distributed in binary form 5 | persuant to this section of the GPL license: 6 | 7 | c) Accompany it with the information you received as to the offer 8 | to distribute corresponding source code. (This alternative is 9 | allowed only for noncommercial distribution and only if you 10 | received the program in object code or executable form with such 11 | an offer, in accord with Subsection b above.) 12 | 13 | Source code to ELILO is available on http://sourceforge.net/projects/elilo. 14 | 15 | A full copy of the GPL is available in "COPYING". 16 | -------------------------------------------------------------------------------- /src/unit_tests/README.txt: -------------------------------------------------------------------------------- 1 | ServerManager Unit Test Framework 2 | --------------------------------- 3 | 1. First you need to set the unit-test environment for unit-testing. 4 | You can do that by running the setup_utenv.sh from the ../src/unit-tests directory 5 | This is a ONE TIME OPERATION 6 | 2. Add your unit-test code by creating a new directory for each functionality like it is done in monitoring 7 | 3. Add the test-suite that you are creating to the wrapper test-suite in sm_unit_test.py 8 | 4. Run the test by running the script run_tests.sh script 9 | 5. Generate the code-coverage report by running the code_coverage.sh script 10 | You can go to the browser and see the report under http:///figleafhtml directory 11 | -------------------------------------------------------------------------------- /src/contrail-server-manager.start: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | setenforce 0 4 | setsebool -P httpd_can_network_connect_cobbler 1 5 | iptables -F 6 | 7 | 8 | service httpd restart 9 | service sqlite restart 10 | service cobblerd restart 11 | 12 | service puppetmaster start 13 | service puppet start 14 | 15 | cobbler sync 16 | #XINETD and NTPD to be restarted after cobbler sync. 17 | service xinetd restart 18 | service ntpd restart 19 | 20 | mkdir -p /var/run/contrail-server-manager/ 21 | nohup /opt/contrail/server_manager/server_mgr_main.py -c /opt/contrail/server_manager/sm-config.ini 0<&- &> /var/run/contrail-server-manager/contrail-server-manager.log& 22 | 23 | cd /var/www/html/thirdparty_packages 24 | dpkg-scanpackages . | gzip -9c > Packages.gz 25 | -------------------------------------------------------------------------------- /ansible/playbooks/build_setup.yaml: -------------------------------------------------------------------------------- 1 | - name: "Install docker-py" 2 | yum: 3 | name: python-docker-py 4 | state: present 5 | become: yes 6 | become_user: root 7 | 8 | - name: Disable selinux for the build 9 | selinux: 10 | state: disabled 11 | become: yes 12 | become_user: root 13 | 14 | - name: "Start runner docker container in background" 15 | docker_container: 16 | name: "{{ docker.0.name|default('runner') }}" 17 | image: "{{ docker.0.image }}" 18 | state: started 19 | env: "{{ docker.0.environment|default(omit) }}" 20 | network_mode: host 21 | command: sleep infinity 22 | volumes: 23 | - "{{ sourcedir }}" 24 | - "/var/run/docker.sock:/var/run/docker.sock" 25 | become: yes 26 | become_user: root 27 | -------------------------------------------------------------------------------- /src/smgr.conf: -------------------------------------------------------------------------------- 1 | # ************************************ 2 | # Vhost template in module puppetlabs-apache 3 | # Managed by Puppet 4 | # ************************************ 5 | 6 | ServerName smgr 7 | ServerAdmin root@localhost 8 | 9 | ## Vhost docroot 10 | DocumentRoot "/var/www/html" 11 | ServerAlias puppet 12 | ## Directories, there should at least be a declaration for /var/www 13 | 14 | 15 | Options Indexes FollowSymLinks MultiViews 16 | AllowOverride None 17 | Order allow,deny 18 | Allow from all 19 | 20 | 21 | ## Logging 22 | ErrorLog "/var/log/apache2/smgr_error.log" 23 | ServerSignature Off 24 | CustomLog "/var/log/apache2/smgr_access.log" combined 25 | 26 | -------------------------------------------------------------------------------- /src/contrail_smgr/smgr.conf: -------------------------------------------------------------------------------- 1 | # ************************************ 2 | # Vhost template in module puppetlabs-apache 3 | # Managed by Puppet 4 | # ************************************ 5 | 6 | ServerName smgr 7 | ServerAdmin root@localhost 8 | 9 | ## Vhost docroot 10 | DocumentRoot "/var/www/html" 11 | ServerAlias puppet 12 | ## Directories, there should at least be a declaration for /var/www 13 | 14 | 15 | Options Indexes FollowSymLinks MultiViews 16 | AllowOverride None 17 | Order allow,deny 18 | Allow from all 19 | 20 | 21 | ## Logging 22 | ErrorLog "/var/log/httpd/smgr_error.log" 23 | ServerSignature Off 24 | CustomLog "/var/log/httpd/smgr_access.log" combined 25 | 26 | -------------------------------------------------------------------------------- /src/cobbler/etc_cobbler/named.template: -------------------------------------------------------------------------------- 1 | options { 2 | directory "/var/named"; 3 | dump-file "/var/named/data/cache_dump.db"; 4 | statistics-file "/var/named/data/named_stats.txt"; 5 | memstatistics-file "/var/named/data/named_mem_stats.txt"; 6 | allow-recursion { any; }; 7 | recursion yes; 8 | }; 9 | 10 | logging { 11 | channel default_debug { 12 | file "data/named.run"; 13 | severity dynamic; 14 | }; 15 | }; 16 | 17 | #for $zone in $forward_zones 18 | zone "${zone}." { 19 | type master; 20 | file "$zone"; 21 | }; 22 | 23 | #end for 24 | #for $zone, $arpa in $reverse_zones 25 | zone "${arpa}." { 26 | type master; 27 | file "$zone"; 28 | }; 29 | 30 | #end for 31 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/named.template: -------------------------------------------------------------------------------- 1 | options { 2 | directory "/var/named"; 3 | dump-file "/var/named/data/cache_dump.db"; 4 | statistics-file "/var/named/data/named_stats.txt"; 5 | memstatistics-file "/var/named/data/named_mem_stats.txt"; 6 | allow-recursion { any; }; 7 | recursion yes; 8 | }; 9 | 10 | logging { 11 | channel default_debug { 12 | file "data/named.run"; 13 | severity dynamic; 14 | }; 15 | }; 16 | 17 | #for $zone in $forward_zones 18 | zone "${zone}." { 19 | type master; 20 | file "$zone"; 21 | }; 22 | 23 | #end for 24 | #for $zone, $arpa in $reverse_zones 25 | zone "${arpa}." { 26 | type master; 27 | file "$zone"; 28 | }; 29 | 30 | #end for 31 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/setup.cfg: -------------------------------------------------------------------------------- 1 | [entry_points] 2 | console_scripts = 3 | server-manager-client = smgrcliapp.smgr_cli_main:main 4 | 5 | smgr.cli.common = 6 | display = smgrcliapp.smgr_show:Show 7 | reimage = smgrcliapp.smgr_reimage_server:Reimage 8 | restart = smgrcliapp.smgr_restart_server:Restart 9 | provision = smgrcliapp.smgr_provision_server:Provision 10 | status = smgrcliapp.smgr_status:Status 11 | add = smgrcliapp.smgr_add:Add 12 | update = smgrcliapp.smgr_edit:Edit 13 | delete = smgrcliapp.smgr_delete:Delete 14 | upload-image = smgrcliapp.smgr_upload_image:UploadImage 15 | run-inventory = smgrcliapp.smgr_run_inventory:RunInventory 16 | issu = smgrcliapp.smgr_issu:Issu 17 | issu-finalize = smgrcliapp.smgr_issu:IssuFinalize 18 | issu-rollback = smgrcliapp.smgr_issu:IssuRollback 19 | -------------------------------------------------------------------------------- /src/client/image.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": [ 3 | { 4 | "id": "ubuntu-12.04.3", 5 | "category": "image", 6 | "type": "ubuntu", 7 | "version": "ubuntu-12.04.3", 8 | "path": "/iso/ubuntu-12.04.3-server-amd64.iso" 9 | }, 10 | { 11 | "id": "centos-6.4", 12 | "category": "image", 13 | "type": "centos", 14 | "version": "centos-6.4", 15 | "path": "/iso/CentOS-6.4-x86_64-minimal.iso" 16 | }, 17 | { 18 | "id": "contrail-ubuntu-150", 19 | "category": "package", 20 | "type": "contrail-ubuntu-package", 21 | "version": "contrail-ubuntu-150", 22 | "path": "/iso/contrail-install-packages_1.03-150_all.deb" 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /src/contrail-server-manager.start.u: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | setenforce 0 &> /dev/null 4 | setsebool -P httpd_can_network_connect_cobbler 1 &> /dev/null 5 | iptables -F &> /dev/null 6 | 7 | echo "" 8 | echo "Restarting Apache2" 9 | echo "" 10 | service apache2 restart &> /dev/null 11 | 12 | echo "" 13 | echo "Restarting Cobbler" 14 | echo "" 15 | service cobblerd restart &> /dev/null 16 | 17 | echo "" 18 | echo "Doing Cobbler Sync" 19 | echo "" 20 | cobbler sync &> /dev/null 21 | 22 | echo "" 23 | echo "Restarting Xinetd" 24 | echo "" 25 | service xinetd restart &> /dev/null 26 | 27 | mkdir -p /var/run/contrail-server-manager/ 28 | echo "" 29 | echo "Starting SMgr" 30 | echo "" 31 | nohup /opt/contrail/server_manager/server_mgr_main.py -c /opt/contrail/server_manager/sm-config.ini 0<&- &> /var/run/contrail-server-manager/contrail-server-manager.log& 32 | 33 | -------------------------------------------------------------------------------- /ansible/config/server_manager_server.yml: -------------------------------------------------------------------------------- 1 | --- 2 | server_manager_server: 3 | 5b11s3-node3: 4 | ip: localhost 5 | connection: local 6 | ssh_user: root 7 | ssh_pass: c0ntrail123 8 | sudo_pass: c0ntrail123 9 | 10 | # Specify either container_path 11 | # container_path: /root/docker/contrail_command_kit/contrail-command.tar 12 | # or registry details and container_name 13 | #registry_insecure: true 14 | container_registry: localhost:5000 15 | #container_name: server-manager 16 | #container_tag: latest 17 | config_dir: /etc/contrail 18 | 19 | # Server configurations given here go to /etc/contrail/server_manager.yml 20 | server_config: 21 | log_level: debug 22 | monitoring: false 23 | address: ":9001" 24 | 25 | -------------------------------------------------------------------------------- /src/unit_tests/sm_unit_test.py: -------------------------------------------------------------------------------- 1 | import sys, os, time, pdb 2 | import unittest 3 | sys.path.append(os.path.abspath(os.pardir)) 4 | sys.path.append(os.path.abspath('../..')) 5 | from test_sm_rest_api.test_sm_rest_api import * 6 | from monitoring.monitoring import * 7 | 8 | #Create a TestSuite for the running the unit-test for the entire ServerManger 9 | def sm_unit_test_suite(): 10 | suite = unittest.TestSuite() 11 | #Adding the Monitoring uni-test suite 12 | suite.addTest(monitoring_suite()) 13 | suite.addTest(sm_rest_api_suite()) 14 | #Test suite for functions in sm_mgr_main.py 15 | suite.addTest(smgr_main_suite()) 16 | return suite 17 | 18 | #Run the entire SM unit testsuite when this scrip is run 19 | if __name__ == '__main__': 20 | mySuite = sm_unit_test_suite() 21 | runner = unittest.TextTestRunner() 22 | runner.run(mySuite) 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: deps lint test build 2 | 3 | .PHONY: docker 4 | 5 | deps: ## Setup the go dependencies 6 | 7 | lint: ## Runs gometalinter on the source code 8 | 9 | test: ## Run go test with race and coverage args 10 | 11 | build: ## Run go build 12 | 13 | generate: ## Run the source code generator 14 | 15 | package: ## Generate the packages 16 | 17 | install: 18 | 19 | docker-cobbler: ## Generate cobbler docker container 20 | docker build -t "cobbler" -f docker/cobbler/Dockerfile . 21 | 22 | docker-contrail-sm: ## Generate Contrail Server Manager docker container 23 | docker build -t "contrail-server-manager" -f docker/contrail-sm/Dockerfile . 24 | 25 | docker: docker-cobbler docker-contrail-sm 26 | 27 | help: 28 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 29 | 30 | .DEFAULT_GOAL := help 31 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/setup_server_manager_client.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | DOCKER_IP=`ifconfig docker0 | grep "inet addr" | awk '{print $2}' | cut -d ':' -f 2` 5 | HOST_IP_LIST=`ifconfig | sed -n -e 's/:127\.0\.0\.1 //g' -e "s/$DOCKER_IP//g" -e 's/ *inet addr:\([0-9.]\+\).*/\1/gp'` 6 | HOST_IP=`echo $HOST_IP_LIST | cut -d' ' -f1` 7 | if [ -f /opt/contrail/contrail_server_manager/IP.txt ]; 8 | then 9 | HOST_IP=$(cat /opt/contrail/contrail_server_manager/IP.txt) 10 | fi 11 | echo $HOST_IP 12 | mkdir -p /etc/contrail/ 13 | cp /tmp/servermanagerclient /etc/contrail/servermanagerclient 14 | cp /tmp/sm-client-config.ini /etc/contrail/sm-client-config.ini 15 | sed -i "s/listen_ip_addr = .*/listen_ip_addr = $HOST_IP/g" /etc/contrail/sm-client-config.ini 16 | sed -i "s/export SMGR_IP=.*/export SMGR_IP=$HOST_IP/g" /etc/contrail/servermanagerclient 17 | source /etc/contrail/servermanagerclient 18 | ln -sbf /opt/contrail/bin/* /usr/bin/ 19 | -------------------------------------------------------------------------------- /src/client/cluster-5-node-interface.json: -------------------------------------------------------------------------------- 1 | { 2 | "cluster" : [ 3 | { 4 | "id" : "5-node", 5 | "parameters" : { 6 | "router_asn": "64512", 7 | "database_dir": "/home/cassandra", 8 | "database_token": "", 9 | "use_certificates": "False", 10 | "multi_tenancy": "True", 11 | "encapsulation_priority": "MPLSoUDP,MPLSoGRE,VXLAN", 12 | "keystone_username": "admin", 13 | "keystone_password": "contrail123", 14 | "keystone_tenant": "admin", 15 | "analytics_data_ttl": "168", 16 | "subnet_mask": "255.255.255.240", 17 | "gateway": "10.204.221.62", 18 | "password": "c0ntrail123", 19 | "haproxy": "disable", 20 | "external_bgp": "", 21 | "domain": "englab.juniper.net" 22 | } 23 | } 24 | ] 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/client/new-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": [ 3 | { 4 | "category": "package", 5 | "id": "image_3_00_2693", 6 | "path": "/home/abhay/contrail/contrail-install-packages_3.0-2693~juno_all.deb", 7 | "type": "contrail-ubuntu-package", 8 | "version": "image-3-00-2693", 9 | "parameters" : { 10 | "provision": { 11 | "contrail": { 12 | "contrail_version": "image-3-00-2693", 13 | "package_sku": "juno" 14 | } 15 | } 16 | } 17 | }, 18 | { 19 | "category": "package", 20 | "id": "containers_4_00_3063", 21 | "path": "/sm-shared-folder/bin/contrail-cloud-docker_4.0.0.0-3063-mitaka.tgz", 22 | "type": "contrail-ubuntu-package", 23 | "version": "4.0.0-3063", 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /src/server_manager/utils/smgr_upgrade_script.sh: -------------------------------------------------------------------------------- 1 | #Upgrade script to upgrade the server-manager RPM(Centos) 2 | #Usage: ./smgr_upgrade_script.sh 3 | #!/bin/sh 4 | set -x -v 5 | mkdir -p /contrail-smgr-save 6 | cp /etc/cobbler/dhcp.template /contrail-smgr-save 7 | cp /etc/cobbler/named.template /contrail-smgr-save 8 | cp /etc/cobbler/settings /contrail-smgr-save 9 | cp /etc/cobbler/zone.template /contrail-smgr-save 10 | cp -r /etc/cobbler/zone_templates /contrail-smgr-save 11 | service contrail-server-manager stop 12 | yum -y remove contrail-server-manager 13 | yum -y localinstall $1 14 | cp /contrail-smgr-save/dhcp.template /etc/cobbler/dhcp.template 15 | cp /contrail-smgr-save/named.template /etc/cobbler/named.template 16 | cp /contrail-smgr-save/settings /etc/cobbler/settings 17 | cp /contrail-smgr-save/zone.template /etc/cobbler/zone.template 18 | cp -r /contrail-smgr-save/zone_templates /etc/cobbler/ 19 | service contrail-server-manager start 20 | 21 | -------------------------------------------------------------------------------- /src/server_manager/utils/provision_test_script.sh: -------------------------------------------------------------------------------- 1 | source /etc/contrail/openstackrc 2 | wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img 3 | glance image-create --name 'cirros' --container-format ovf --disk-format qcow2 --file ./cirros-0.3.0-x86_64-disk.img 4 | neutron net-create testvn 5 | neutron subnet-create testvn 30.30.31.0/24 --name test_subnet 6 | nova image-list | grep cirros| grep -oh "[a-z0-9]*-[a-z0-9]*-[a-z0-9]*-[a-z0-9]*-[a-z0-9]*" 7 | image_id=$(nova image-list | grep cirros| grep -oh "[a-z0-9]*-[a-z0-9]*-[a-z0-9]*-[a-z0-9]*-[a-z0-9]*") 8 | net_id=$(nova net-list | grep testvn_nitishk| grep -oh "[a-z0-9]*-[a-z0-9]*-[a-z0-9]*-[a-z0-9]*-[a-z0-9]*") 9 | nova boot --flavor 1 --nic net-id=$net_id --image $image_id vm100 10 | nova list 11 | nova boot --flavor 1 --nic net-id=$net_id --image $image_id vm101 12 | nova list 13 | sleep 15 14 | nova list 15 | 16 | # On the spawned VM100: 17 | # ping 30.30.31.4 18 | # wget http://169.254.169.254/openstack 19 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/puppet.conf.rpmsave: -------------------------------------------------------------------------------- 1 | [main] 2 | # The Puppet log directory. 3 | # The default value is '$vardir/log'. 4 | logdir = /var/log/puppet 5 | 6 | # Where Puppet PID files are kept. 7 | # The default value is '$vardir/run'. 8 | rundir = /var/run/puppet 9 | 10 | # Where SSL certificates are kept. 11 | # The default value is '$confdir/ssl'. 12 | ssldir = $vardir/ssl 13 | 14 | [agent] 15 | # The file in which puppetd stores a list of the classes 16 | # associated with the retrieved configuratiion. Can be loaded in 17 | # the separate ``puppet`` executable using the ``--loadclasses`` 18 | # option. 19 | # The default value is '$confdir/classes.txt'. 20 | classfile = $vardir/classes.txt 21 | 22 | # Where puppetd caches the local configuration. An 23 | # extension indicating the cache format is added automatically. 24 | # The default value is '$confdir/localconfig'. 25 | localconfig = $vardir/localconfig 26 | 27 | -------------------------------------------------------------------------------- /ansible/playbooks/roles/create_configs/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - set_fact: 4 | config_dir: >- 5 | {%- for server,cfg in server_manager_server.iteritems() -%} 6 | {%- if cfg.ip == inventory_hostname -%} 7 | {{ cfg.get('config_dir', '/etc/contrail') }} 8 | {%- endif -%} 9 | {%- endfor -%} 10 | 11 | - name: Create host specific server_manager_config 12 | set_fact: 13 | host_server_config: >- 14 | {%- for server,cfg in command_servers.iteritems() -%} 15 | {%- if cfg.ip == inventory_hostname -%} 16 | {{ cfg.get('server_config', {}) }} 17 | {%- endif -%} 18 | {%- endfor -%} 19 | 20 | - name: Create merged server_config 21 | set_fact: 22 | server_manager_config: "{{ default_server_manage_config|combine(host_server_config, recursive=True) }}" 23 | 24 | - name: Creating sm-config.ini 25 | template: 26 | src: "{{ role_path }}/templates/sm-config.ini.j2" 27 | dest: "{{ config_dir }}/sm-config.ini" 28 | 29 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/test-data/sensor/supermicro_sensor_expected_output.txt: -------------------------------------------------------------------------------- 1 | System Temp | 28 degrees C | ok 2 | CPU Temp | 0 unspecified | ok 3 | FAN 1 | 3825 RPM | ok 4 | FAN 4 | disabled | ns 5 | Vcore | 0.89 Volts | ok 6 | 3.3VCC | 3.28 Volts | ok 7 | 12V | 12.30 Volts | ok 8 | VDIMM | 1.54 Volts | ok 9 | 5VCC | 5.02 Volts | ok 10 | -12V | -12.49 Volts | ok 11 | VBAT | 3.17 Volts | ok 12 | VSB | 3.33 Volts | ok 13 | AVCC | 3.30 Volts | ok 14 | Chassis Intru | 0 unspecified | ok 15 | PS Status | 0 unspecified | nc 16 | BMC FRU | Log FRU @00h 00.0 | ok 17 | ATEN BMC | Dynamic MC @ 20h | ok 18 | NM exception | Event-Only | ns 19 | NM health | Event-Only | ns 20 | NM op cap | Event-Only | ns 21 | NM alert | Event-Only | ns 22 | -------------------------------------------------------------------------------- /src/cobbler/etc_cobbler/tftpd.template: -------------------------------------------------------------------------------- 1 | # default: off 2 | # description: The tftp server serves files using the trivial file transfer \ 3 | # protocol. The tftp protocol is often used to boot diskless \ 4 | # workstations, download configuration files to network-aware printers, \ 5 | # and to start the installation process for some operating systems. 6 | service tftp 7 | { 8 | disable = no 9 | socket_type = dgram 10 | protocol = udp 11 | wait = yes 12 | user = root 13 | server = /usr/sbin/in.tftpd 14 | server_args = -B 1380 -R 49152:49160 -v -s /var/lib/tftpboot 15 | log_type = FILE /var/log/tftp.log 16 | log_on_success = PID HOST USERID EXIT DURATION 17 | log_on_failure = USERID ATTEMPT 18 | per_source = 11 19 | cps = 100 2 20 | flags = IPv4 21 | } 22 | -------------------------------------------------------------------------------- /src/scons/monitoring/ipmi/SConscript: -------------------------------------------------------------------------------- 1 | # -*- mode: python; -*- 2 | 3 | import os 4 | Import('BuildEnv') 5 | env = BuildEnv.Clone() 6 | 7 | sources = [ 8 | 'MANIFEST.in', 9 | 'setup.py' 10 | ] 11 | 12 | setup_sources_rules = [] 13 | for file in sources: 14 | setup_sources_rules.append(env.Install("", "#controller/src/server-manager/monitoring/ipmi/" + file)) 15 | 16 | sources += env.SandeshGenPy( 17 | 'monitoring.sandesh', 18 | 'contrail_sm_monitoring/', False) 19 | 20 | MonitoringDocFiles = [] 21 | MonitoringDocFiles += env.SandeshGenDoc('monitoring.sandesh') 22 | 23 | cd_cmd = 'cd ' + Dir('.').path + ' && ' 24 | if 'install_contrail_sm_monitoring' in BUILD_TARGETS: 25 | install_cmd = env.Command(None, sources, 26 | cd_cmd + 'python setup.py install %s' % 27 | env['PYTHON_INSTALL_OPT']) 28 | env.Alias('install_contrail_sm_monitoring', install_cmd) 29 | env.Alias('install', env.Install( 30 | env['INSTALL_MESSAGE_DOC'] + '/contrail-sm-monitoring/', 31 | MonitoringDocFiles)) 32 | -------------------------------------------------------------------------------- /src/scons/inventory/inventory-daemon/SConscript: -------------------------------------------------------------------------------- 1 | # -*- mode: python; -*- 2 | 3 | import os 4 | Import('BuildEnv') 5 | env = BuildEnv.Clone() 6 | 7 | sources = [ 8 | 'MANIFEST.in', 9 | 'setup.py', 10 | ] 11 | 12 | sources += env.SandeshGenPy( 13 | 'server_inventory.sandesh', 14 | 'inventory_daemon/', False) 15 | 16 | local_sources = [ 17 | '__init__.py', 18 | ] 19 | 20 | local_sources_rules = [] 21 | for file in local_sources: 22 | local_sources_rules.append(env.Install(Dir("inventory_daemon"), file)) 23 | 24 | cd_cmd = 'cd ' + Dir('.').path + ' && ' 25 | sdist_gen = env.Command('dist', 26 | sources+local_sources, 27 | cd_cmd + 'python setup.py sdist') 28 | env.Alias('controller/src/inventory:sdist', sdist_gen) 29 | env.Default(sdist_gen) 30 | 31 | if 'install_contrail_sm_inventory' in BUILD_TARGETS: 32 | env.Alias('install_contrail_sm_inventory', 33 | env.Command(None, sources+local_sources, 34 | cd_cmd + 'python setup.py install %s' % 35 | env['PYTHON_INSTALL_OPT'])) 36 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/cobbler.conf: -------------------------------------------------------------------------------- 1 | # This configuration file allows cobbler data 2 | # to be accessed over HTTP. 3 | 4 | AliasMatch ^/cblr(?!/svc/)(.*)?$ "/var/www/cobbler$1" 5 | AliasMatch ^/cobbler_track(.*)?$ "/var/www/cobbler$1" 6 | #AliasMatch ^/cobbler(.*)?$ "/var/www/cobbler$1" 7 | Alias /cobbler /var/www/cobbler 8 | Alias /cobbler_webui_content /var/www/cobbler_webui_content 9 | 10 | WSGIScriptAliasMatch ^/cblr/svc/([^/]*) /var/www/cobbler/svc/services.py 11 | 12 | 13 | Options Indexes FollowSymLinks 14 | Order allow,deny 15 | Allow from all 16 | 17 | 18 | ProxyRequests off 19 | 20 | ProxyPass /cobbler_api http://localhost:25151/ 21 | ProxyPassReverse /cobbler_api http://localhost:25151/ 22 | 23 | BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On 24 | 25 | # the webui is now part of the "cobbler-web" package 26 | # and is visited at http://.../cobbler_web not this URL. 27 | # this is only a pointer to the new page. 28 | 29 | 30 | Options Indexes FollowSymLinks 31 | Order allow,deny 32 | Allow from all 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/cobbler.conf.sample: -------------------------------------------------------------------------------- 1 | # This configuration file allows cobbler data 2 | # to be accessed over HTTP. 3 | 4 | AliasMatch ^/cblr(?!/svc/)(.*)?$ "/var/www/cobbler$1" 5 | AliasMatch ^/cobbler_track(.*)?$ "/var/www/cobbler$1" 6 | #AliasMatch ^/cobbler(.*)?$ "/var/www/cobbler$1" 7 | Alias /cobbler /var/www/cobbler 8 | Alias /cobbler_webui_content /var/www/cobbler_webui_content 9 | 10 | WSGIScriptAliasMatch ^/cblr/svc/([^/]*) /var/www/cobbler/svc/services.py 11 | 12 | 13 | Options Indexes FollowSymLinks 14 | Order allow,deny 15 | Allow from all 16 | 17 | 18 | ProxyRequests off 19 | 20 | ProxyPass /cobbler_api http://localhost:25151/ 21 | ProxyPassReverse /cobbler_api http://localhost:25151/ 22 | 23 | BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On 24 | 25 | # the webui is now part of the "cobbler-web" package 26 | # and is visited at http://.../cobbler_web not this URL. 27 | # this is only a pointer to the new page. 28 | 29 | 30 | Options Indexes FollowSymLinks 31 | Order allow,deny 32 | Allow from all 33 | 34 | 35 | -------------------------------------------------------------------------------- /ansible/playbooks/build.yml: -------------------------------------------------------------------------------- 1 | - name: Build containers 2 | hosts: localhost 3 | roles: 4 | - install-docker-daemon 5 | - role: add-insecure-registry 6 | new_registry: "{{ contrail_docker_registry }}" 7 | vars: 8 | workdir: /root/contrail-server-manager 9 | sourcedir: "{{ ansible_env.HOME }}" 10 | tasks: 11 | - include: build-setup.yaml 12 | 13 | - name: run 14 | include: build-step.yaml 15 | loop_control: 16 | label: "{{ item.name }}" 17 | with_items: # Insert tasks here 18 | - name: Make docker 19 | command: make docker 20 | 21 | - name: Fix files ownerships 22 | file: 23 | name: "{{ sourcedir }}" 24 | recurse: yes 25 | owner: "{{ ansible_env.USER }}" 26 | become: yes 27 | become_user: root 28 | 29 | - hosts: localhost 30 | name: Publish containers to the internal registry 31 | roles: 32 | - role: publish-container-images 33 | registry: "{{ contrail_docker_registry }}" 34 | tag: "{{ packaging.docker_version }}" 35 | images: 36 | - { name: server-manager, tag: latest } 37 | - { name: cobbler, tag: latest } 38 | -------------------------------------------------------------------------------- /ansible/playbooks/roles/create_configs/defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | default_server_manager_config: 3 | 4 | # Server Manager 5 | log_level: debug 6 | listen_ip_addr: 127.0.0.1 7 | listen_port: 9001 8 | database_name: smgr_data.db 9 | server_manager_base_dir: /etc/contrail_smgr/ 10 | html_root_dir: /var/www/html/ 11 | 12 | # Cobbler 13 | cobbler: true 14 | cobbler_ip_address: 127.0.0.1 15 | cobbler_port: 25151 16 | cobbler_username: testing 17 | cobbler_password: testing 18 | 19 | # IPMI 20 | ipmi_username: ADMIN 21 | ipmi_password: ADMIN 22 | ipmi_interface: 23 | ipmi_type: ipmilan 24 | 25 | # Sandesh 26 | collectors: ['127.0.0.1:8086'] 27 | http_introspect_port: 8107 28 | sandesh_log_level: SYS_ERR 29 | 30 | # Ansible 31 | ansible_srvr_ip : 127.0.0.1 32 | ansible_srvr_port: 9003 33 | ansible_log_path: /var/log/contrail-server-manager/debug.log 34 | 35 | # Monitoring 36 | monitoring: false 37 | monitoring_frequency: 300 38 | monitoring_plugin: server_mgr_ipmi_monitoring.ServerMgrIPMIMonitoring 39 | inventory_plugin: server_mgr_inventory.ServerMgrInventory 40 | -------------------------------------------------------------------------------- /src/cobbler/var_lib_cobbler/loaders/README: -------------------------------------------------------------------------------- 1 | ** DISCLAIMER ** 2 | 3 | In order to network install ("netboot") various arches, different boot loaders are required 4 | for each architecture. Unfortunately for Enterprise Linux and Fedora, these packages 5 | are not available to all arches. 6 | 7 | The requirements for netbooting each are as follows: 8 | 9 | x86/x86_64 require syslinux (pxelinux.0), and menu.c32 10 | ppc/ppc64 use yaboot 11 | ia64 uses elilo 12 | 13 | This is further complicated by Fedora not supporting IA64 and needing to provide 14 | the same content to Debian and other install bases using the install server. 15 | 16 | So, to faciliate providing content for users that do not wish to source content manually 17 | these are supplied from https://cobbler.github.io as an optional way of getting that content. 18 | 19 | Users may also want to use the latest versions of these packages from source or supply 20 | their own from another source -- these are provided only for convience. 21 | 22 | We are not responsible for ensuring these versions are up to date, but if you would like 23 | to see a later version made available here email the project mailing list. 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/cobbler/etc_bind/named.conf.options: -------------------------------------------------------------------------------- 1 | options { 2 | directory "/var/cache/bind"; 3 | 4 | // If there is a firewall between you and nameservers you want 5 | // to talk to, you may need to fix the firewall to allow multiple 6 | // ports to talk. See http://www.kb.cert.org/vuls/id/800113 7 | 8 | // If your ISP provided one or more IP addresses for stable 9 | // nameservers, you probably want to use them as forwarders. 10 | // Uncomment the following block, and insert the addresses replacing 11 | // the all-0's placeholder. 12 | 13 | // forwarders { 14 | // 0.0.0.0; 15 | // }; 16 | allow-query { any;}; 17 | recursion yes; 18 | //======================================================================== 19 | // If BIND logs error messages about the root key being expired, 20 | // you will need to update your keys. See https://www.isc.org/bind-keys 21 | //======================================================================== 22 | dnssec-validation auto; 23 | 24 | auth-nxdomain no; # conform to RFC1035 25 | listen-on-v6 { any; }; 26 | }; 27 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/test-data/sensor/sensor_wrongoutput.txt: -------------------------------------------------------------------------------- 1 | System Temp 28 degrees C | ok 2 | Peripheral Temp | 36 degrees C | ok 3 | CPU Temp | 0 unspecified | ok 4 | FAN 1 | 3825 RPM | ok 5 | FAN 2 | disabled | ok 6 | FAN 3 | 3525 RPM | ok 7 | FAN 4 | disabled | ns 8 | FAN A | 3600 RPM | ok 9 | Vcore | 0.89 Volts | ok 10 | 3.3VCC | 3.28 Volts | ok 11 | 12V | 12.30 Volts | ok 12 | VDIMM | 1.54 Volts | ok 13 | 5VCC | 5.02 Volts | ok 14 | -12V | -12.49 Volts | ok 15 | VBAT | 3.17 Volts | ok 16 | VSB | 3.33 Volts | ok 17 | AVCC | 3.30 Volts | ok 18 | Chassis Intru | 0 unspecified | ok 19 | PS Status | 0 unspecified | nc 20 | BMC FRU | Log FRU @00h 00.0 | ok 21 | ATEN BMC | Dynamic MC @ 20h | ok 22 | NM exception | Event-Only | ns 23 | NM health | Event-Only | ns 24 | NM op cap | Event-Only | ns 25 | NM alert | Event-Only | ns 26 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/named.conf.options.u: -------------------------------------------------------------------------------- 1 | options { 2 | directory "/var/cache/bind"; 3 | 4 | // If there is a firewall between you and nameservers you want 5 | // to talk to, you may need to fix the firewall to allow multiple 6 | // ports to talk. See http://www.kb.cert.org/vuls/id/800113 7 | 8 | // If your ISP provided one or more IP addresses for stable 9 | // nameservers, you probably want to use them as forwarders. 10 | // Uncomment the following block, and insert the addresses replacing 11 | // the all-0's placeholder. 12 | 13 | // forwarders { 14 | // 0.0.0.0; 15 | // }; 16 | allow-query { any;}; 17 | recursion yes; 18 | //======================================================================== 19 | // If BIND logs error messages about the root key being expired, 20 | // you will need to update your keys. See https://www.isc.org/bind-keys 21 | //======================================================================== 22 | dnssec-validation auto; 23 | 24 | auth-nxdomain no; # conform to RFC1035 25 | listen-on-v6 { any; }; 26 | }; 27 | -------------------------------------------------------------------------------- /src/contrail_smgr/kickstarts/contrail-esxi.ks: -------------------------------------------------------------------------------- 1 | # 2 | # Sample scripted installation file 3 | # for ESXi 5+ 4 | # 5 | 6 | vmaccepteula 7 | reboot --noeject 8 | rootpw --iscrypted $passwd 9 | 10 | # Set the network to DHCP on the first network adapter 11 | network --bootproto=dhcp --device=$esx_nicname 12 | 13 | install --firstdisk --overwritevmfs 14 | clearpart --firstdisk --overwritevmfs 15 | 16 | %pre --interpreter=busybox 17 | 18 | %firstboot --interpreter=busybox 19 | # enable VHV (Virtual Hardware Virtualization to run nested 64bit Guests + Hyper-V VM) 20 | grep -i "vhv.enable" /etc/vmware/config || echo "vhv.enable = \"TRUE\"" >> /etc/vmware/config 21 | # enable & start remote ESXi Shell (SSH) 22 | vim-cmd hostsvc/enable_ssh 23 | vim-cmd hostsvc/start_ssh 24 | # enable & start ESXi Shell (TSM) 25 | vim-cmd hostsvc/enable_esx_shell 26 | vim-cmd hostsvc/start_esx_shell 27 | # supress ESXi Shell shell warning 28 | esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1 29 | # ESXi Shell interactive idle time logout 30 | esxcli system settings advanced set -o /UserVars/ESXiShellInteractiveTimeOut -i 3600 31 | # assign license 32 | vim-cmd vimsvc/license --set $server_license 33 | 34 | %post --interpreter=busybox 35 | $SNIPPET('kickstart_done') 36 | -------------------------------------------------------------------------------- /src/SConscript: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. 3 | # 4 | 5 | # -*- mode: python; -*- 6 | # src directory 7 | 8 | import sys 9 | import subprocess 10 | import platform 11 | 12 | subdirs = [ 13 | 'scons', 14 | ] 15 | 16 | libs = ['boost_system', 'boost_thread', 'log4cplus'] 17 | libs.append('pthread') 18 | 19 | common = DefaultEnvironment().Clone() 20 | 21 | libs.append('tbb_debug') 22 | 23 | common.Append(CXXFLAGS = '-Wall -Werror -Wsign-compare') 24 | if subprocess.check_output("g++ --version | grep g++ | awk '{print $3}'", 25 | shell=True).rstrip() == "4.8.5": 26 | common.Append(CCFLAGS = '-Wno-narrowing -Wno-conversion-null') 27 | 28 | if platform.system().startswith('Linux'): 29 | if not platform.linux_distribution()[0].startswith('XenServer'): 30 | common.Append(CCFLAGS = ['-Wno-unused-local-typedefs']) 31 | common.Append(CCFLAGS = [common['CPPDEFPREFIX'] + 'RAPIDJSON_NAMESPACE=contrail_rapidjson']) 32 | 33 | BuildEnv = common.Clone() 34 | 35 | if sys.platform.startswith('linux'): 36 | BuildEnv.Append(CCFLAGS = ['-DLINUX']) 37 | 38 | for dir in subdirs: 39 | BuildEnv.SConscript(dir + '/SConscript', 40 | exports='BuildEnv', 41 | duplicate=0) 42 | -------------------------------------------------------------------------------- /ansible/playbooks/roles/create_configs/templates/sm.config.ini.j2: -------------------------------------------------------------------------------- 1 | [SERVER-MANAGER] 2 | listen_ip_addr = {{ listen_ip_addr }} 3 | listen_port = {{ listen_port }} 4 | database_name = {{ database_name }} 5 | server_manager_base_dir = {{ server_manager_base_dir }} 6 | html_root_dir = {{ html_root_dir }} 7 | cobbler = {{ cobbler }} 8 | monitoring = {{ monitoring }} 9 | cobbler_ip_address = {{ cobbler_ip_address }} 10 | cobbler_port = {{ cobbler_port }} 11 | cobbler_username = {{ cobbler_username }} 12 | cobbler_password = {{ cobbler_password }} 13 | ipmi_password = {{ ipmi_password }} 14 | ipmi_interface = {{ ipmi_interface }} 15 | ipmi_type = {{ ipmi_type }} 16 | collectors = {{ collectors }} 17 | http_introspect_port = {{ http_introspect_port }} 18 | sandesh_log_level = {{ sandesh_log_level }} 19 | 20 | [ANSIBLE-SERVER] 21 | ansible_srvr_ip = {{ ansible_srvr_ip }} 22 | ansible_srvr_port = {{ ansible_srvr_port }} 23 | ansible_log_path = {{ ansible_log_path }} 24 | 25 | [CLUSTER] 26 | 27 | [SERVER] 28 | 29 | [IMAGE] 30 | 31 | [DHCP_HOST] 32 | 33 | [DHCP_SUBNET] 34 | 35 | [MONITORING] 36 | monitoring_frequency = {{ monitoring_frequency }} 37 | monitoring_plugin = {{ monitoring_plugin }} 38 | 39 | [INVENTORY] 40 | inventory_plugin = {{ inventory_plugin }} 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | contrail-server-manager 2 | ======================= 3 | 4 | # contrail server management 5 | 6 | This software is licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this software except in compliance with the License. 8 | You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 9 | 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 implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | ### Overview 17 | 18 | Contrail Server Manager repo contains code that facilitates management of servers in a contrail cluster. It provides functions to install base OS on servers (reimaging), and configuring the servers by installing necessary packages, configuring and starting different services needed to provide a contrail role functionality on these servers (provisioning). Contrail server manager uses other widely deployed tools such as cobbler and puppet to accomplish the task of reimaging and provisioning. 19 | 20 | Summary, server manager includes Openstack and Contrail installation and provisioning and lifecycle management of each node in a contrail cluster. More details on this feature is described here. http://juni.pr/1nHLtCB. 21 | -------------------------------------------------------------------------------- /src/server_manager/sm-config.ini: -------------------------------------------------------------------------------- 1 | [SERVER-MANAGER] 2 | listen_ip_addr = __$IPADDRESS__ 3 | listen_port = 9001 4 | database_name = smgr_data.db 5 | server_manager_base_dir = /etc/contrail_smgr/ 6 | html_root_dir = /var/www/html/ 7 | cobbler = true 8 | monitoring = true 9 | cobbler_ip_address = __$IPADDRESS__ 10 | cobbler_port = 11 | cobbler_username = testing 12 | cobbler_password = testing 13 | ipmi_username = ADMIN 14 | ipmi_password = ADMIN 15 | ipmi_interface = 16 | ipmi_type = ipmilan 17 | puppet_dir = /etc/puppet/ 18 | puppet_agent_retry_count = 10 19 | puppet_agent_retry_poll_interval_seconds = 20 20 | collectors = ['127.0.0.1:8086'] 21 | http_introspect_port = 8107 22 | sandesh_log_level = SYS_ERR 23 | 24 | [ANSIBLE-SERVER] 25 | docker_insecure_registries = __$IPADDRESS__:5100 26 | docker_registry = __$IPADDRESS__:5100 27 | ansible_srvr_ip = __$IPADDRESS__ 28 | ansible_srvr_port = 9003 29 | ansible_log_path = /var/log/contrail-server-manager/debug.log 30 | 31 | [CLUSTER] 32 | 33 | [SERVER] 34 | 35 | [IMAGE] 36 | 37 | [DHCP_HOST] 38 | 39 | [DHCP_SUBNET] 40 | 41 | [MONITORING] 42 | monitoring_frequency = 300 43 | monitoring_plugin = server_mgr_ipmi_monitoring.ServerMgrIPMIMonitoring 44 | 45 | [INVENTORY] 46 | inventory_plugin = server_mgr_inventory.ServerMgrInventory 47 | -------------------------------------------------------------------------------- /src/server_manager/utils/sm-cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script removes all files and packages related to server manager 3 | 4 | # If you do not have docker running or do not wish to stop docker, you can skip the docker lines 5 | 6 | docker rmi -f `docker images -a | grep -v registry | grep -v REPOSITORY | awk '{print $3}'` 7 | docker stop registry 8 | docker rm registry 9 | docker images -a | awk '{print $3}' | xargs docker rmi -f 10 | 11 | service contrail-server-manager stop 12 | service supervisor-webui-sm stop 13 | sleep 4 14 | 15 | dpkg -l | grep contrail | awk -F ' ' '{print $2}' | xargs dpkg -P 16 | dpkg -l | grep puppet | awk -F ' ' '{print $2}' | xargs dpkg -P 17 | dpkg -l | grep cobbler | awk -F ' ' '{print $2}' | xargs dpkg -P 18 | dpkg -l | grep passenger | awk -F ' ' '{print $2}' | xargs dpkg -P 19 | dpkg -l | grep docker | awk -F ' ' '{print $2}' | xargs dpkg -P 20 | dpkg -l | grep ansible | awk -F ' ' '{print $2}' | xargs dpkg -P 21 | 22 | rm -rf /etc/contrail_smgr/contrail-centos-repo /etc/contrail_smgr/contrail-redhat-repo /var/www/html/thirdparty_packages /opt/contrail/ /var/log/contrail /etc/cobbler/pxe /srv/www/cobbler/ /var/lib/cobbler/ /usr/src/contrail/contrail-web-core/webroot/img /etc/puppet/ /var/lib/puppet /usr/share/puppet /etc/contrail_smgr /etc/contrail /var/www/html/contrail/ /etc/ansible 23 | rm -rf /var/lib/cobbler /var/lib/puppet /etc/puppet /etc/cobbler /etc/contrail* /opt/contrail/contrail_server_manager 24 | rm -rf /var/lib/docker /etc/docker /run/docker 25 | rm -rf /usr/local/bin/ansible* 26 | rm -rf /etc/apt/sources.list.d/*.list 27 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @echo "Making Tar ball" 3 | rpm: 4 | @echo "RPM" 5 | $(eval commit_id=$(shell git log --format="%H" | head -n1)) 6 | @echo git_log is $(commit_id) 7 | mkdir -p ~/rpmbuild/BUILD 8 | mkdir -p ~/rpmbuild/RPMS 9 | mkdir -p ~/rpmbuild/SOURCES 10 | mkdir -p ~/rpmbuild/SPECS 11 | mkdir -p ~/rpmbuild/SRPMS 12 | cp contrail-server-manager.spec ~/rpmbuild/SPECS 13 | rpmbuild -bb ~/rpmbuild/SPECS/contrail-server-manager.spec 14 | cp ~/rpmbuild/RPMS/noarch/contrail_server-manager-1.0-1.noarch.rpm ~/rpmbuild/RPMS/noarch/contrail_server-manager-1.0-1_$(commit_id).noarch.rpm 15 | 16 | deb: 17 | (cd debian-contrail-smgr; fakeroot debian/rules binary) 18 | 19 | client-rpm: 20 | @echo "Client-RPM" 21 | $(eval commit_id=$(shell git log --format="%H" | head -n1)) 22 | @echo git_log is $(commit_id) 23 | mkdir -p ~/rpmbuild/BUILD 24 | mkdir -p ~/rpmbuild/RPMS 25 | mkdir -p ~/rpmbuild/SOURCES 26 | mkdir -p ~/rpmbuild/SPECS 27 | mkdir -p ~/rpmbuild/SRPMS 28 | cp contrail-server-manager-client.spec ~/rpmbuild/SPECS 29 | rpmbuild -bb ~/rpmbuild/SPECS/contrail-server-manager-client.spec 30 | 31 | client-deb: 32 | (cd debian-contrail-smgr-client; fakeroot debian/rules binary) 33 | clean-client-deb: 34 | (cd debian-contrail-smgr-client; fakeroot debian/rules clean) 35 | 36 | client-tar: 37 | tar cvfz server_manager_client.tar.gz client/*.py client/*.json client/*.ini client/server-manager utils/create_smgr_db.py 38 | cp server_manager_client.tar.gz ~/rpmbuild/RPMS/noarch 39 | clean: 40 | (cd debian-contrail-smgr; fakeroot debian/rules clean) 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/bootcfg_esxi55.template: -------------------------------------------------------------------------------- 1 | bootstate=0 2 | title=Loading ESXi installer 3 | prefix=$img_path 4 | kernel=tboot.b00 5 | #if $getVar('system_name','') != '' 6 | #set $what = "system" 7 | #else 8 | #set $what = "profile" 9 | #end if 10 | kernelopt=ks=http://$server/cblr/svc/op/ks/$what/$name 11 | modules=b.b00 --- jumpstrt.gz --- useropts.gz --- k.b00 --- chardevs.b00 --- a.b00 --- user.b00 --- sb.v00 --- s.v00 --- ata_pata.v00 --- ata_pata.v01 --- ata_pata.v02 --- ata_pata.v03 --- ata_pata.v04 --- ata_pata.v05 --- ata_pata.v06 --- ata_pata.v07 --- block_cc.v00 --- ehci_ehc.v00 --- elxnet.v00 --- weaselin.t00 --- esx_dvfi.v00 --- xlibs.v00 --- ima_qla4.v00 --- ipmi_ipm.v00 --- ipmi_ipm.v01 --- ipmi_ipm.v02 --- lpfc.v00 --- lsi_mr3.v00 --- lsi_msgp.v00 --- misc_cni.v00 --- misc_dri.v00 --- mtip32xx.v00 --- net_be2n.v00 --- net_bnx2.v00 --- net_bnx2.v01 --- net_cnic.v00 --- net_e100.v00 --- net_e100.v01 --- net_enic.v00 --- net_forc.v00 --- net_igb.v00 --- net_ixgb.v00 --- net_mlx4.v00 --- net_mlx4.v01 --- net_nx_n.v00 --- net_tg3.v00 --- net_vmxn.v00 --- ohci_usb.v00 --- qlnative.v00 --- rste.v00 --- sata_ahc.v00 --- sata_ata.v00 --- sata_sat.v00 --- sata_sat.v01 --- sata_sat.v02 --- sata_sat.v03 --- sata_sat.v04 --- scsi_aac.v00 --- scsi_adp.v00 --- scsi_aic.v00 --- scsi_bnx.v00 --- scsi_bnx.v01 --- scsi_fni.v00 --- scsi_hps.v00 --- scsi_ips.v00 --- scsi_lpf.v00 --- scsi_meg.v00 --- scsi_meg.v01 --- scsi_meg.v02 --- scsi_mpt.v00 --- scsi_mpt.v01 --- scsi_mpt.v02 --- scsi_qla.v00 --- scsi_qla.v01 --- uhci_usb.v00 --- tools.t00 --- xorg.v00 --- imgdb.tgz --- imgpayld.tgz 12 | build= 13 | updated=0 14 | -------------------------------------------------------------------------------- /src/contrail-server-manager: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # 3 | # chkconfig: 2345 55 45 4 | # description: The server mangement daemon maintains all the servers belonging to contrail ecosystem. 5 | # processname: contrail-server-manager 6 | # config: /etc/sysconfig/contrail-server-manager 7 | # pidfile: /var/run/contrail-server-manager/contrail-server-manager.pid 8 | 9 | #SYSTEMCTL_SKIP_REDIRECT=1 10 | 11 | # Source function library. 12 | . /etc/init.d/functions 13 | 14 | 15 | USER=root 16 | RETVAL=0 17 | prog="contrail-server-manager" 18 | pidfile=${PIDFILE-/var/run/$prog/$prog.pid} 19 | 20 | if [ -f /etc/sysconfig/$prog ];then 21 | . /etc/sysconfig/$prog 22 | fi 23 | 24 | 25 | 26 | start () { 27 | echo -n $"Starting $prog: " 28 | # Ensure that $pidfile directory has proper permissions and exists 29 | piddir=`dirname $pidfile` 30 | if [ ! -d $piddir ]; then 31 | mkdir $piddir 32 | fi 33 | if [ "`stat -c %U $piddir`" != "$USER" ]; then 34 | chown $USER $piddir 35 | fi 36 | daemon --pidfile ${pidfile} /usr/sbin/contrail-server-manager 37 | RETVAL=$? 38 | } 39 | stop () { 40 | echo -n $"Stopping $prog: " 41 | killproc -p ${pidfile} $prog 42 | RETVAL=$? 43 | echo 44 | if [ $RETVAL -eq 0 ] ; then 45 | rm -f ${pidfile} 46 | fi 47 | } 48 | 49 | restart () { 50 | stop 51 | start 52 | } 53 | 54 | 55 | # See how we were called. 56 | case "$1" in 57 | start) 58 | start 59 | ;; 60 | stop) 61 | stop 62 | ;; 63 | status) 64 | status -p ${pidfile} $prog 65 | RETVAL=$? 66 | ;; 67 | restart) 68 | restart 69 | ;; 70 | *) 71 | echo $"Usage: $0 {start|stop|status|restart}" 72 | RETVAL=2 73 | ;; 74 | esac 75 | 76 | exit $RETVAL 77 | -------------------------------------------------------------------------------- /src/server_manager/utils/ipmi_reboot.py: -------------------------------------------------------------------------------- 1 | import time 2 | import sys 3 | from subprocess import Popen,PIPE,check_output,check_call 4 | 5 | ipmi_addresses = ['1.1.1.1'] 6 | total_address = len(ipmi_addresses) 7 | i=0 8 | 9 | 10 | def progress(count, total, suffix='', prefix = ''): 11 | bar_len = 60 12 | filled_len = int(round(bar_len * count / float(total))) 13 | 14 | prefix_len = len(prefix) 15 | prefix_fill = ' ' * (15-prefix_len) 16 | 17 | percents = round(100.0 * count / float(total), 1) 18 | bar = '#' * filled_len + '-' * (bar_len - filled_len) 19 | 20 | sys.stdout.write('%s%s [ %s ] %s%s ...%s\r' % (prefix,prefix_fill,bar, percents, '%', suffix)) 21 | sys.stdout.flush() # As suggested by Rom Ruben 22 | 23 | 24 | 25 | #def update_progress(progress): 26 | #print '\r[{0}] {1}%'.format('#'*(progress/10), progress) 27 | 28 | def hilite(string, status, bold): 29 | attr = [] 30 | if status: 31 | # green 32 | attr.append('32') 33 | else: 34 | # red 35 | attr.append('31') 36 | if bold: 37 | attr.append('1') 38 | return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), string) 39 | 40 | 41 | failed_address = [] 42 | for address in ipmi_addresses: 43 | i+=1 44 | status = " TRYING" 45 | #print address 46 | progress(10, 100, prefix=address, suffix=status ) 47 | cmd=['/usr/bin/ipmitool -U ADMIN -P ADMIN -H '+ address+ ' mc info'] 48 | try: 49 | ipmi_output=check_call(cmd,shell=True,stdout=PIPE, stderr=PIPE) 50 | status = " PASSED " 51 | status = hilite(status, 1, 0) 52 | except: 53 | failed_address.append(address) 54 | status = " FAILED " 55 | status = hilite(status, 0, 0) 56 | pass 57 | 58 | progress(100, 100, prefix=address, suffix=status ) 59 | print "" 60 | 61 | 62 | print "" 63 | print failed_address 64 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/puppet.conf: -------------------------------------------------------------------------------- 1 | [main] 2 | # The Puppet log directory. 3 | # The default value is '$vardir/log'. 4 | logdir = /var/log/puppet 5 | 6 | # Where Puppet PID files are kept. 7 | # The default value is '$vardir/run'. 8 | rundir = /var/run/puppet 9 | 10 | # Where SSL certificates are kept. 11 | # The default value is '$confdir/ssl'. 12 | ssldir = $vardir/ssl 13 | 14 | # Set pluginsync to true (for custom facts) 15 | pluginsync=true 16 | runinterval = 10 17 | configtimeout = 500 18 | 19 | # Enable Environments 20 | environmentpath = $confdir/environments 21 | 22 | # Alternate DNS name to use for server manager node 23 | dns_alt_names = puppet 24 | 25 | [agent] 26 | # The file in which puppetd stores a list of the classes 27 | # associated with the retrieved configuratiion. Can be loaded in 28 | # the separate ``puppet`` executable using the ``--loadclasses`` 29 | # option. 30 | # The default value is '$confdir/classes.txt'. 31 | classfile = $vardir/classes.txt 32 | 33 | # Where puppetd caches the local configuration. An 34 | # extension indicating the cache format is added automatically. 35 | # The default value is '$confdir/localconfig'. 36 | localconfig = $vardir/localconfig 37 | pluginsync = true 38 | ignorecache = true 39 | usecacheonfailure = false 40 | ordering = manifest 41 | report = true 42 | stringify_facts = false 43 | 44 | [master] 45 | node_terminus = exec 46 | external_nodes = /etc/contrail_smgr/puppet/node_classifier.py 47 | # Removing custom report generator to address SM CPU/memory load resulting 48 | # in catalog execution failure in scaled up setup. This is to be revisited 49 | # later along with puppetDb. 50 | # report = true 51 | # reports = smgr_report 52 | pluginsync = true 53 | 54 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/smgrcliapp/smgr_monitoring.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 4 | """ 5 | Name : smgr_monitoring.py 6 | Author : Nitish Krishna 7 | Description : TBD 8 | """ 9 | 10 | import os 11 | import syslog 12 | import time 13 | import signal 14 | from StringIO import StringIO 15 | import sys 16 | import re 17 | import abc 18 | import datetime 19 | import subprocess 20 | import cStringIO 21 | import pycurl 22 | import json 23 | import pdb 24 | 25 | 26 | # Class ServerMgrIPMIQuerying describes the API layer exposed to ServerManager to allow it to query 27 | # the device environment information of the servers stored in its DB. The information is gathered through 28 | # REST API calls to the Server Mgr Analytics Node that hosts the relevant DB. 29 | class ServerMgrIPMIQuerying(): 30 | _query_engine_port = 8107 31 | 32 | def __init__(self): 33 | ''' Constructor ''' 34 | 35 | def show_mon_details(self, args): 36 | rest_api_params = {} 37 | rest_api_params['object'] = 'MonitorInfo' 38 | rest_api_params['select'] = getattr(args, 'select', None) 39 | if getattr(args, "server_id", None): 40 | rest_api_params['match_key'] = 'id' 41 | rest_api_params['match_value'] = args.server_id 42 | elif getattr(args, "cluster_id", None): 43 | rest_api_params['match_key'] = 'cluster_id' 44 | rest_api_params['match_value'] = args.cluster_id 45 | elif getattr(args, "tag", None): 46 | rest_api_params['match_key'] = 'tag' 47 | rest_api_params['match_value'] = args.tag 48 | elif getattr(args, "where", None): 49 | rest_api_params['match_key'] = 'where' 50 | rest_api_params['match_value'] = args.where 51 | else: 52 | rest_api_params['match_key'] = None 53 | rest_api_params['match_value'] = None 54 | return rest_api_params 55 | # end def show_mon_details 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/contrail/server.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 283 4 | a3s15 5 | 10.84.17.2 6 | 10.84.6.215 7 | A3 8 | 15 9 | pmiriyala 10 | 00:25:90:a5:3b:34 11 | Setup 5 12 | SUPERMICRO X9SCL/X9SCM 13 | Ubuntu 12.04.3 14 | 15 | Intel i3-2120 CPU @ 3.30GHz 16 | 4 17 | 32G 18 | SSD-240G 19 | 20 | 21 | 22 | 284 23 | a3s16 24 | 10.84.17.3 25 | 10.84.6.216 26 | A3 27 | 16 28 | pmiriyala 29 | 00:25:90:a4:24:46 30 | Setup 5 31 | SUPERMICRO X9SCL/X9SCM 32 | CentOS 6.4 33 | 34 | Intel i3-2120 CPU @ 3.30GHz 35 | 4 36 | 32G 37 | SSD-240G 38 | 39 | 40 | 41 | 285 42 | a3s18 43 | 10.84.17.4 44 | 10.84.6.218 45 | A3 46 | 18 47 | pmiriyala 48 | 00:25:90:7e:12:b8 49 | Setup 5 50 | SUPERMICRO X9SCL/X9SCM 51 | Ubuntu 12.04.3 52 | 53 | Intel i3-2100 CPU @ 3.10GHz 54 | 4 55 | 32G 56 | SSD-240G 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/smgrcliapp/smgr_inventory.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 4 | """ 5 | Name : smgr_inventory.py 6 | Author : Nitish Krishna 7 | Description : TBD 8 | """ 9 | 10 | import os 11 | import syslog 12 | import time 13 | import signal 14 | from StringIO import StringIO 15 | import sys 16 | import re 17 | import abc 18 | import datetime 19 | import subprocess 20 | import cStringIO 21 | import pycurl 22 | import json 23 | import pdb 24 | 25 | # Class ServerMgrInventory describes the API layer exposed to ServerManager to allow it to query 26 | # the device inventory information of the servers stored in its DB. The information is gathered through 27 | # REST API calls to the Server Mgr Node that hosts the relevant DB and Cache. 28 | class ServerMgrInventory(): 29 | 30 | def __init__(self): 31 | ''' Constructor ''' 32 | 33 | # Filters the data returned from REST API call for requested information 34 | 35 | 36 | def show_inv_details(self, args): 37 | rest_api_params = {} 38 | rest_api_params['object'] = 'InventoryInfo' 39 | rest_api_params['select'] = getattr(args, 'select', None) 40 | if getattr(args, "server_id", None): 41 | rest_api_params['match_key'] = 'id' 42 | rest_api_params['match_value'] = args.server_id 43 | elif getattr(args, "cluster_id", None): 44 | rest_api_params['match_key'] = 'cluster_id' 45 | rest_api_params['match_value'] = args.cluster_id 46 | elif getattr(args, "tag", None): 47 | rest_api_params['match_key'] = 'tag' 48 | rest_api_params['match_value'] = args.tag 49 | elif getattr(args, "where", None): 50 | rest_api_params['match_key'] = 'where' 51 | rest_api_params['match_value'] = args.where 52 | else: 53 | rest_api_params['match_key'] = None 54 | rest_api_params['match_value'] = None 55 | return rest_api_params 56 | # end def show_inv_details 57 | -------------------------------------------------------------------------------- /src/unit_tests/logger.conf: -------------------------------------------------------------------------------- 1 | [loggers] 2 | keys=root,SMGR,TRANS,MONITORING, INVENTORY 3 | 4 | [handlers] 5 | keys=transactionHandler,debugHandler,consoleHandler,mondebugHandler,invdebugHandler 6 | 7 | [formatters] 8 | keys=transactionFormatter,simpleFormatter 9 | 10 | [logger_root] 11 | level=NOTSET 12 | handlers= 13 | 14 | [logger_MONITORING] 15 | level=DEBUG 16 | handlers=mondebugHandler 17 | qualname=MONITORING 18 | propagate=0 19 | 20 | [logger_INVENTORY] 21 | level=DEBUG 22 | handlers=invdebugHandler 23 | qualname=INVENTORY 24 | propagate=0 25 | 26 | [logger_SMGR] 27 | level=DEBUG 28 | handlers=debugHandler 29 | qualname=SMGR 30 | propagate=0 31 | 32 | [logger_TRANS] 33 | level=DEBUG 34 | handlers=transactionHandler 35 | qualname=TRANSACTION 36 | 37 | [handler_transactionHandler] 38 | class=handlers.RotatingFileHandler 39 | level=DEBUG 40 | formatter=transactionFormatter 41 | args=("./transaction.log",) 42 | filename=transaction.log 43 | 44 | [handler_debugHandler] 45 | class=handlers.RotatingFileHandler 46 | level=DEBUG 47 | formatter=simpleFormatter 48 | args=("./debug.log",) 49 | filename=debug.log 50 | 51 | [handler_mondebugHandler] 52 | class=handlers.RotatingFileHandler 53 | level=DEBUG 54 | formatter=simpleFormatter 55 | args=("./monitoring_debug.log",'a',1000*1024) 56 | filename=monitoring_debug.log 57 | 58 | [handler_invdebugHandler] 59 | class=handlers.RotatingFileHandler 60 | level=DEBUG 61 | formatter=simpleFormatter 62 | args=("./inventory_debug.log",'a',1000*1024) 63 | filename=inventory_debug.log 64 | 65 | [handler_consoleHandler] 66 | class=StreamHandler 67 | level=DEBUG 68 | formatter=simpleFormatter 69 | args=(sys.stdout,) 70 | 71 | [formatter_simpleFormatter] 72 | #format="[%(asctime)s:%(log_filename)s:%(log_line_number)s - %(levelname)s - %(log_function_name)s() ] %(message)s" 73 | format="%(asctime)-15s-%(levelname)s-%(log_filename)s:%(log_line_number)s-%(log_function_name)s(): %(message)s" 74 | 75 | datefmt= 76 | 77 | 78 | [formatter_transactionFormatter] 79 | format=%(asctime)s - %(name)s - %(message)s 80 | datefmt= 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | PROJECT = 'servermanagercli' 4 | 5 | def get_version(): 6 | version = None 7 | with open('version.txt') as f: 8 | version = f.read() 9 | version = version.strip() 10 | if version: 11 | return version 12 | else: 13 | return "1.0" 14 | 15 | CONTRAIL_VERSION = get_version() 16 | 17 | VERSION = CONTRAIL_VERSION.replace('-','.') 18 | 19 | import setuptools 20 | import ConfigParser 21 | 22 | install_reqs = [] 23 | 24 | for line in open('requirements.txt', 'r'): 25 | if not str(line.strip()).startswith("#"): 26 | install_reqs.append(line.strip()) 27 | 28 | reqs = install_reqs 29 | config = ConfigParser.ConfigParser() 30 | config.read('setup.cfg') 31 | 32 | config_dict = dict(config._sections) 33 | for k in config_dict: 34 | config_dict[k] = dict(config._defaults, **config_dict[k]) 35 | config_dict[k].pop('__name__', None) 36 | 37 | console_script_list = [str(x) for x in (config_dict['entry_points']['console_scripts']).splitlines() if x and x[0] != "#"] 38 | entry_points_dict = dict() 39 | entry_points_dict['console_scripts'] = console_script_list 40 | 41 | entry_points = [key for key in (config_dict['entry_points']) if key != "console_scripts"] 42 | for entry_point in entry_points: 43 | command_list = [str(x) for x in (config_dict['entry_points'][str(entry_point)]).splitlines() if x and x[0] != "#"] 44 | entry_points_dict[str(entry_point)] = command_list 45 | 46 | 47 | setuptools.setup( 48 | name=PROJECT, 49 | version=VERSION, 50 | setup_requires=['configparser'], 51 | description='Server Manager Command Line Interface', 52 | package_data={'': ['*.ini', '*.txt', '*.sh']}, 53 | packages=setuptools.find_packages(), 54 | include_package_data=True, 55 | install_requires=reqs, 56 | platforms=['Any'], 57 | entry_points=entry_points_dict, 58 | scripts=['setup_server_manager_client.sh'], 59 | data_files=[ 60 | ('/tmp', ['smgrcliapp/sm-client-config.ini']), 61 | ('/tmp', ['servermanagerclient']) 62 | ], 63 | zip_safe=False) 64 | -------------------------------------------------------------------------------- /src/unit_tests/fake-logger.conf: -------------------------------------------------------------------------------- 1 | [loggers] 2 | keys=root,SMGR,TRANS,MONITORING, INVENTORY 3 | 4 | [handlers] 5 | keys=transactionHandler,debugHandler,consoleHandler,mondebugHandler,invdebugHandler 6 | 7 | [formatters] 8 | keys=transactionFormatter,simpleFormatter 9 | 10 | [logger_root] 11 | level=NOTSET 12 | handlers= 13 | 14 | [logger_MONITORING] 15 | level=DEBUG 16 | handlers=mondebugHandler 17 | qualname=MONITORING 18 | propagate=0 19 | 20 | [logger_INVENTORY] 21 | level=DEBUG 22 | handlers=invdebugHandler 23 | qualname=INVENTORY 24 | propagate=0 25 | 26 | [logger_SMGR] 27 | level=DEBUG 28 | handlers=debugHandler 29 | qualname=SMGR 30 | propagate=0 31 | 32 | [logger_TRANS] 33 | level=DEBUG 34 | handlers=transactionHandler 35 | qualname=TRANSACTION 36 | 37 | [handler_transactionHandler] 38 | class=handlers.RotatingFileHandler 39 | level=DEBUG 40 | formatter=transactionFormatter 41 | args=("./fake-logs/transaction.log",) 42 | filename=transaction.log 43 | 44 | [handler_debugHandler] 45 | class=handlers.RotatingFileHandler 46 | level=DEBUG 47 | formatter=simpleFormatter 48 | args=("./fake-logs/debug.log",) 49 | filename=debug.log 50 | 51 | [handler_mondebugHandler] 52 | class=handlers.RotatingFileHandler 53 | level=DEBUG 54 | formatter=simpleFormatter 55 | args=("./fake-logs/monitoring_debug.log",'a',1000*1024) 56 | filename=monitoring_debug.log 57 | 58 | [handler_invdebugHandler] 59 | class=handlers.RotatingFileHandler 60 | level=DEBUG 61 | formatter=simpleFormatter 62 | args=("./fake-logs/inventory_debug.log",'a',1000*1024) 63 | filename=inventory_debug.log 64 | 65 | [handler_consoleHandler] 66 | class=StreamHandler 67 | level=DEBUG 68 | formatter=simpleFormatter 69 | args=(sys.stdout,) 70 | 71 | [formatter_simpleFormatter] 72 | #format="[%(asctime)s:%(log_filename)s:%(log_line_number)s - %(levelname)s - %(log_function_name)s() ] %(message)s" 73 | format="%(asctime)-15s-%(levelname)s-%(log_filename)s:%(log_line_number)s-%(log_function_name)s(): %(message)s" 74 | 75 | datefmt= 76 | 77 | 78 | [formatter_transactionFormatter] 79 | format=%(asctime)s - %(name)s - %(message)s 80 | datefmt= 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /src/client/testbed-format-translator.json: -------------------------------------------------------------------------------- 1 | { 2 | "cluster_params": ["ext_routers", "router_asn", "host_build", "openstack_admin_password", "orchestrator", 3 | "ntp_server", "key_filename", "backup_node", "backup_db_path", "cassandra_backup", 4 | "skip_keyspace", "service_token", "database_dir", "analytics_data_dir", "ssd_data_dir", 5 | "database_ttl", "analytics_config_audit_ttl", "analytics_statistics_ttl", "analytics_flow_ttl", 6 | "storage_replica_size", "live_migration", "nova_uid_fix", "live_migration_scope", 7 | "ext_nfs_livem", "ext_nfs_livem_mount", "ceph_nfs_livem", "ceph_nfs_livem_subnet", "ceph_nfs_livem_image", 8 | "ceph_nfs_livem_host", "ceph_ssd_cache_tier", "ceph_object_storage", "ceph_object_storage_pool", 9 | "interface_rename", "ca_cert_file", "neutron_metadata_proxy_shared_secret", "multi_tenancy", 10 | "cloud_admin_role", "analytics_aaa_mode", "haproxy", "do_parallel", "encap_priority", "http_proxy", 11 | "enable_lbaas", "enable_ceilometer", "ceilometer_polling_interval", "ceilometer_ttl", "rally_git_url", 12 | "rally_git_branch", "kernel_upgrade", "kernel_version", "metadata_ssl_enable", 13 | "xmpp_auth_enable", "xmpp_dns_auth_enable", "analyticsdb_minimum_diskgb", "configdb_minimum_diskgb"], 14 | "server_params": ["hostnames", "passwords", "ostypes", "hypervisor", "qos_priority_tagging", "tsn_evpn_mode", "tsn_server_list", "compute_as_gateway_mode", "compute_controller_list", "resource_backup_restore", 15 | "backup_idle_timeout", "restore_audit_timeout", "backup_file_count", "vrouter_1G_hugepages", "vrouter_2M_hugepages", "local_asn"], 16 | "cluster_dict_params": ["keystone", "nova", "ha", "openstack", "cfgm"], 17 | "server_dict_params": ["bond", "control_data", "dpdk", "vrouter_module_params"], 18 | "server_dict_list_params": ["sriov", "static_route", "qos", "qos_niantic", "tor_agent"], 19 | "server_group_params": ["roledefs"], 20 | "server_nested_dict_params": ["vgw"] 21 | } 22 | -------------------------------------------------------------------------------- /src/client/image_json_schema.txt: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-04/schema#", 3 | "definitions": {}, 4 | "id": "http://example.com/example.json", 5 | "properties": { 6 | "image": { 7 | "id": "/properties/image", 8 | "items": { 9 | "id": "/properties/image/items", 10 | "properties": { 11 | "category": { 12 | "default": "", 13 | "description": "image category, acceptable values are 'image' for os or 'package' for contrail artifacts", 14 | "mandatory": "true", 15 | "values": ['image', 'package'], 16 | "type": "string" 17 | }, 18 | "id": { 19 | "default": "", 20 | "description": "unique id for the image", 21 | "mandatory": "true", 22 | "type": "string" 23 | }, 24 | "parameters": { 25 | "id": "/properties/image/items/properties/parameters", 26 | "properties": { 27 | "openstack_sku": { 28 | "default": "", 29 | "description": "specify contrail sku, value 'vcenter' indicates package vcenter", 30 | "mandatory": "mandatory for vcenter-as-orchestrator package", 31 | "values": ['vcenter'] 32 | "type": "string" 33 | } 34 | }, 35 | "type": "object" 36 | }, 37 | "path": { 38 | "default": "", 39 | "description": "path to the package", 40 | "mandatory": "true", 41 | "type": "string" 42 | }, 43 | "type": { 44 | "default": "", 45 | "description": "type of the os image or package", 46 | "mandatory": "true", 47 | "values": ['contrail-ubuntu-package'], 48 | "type": "string" 49 | }, 50 | "version": { 51 | "default": "", 52 | "description": "version string for the package or os version", 53 | "type": "string" 54 | } 55 | }, 56 | "type": "object" 57 | }, 58 | "type": "array" 59 | } 60 | }, 61 | "type": "object" 62 | } 63 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/node_classifier.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | ''' 3 | This program reads a json file containing mapping of node name to 4 | environment to be used for the given node. It is used as an External 5 | node classifier by puppet master. To specify a particular environment 6 | to be used for a node, add an entry for the node name to environment 7 | name in the json file. 8 | The default json file used is /etc/contrail_smgr/puppet/node_mapping.json. 9 | If there is error in reading the node configuration file, or if 10 | given node is not found in the file, program returns null output. 11 | If node is found, "environment : env_name", where env_name is the 12 | environment corresponding to the node is output. 13 | ''' 14 | import sys 15 | import json 16 | import argparse 17 | 18 | _NODE_ENV_DICT_FILE = "/etc/contrail_smgr/puppet/node_mapping.json" 19 | 20 | def main(args_str=None): 21 | # import pdb; pdb.set_trace() 22 | # Accept parameters 23 | parser = argparse.ArgumentParser( 24 | description = '''Program to classify a puppet node 25 | to fetch environment, given node name''') 26 | # Optional config file, to be used to run the program directly 27 | # for testing the logic, will not be used when puppet invokes this 28 | # code. 29 | parser.add_argument( 30 | "--node_env_map_file", "-c", default = _NODE_ENV_DICT_FILE, 31 | help = ("file containing node to environment mapping, default %s", 32 | _NODE_ENV_DICT_FILE)) 33 | # Mandatoty paramater, node name for which environment is desired./ 34 | parser.add_argument( 35 | "node_name", 36 | help = "Node name of server for which environment is to be fetched." ) 37 | args = parser.parse_args(args_str) 38 | 39 | # Read the file and get mapping for node specified 40 | environement = None 41 | try: 42 | with open(args.node_env_map_file, "r") as env_file: 43 | node_env_dict = json.loads(env_file.read()) 44 | environment = node_env_dict.get(args.node_name, None) 45 | if environment: 46 | print ("environment : %s" %environment) 47 | except: 48 | pass 49 | # End of main 50 | 51 | if __name__ == "__main__": 52 | import cgitb 53 | cgitb.enable(format='text') 54 | 55 | main(sys.argv[1:]) 56 | # End if __name__ 57 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/environments/production/modules/smgr_report/lib/puppet/reports/smgr_report.rb: -------------------------------------------------------------------------------- 1 | require 'puppet' 2 | require 'net/http' 3 | require 'uri' 4 | 5 | Puppet::Reports.register_report(:smgr_report) do 6 | 7 | desc <<-DESC 8 | A new report processor. 9 | DESC 10 | 11 | def process 12 | client = self.host 13 | logs = self.logs 14 | print "start new report\n" 15 | print "host: " + self.host + "\n" 16 | print "status: " + self.status+ "\n" 17 | hostname = Socket.gethostname 18 | cur_time=Time.now.strftime("%d-%m-%Y_%H:%M:%S") 19 | print "Server Hostname:" + hostname + "\n" 20 | print "Server cur_time:" + cur_time+ "\n" 21 | log_dir = "/var/log/contrail-server-manager/provision" 22 | config_version = self.host + "_" + cur_time 23 | dir = File.join(log_dir, client) 24 | Dir.mkdir(dir) unless File.exists?(dir) 25 | print config_version + "\n" 26 | file = config_version + ".log" 27 | destination = File.join(dir, file) 28 | log_data = "" 29 | logs.each do |item| 30 | resource = item.source 31 | msg = item.message 32 | time = item.time.strftime("%d-%m-%Y_%H:%M:%S") 33 | if msg.include? "TurningOffPuppetAgent__" 34 | puts "Puppet agent Turned Off." 35 | return 36 | end 37 | if msg.include? "Could not find node " 38 | puts "Catalog for server not found." 39 | return 40 | end 41 | if msg.include? "Caught TERM; calling stop" 42 | puts "Puppet agent exited" 43 | return 44 | end 45 | log_data += time + ":" + resource + ":" + msg + "\n" 46 | end 47 | File.open(destination,"w") do |f| 48 | f.write(log_data) 49 | 50 | 51 | if self.status == "failed" 52 | puts "puppet run failed" 53 | client_fqdn = client.split(".") 54 | client_hostname = client_fqdn[0] 55 | print "log data =" + log_data +"\n" 56 | 57 | http = Net::HTTP.new(hostname, 9002) 58 | 59 | log_path = client +"/" +file + "\n" 60 | print "http://" + hostname + ":9001/logs/"+ log_path + "\n" 61 | response = http.send_request('PUT', '/server_status?server_id=' + client_hostname + '&state=puppet_failed') 62 | puts "response code is " + response.code 63 | if response.code != "200" 64 | puts "Error posting puppet status" 65 | end 66 | else 67 | puts "puppet run successful" 68 | end 69 | end 70 | end 71 | end 72 | -------------------------------------------------------------------------------- /src/scons/inventory/inventory-daemon/server_inventory.sandesh: -------------------------------------------------------------------------------- 1 | struct interface_info { 2 | 1: optional string interface_name 3 | 2: optional string macaddress 4 | 3: optional string ip_addr 5 | 4: optional string netmask 6 | 5: optional u64 speed_Mb_per_sec 7 | 6: optional string model 8 | } 9 | 10 | struct fru_info { 11 | 1: optional string fru_description 12 | 2: optional string chassis_type 13 | 3: optional string chassis_serial_number 14 | 4: optional string board_mfg_date 15 | 5: optional string board_manufacturer 16 | 6: optional string board_product_name 17 | 7: optional string board_serial_number 18 | 8: optional string board_part_number 19 | 9: optional string product_manfacturer 20 | 10: optional string product_name 21 | 11: optional string product_part_number 22 | } 23 | 24 | struct memory_info { 25 | 1: string mem_type 26 | 2: u64 mem_speed_MHz 27 | 3: u32 num_of_dimms 28 | 4: u64 dimm_size_mb 29 | 5: double swap_size_mb 30 | 6: u64 total_mem_mb 31 | } 32 | 33 | struct cpu_info { 34 | 1: string model 35 | 2: u32 core_count 36 | 3: double clock_speed_MHz 37 | 4: u32 num_of_threads 38 | } 39 | 40 | struct ethernet_controller { 41 | 1: u64 num_of_ports 42 | } 43 | 44 | struct ServerInventoryInfo { 45 | 1: string name (key="ObjectServerTable") 46 | 2: optional bool deleted 47 | 3: optional string hardware_model 48 | 4: optional u32 physical_processor_count 49 | 5: optional u32 cpu_cores_count 50 | 6: optional string virtual_machine 51 | 7: optional u64 total_memory_mb 52 | 8: optional u32 total_numof_disks 53 | 9: optional string os 54 | 10: optional string os_version 55 | 11: optional string os_family 56 | 12: optional string kernel_version 57 | 13: optional u64 uptime_seconds 58 | 14: optional list interface_infos 59 | 15: optional list fru_infos 60 | 16: optional memory_info mem_state 61 | 17: optional cpu_info cpu_info_state 62 | 18: optional ethernet_controller eth_controller_state 63 | } 64 | 65 | uve sandesh ServerInventoryInfoUve { 66 | 1: ServerInventoryInfo data 67 | } 68 | -------------------------------------------------------------------------------- /src/cobbler/python_cobbler/server_pre_install.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | 4 | import distutils.sysconfig 5 | import sys 6 | import os 7 | from utils import _ 8 | import traceback 9 | import cexceptions 10 | import os 11 | import sys 12 | import time 13 | import pycurl 14 | from StringIO import StringIO 15 | import json 16 | import socket 17 | import urllib 18 | import ConfigParser 19 | 20 | plib = distutils.sysconfig.get_python_lib() 21 | mod_path="%s/cobbler" % plib 22 | sys.path.insert(0, mod_path) 23 | 24 | #[root@a3s17 modules]# more /var/log/cobbler/install.log 25 | #system a3s10 10.84.16.3 start 1401606565.15 26 | 27 | _DEF_SMGR_CONFIG_FILE = '/opt/contrail/server_manager/sm-config.ini' 28 | _DEF_SMGR_STATUS_PORT = 9002 29 | 30 | def register(): 31 | # trigger type 32 | return "/var/lib/cobbler/triggers/install/pre/*" 33 | 34 | 35 | def send_REST_request(ip, port, object, payload): 36 | try: 37 | response = StringIO() 38 | headers = ["Content-Type:application/json"] 39 | url = "http://%s:%s/%s" %( 40 | ip, port, object) 41 | conn = pycurl.Curl() 42 | conn.setopt(pycurl.URL, url) 43 | conn.setopt(pycurl.HTTPHEADER, headers) 44 | conn.setopt(pycurl.POST, 1) 45 | conn.setopt(pycurl.POSTFIELDS, '%s'%json.dumps(payload)) 46 | conn.setopt(pycurl.CUSTOMREQUEST, "PUT") 47 | conn.setopt(pycurl.WRITEFUNCTION, response.write) 48 | conn.perform() 49 | return response.getvalue() 50 | except: 51 | return None 52 | 53 | 54 | def run(api, args, logger): 55 | objtype = args[0] # "system" or "profile" 56 | name = args[1] # name of system or profile 57 | server_ip = args[2] # ip or "?" 58 | # get server manager ip 59 | try: 60 | config = ConfigParser.SafeConfigParser() 61 | config.read(_DEF_SMGR_CONFIG_FILE) 62 | ip = dict(config.items("SERVER-MANAGER"))['listen_ip_addr'] 63 | except: 64 | ip = socket.gethostbyname(socket.gethostname()) 65 | object = 'server_status' 66 | url_str = object + "?" + "server_id=" + name + "&state=reimage_started" 67 | payload = 'reimage start' 68 | send_REST_request(ip, str(_DEF_SMGR_STATUS_PORT), url_str, payload) 69 | fd = open("/var/log/cobbler/contrail_install.log","a+") 70 | fd.write("\n%s\t%s\t%s\tstart\t%s\n" % (objtype,name,ip,time.asctime(time.localtime(time.time())))) 71 | fd.write("url:%s, payload:%s\n" % (url_str, payload)) 72 | fd.close() 73 | return 0 74 | -------------------------------------------------------------------------------- /src/cobbler/python_cobbler/server_post_install.py: -------------------------------------------------------------------------------- 1 | """ 2 | """ 3 | 4 | import distutils.sysconfig 5 | import sys 6 | import os 7 | from utils import _ 8 | import traceback 9 | import cexceptions 10 | import os 11 | import sys 12 | import time 13 | import pycurl 14 | from StringIO import StringIO 15 | import json 16 | import socket 17 | import ConfigParser 18 | 19 | 20 | plib = distutils.sysconfig.get_python_lib() 21 | mod_path="%s/cobbler" % plib 22 | sys.path.insert(0, mod_path) 23 | 24 | #[root@a3s17 modules]# more /var/log/cobbler/install.log 25 | #system a3s10 10.84.16.3 stop Thu Jun 5 14:37:58 2014 26 | 27 | _DEF_SMGR_CONFIG_FILE = '/opt/contrail/server_manager/sm-config.ini' 28 | _DEF_SMGR_STATUS_PORT=9002 29 | 30 | def register(): 31 | # trigger type 32 | return "/var/lib/cobbler/triggers/install/post/*" 33 | 34 | 35 | def send_REST_request(ip, port, object, payload): 36 | try: 37 | response = StringIO() 38 | headers = ["Content-Type:application/json"] 39 | url = "http://%s:%s/%s" %( 40 | ip, port, object) 41 | conn = pycurl.Curl() 42 | conn.setopt(pycurl.URL, url) 43 | conn.setopt(pycurl.HTTPHEADER, headers) 44 | conn.setopt(pycurl.POST, 1) 45 | conn.setopt(pycurl.POSTFIELDS, '%s'%json.dumps(payload)) 46 | conn.setopt(pycurl.CUSTOMREQUEST, "PUT") 47 | conn.setopt(pycurl.WRITEFUNCTION, response.write) 48 | conn.perform() 49 | return response.getvalue() 50 | except: 51 | return None 52 | 53 | 54 | def run(api, args, logger): 55 | objtype = args[0] # "system" or "profile" 56 | name = args[1] # name of system or profile 57 | server_ip = args[2] # ip or "?" 58 | # get server manager ip 59 | try: 60 | config = ConfigParser.SafeConfigParser() 61 | config.read(_DEF_SMGR_CONFIG_FILE) 62 | ip = dict(config.items("SERVER-MANAGER"))['listen_ip_addr'] 63 | except: 64 | ip = socket.gethostbyname(socket.gethostname()) 65 | object = 'server_status' 66 | url_str = object + "?" + "server_id=" + name + "&state=reimage_completed" 67 | payload = 'reimage completed' 68 | send_REST_request(ip, str(_DEF_SMGR_STATUS_PORT), url_str, payload) 69 | fd = open("/var/log/cobbler/contrail_install.log","a+") 70 | fd.write("\n%s\t%s\t%s\tcompleted\t%s\n" % (objtype,name,ip,time.asctime(time.localtime(time.time())))) 71 | fd.write("url:%s, payload:%s\n" % (url_str, payload)) 72 | fd.close() 73 | return 0 74 | -------------------------------------------------------------------------------- /src/server_manager/logger.conf: -------------------------------------------------------------------------------- 1 | [loggers] 2 | keys=root,SMGR,TRANS,CERT,MONITORING,INVENTORY 3 | 4 | [handlers] 5 | keys=certHandler,transactionHandler,debugHandler,consoleHandler,mondebugHandler,invdebugHandler 6 | 7 | [formatters] 8 | keys=transactionFormatter,simpleFormatter 9 | 10 | [logger_root] 11 | level=NOTSET 12 | handlers= 13 | 14 | [logger_MONITORING] 15 | level=DEBUG 16 | handlers=mondebugHandler 17 | qualname=MONITORING 18 | propagate=0 19 | 20 | [logger_INVENTORY] 21 | level=DEBUG 22 | handlers=invdebugHandler 23 | qualname=INVENTORY 24 | propagate=0 25 | 26 | [logger_CERT] 27 | level=DEBUG 28 | handlers=certHandler 29 | qualname=CERT 30 | propagate=0 31 | 32 | [logger_SMGR] 33 | level=DEBUG 34 | handlers=debugHandler 35 | qualname=SMGR 36 | propagate=0 37 | 38 | [logger_TRANS] 39 | level=DEBUG 40 | handlers=transactionHandler 41 | qualname=TRANSACTION 42 | 43 | [handler_transactionHandler] 44 | class=handlers.RotatingFileHandler 45 | level=DEBUG 46 | formatter=transactionFormatter 47 | args=("/var/log/contrail-server-manager/transaction.log",'a',100*1000*1024,10) 48 | filename=transaction.log 49 | 50 | [handler_debugHandler] 51 | class=handlers.RotatingFileHandler 52 | level=DEBUG 53 | formatter=simpleFormatter 54 | args=("/var/log/contrail-server-manager/debug.log",'a',100*1000*1024,10) 55 | filename=debug.log 56 | 57 | [handler_mondebugHandler] 58 | class=handlers.RotatingFileHandler 59 | level=DEBUG 60 | formatter=simpleFormatter 61 | args=("/var/log/contrail-server-manager/monitoring_debug.log",'a',1000*1024) 62 | filename=monitoring_debug.log 63 | 64 | [handler_invdebugHandler] 65 | class=handlers.RotatingFileHandler 66 | level=DEBUG 67 | formatter=simpleFormatter 68 | args=("/var/log/contrail-server-manager/inventory_debug.log",'a',1000*1024) 69 | filename=inventory_debug.log 70 | 71 | [handler_certHandler] 72 | class=handlers.RotatingFileHandler 73 | level=DEBUG 74 | formatter=simpleFormatter 75 | args=("/var/log/contrail-server-manager/smgrcerts.log",'a',1000*1024) 76 | filename=smgrcerts.log 77 | 78 | [handler_consoleHandler] 79 | class=StreamHandler 80 | level=DEBUG 81 | formatter=simpleFormatter 82 | args=(sys.stdout,) 83 | 84 | [formatter_simpleFormatter] 85 | #format="[%(asctime)s:%(log_filename)s:%(log_line_number)s - %(levelname)s - %(log_function_name)s() ] %(message)s" 86 | format="%(asctime)-15s-%(levelname)s-%(log_filename)s:%(log_line_number)s-%(log_function_name)s(): %(message)s" 87 | 88 | datefmt= 89 | 90 | [formatter_transactionFormatter] 91 | format=%(asctime)s - %(name)s - %(message)s 92 | datefmt= 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/client/server_esxi.json: -------------------------------------------------------------------------------- 1 | { 2 | "server": [ 3 | { 4 | "id": "a3s14", 5 | "cluster_id": "cluster2", 6 | "password": "c0ntrail123", 7 | "ipmi_address": "10.84.6.214", 8 | "domain": "contrail.juniper.net", 9 | "contrail": { 10 | "control_data_interface": "eth1" 11 | }, 12 | "network": { 13 | "interfaces": [ 14 | { 15 | "default_gateway": "10.84.17.254", 16 | "dhcp": true, 17 | "ip_address": "10.84.17.1/24", 18 | "mac_address": "00:25:90:a1:1a:38", 19 | "name": "eth1", 20 | "type": "physical" 21 | } 22 | ], 23 | "management_interface": "eth1" 24 | }, 25 | "parameters": { 26 | "esx_nicname": "vmnic0", 27 | "interface_name": "eth1", 28 | "server_license": "" 29 | }, 30 | "roles": [] 31 | }, 32 | { 33 | "id": "contrailvm", 34 | "host_name": "contrailvm", 35 | "password": "c0ntrail123", 36 | "domain": "contrail.juniper.net", 37 | "cluster_id": "cluster2", 38 | "contrail": { 39 | "control_data_interface": "eth1" 40 | }, 41 | "network": { 42 | "interfaces": [ 43 | { 44 | "default_gateway": "10.84.17.254", 45 | "dhcp": true, 46 | "ip_address": "10.84.17.10/24", 47 | "mac_address": "00:50:56:01:BA:BA", 48 | "name": "eth1" 49 | } 50 | ], 51 | "management_interface": "eth1", 52 | "provisioning": "kickstart" 53 | }, 54 | "parameters": { 55 | "esx_fab_port_group": "contrail-fab-pg", 56 | "esx_fab_vswitch": "vSwitch0", 57 | "esx_server": "a3s14", 58 | "esx_uplink_nic": "vmnic0", 59 | "esx_vm_port_group": "contrail-vm-pg", 60 | "esx_vm_vswitch": "vSwitch1", 61 | "esx_vmdk": "/root/ContrailVM-disk1.vmdk", 62 | "interface_name": "eth1", 63 | "vm_deb": "/root/b35.deb" 64 | }, 65 | "roles": [ 66 | "compute" 67 | ] 68 | } 69 | ] 70 | } 71 | -------------------------------------------------------------------------------- /src/smgr_cliff_client/smgrcliapp/commandmanager.py: -------------------------------------------------------------------------------- 1 | # Copyright 2012-2013 OpenStack Foundation 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | # not use this file except in compliance with the License. You may obtain 5 | # a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 | # License for the specific language governing permissions and limitations 13 | # under the License. 14 | # 15 | 16 | """Modify cliff.CommandManager""" 17 | 18 | import logging 19 | import pkg_resources 20 | 21 | import cliff.commandmanager 22 | 23 | 24 | LOG = logging.getLogger(__name__) 25 | 26 | 27 | class CommandManager(cliff.commandmanager.CommandManager): 28 | """Add additional functionality to cliff.CommandManager 29 | 30 | Load additional command groups after initialization 31 | Add _command_group() methods 32 | """ 33 | 34 | def __init__(self, namespace, convert_underscores=True): 35 | self.group_list = [] 36 | super(CommandManager, self).__init__(namespace, convert_underscores) 37 | 38 | def load_commands(self, namespace): 39 | """Load all the commands from an entrypoint""" 40 | for ep in pkg_resources.iter_entry_points(namespace): 41 | LOG.debug('found command %r', ep.name) 42 | cmd_name = (ep.name.replace('_', ' ') 43 | if self.convert_underscores 44 | else ep.name) 45 | self.commands[cmd_name] = ep 46 | self.group_list.append(namespace) 47 | 48 | def add_command_group(self, group=None): 49 | """Adds another group of command entrypoints""" 50 | if group: 51 | self.load_commands(group) 52 | 53 | def get_command_groups(self): 54 | """Returns a list of the loaded command groups""" 55 | return self.group_list 56 | 57 | def get_added_commands(self): 58 | command_list = [] 59 | default_command_list = ['quit', 'exit', 'help'] 60 | group_list = self.get_command_groups() 61 | for ns in group_list: 62 | for ep in pkg_resources.iter_entry_points(ns): 63 | cmd_name = (ep.name.replace('_', ' ') 64 | if self.convert_underscores 65 | else ep.name) 66 | command_list.append(cmd_name) 67 | command_list += default_command_list 68 | return command_list 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/unit_tests/test_cluster.json: -------------------------------------------------------------------------------- 1 | { 2 | "cluster": [ 3 | { 4 | "base_image_id": "", 5 | "email": "", 6 | "id": "test-cluster-01", 7 | "package_image_id": "", 8 | "parameters": { 9 | "analytics_data_ttl": "168", 10 | "database_dir": "/home/cassandra", 11 | "database_minimum_diskGB": "32", 12 | "database_token": "", 13 | "domain": "englab.juniper.net", 14 | "enable_lbaas": "True", 15 | "encapsulation_priority": "MPLSoUDP,MPLSoGRE,VXLAN", 16 | "external_bgp": "", 17 | "gateway": "10.204.221.46", 18 | "haproxy": "disable", 19 | "keystone_password": "contrail123", 20 | "keystone_tenant": "admin", 21 | "keystone_username": "admin", 22 | "multi_tenancy": "True", 23 | "openstack_mgmt_ip": "", 24 | "password": "c0ntrail123", 25 | "router_asn": "64512", 26 | "subnet_mask": "255.255.255.0", 27 | "use_certificates": "False" 28 | }, 29 | "provisioned_id": null 30 | }, 31 | { 32 | "base_image_id": "", 33 | "email": "", 34 | "id": "test-cluster-02", 35 | "package_image_id": "", 36 | "parameters": { 37 | "analytics_data_ttl": "168", 38 | "compute_non_mgmt_gway": "", 39 | "compute_non_mgmt_ip": "", 40 | "database_dir": "/home/cassandra", 41 | "database_minimum_diskGB": "32", 42 | "database_token": "0", 43 | "db_initial_token": "", 44 | "domain": "englab.juniper.net", 45 | "enable_ceilometer": "True", 46 | "enable_lbaas": "True", 47 | "encapsulation_priority": "MPLSoUDP,MPLSoGRE,VXLAN", 48 | "external_bgp": "", 49 | "gateway": "10.204.221.46", 50 | "haproxy": "disable", 51 | "internal_vip": "", 52 | "keystone_password": "contrail123", 53 | "keystone_tenant": "admin", 54 | "keystone_username": "admin", 55 | "multi_tenancy": "True", 56 | "openstack_mgmt_ip": "", 57 | "openstack_password": "contrail123", 58 | "password": "c0ntrail123", 59 | "router_asn": "64512", 60 | "service_token": "contrail123", 61 | "subnet_mask": "255.255.255.240", 62 | "use_certificates": "False", 63 | "use_certificatess": "False" 64 | }, 65 | "provisioned_id": null 66 | } 67 | ] 68 | } 69 | 70 | -------------------------------------------------------------------------------- /src/contrail-server-manager-client.spec: -------------------------------------------------------------------------------- 1 | # 2 | # Spec file for server manager... 3 | # 4 | 5 | %define _contrailetc /etc/contrail_smgr 6 | %define _initd/etc /etc/init.d 7 | %define _contrailutils /opt/contrail/utils 8 | %define _etc /etc 9 | %define _contrail_smgr /server_manager 10 | %define _contrail_smgr_src %(pwd)/ 11 | %define _third_party %(pwd)/../../third_party/ 12 | %define _mydate %(date) 13 | %define _initdetc /etc/init.d/ 14 | %define _etc /etc/ 15 | %define _cobbleretc /etc/cobbler/ 16 | %define _puppetetc /etc/puppet/ 17 | %define _contrailopt /opt/contrail/ 18 | %define _sbinusr /usr/sbin/ 19 | %define _pyver %( %{__python} -c "import sys; print '%s.%s' % sys.version_info[0:2]" ) 20 | %define _pysitepkg /usr/lib/python%{_pyver}/site-packages 21 | 22 | 23 | Name: contrail_smgr_client 24 | Version: 1.0 25 | Release: 1 26 | Summary: A Client for Server Manager 27 | 28 | Group: Applications/System 29 | License: Commercial 30 | URL: http://www.juniper.net/ 31 | Vendor: Juniper Networks Inc 32 | 33 | BuildArch: noarch 34 | SOURCE0 : %{name}-%{version}.tar.gz 35 | 36 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root 37 | 38 | #BuildRequires: 39 | Requires: python >= 2.6.6 40 | 41 | %description 42 | A Client for Server manager 43 | 44 | %prep 45 | #%setup -q 46 | 47 | %post 48 | HOST_IP=`ifconfig | sed -n -e 's/:127\.0\.0\.1 //g' -e 's/ *inet addr:\([0-9.]\+\).*/\1/gp'` 49 | echo $HOST_IP 50 | 51 | easy_install argparse 52 | easy_install pycurl 53 | 54 | if [ -e /usr/bin/server-manager ]; then 55 | unlink /usr/bin/server-manager 56 | fi 57 | ln -s /opt/contrail/server_manager/client/server-manager /usr/bin/server-manager 58 | %build 59 | cd %{_contrail_smgr_src}client/ 60 | 61 | %install 62 | rm -rf %{buildroot} 63 | mkdir -p %{buildroot} 64 | 65 | 66 | install -d -m 755 %{buildroot}%usr 67 | 68 | install -d -m 755 %{buildroot}%{_contrailopt} 69 | install -d -m 755 %{buildroot}%{_contrailopt}%{_contrail_smgr} 70 | install -d -m 755 %{buildroot}%{_contrailopt}%{_contrail_smgr}/client 71 | 72 | 73 | pwd 74 | cp %{_contrail_smgr_src}client/*.py %{buildroot}%{_contrailopt}%{_contrail_smgr}/client 75 | cp %{_contrail_smgr_src}client/*.json %{buildroot}%{_contrailopt}%{_contrail_smgr}/client 76 | cp %{_contrail_smgr_src}utils/create_smgr_db.py %{buildroot}%{_contrailopt}%{_contrail_smgr}/client 77 | cp %{_contrail_smgr_src}client/server-manager %{buildroot}%{_contrailopt}%{_contrail_smgr}/client 78 | 79 | 80 | cp -r %{_contrail_smgr_src}client/sm-client-config.ini %{buildroot}%{_contrailopt}%{_contrail_smgr}/client 81 | 82 | %clean 83 | rm -rf %{buildroot} 84 | 85 | %files 86 | %defattr(-,root,root,-) 87 | #%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf 88 | %{_contrailopt}/* 89 | %changelog 90 | * Thu Nov 29 2013 Thilak Raj S 1.0-1 91 | - First Build 92 | 93 | -------------------------------------------------------------------------------- /src/client/smgr_monitoring.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 4 | """ 5 | Name : smgr_monitoring.py 6 | Author : Nitish Krishna 7 | Description : TBD 8 | """ 9 | 10 | import os 11 | import syslog 12 | import time 13 | import signal 14 | from StringIO import StringIO 15 | import sys 16 | import re 17 | import abc 18 | import datetime 19 | import subprocess 20 | import cStringIO 21 | import pycurl 22 | import json 23 | import pdb 24 | 25 | 26 | # Class ServerMgrIPMIQuerying describes the API layer exposed to ServerManager to allow it to query 27 | # the device environment information of the servers stored in its DB. The information is gathered through 28 | # REST API calls to the Server Mgr Analytics Node that hosts the relevant DB. 29 | class ServerMgrIPMIQuerying(): 30 | _query_engine_port = 8107 31 | 32 | def __init__(self): 33 | ''' Constructor ''' 34 | 35 | # Packages and sends a REST API call to the Server Manager node 36 | def send_REST_request(self, server_ip, port): 37 | try: 38 | response = StringIO() 39 | headers = ["Content-Type:application/json"] 40 | url = "http://%s:%s/%s" % (server_ip, port, 'MonitorInfo') 41 | args_str = '' 42 | conn = pycurl.Curl() 43 | conn.setopt(pycurl.URL, url) 44 | conn.setopt(pycurl.HTTPHEADER, headers) 45 | conn.setopt(pycurl.HTTPGET, 1) 46 | conn.setopt(pycurl.WRITEFUNCTION, response.write) 47 | conn.perform() 48 | data_dict = response.getvalue() 49 | data_dict = dict(json.loads(data_dict)) 50 | data_list = list(data_dict["__ServerMonitoringInfoTrace_list"]["ServerMonitoringInfoTrace"]) 51 | return data_list 52 | except Exception as e: 53 | print "Error is: " + str(e) 54 | return None 55 | # end def send_REST_request 56 | 57 | def show_mon_details(self, args): 58 | rest_api_params = {} 59 | rest_api_params['object'] = 'MonitorInfo' 60 | if args.server_id: 61 | rest_api_params['match_key'] = 'id' 62 | rest_api_params['match_value'] = args.server_id 63 | elif args.cluster_id: 64 | rest_api_params['match_key'] = 'cluster_id' 65 | rest_api_params['match_value'] = args.cluster_id 66 | elif args.tag: 67 | rest_api_params['match_key'] = 'tag' 68 | rest_api_params['match_value'] = args.tag 69 | elif args.where: 70 | rest_api_params['match_key'] = 'where' 71 | rest_api_params['match_value'] = args.where 72 | else: 73 | rest_api_params['match_key'] = None 74 | rest_api_params['match_value'] = None 75 | rest_api_params['select'] = None 76 | return rest_api_params 77 | # end def show_mon_details 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/client/smgr_inventory.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 4 | """ 5 | Name : smgr_inventory.py 6 | Author : Nitish Krishna 7 | Description : TBD 8 | """ 9 | 10 | import os 11 | import syslog 12 | import time 13 | import signal 14 | from StringIO import StringIO 15 | import sys 16 | import re 17 | import abc 18 | import datetime 19 | import subprocess 20 | import cStringIO 21 | import pycurl 22 | import json 23 | import xmltodict 24 | import pdb 25 | 26 | # Class ServerMgrInventory describes the API layer exposed to ServerManager to allow it to query 27 | # the device inventory information of the servers stored in its DB. The information is gathered through 28 | # REST API calls to the Server Mgr Node that hosts the relevant DB and Cache. 29 | class ServerMgrInventory(): 30 | 31 | def __init__(self): 32 | ''' Constructor ''' 33 | 34 | # Packages and sends a REST API call to the ServerManager node 35 | def send_REST_request(self, server_ip, port): 36 | try: 37 | response = StringIO() 38 | url = "http://%s:%s/%s" % (server_ip, port, 'InventoryInfo') 39 | headers = ["Content-Type:application/json"] 40 | conn = pycurl.Curl() 41 | conn.setopt(pycurl.URL, str(url)) 42 | conn.setopt(pycurl.HTTPHEADER, headers) 43 | conn.setopt(conn.WRITEFUNCTION, response.write) 44 | conn.setopt(pycurl.HTTPGET, 1) 45 | conn.perform() 46 | data_dict = response.getvalue() 47 | data_dict = dict(json.loads(data_dict)) 48 | data_list = list(data_dict["__ServerInventoryInfoUve_list"]["ServerInventoryInfoUve"]) 49 | return data_list 50 | except Exception as e: 51 | print "Inventory Error is: " + str(e) 52 | return None 53 | 54 | # end def send_REST_request 55 | 56 | # Filters the data returned from REST API call for requested information 57 | 58 | 59 | def show_inv_details(self, args): 60 | rest_api_params = {} 61 | rest_api_params['object'] = 'InventoryInfo' 62 | if args.server_id: 63 | rest_api_params['match_key'] = 'id' 64 | rest_api_params['match_value'] = args.server_id 65 | elif args.cluster_id: 66 | rest_api_params['match_key'] = 'cluster_id' 67 | rest_api_params['match_value'] = args.cluster_id 68 | elif args.tag: 69 | rest_api_params['match_key'] = 'tag' 70 | rest_api_params['match_value'] = args.tag 71 | elif args.where: 72 | rest_api_params['match_key'] = 'where' 73 | rest_api_params['match_value'] = args.where 74 | else: 75 | rest_api_params['match_key'] = None 76 | rest_api_params['match_value'] = None 77 | rest_api_params['select'] = None 78 | return rest_api_params 79 | # end def show_inv_details 80 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/test-data/sensor/quanta_sensor_expected_output.txt: -------------------------------------------------------------------------------- 1 | ST2300 | Dynamic MC @ 20h | ok 2 | MB1_Temp | 28 degrees C | ok 3 | HDDBP_Ambient1 | 17 degrees C | ok 4 | HDDBP_Ambient2 | 17 degrees C | ok 5 | CPU0_PROC_HOT | 0x00 | ok 6 | CPU1_PROC_HOT | 0x00 | ok 7 | PVCCP_CPU0_VRHOT | 0x00 | ok 8 | PVCCP_CPU1_VRHOT | 0x00 | ok 9 | PVDQ_AB_VRHOT | 0x00 | ok 10 | PVDQ_CD_VRHOT | 0x00 | ok 11 | PVDQ_EF_VRHOT | 0x00 | ok 12 | PVDQ_GH_VRHOT | 0x00 | ok 13 | CPU0_MEM01_HOT | 0x00 | ok 14 | CPU0_MEM23_HOT | 0x00 | ok 15 | CPU1_MEM01_HOT | 0x00 | ok 16 | CPU1_MEM23_HOT | 0x00 | ok 17 | P5V | 5.08 Volts | ok 18 | P3V3 | 3.37 Volts | ok 19 | P12V | 12.39 Volts | ok 20 | P12V_AUX | 12.33 Volts | ok 21 | PVDDQ_AB | 1.41 Volts | ok 22 | PVDDQ_CD | 1.39 Volts | ok 23 | PVDDQ_EF | 1.42 Volts | ok 24 | PVDDQ_GH | 1.41 Volts | ok 25 | CPU0_Vcore | 0.71 Volts | ok 26 | CPU1_Vcore | 0.77 Volts | ok 27 | P1V1_SSB | 1.15 Volts | ok 28 | PDB_FAN1A | 4700 RPM | ok 29 | PDB_FAN4A | no reading | ns 30 | PDB_FAN4B | no reading | ns 31 | CPU0 | 0x00 | ok 32 | CPU1 | 0x00 | ok 33 | CPU_IERR | 0x00 | ok 34 | MB_HW_Throttle | 0x00 | ok 35 | DIMM | 0x00 | ok 36 | DIMM Error Log | 0x00 | ok 37 | SSB ThermalTrip | 0x00 | ok 38 | Top_PSU_Status | 0x09 | ok 39 | Bot_PSU_Status | 0x01 | ok 40 | PSU_Redundancy | 0x02 | ok 41 | PSU_Input_Power | 0 Watts | ok 42 | MB_Type_Error | 0x00 | ok 43 | Fan_Table_Error | 0x00 | ok 44 | Repeater_Error | 0x00 | ok 45 | PDB_Event | 0x00 | ok 46 | Watchdog | 0x00 | ok 47 | Event Log | 0x00 | ok 48 | System Event | 0x00 | ok 49 | Critical IRQ | 0x00 | ok 50 | POST Error | 0x00 | ok 51 | PCI-E Error | 0x00 | ok 52 | QPI Error | 0x00 | ok 53 | Power Unit | 0x00 | ok 54 | SPS FW Health | Event-Only | ns 55 | NM Health | Event-Only | ns 56 | NM Exception | Event-Only | ns 57 | NM Threshold | Event-Only | ns 58 | NM Capabilities | Event-Only | ns 59 | TSOD | Event-Only | ns 60 | MB FRU | Log FRU @00h 07.0 | ok 61 | PDB FRU | Log FRU @01h 15.0 | ok 62 | BP FRU | Log FRU @02h 0f.0 | ok 63 | QME | Dynamic MC @ 2Ch | ok 64 | -------------------------------------------------------------------------------- /docker/cobbler/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | 3 | MAINTAINER Nitish Krishna nitishk@juniper.net 4 | 5 | COPY docker/cobbler/entrypoint.sh / 6 | 7 | # Copy our custom cobbler configs 8 | COPY src/cobbler/etc_cobbler/* /etc/cobbler/ 9 | COPY src/cobbler/var_lib_cobbler/* /var/lib/cobbler/ 10 | COPY src/cobbler/python_cobbler/* /usr/lib/python2.7/dist-packages/cobbler/modules/ 11 | COPY src/cobbler/etc_bind/named.conf.options /etc/named/ 12 | COPY src/cobbler/etc_cobbler/tftpd.template /etc/xinetd.d/tftp 13 | 14 | # Configure systemd 15 | RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ 16 | rm -f /lib/systemd/system/multi-user.target.wants/*;\ 17 | rm -f /etc/systemd/system/*.wants/*;\ 18 | rm -f /lib/systemd/system/local-fs.target.wants/*; \ 19 | rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ 20 | rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ 21 | rm -f /lib/systemd/system/basic.target.wants/*;\ 22 | rm -f /lib/systemd/system/anaconda.target.wants/*; 23 | 24 | # Install dependent packages 25 | #RUN yum -y install epel-release 26 | RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 27 | RUN yum -y install cobbler \ 28 | cobbler-web \ 29 | systemd \ 30 | dhcp \ 31 | bind \ 32 | syslinux \ 33 | pykickstart \ 34 | initscripts \ 35 | net-tools \ 36 | file \ 37 | fence-agents \ 38 | tftp \ 39 | tftp-server \ 40 | xinetd 41 | 42 | # Create required folders 43 | RUN mkdir -p /etc/httpd/sites-available /etc/httpd/sites-enabled 44 | 45 | COPY src/contrail_smgr/smgr.conf /etc/httpd/sites-enabled/ 46 | RUN echo 'IncludeOptional sites-enabled/*.conf' >> /etc/httpd/conf/httpd.conf 47 | 48 | # Enable required packages 49 | RUN systemctl enable cobblerd 50 | RUN systemctl enable httpd 51 | RUN systemctl enable dhcpd 52 | RUN systemctl enable xinetd 53 | RUN systemctl enable tftp 54 | RUN chkconfig tftp on 55 | 56 | # Mount common volumes 57 | VOLUME [ "/usr/bin/", \ 58 | "/sys/fs/cgroup/", \ 59 | "/usr/lib/systemd/system/", \ 60 | "/etc/cobbler/", \ 61 | "/usr/share/cobbler/", \ 62 | "/var/lib/cobbler/", \ 63 | "/var/log/cobbler/", \ 64 | "/var/www/cobbler_webui_content/", \ 65 | "/var/www/cobbler/", \ 66 | "/etc/httpd/", \ 67 | "/usr/lib/python2.7/site-packages/cobbler/", \ 68 | "/usr/lib/python2.7/dist-packages/cobbler/", \ 69 | "/etc/xinetd.d/", \ 70 | "/var/lib/tftpboot" ] 71 | 72 | # Expose the ports for Cobbler/Httpd/DHCPD APIs 73 | EXPOSE 80 74 | EXPOSE 443 75 | EXPOSE 25151 76 | EXPOSE 69/udp 77 | EXPOSE 49152-49160/udp 78 | 79 | ENTRYPOINT ["bash", "entrypoint.sh"] 80 | CMD ["/sbin/init"] 81 | -------------------------------------------------------------------------------- /src/server_manager/smgr_dhcp_event.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 4 | """ 5 | Name : smgr_dhcp_event.py 6 | Author : Abhay Joshi 7 | Description : Small python script that gets called from DHCP server to 8 | notify of new IP address assignment or removal to hosts. This 9 | script takes that information and does update to the DB for the 10 | corresponding server. 11 | """ 12 | import argparse 13 | import pdb 14 | import sys 15 | import pycurl 16 | 17 | # The following 2 variable settings are important. These specify the IP address 18 | # and port where the below DHCP hook, that gets called from dhcpd, will send 19 | # REST request to server manager. The IP address field is replaced with host ip 20 | # as part of install process. The port number, if changed from default value (9001) 21 | # needs to be changed here too. 22 | _DEF_SMGR_IP_ADDR = '__$IPADDRESS__' 23 | _DEF_SMGR_PORT = 9001 24 | 25 | IP_ADDRESS_KEY = "ip_address" 26 | MAC_ADDRESS_KEY = "mac_address" 27 | 28 | 29 | def parse_arguments(args_str=None): 30 | if not args_str: 31 | args_str = sys.argv[1:] 32 | 33 | # Process the arguments 34 | parser = argparse.ArgumentParser( 35 | description=''' Add a server to server manager DB. ''', 36 | ) 37 | parser.add_argument("action", 38 | help="action is one of commit release or expiry.") 39 | parser.add_argument("server_ip", 40 | help="IP address of the server.") 41 | parser.add_argument("server_mac", 42 | help="mac_address of the server.") 43 | args = parser.parse_args() 44 | return args 45 | 46 | 47 | def send_REST_request(ip, port, action, payload): 48 | try: 49 | url = "http://%s:%s/dhcp_event?action=%s" % (ip, port, action) 50 | headers = ["Content-Type:application/json"] 51 | 52 | conn = pycurl.Curl() 53 | conn.setopt(pycurl.TIMEOUT, 1) 54 | conn.setopt(pycurl.URL, url) 55 | conn.setopt(pycurl.HTTPHEADER, headers) 56 | conn.setopt(pycurl.POST, 1) 57 | conn.setopt(pycurl.POSTFIELDS, payload) 58 | conn.perform() 59 | except: 60 | return 61 | 62 | 63 | def dhcp_event(args_str=None): 64 | serverMgrCfg = { 65 | 'smgr_ip_addr': _DEF_SMGR_IP_ADDR, 66 | 'smgr_port': _DEF_SMGR_PORT 67 | } 68 | args = parse_arguments(args_str) 69 | if args.action.lower() == "commit": 70 | smgr_action = "add" 71 | else: 72 | smgr_action = "delete" 73 | server_def = '{"%s":"%s", "%s":"%s"}' \ 74 | % (IP_ADDRESS_KEY, args.server_ip, \ 75 | MAC_ADDRESS_KEY, args.server_mac) 76 | send_REST_request(serverMgrCfg['smgr_ip_addr'], 77 | serverMgrCfg['smgr_port'], 78 | smgr_action, server_def) 79 | # End of dhcp_event 80 | 81 | if __name__ == "__main__": 82 | import cgitb 83 | cgitb.enable(format='text') 84 | 85 | dhcp_event(sys.argv[1:]) 86 | # End if __name__ 87 | -------------------------------------------------------------------------------- /src/role_sequence.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": { 3 | "role_sequence": [[["haproxy"], "p"], 4 | [["loadbalancer"], "p"], 5 | [["database"], "p"], 6 | [["openstack"], "p"], 7 | [["config"], "p"], 8 | [["control"], "p"], 9 | [["global_controller"], "p"], 10 | [["collector"], "p"], 11 | [["webui"], "p"], 12 | [["compute"], "p"], 13 | [["tsn"], "p"], 14 | [["toragent"], "p"], 15 | [["storage-compute"], "p"], 16 | [["storage-master"], "p"]] 17 | }, 18 | "default_ha": { 19 | "role_sequence": [[["keepalived"], "p"], 20 | [["haproxy"], "p"], 21 | [["loadbalancer"], "p"], 22 | [["database"], "p"], 23 | [["openstack"], "p"], 24 | [["pre_exec_vnc_galera"], "s"], 25 | [["post_exec_vnc_galera"], "s"], 26 | [["config"], "p"], 27 | [["control"], "p"], 28 | [["global_controller"], "p"], 29 | [["collector"], "p"], 30 | [["webui"], "p"], 31 | [["compute"], "p"]] 32 | }, 33 | "default_contrail_ha": { 34 | "role_sequence": [[["keepalived"], "p"], 35 | [["haproxy"], "p"], 36 | [["loadbalancer"], "p"], 37 | [["database"], "p"], 38 | [["openstack"], "p"], 39 | [["config"], "p"], 40 | [["control"], "p"], 41 | [["global_controller"], "p"], 42 | [["collector"], "p"], 43 | [["webui"], "p"], 44 | [["compute"], "p"]] 45 | }, 46 | "cluster": [ 47 | { 48 | "id": "all_roles_sequential_computes_parallel_sample", 49 | "role_sequence": [[["database"], "s"], 50 | [["openstack"], "s"], 51 | [["config"], "s"], 52 | [["control"], "s"], 53 | [["collector"], "s"], 54 | [["webui"], "s"], 55 | [["compute"], "p"]] 56 | 57 | }, 58 | { 59 | "id": "all_roles_parallel_sample", 60 | "role_sequence": [[["database","openstack", 61 | "config", "control", 62 | "collector", "webui", "compute"], "s"]] 63 | } 64 | ] 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/contrail_smgr/role_sequence.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": { 3 | "role_sequence": [[["haproxy"], "p"], 4 | [["loadbalancer"], "p"], 5 | [["database"], "p"], 6 | [["openstack"], "p"], 7 | [["config"], "p"], 8 | [["control"], "p"], 9 | [["global_controller"], "p"], 10 | [["collector"], "p"], 11 | [["webui"], "p"], 12 | [["compute"], "p"], 13 | [["tsn"], "p"], 14 | [["toragent"], "p"], 15 | [["storage-compute"], "p"], 16 | [["storage-master"], "p"]] 17 | }, 18 | "default_ha": { 19 | "role_sequence": [[["keepalived"], "p"], 20 | [["haproxy"], "p"], 21 | [["loadbalancer"], "p"], 22 | [["database"], "p"], 23 | [["openstack"], "p"], 24 | [["pre_exec_vnc_galera"], "s"], 25 | [["post_exec_vnc_galera"], "s"], 26 | [["config"], "p"], 27 | [["control"], "p"], 28 | [["global_controller"], "p"], 29 | [["collector"], "p"], 30 | [["webui"], "p"], 31 | [["compute"], "p"]] 32 | }, 33 | "default_contrail_ha": { 34 | "role_sequence": [[["keepalived"], "p"], 35 | [["haproxy"], "p"], 36 | [["loadbalancer"], "p"], 37 | [["database"], "p"], 38 | [["openstack"], "p"], 39 | [["config"], "p"], 40 | [["control"], "p"], 41 | [["global_controller"], "p"], 42 | [["collector"], "p"], 43 | [["webui"], "p"], 44 | [["compute"], "p"]] 45 | }, 46 | "cluster": [ 47 | { 48 | "id": "all_roles_sequential_computes_parallel_sample", 49 | "role_sequence": [[["database"], "s"], 50 | [["openstack"], "s"], 51 | [["config"], "s"], 52 | [["control"], "s"], 53 | [["collector"], "s"], 54 | [["webui"], "s"], 55 | [["compute"], "p"]] 56 | 57 | }, 58 | { 59 | "id": "all_roles_parallel_sample", 60 | "role_sequence": [[["database","openstack", 61 | "config", "control", 62 | "collector", "webui", "compute"], "s"]] 63 | } 64 | ] 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/auth.conf.rpmnew: -------------------------------------------------------------------------------- 1 | # This is an example auth.conf file, it mimics the puppetmasterd defaults 2 | # 3 | # The ACL are checked in order of appearance in this file. 4 | # 5 | # Supported syntax: 6 | # This file supports two different syntax depending on how 7 | # you want to express the ACL. 8 | # 9 | # Path syntax (the one used below): 10 | # --------------------------------- 11 | # path /path/to/resource 12 | # [environment envlist] 13 | # [method methodlist] 14 | # [auth[enthicated] {yes|no|on|off|any}] 15 | # allow [host|ip|*] 16 | # deny [host|ip] 17 | # 18 | # The path is matched as a prefix. That is /file match at 19 | # the same time /file_metadat and /file_content. 20 | # 21 | # Regex syntax: 22 | # ------------- 23 | # This one is differenciated from the path one by a '~' 24 | # 25 | # path ~ regex 26 | # [environment envlist] 27 | # [method methodlist] 28 | # [auth[enthicated] {yes|no|on|off|any}] 29 | # allow [host|ip|*] 30 | # deny [host|ip] 31 | # 32 | # The regex syntax is the same as ruby ones. 33 | # 34 | # Ex: 35 | # path ~ .pp$ 36 | # will match every resource ending in .pp (manifests files for instance) 37 | # 38 | # path ~ ^/path/to/resource 39 | # is essentially equivalent to path /path/to/resource 40 | # 41 | # environment:: restrict an ACL to a specific set of environments 42 | # method:: restrict an ACL to a specific set of methods 43 | # auth:: restrict an ACL to an authenticated or unauthenticated request 44 | # the default when unspecified is to restrict the ACL to authenticated requests 45 | # (ie exactly as if auth yes was present). 46 | # 47 | 48 | ### Authenticated ACL - those applies only when the client 49 | ### has a valid certificate and is thus authenticated 50 | 51 | # allow nodes to retrieve their own catalog (ie their configuration) 52 | path ~ ^/catalog/([^/]+)$ 53 | method find 54 | allow $1 55 | 56 | # allow nodes to retrieve their own node definition 57 | path ~ ^/node/([^/]+)$ 58 | method find 59 | allow $1 60 | 61 | # allow all nodes to access the certificates services 62 | path /certificate_revocation_list/ca 63 | method find 64 | allow * 65 | 66 | # allow all nodes to store their reports 67 | path /report 68 | method save 69 | allow * 70 | 71 | # inconditionnally allow access to all files services 72 | # which means in practice that fileserver.conf will 73 | # still be used 74 | path /file 75 | allow * 76 | 77 | ### Unauthenticated ACL, for clients for which the current master doesn't 78 | ### have a valid certificate; we allow authenticated users, too, because 79 | ### there isn't a great harm in letting that request through. 80 | 81 | # allow access to the master CA 82 | path /certificate/ca 83 | auth any 84 | method find 85 | allow * 86 | 87 | path /certificate/ 88 | auth any 89 | method find 90 | allow * 91 | 92 | path /certificate_request 93 | auth any 94 | method find, save 95 | allow * 96 | 97 | # this one is not stricly necessary, but it has the merit 98 | # to show the default policy which is deny everything else 99 | path / 100 | auth any 101 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/auth.conf: -------------------------------------------------------------------------------- 1 | # This is an example auth.conf file, it mimics the puppetmasterd defaults 2 | # 3 | # The ACL are checked in order of appearance in this file. 4 | # 5 | # Supported syntax: 6 | # This file supports two different syntax depending on how 7 | # you want to express the ACL. 8 | # 9 | # Path syntax (the one used below): 10 | # --------------------------------- 11 | # path /path/to/resource 12 | # [environment envlist] 13 | # [method methodlist] 14 | # [auth[enthicated] {yes|no|on|off|any}] 15 | # allow [host|ip|*] 16 | # deny [host|ip] 17 | # 18 | # The path is matched as a prefix. That is /file match at 19 | # the same time /file_metadat and /file_content. 20 | # 21 | # Regex syntax: 22 | # ------------- 23 | # This one is differenciated from the path one by a '~' 24 | # 25 | # path ~ regex 26 | # [environment envlist] 27 | # [method methodlist] 28 | # [auth[enthicated] {yes|no|on|off|any}] 29 | # allow [host|ip|*] 30 | # deny [host|ip] 31 | # 32 | # The regex syntax is the same as ruby ones. 33 | # 34 | # Ex: 35 | # path ~ .pp$ 36 | # will match every resource ending in .pp (manifests files for instance) 37 | # 38 | # path ~ ^/path/to/resource 39 | # is essentially equivalent to path /path/to/resource 40 | # 41 | # environment:: restrict an ACL to a specific set of environments 42 | # method:: restrict an ACL to a specific set of methods 43 | # auth:: restrict an ACL to an authenticated or unauthenticated request 44 | # the default when unspecified is to restrict the ACL to authenticated requests 45 | # (ie exactly as if auth yes was present). 46 | # 47 | 48 | ### Authenticated ACL - those applies only when the client 49 | ### has a valid certificate and is thus authenticated 50 | 51 | # allow nodes to retrieve their own catalog (ie their configuration) 52 | path ~ ^/catalog/([^/]+)$ 53 | method find 54 | allow $1 55 | #allow $1 Abhay 56 | 57 | # allow nodes to retrieve their own node definition 58 | path ~ ^/node/([^/]+)$ 59 | method find 60 | allow $1 61 | 62 | # allow all nodes to access the certificates services 63 | path /certificate_revocation_list/ca 64 | method find 65 | allow * 66 | 67 | # allow all nodes to store their reports 68 | path /report 69 | method save 70 | allow * 71 | 72 | # inconditionnally allow access to all files services 73 | # which means in practice that fileserver.conf will 74 | # still be used 75 | path /file 76 | allow * 77 | 78 | ### Unauthenticated ACL, for clients for which the current master doesn't 79 | ### have a valid certificate; we allow authenticated users, too, because 80 | ### there isn't a great harm in letting that request through. 81 | 82 | # allow access to the master CA 83 | path /certificate/ca 84 | auth any 85 | method find 86 | allow * 87 | 88 | path /certificate/ 89 | auth any 90 | method find 91 | allow * 92 | 93 | path /certificate_request 94 | auth any 95 | method find, save 96 | allow * 97 | 98 | # this one is not stricly necessary, but it has the merit 99 | # to show the default policy which is deny everything else 100 | path / 101 | auth any 102 | -------------------------------------------------------------------------------- /src/unit_tests/test_sm_mgr_main/verfiy_server_cfg.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | def verify_interface(self, output): 4 | list = output.split() 5 | self.assertEqual(list[0].strip(), 'python') 6 | self.assertEqual(list[1].strip(), '/root/interface_setup.py') 7 | self.assertEqual(list[2].strip(), '--device') 8 | self.assertEqual(list[3].strip(), 'c4:54:44:44:d7:4a') 9 | self.assertEqual(list[4].strip(), '--ip') 10 | self.assertEqual(list[5].strip(), '172.16.70.30/24') 11 | self.assertEqual(list[6].strip(), '--gw') 12 | self.assertEqual(list[7].strip(), '172.16.70.254') 13 | 14 | def verify_bond_interface(self, output): 15 | list = output.split() 16 | self.assertEqual(list[0].strip(), 'python') 17 | self.assertEqual(list[1].strip(), '/root/interface_setup.py') 18 | self.assertEqual(list[2].strip(), '--device') 19 | self.assertEqual(list[3].strip(), 'bond0') 20 | self.assertEqual(list[4].strip(), '--members') 21 | self.assertEqual(list[5].strip(), '--bond-opts') 22 | # self.assertEqual(list[6].strip(), '"{"miimon":') 23 | self.assertEqual(list[7].strip(), '"100",') 24 | self.assertEqual(list[8].strip(), '"mode":') 25 | self.assertEqual(list[9].strip(), '"802.3ad",') 26 | self.assertEqual(list[10].strip(), '"xmit_hash_policy":') 27 | #self.assertEqual(list[11].strip(), '"layer3+4"}"') 28 | self.assertEqual(list[12].strip(), '--ip') 29 | self.assertEqual(list[13].strip(), '192.168.100.1/24') 30 | 31 | def verify_static_route(self, output): 32 | list = output.split() 33 | self.assertEqual(list[0].strip(), 'python') 34 | self.assertEqual(list[1].strip(), '/root/staticroute_setup.py') 35 | self.assertEqual(list[2].strip(), '--device') 36 | self.assertEqual(list[3].strip(), 'eth1') 37 | self.assertEqual(list[4].strip(), '--network') 38 | self.assertEqual(list[5].strip(), '3.3.4.0') 39 | self.assertEqual(list[6].strip(), '--netmask') 40 | self.assertEqual(list[7].strip(), '255.255.255.0') 41 | self.assertEqual(list[8].strip(), '--gw') 42 | self.assertEqual(list[9].strip(), '3.3.3.254') 43 | 44 | def verify_dhcp_config(self, output): 45 | list = output.split() 46 | self.assertEqual(list[0].strip(), 'python') 47 | self.assertEqual(list[1].strip(), '/root/interface_setup.py') 48 | self.assertEqual(list[2].strip(), '--device') 49 | self.assertEqual(list[3].strip(), 'c4:54:44:44:d7:4a') 50 | self.assertEqual(list[4].strip(), '--mtu') 51 | self.assertEqual(list[5].strip(), '1400') 52 | self.assertEqual(list[6].strip(), '--vlan') 53 | self.assertEqual(list[7].strip(), '1') 54 | self.assertEqual(list[8].strip(), '--dhcp') 55 | 56 | def verify_rm_line(self, output): 57 | list = output.split() 58 | self.assertEqual(list[0].strip(), 'rm') 59 | self.assertEqual(list[1].strip(), '/etc/init.d/host05.sh') 60 | 61 | def verify_server_cfg(self,output): 62 | list = output.split('\n') 63 | verify_interface(self, list[1].strip()) 64 | verify_bond_interface(self, list[2].strip()) 65 | verify_rm_line(self, list[4].strip()) 66 | 67 | def verify_parameter_translation(self, translated_params,key_list): 68 | translated_key_list = translated_params['provision']['contrail'] 69 | self.assertEqual(set(key_list), set(translated_key_list)) 70 | -------------------------------------------------------------------------------- /src/repos/contrail-centos-repo/repodata/repomd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1398802960 4 | 5 | 20d387fec8b9bac544a259ec672ab9e5e6e918f99f15f8eceb82fe9792011fa5 6 | 910ac965234c1a05f3e3d29bf8f6f2c7178e93e5327ca4fbd7a0ae7b921334b9 7 | 8 | 1398802961 9 | 11740 10 | 126913 11 | 12 | 13 | d24d50fe8fb38188b064f135e4956105f8d01ab91f9274ef422a740f12f4baf8 14 | 337db42a648aabf677af7b9483cb379e33b716b38e87887fd8921c9988e5ca5f 15 | 16 | 1398802961 17 | 4336 18 | 21245 19 | 20 | 21 | 81049688865d7515ec93026456c3bfa00569ff6f607bb204475643416b275fbd 22 | 1bb137a7933d4140fcd9599cc54a2cc5f701ffd0edb12aec572856c2107b5a49 23 | 24 | 1398802961.09 25 | 10 26 | 9652 27 | 43008 28 | 29 | 30 | b7a568f368fe9d4540554d64b8be9d9e379cad23f13ac02ae0fbbaa9e28ba0c1 31 | 5883bfaa07b5ce0605945de284a3bdae08a22f36a28861e351478f3605b31e05 32 | 33 | 1398802961.04 34 | 10 35 | 6227 36 | 21504 37 | 38 | 39 | 231b4689c9cf577f66845b4de859ae8e1bd3f75933bbcddabea043e235c2aefb 40 | d7c4cbec8fa2ba547578c985124f99c4ba4e9629f969a402e27ecba448befbfb 41 | 42 | 1398802961 43 | 3810 44 | 18480 45 | 46 | 47 | b8f129511cb4d852708ea6e9ee66a7b7e19890b0c42ecad5ed32dc88a3b73a46 48 | 9d8117a3598732340a1a3b1b509e2aefb91df781d99c994401b6404439d1e576 49 | 50 | 1398802961.06 51 | 10 52 | 17983 53 | 71680 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/contrail_smgr/puppet/puppet_init_rd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # puppet Init script for running the puppet client daemon 3 | # 4 | # Author: Duane Griffin 5 | # David Lutterkort 6 | # 7 | # chkconfig: - 98 02 8 | # 9 | # description: Enables periodic system configuration checks through puppet. 10 | # processname: puppet 11 | # config: /etc/sysconfig/puppet 12 | 13 | PATH=/usr/bin:/sbin:/bin:/usr/sbin 14 | export PATH 15 | 16 | [ -f /etc/sysconfig/puppet ] && . /etc/sysconfig/puppet 17 | lockfile=${LOCKFILE-/var/lock/subsys/puppet} 18 | pidfile=${PIDFILE-/var/run/puppet/agent.pid} 19 | puppetd=${PUPPETD-/usr/sbin/puppetd} 20 | RETVAL=0 21 | 22 | # Source function library. 23 | . /etc/rc.d/init.d/functions 24 | 25 | PUPPET_OPTS="" 26 | [ -n "${PUPPET_SERVER}" ] && PUPPET_OPTS="--server=${PUPPET_SERVER}" 27 | [ -n "$PUPPET_LOG" ] && PUPPET_OPTS="${PUPPET_OPTS} --logdest=${PUPPET_LOG}" 28 | [ -n "$PUPPET_PORT" ] && PUPPET_OPTS="${PUPPET_OPTS} --masterport=${PUPPET_PORT}" 29 | 30 | # Determine if we can use the -p option to daemon, killproc, and status. 31 | # RHEL < 5 can't. 32 | if status | grep -q -- '-p' 2>/dev/null; then 33 | daemonopts="--pidfile $pidfile" 34 | pidopts="-p $pidfile" 35 | fi 36 | 37 | # Figure out if the system just booted. Let's assume 38 | # boot doesn't take longer than 5 minutes 39 | ## Not used for now 40 | ##[ -n "$INIT_VERSION" ] && PUPPET_OPTS="${PUPPET_OPTS} --fullrun" 41 | 42 | start() { 43 | echo -n $"Starting puppet: " 44 | daemon $daemonopts $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} 45 | RETVAL=$? 46 | echo 47 | [ $RETVAL = 0 ] && touch ${lockfile} 48 | return $RETVAL 49 | } 50 | 51 | stop() { 52 | echo -n $"Stopping puppet: " 53 | killproc $pidopts $puppetd 54 | RETVAL=$? 55 | echo 56 | [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} 57 | } 58 | 59 | reload() { 60 | echo -n $"Restarting puppet: " 61 | killproc $pidopts $puppetd -HUP 62 | RETVAL=$? 63 | echo 64 | return $RETVAL 65 | } 66 | 67 | restart() { 68 | stop 69 | start 70 | } 71 | 72 | rh_status() { 73 | status $pidopts $puppetd 74 | RETVAL=$? 75 | return $RETVAL 76 | } 77 | 78 | rh_status_q() { 79 | rh_status >/dev/null 2>&1 80 | } 81 | 82 | genconfig() { 83 | echo -n $"Generate configuration puppet: " 84 | $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} --genconfig 85 | } 86 | 87 | case "$1" in 88 | start) 89 | start 90 | ;; 91 | stop) 92 | stop 93 | ;; 94 | restart) 95 | restart 96 | ;; 97 | reload|force-reload) 98 | reload 99 | ;; 100 | condrestart|try-restart) 101 | rh_status_q || exit 0 102 | restart 103 | ;; 104 | status) 105 | rh_status 106 | ;; 107 | once) 108 | shift 109 | $puppetd -o ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} $@ 110 | ;; 111 | genconfig) 112 | genconfig 113 | ;; 114 | *) 115 | echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|once|genconfig}" 116 | exit 1 117 | esac 118 | 119 | exit $RETVAL 120 | -------------------------------------------------------------------------------- /src/client/server-manager: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 4 | """ 5 | Name : server-manager.py 6 | Author : Abhay Joshi 7 | Description : This program is a simple cli interface with 8 | wrapper code to call individual programs such as create, show 9 | etc. 10 | """ 11 | import argparse 12 | import pdb 13 | import sys 14 | import smgr_delete 15 | import smgr_show 16 | import smgr_upload_image 17 | import smgr_reimage_server 18 | import smgr_provision_server 19 | import smgr_restart_server 20 | import smgr_status 21 | import smgr_add 22 | import smgr_client_def 23 | import smgr_run_inventory 24 | import smgr_issu 25 | 26 | commands_dict = { 27 | 'add' : smgr_add.add_config, 28 | 'delete' : smgr_delete.delete_config, 29 | 'show' : smgr_show.show_config, 30 | 'reimage' : smgr_reimage_server.reimage_server, 31 | 'provision' : smgr_provision_server.provision_server, 32 | 'restart' : smgr_restart_server.restart_server, 33 | 'upload_image' : smgr_upload_image.upload_image, 34 | 'status' : smgr_status.show_status, 35 | 'run_inventory' : smgr_run_inventory.run_inventory, 36 | 'issu' : smgr_issu.do_issu, 37 | 'issu_finalize': smgr_issu.do_issu_finalize 38 | } 39 | 40 | def server_manager(args_str=None): 41 | if not args_str: 42 | args_str = sys.argv[1:] 43 | 44 | # Process the arguments 45 | parser = argparse.ArgumentParser( 46 | description='''server manager client program''', 47 | usage= '''server-manager [-c ] [] 48 | 49 | The server manager commands are: 50 | add Add server manager objects(create or modify server manager objects) 51 | delete Delete server manager objects 52 | show Show server manager objects configuration 53 | reimage Prepare servers for reimaging with given image 54 | provision Provision servers to provide configured roles 55 | run_inventory Run inventory on a particular server or cluster 56 | restart Restart servers 57 | upload_image Upload images to server manager DB 58 | status Status of servers 59 | issu Perform in-service-software upgrade 60 | issu_finalize Finalize in-service-software upgrade procedure 61 | 62 | ''' 63 | ) 64 | parser.add_argument("--config_file", "-c", 65 | help=("Server manager client config file" 66 | " (default - %s)" %( 67 | smgr_client_def._DEF_SMGR_CFG_FILE))) 68 | parser.add_argument( 69 | 'command', 70 | help='server manager command to run', 71 | choices=['add', 'delete', 'issu', 'issu_finalize', 72 | 'show', 'reimage', 'provision', 73 | 'restart', 'upload_image', 'status', 'run_inventory']) 74 | if len(sys.argv) > 1 and (sys.argv[1] == '-c' or sys.argv[1] == '--config_file'): 75 | args = parser.parse_args(sys.argv[1:4]) 76 | argv = sys.argv[1:3] + sys.argv[4:] 77 | else: 78 | args = parser.parse_args(sys.argv[1:2]) 79 | argv = sys.argv[2:] 80 | commands_dict[args.command](argv) 81 | # End of server_manager 82 | 83 | if __name__ == "__main__": 84 | import cgitb 85 | cgitb.enable(format='text') 86 | 87 | server_manager(sys.argv[1:]) 88 | # End if __name__ 89 | -------------------------------------------------------------------------------- /src/contrail/server_xmltoserver.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import xmltodict 4 | import json 5 | import argparse 6 | import cgitb 7 | import sys 8 | 9 | 10 | def convert_xml_to_json(input_file, output_file): 11 | server_file = open(input_file, "r") 12 | original_server_file = server_file.read() 13 | servers_dict = xmltodict.parse(original_server_file) 14 | servers_list = servers_dict['servers']['server'] 15 | smgr_server_dict = {} 16 | smgr_server_dict['server'] = [] 17 | for server in servers_list: 18 | smgr_server = {} 19 | smgr_server['id'] = server['hostname'] 20 | network = {} 21 | network['interfaces'] = [] 22 | interface = {} 23 | interface['ip_address'] = server['ipaddr'] + '/24' 24 | interface['mac_addres'] = server['mac'] 25 | interface['name'] = 'eth1' 26 | interface['type'] = 'physical' 27 | ip_addr_list = server['ipaddr'].split('.') 28 | ip_addr_list[3] = '254' 29 | interface['default_gateway'] = '.'.join(ip_addr_list) 30 | interface['dhcp'] = True 31 | network['interfaces'].append(interface) 32 | network['management_interface'] = interface['name'] 33 | contrail = {} 34 | contrail['control_data_interface'] = interface['name'] 35 | tag = {} 36 | tag['datacenter'] = 'contrail_lab' 37 | tag['floor'] = 'floor_6' 38 | tag['row'] = 'row_' + server['row'] 39 | tag['rack'] = 'rack_' + server['rack'] 40 | tag['userid'] = server['reserved'] 41 | smgr_server['network'] = network 42 | smgr_server['contrail'] = contrail 43 | smgr_server['tag'] = tag 44 | smgr_server['password'] = 'c0ntrail123' 45 | smgr_server['domain'] = 'contrail.juniper.net' 46 | smgr_server['ipmi_address'] = server['ipmi'] 47 | smgr_server_dict['server'].append(smgr_server) 48 | 49 | servers_jdump = json.dumps(smgr_server_dict, indent=4) 50 | servers_list_file = open(output_file, 'w') 51 | servers_list_file.write(servers_jdump) 52 | servers_list_file.close() 53 | # end convert_xml_to_json 54 | 55 | def parse_args(args_str): 56 | conf_parser = argparse.ArgumentParser(add_help=False) 57 | args, remaining_argv = conf_parser.parse_known_args(args_str.split()) 58 | parser = argparse.ArgumentParser( 59 | # Inherit options from config_parser 60 | parents=[conf_parser], 61 | # script description with -h/--help 62 | description=__doc__, 63 | # Don't mess with format of description 64 | formatter_class=argparse.RawDescriptionHelpFormatter, 65 | ) 66 | defaults = { 67 | 'input_file': 'server.xml', 68 | 'output_file': 'server.json', 69 | } 70 | parser.set_defaults(**defaults) 71 | parser.add_argument( 72 | "--input_file", "-i", help="input xml file") 73 | parser.add_argument( 74 | "--output_file", "-o", help="output json file") 75 | args = parser.parse_args(remaining_argv) 76 | return args 77 | # end parse_args 78 | 79 | def main(args_str=None): 80 | if not args_str: 81 | args_str = ' '.join(sys.argv[1:]) 82 | args = parse_args(args_str) 83 | convert_xml_to_json(args.input_file, args.output_file) 84 | # end main 85 | 86 | if __name__ == '__main__': 87 | cgitb.enable(format='text') 88 | main() 89 | -------------------------------------------------------------------------------- /src/cobbler/etc_cobbler/modules.conf: -------------------------------------------------------------------------------- 1 | # cobbler module configuration file 2 | # ================================= 3 | 4 | # authentication: 5 | # what users can log into the WebUI and Read-Write XMLRPC? 6 | # choices: 7 | # authn_denyall -- no one (default) 8 | # authn_configfile -- use /etc/cobbler/users.digest (for basic setups) 9 | # authn_passthru -- ask Apache to handle it (used for kerberos) 10 | # authn_ldap -- authenticate against LDAP 11 | # authn_spacewalk -- ask Spacewalk/Satellite (experimental) 12 | # authn_pam -- use PAM facilities 13 | # authn_testing -- username/password is always testing/testing (debug) 14 | # (user supplied) -- you may write your own module 15 | # WARNING: this is a security setting, do not choose an option blindly. 16 | # for more information: 17 | # https://github.com/cobbler/cobbler/wiki/Cobbler-web-interface 18 | # https://github.com/cobbler/cobbler/wiki/Security-overview 19 | # https://github.com/cobbler/cobbler/wiki/Kerberos 20 | # https://github.com/cobbler/cobbler/wiki/Ldap 21 | 22 | [authentication] 23 | module = authn_testing 24 | 25 | # authorization: 26 | # once a user has been cleared by the WebUI/XMLRPC, what can they do? 27 | # choices: 28 | # authz_allowall -- full access for all authneticated users (default) 29 | # authz_ownership -- use users.conf, but add object ownership semantics 30 | # (user supplied) -- you may write your own module 31 | # WARNING: this is a security setting, do not choose an option blindly. 32 | # If you want to further restrict cobbler with ACLs for various groups, 33 | # pick authz_ownership. authz_allowall does not support ACLs. configfile 34 | # does but does not support object ownership which is useful as an additional 35 | # layer of control. 36 | 37 | # for more information: 38 | # https://github.com/cobbler/cobbler/wiki/Cobbler-web-interface 39 | # https://github.com/cobbler/cobbler/wiki/Security-overview 40 | # https://github.com/cobbler/cobbler/wiki/Web-authorization 41 | 42 | [authorization] 43 | module = authz_allowall 44 | 45 | # dns: 46 | # chooses the DNS management engine if manage_dns is enabled 47 | # in /etc/cobbler/settings, which is off by default. 48 | # choices: 49 | # manage_bind -- default, uses BIND/named 50 | # manage_dnsmasq -- uses dnsmasq, also must select dnsmasq for dhcp below 51 | # NOTE: more configuration is still required in /etc/cobbler 52 | # for more information: 53 | # https://github.com/cobbler/cobbler/wiki/Dns-management 54 | 55 | [dns] 56 | module = manage_bind 57 | 58 | # dhcp: 59 | # chooses the DHCP management engine if manage_dhcp is enabled 60 | # in /etc/cobbler/settings, which is off by default. 61 | # choices: 62 | # manage_isc -- default, uses ISC dhcpd 63 | # manage_dnsmasq -- uses dnsmasq, also must select dnsmasq for dns above 64 | # NOTE: more configuration is still required in /etc/cobbler 65 | # for more information: 66 | # https://github.com/cobbler/cobbler/wiki/Dhcp-management 67 | 68 | [dhcp] 69 | module = manage_isc 70 | 71 | # tftpd: 72 | # chooses the TFTP management engine if manage_tftp is enabled 73 | # in /etc/cobbler/settings, which is ON by default. 74 | # 75 | # choices: 76 | # manage_in_tftpd -- default, uses the system's tftp server 77 | # manage_tftpd_py -- uses cobbler's tftp server 78 | # 79 | 80 | [tftpd] 81 | module = manage_in_tftpd 82 | 83 | #-------------------------------------------------- 84 | -------------------------------------------------------------------------------- /src/contrail-defaults.yaml: -------------------------------------------------------------------------------- 1 | openstack::region: 'RegionOne' 2 | ######## Networks 3 | openstack::network::external::ippool::start: '' 4 | openstack::network::external::ippool::end: '' 5 | openstack::network::external::gateway: '' 6 | openstack::network::external::dns: '' 7 | ######## Private Neutron Network 8 | openstack::network::neutron::private: '192.168.0.0/24' 9 | ######## Database 10 | openstack::mysql::root_password: 'XLbZ3ZzRsMoqwRJcFlmrpocd' 11 | openstack::mysql::service_password: 'XLbZ3ZzRsMoqwRJcFlmrpocd' 12 | ######## RabbitMQ 13 | openstack::rabbitmq::user: 'guest' 14 | openstack::rabbitmq::password: 'guest' 15 | ######## Keystone 16 | openstack::keystone::admin_token: 'XLbZ3ZzRsMoqwRJcFlmrpocd' 17 | openstack::keystone::admin_email: 'test@orgname.com' 18 | openstack::keystone::admin_password: 'XLbZ3ZzRsMoqwRJcFlmrpocd' 19 | openstack::keystone::tenants: 20 | "test": 21 | description: "Test tenant" 22 | 23 | openstack::keystone::users: 24 | "test": 25 | password: "test123" 26 | tenant: "test" 27 | email: "test@orgname.com" 28 | admin: true 29 | "demo": 30 | password: "demo123" 31 | tenant: "test" 32 | email: "test@orgname.com" 33 | admin: false 34 | ######## Glance 35 | openstack::glance::password: $openstack::keystone::admin_password 36 | ######## Cinder 37 | openstack::cinder::password: $openstack::keystone::admin_password 38 | openstack::cinder::volume_size: '8G' 39 | ######## Swift 40 | openstack::swift::password: $openstack::keystone::admin_password 41 | openstack::swift::hash_suffix: '' 42 | ######## Nova 43 | openstack::nova::libvirt_type: 'kvm' 44 | openstack::nova::password: $openstack::keystone::admin_password 45 | ######## Neutron 46 | openstack::neutron::password: $openstack::keystone::admin_password 47 | neutron::bind_port: '9697' 48 | ######## Ceilometer 49 | openstack::ceilometer::mongo: $openstack::keystone::admin_password 50 | openstack::ceilometer::password: $openstack::keystone::admin_password 51 | openstack::ceilometer::meteringsecret: '' 52 | ######## Heat 53 | openstack::heat::password: $openstack::keystone::admin_password 54 | openstack::heat::encryption_key: $openstack::keystone::admin_password 55 | ######## Horizon 56 | openstack::horizon::secret_key: $openstack::keystone::admin_password 57 | ######## Tempest 58 | openstack::tempest::configure_images : true 59 | openstack::tempest::image_name : 'Cirros' 60 | openstack::tempest::image_name_alt : 'Cirros' 61 | openstack::tempest::username : 'demo' 62 | openstack::tempest::username_alt : 'demo2' 63 | openstack::tempest::username_admin : 'test' 64 | openstack::tempest::configure_network : true 65 | openstack::tempest::public_network_name : 'public' 66 | openstack::tempest::cinder_available : true 67 | openstack::tempest::glance_available : true 68 | openstack::tempest::horizon_available : true 69 | openstack::tempest::nova_available : true 70 | openstack::tempest::neutron_available : true 71 | openstack::tempest::heat_available : false 72 | openstack::tempest::swift_available : false 73 | ######## Log levels 74 | openstack::verbose: 'True' 75 | openstack::debug: 'True' 76 | ######## Ceph Keys 77 | contrail::storage::storage_monitor_secret: 'AQBM78tTEMz+GhAA3WiOXQI7UVdIy0YFFuTGdw==' 78 | contrail::storage::osd_bootstrap_key: 'AQCq7NFTeJUoBhAAlTVpxwWQJtBej/JDNhT6+Q==' 79 | contrail::storage::storage_admin_key: 'AQDIgtNTgPLWARAAK6gs/fj8m88LnY9DwxJdYA==' 80 | -------------------------------------------------------------------------------- /src/contrail_smgr/contrail-defaults.yaml: -------------------------------------------------------------------------------- 1 | openstack::region: 'RegionOne' 2 | ######## Networks 3 | openstack::network::external::ippool::start: '' 4 | openstack::network::external::ippool::end: '' 5 | openstack::network::external::gateway: '' 6 | openstack::network::external::dns: '' 7 | ######## Private Neutron Network 8 | openstack::network::neutron::private: '192.168.0.0/24' 9 | ######## Database 10 | openstack::mysql::root_password: 'XLbZ3ZzRsMoqwRJcFlmrpocd' 11 | openstack::mysql::service_password: 'XLbZ3ZzRsMoqwRJcFlmrpocd' 12 | ######## RabbitMQ 13 | openstack::rabbitmq::user: 'guest' 14 | openstack::rabbitmq::password: 'guest' 15 | ######## Keystone 16 | openstack::keystone::admin_token: 'XLbZ3ZzRsMoqwRJcFlmrpocd' 17 | openstack::keystone::admin_email: 'test@orgname.com' 18 | openstack::keystone::admin_password: 'XLbZ3ZzRsMoqwRJcFlmrpocd' 19 | openstack::keystone::tenants: 20 | "test": 21 | description: "Test tenant" 22 | 23 | openstack::keystone::users: 24 | "test": 25 | password: "test123" 26 | tenant: "test" 27 | email: "test@orgname.com" 28 | admin: true 29 | "demo": 30 | password: "demo123" 31 | tenant: "test" 32 | email: "test@orgname.com" 33 | admin: false 34 | ######## Glance 35 | openstack::glance::password: $openstack::keystone::admin_password 36 | ######## Cinder 37 | openstack::cinder::password: $openstack::keystone::admin_password 38 | openstack::cinder::volume_size: '8G' 39 | ######## Swift 40 | openstack::swift::password: $openstack::keystone::admin_password 41 | openstack::swift::hash_suffix: '' 42 | ######## Nova 43 | openstack::nova::libvirt_type: 'kvm' 44 | openstack::nova::password: $openstack::keystone::admin_password 45 | ######## Neutron 46 | openstack::neutron::password: $openstack::keystone::admin_password 47 | neutron::bind_port: '9697' 48 | ######## Ceilometer 49 | openstack::ceilometer::mongo: $openstack::keystone::admin_password 50 | openstack::ceilometer::password: $openstack::keystone::admin_password 51 | openstack::ceilometer::meteringsecret: '' 52 | ######## Heat 53 | openstack::heat::password: $openstack::keystone::admin_password 54 | openstack::heat::encryption_key: $openstack::keystone::admin_password 55 | ######## Horizon 56 | openstack::horizon::secret_key: $openstack::keystone::admin_password 57 | ######## Tempest 58 | openstack::tempest::configure_images : true 59 | openstack::tempest::image_name : 'Cirros' 60 | openstack::tempest::image_name_alt : 'Cirros' 61 | openstack::tempest::username : 'demo' 62 | openstack::tempest::username_alt : 'demo2' 63 | openstack::tempest::username_admin : 'test' 64 | openstack::tempest::configure_network : true 65 | openstack::tempest::public_network_name : 'public' 66 | openstack::tempest::cinder_available : true 67 | openstack::tempest::glance_available : true 68 | openstack::tempest::horizon_available : true 69 | openstack::tempest::nova_available : true 70 | openstack::tempest::neutron_available : true 71 | openstack::tempest::heat_available : false 72 | openstack::tempest::swift_available : false 73 | ######## Log levels 74 | openstack::verbose: 'True' 75 | openstack::debug: 'True' 76 | ######## Ceph Keys 77 | contrail::storage::storage_monitor_secret: 'AQBM78tTEMz+GhAA3WiOXQI7UVdIy0YFFuTGdw==' 78 | contrail::storage::osd_bootstrap_key: 'AQCq7NFTeJUoBhAAlTVpxwWQJtBej/JDNhT6+Q==' 79 | contrail::storage::storage_admin_key: 'AQDIgtNTgPLWARAAK6gs/fj8m88LnY9DwxJdYA==' 80 | -------------------------------------------------------------------------------- /src/server_manager/server_mgr_ssh_client.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | import signal 4 | import sys 5 | import datetime 6 | import syslog 7 | import subprocess 8 | import re 9 | import socket 10 | import pdb 11 | import re 12 | import ast 13 | from StringIO import StringIO 14 | import paramiko 15 | from os import chmod 16 | from server_mgr_db import ServerMgrDb as db 17 | from server_mgr_logger import ServerMgrlogger as ServerMgrlogger 18 | from server_mgr_utils import * 19 | 20 | DEF_SERVER_DB_LOCATION = "/etc/contrail_smgr/smgr_data.db" 21 | 22 | 23 | class ServerMgrSSHClient(object): 24 | 25 | _serverDb = None 26 | _key_folder = None 27 | _ssh_client = None 28 | 29 | def __init__(self, serverdb=None, log_file=None): 30 | if serverdb: 31 | self._serverDb = serverdb 32 | else: 33 | self._serverDb = db(DEF_SERVER_DB_LOCATION) 34 | 35 | self._smgr_log = ServerMgrlogger() 36 | 37 | def connect(self, ip, server_id, option="key"): 38 | try: 39 | ssh = paramiko.SSHClient() 40 | ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 41 | match_dict = dict() 42 | match_dict["id"] = server_id 43 | smutil = ServerMgrUtil() 44 | server = self._serverDb.get_server(match_dict, detail=True) 45 | password = smutil.get_password(server[0],self._serverDb) 46 | if len(server) == 1: 47 | server = server[0] 48 | if "ssh_private_key" in server and option == "key" and server["ssh_private_key"]: 49 | key = str(server["ssh_private_key"]) 50 | private_key = StringIO(key) 51 | pkey = paramiko.RSAKey.from_private_key(private_key) 52 | ssh.connect(ip, username='root', pkey=pkey, timeout=30) 53 | elif option == "password" and password is not None: 54 | root_pwd = password 55 | ssh.connect(ip, username='root', password=root_pwd, timeout=30) 56 | self._ssh_client = ssh 57 | 58 | except Exception as e: 59 | msg = "CONNECT FAILED: Host => %s, option => %s, ERROR => %s" % (ip, option, str(e)) 60 | self._smgr_log.log(self._smgr_log.INFO, msg) 61 | ssh.close() 62 | raise e 63 | 64 | msg = "CONNECT SUCCESS: Host => %s, option => %s" % (ip, option) 65 | self._smgr_log.log(self._smgr_log.INFO, msg) 66 | return ssh 67 | 68 | def copy(self, source, dest): 69 | try: 70 | sftp = self._ssh_client.open_sftp() 71 | sftp_attr = sftp.put(source, dest) 72 | bytes_sent = sftp_attr.st_size 73 | sftp.close() 74 | except Exception as e: 75 | if sftp: 76 | sftp.close() 77 | raise e 78 | return bytes_sent 79 | 80 | def exec_command(self, cmd): 81 | try: 82 | stdin, stdout, stderr = self._ssh_client.exec_command(cmd) 83 | if stdout.channel.recv_exit_status() is 1 or stdout.channel.recv_exit_status() is 127: 84 | return None 85 | filestr = stdout.read() 86 | if not filestr: 87 | return None 88 | else: 89 | return filestr 90 | except Exception as e: 91 | raise e 92 | 93 | def close(self): 94 | if self._ssh_client: 95 | self._ssh_client.close() 96 | 97 | -------------------------------------------------------------------------------- /src/server_manager/send_mail.py: -------------------------------------------------------------------------------- 1 | # Import smtplib for the actual sending function 2 | import smtplib 3 | import socket 4 | import cgitb 5 | import sys 6 | import argparse 7 | 8 | # Import the email modules we'll need 9 | from email.mime.text import MIMEText 10 | 11 | def send_mail(subject, message, mail_sender, mail_to, smtp_server, smtp_port='25'): 12 | if len(mail_to) == 0: 13 | print "email recepient is not present." 14 | return 15 | 16 | if mail_sender == '': 17 | mail_sender = mail_to[0] 18 | 19 | if subject == '' and message == '': 20 | print "email subject and message are empty." 21 | return 22 | 23 | if subject == '': 24 | subject = message 25 | 26 | if message == '': 27 | message = subject 28 | 29 | 30 | msg = MIMEText(message) 31 | msg['Subject'] = '%s' % subject 32 | msg['From'] = mail_sender 33 | msg['To'] = ', '.join(mail_to) 34 | 35 | # Send the message via our own SMTP server, but don't include the 36 | # envelope header. 37 | s = None 38 | try: 39 | s = smtplib.SMTP(smtp_server, smtp_port) 40 | except Exception, e: 41 | print "Unable to connect to Mail Server" 42 | return 43 | s.ehlo() 44 | 45 | try: 46 | s.sendmail(mail_sender, mail_to, msg.as_string()) 47 | s.quit() 48 | except smtplib.SMTPException, e : 49 | print "Error while sending mail" 50 | # end send_mail 51 | 52 | def get_local_host_ip(): 53 | return socket.gethostbyname(socket.gethostname()) 54 | # end get_local_host_ip 55 | 56 | def parse_args(args_str): 57 | conf_parser = argparse.ArgumentParser(add_help=False) 58 | args, remaining_argv = conf_parser.parse_known_args(args_str.split()) 59 | parser = argparse.ArgumentParser( 60 | # Inherit options from config_parser 61 | parents=[conf_parser], 62 | # script description with -h/--help 63 | description=__doc__, 64 | # Don't mess with format of description 65 | formatter_class=argparse.RawDescriptionHelpFormatter, 66 | ) 67 | 68 | defaults = { 69 | 'mail_from': 'pmiriyala@juniper.net', 70 | 'mail_to': '', 71 | 'smtp_server': get_local_host_ip(), 72 | 'smtp_port':'25', 73 | 'message':'Lab testing', 74 | } 75 | parser.set_defaults(**defaults) 76 | parser.add_argument( 77 | "--mail_from", "-f", help="mail from") 78 | parser.add_argument( 79 | "mail_to", help="mail to") 80 | parser.add_argument( 81 | "--smtp_server", "-s", help="smtp server") 82 | parser.add_argument( 83 | "--smtp_port", "-p", help="smtp server port") 84 | parser.add_argument( 85 | "--message", "-m", help="message to send") 86 | args = parser.parse_args(remaining_argv) 87 | return args 88 | # end parse_args 89 | 90 | def main(args_str=None): 91 | if not args_str: 92 | args_str = ' '.join(sys.argv[1:]) 93 | args = parse_args(args_str) 94 | mail_from = args.mail_from 95 | mail_to = [] 96 | mail_to.append(args.mail_to) 97 | if mail_from == '': 98 | mail_from = args.mail_to 99 | 100 | subject = args.message 101 | send_mail(subject, args.message, mail_from, mail_to, args.smtp_server, args.smtp_port) 102 | # end main 103 | 104 | if __name__ == '__main__': 105 | cgitb.enable(format='text') 106 | main() 107 | 108 | -------------------------------------------------------------------------------- /src/unit_tests/server.json: -------------------------------------------------------------------------------- 1 | { 2 | "server": [ 3 | { 4 | "base_image_id": "", 5 | "cluster_id": "test-cluster", 6 | "contrail": { 7 | "control_data_interface": "eth1" 8 | }, 9 | "domain": "test.juniper.net", 10 | "gateway": "10.84.51.254", 11 | "host_name": "", 12 | "id": "testserver1", 13 | "ip_address": "10.84.51.12", 14 | "ipmi_address": "10.84.6.62", 15 | "mac_address": "00:25:90:A9:1B:6C", 16 | "network": { 17 | "interfaces": [ 18 | { 19 | "default_gateway": "10.84.51.254", 20 | "dhcp": true, 21 | "ip_address": "10.84.51.12/24", 22 | "mac_address": "00:25:90:a9:1b:6c", 23 | "name": "eth1" 24 | } 25 | ], 26 | "management_interface": "eth1", 27 | "provisioning": "kickstart" 28 | }, 29 | "package_image_id": "", 30 | "parameters": { 31 | "interface_name": "eth1" 32 | }, 33 | "password": "c0ntrail123", 34 | "roles": [ 35 | "config", 36 | "control", 37 | "collector", 38 | "database", 39 | "webui", 40 | "openstack", 41 | "compute" 42 | ], 43 | "static_ip": "N", 44 | "subnet_mask": "255.255.255.0", 45 | "tag": { 46 | "datacenter": "test-dc", 47 | "floor": "test-floor", 48 | "hall": "test-hall", 49 | "rack": "test-rack", 50 | "user_tag": "test-user" 51 | } 52 | }, 53 | { 54 | "base_image_id": "", 55 | "cluster_id": "test-cluster", 56 | "contrail": { 57 | "control_data_interface": "eth1" 58 | }, 59 | "domain": "test.juniper.net", 60 | "gateway": "10.84.51.254", 61 | "host_name": "", 62 | "id": "testserver2", 63 | "ip_address": "10.84.51.13", 64 | "ipmi_address": "10.84.6.63", 65 | "mac_address": "00:25:90:AA:36:32", 66 | "network": { 67 | "interfaces": [ 68 | { 69 | "default_gateway": "10.84.51.254", 70 | "dhcp": true, 71 | "ip_address": "10.84.51.13/24", 72 | "mac_address": "00:25:90:aa:36:32", 73 | "name": "eth1" 74 | } 75 | ], 76 | "management_interface": "eth1", 77 | "provisioning": "kickstart" 78 | }, 79 | "package_image_id": "", 80 | "parameters": { 81 | "interface_name": "eth1" 82 | }, 83 | "password": "c0ntrail123", 84 | "roles": [ 85 | "compute" 86 | ], 87 | "static_ip": "N", 88 | "subnet_mask": "255.255.255.0", 89 | "tag": { 90 | "datacenter": "test-dc", 91 | "floor": "test-floor", 92 | "hall": "test-hall", 93 | "rack": "test-rack", 94 | "user_tag": "test-user2" 95 | } 96 | } 97 | ] 98 | } 99 | -------------------------------------------------------------------------------- /src/server_manager/server_mgr_defaults.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | #validation DS 4 | server_fields = { 5 | "match_keys": "['id', 'mac_address', 'cluster_id', 'ip_address', 'tag', 'where']", 6 | "obj_name": "server", 7 | "primary_keys": "['id', 'mac_address']", 8 | "id": "", 9 | "host_name": "", 10 | "mac_address": "", 11 | "ip_address": "", 12 | "parameters": """{ 13 | 'interface_name': '' 14 | }""", 15 | "roles": [], 16 | "cluster_id": "", 17 | "subnet_mask": "", 18 | "gateway": "", 19 | "network": {}, 20 | "contrail": {}, 21 | "top_of_rack" : {}, 22 | "password": "", 23 | "domain": "", 24 | "email": "", 25 | "ipmi_username": "", 26 | "ipmi_type": "", 27 | "ipmi_password": "", 28 | "ipmi_address": "", 29 | "ipmi_interface": "", 30 | "tag": None, 31 | "base_image_id": "", 32 | "ssh_public_key": "", 33 | "ssh_private_key" : "", 34 | "package_image_id": "" 35 | } 36 | 37 | cluster_fields = { 38 | "match_keys": "['id', 'where']", 39 | "obj_name": "cluster", 40 | "id": "", 41 | "email": "", 42 | "primary_keys": "['id']", 43 | "base_image_id": "", 44 | "package_image_id": "", 45 | "parameters": """{ 46 | }""" 47 | } 48 | 49 | image_fields = { 50 | "match_keys": "['id', 'where']", 51 | "obj_name": "image", 52 | "primary_keys": "['id']", 53 | "id": "", 54 | "category": "", 55 | "type": "", 56 | "version": "", 57 | "path": "", 58 | "parameters": """{ 59 | "kickstart": "", 60 | "kickseed":"" 61 | }""" 62 | } 63 | 64 | fru_fields = { 65 | "id": "", 66 | "fru_description": "", 67 | "board_serial_number": "", 68 | "chassis_type": "", 69 | "chassis_serial_number": "", 70 | "board_mfg_date": "", 71 | "board_manufacturer": "", 72 | "board_product_name": "", 73 | "board_part_number": "", 74 | "product_manfacturer": "", 75 | "product_name": "", 76 | "product_part_number": "" 77 | } 78 | 79 | dhcp_host_fields = { 80 | "match_keys": "['host_fqdn']", 81 | "primary_keys": "['host_fqdn']", 82 | "obj_name": "dhcp_host", 83 | "host_fqdn": "", 84 | "mac_address": "", 85 | "ip_address": "", 86 | "host_name": "", 87 | "parameters": """{ 88 | }""" 89 | } 90 | 91 | dhcp_subnet_fields = { 92 | "match_keys": "['subnet_address']", 93 | "primary_keys": "['subnet_address']", 94 | "obj_name": "dhcp_subnet", 95 | "subnet_address": "", 96 | "subnet_mask": "", 97 | "subnet_gateway": "", 98 | "subnet_domain": "", 99 | "search_domains_list": [], 100 | "dns_server_list": [], 101 | "parameters": """{ 102 | }""", 103 | "default_lease_time": 21600, 104 | "max_lease_time": 43200 105 | } 106 | 107 | default_kernel_trusty = "3.13.0-106" 108 | default_kernel_xenial = "4.4.0-38" 109 | 110 | email_events = ["reimage_started", "reimage_completed", "provision_completed"] 111 | server_blocked_fields = ["ssh_private_key"] 112 | default_global_ansible_config = { 113 | "ssl_certs_src_dir": "/etc/contrail_smgr/puppet/ssl", 114 | "tor_ca_cert_file": "/etc/contrail_smgr/puppet/ssl/ca-cert.pem", 115 | "tor_ssl_certs_src_dir": "/etc/contrail_smgr/puppet/ssl/tor", 116 | "docker_install_method": "package", 117 | "docker_package_name": "docker-engine", 118 | "contrail_compute_mode": "bare_metal", 119 | "docker_registry_insecure": True, 120 | "docker_network_bridge": False, 121 | "enable_lbaas": True 122 | } 123 | -------------------------------------------------------------------------------- /src/server_manager/ansible/README.md: -------------------------------------------------------------------------------- 1 | Provisioning Contrail Docker Containers 2 | ======================================= 3 | 4 | ### 1. Introduction 5 | 6 | This document describes the changes that are needed in the Server Manager module in order to support the provisioning of Contrail services that will be distributed as docker containers in version 4.0. It also serves as a user-guide that describes the procedure to provision a node with a particular contrail role running the appropriate service in a docker container. 7 | 8 | ### 2. Problem Statement 9 | 10 | ### 3. Proposed Solution 11 | 12 | ## 3.1 Alternatives Considered 13 | 14 | ## 3.2 API schema Changes 15 | 16 | ## 3.3 User Workflow Impact 17 | 18 | ## 3.4 UI Changes 19 | 20 | ## 3.5 Operations and Notification Impact 21 | 22 | ### 4. Implementation 23 | 24 | ## 4.1 Assignee(s) 25 | 26 | ## 4.2 Work Items 27 | 28 | ### Modifications needed to the existing server-manager code to support 29 | ### provisioning of contrail containers: 30 | 1. Ansible playbook scripts needed to provision the relevant containers are 31 | added in the contrail-server-manager/src/ansible/playbooks directory 32 | 2. The existing workflow of using server-manager to provision a node is not 33 | disturbed in any way: 34 | * server-manager add image 35 | * server-manager add server 36 | * server-manager provision 37 | 38 | The difference here is that during the "add image", if the "category" of the 39 | image is "container", then the image gets pushed into the docker registry 40 | (configured in the global server-manager configuration) in the following 41 | format : 42 | 43 | `--` 44 | 45 | | | |--- e.g: liberty:3.1.1.0-29 46 | | | 47 | | |--- e.g: controller, analytics, agent - based on 48 | | roles 49 | |--- e.g: contrail-container 50 | 3. During the "add server", all configuration parameters needed by the 51 | container that will be launched on that server needs to be provided as part 52 | of the json configuration file 53 | 4. Running the playbooks via python is not compatible with the existing 54 | server-manager because of the use of gevent library in the existing server- 55 | manager codebase (Refer [Gevent docs] (http://www.gevent.org/whatsnew_1_2.html#compatibility)) for details. 56 | This is because ansible code uses multiprocessing.Queue module and this 57 | module is incompatibe with gevent greenlets. To work around this limitation 58 | and also to keep the ansible playbook module modular, it has been decided 59 | to run the module as a separate server that exposes the following REST APIs: 60 | * server\_ip:9003/run\_playbook 61 | * server\_ip:9003/playbook\_status 62 | 5. These REST APIs are used by the server-manager during the provision phase to 63 | run the relevant playbook and to get the status for a previous playbook run 64 | 6. The playbook does the following tasks: 65 | * create a single configuration file on the server being provisioned in 66 | the /etc/contrail/.conf 67 | a sample config file can be found [here] 68 | (https://github.com/Juniper/contrail-docker/blob/master/tools/python-contrailctl/examples/configs/controller.conf) 69 | * create mount points for logs, persistent databases if required for the 70 | containers 71 | * launch the containers 72 | 7. The logs for the actual playbook run can be found in the existing 73 | /var/log/contrail-server-manager/debug.log file 74 | 75 | 76 | ### 5. Performance and Scaling Impact 77 | 78 | ## 5.1 API and Control Plane 79 | 80 | ## 5.2 Forwarding Performance 81 | 82 | ### 6. Upgrade 83 | 84 | ### 7. Deprecations 85 | 86 | ### 8. Dependencies 87 | 88 | ### 9. Testing 89 | -------------------------------------------------------------------------------- /src/unit_tests/monitoring/verify_result.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | #Function to test the output of the expected Quanta output for ipmi sensor 4 | def checkQuantaData(self,output): 5 | self.assertEqual(output[0].sensor, 'MB1_Temp') 6 | self.assertEqual(output[0].sensor_type, 'temperature') 7 | self.assertEqual(output[0].reading, 28) 8 | self.assertEqual(output[0].unit, 'C') 9 | self.assertEqual(output[0].status, 'ok') 10 | self.assertEqual(output[1].sensor, 'PDB_FAN1A') 11 | self.assertEqual(output[1].sensor_type, 'fan') 12 | self.assertEqual(output[1].reading, 4700) 13 | self.assertEqual(output[1].unit, 'RPM') 14 | self.assertEqual(output[1].status, 'ok') 15 | self.assertEqual(output[2].sensor, 'PSU_Input_Power') 16 | self.assertEqual(output[2].sensor_type, 'power') 17 | self.assertEqual(output[2].reading, 0) 18 | self.assertEqual(output[2].unit, 'Watts') 19 | self.assertEqual(output[2].status, 'ok') 20 | 21 | #Function to test the output of the expected SuperMicro output for ipmi sensor 22 | def checkSuperMicroData(self, output): 23 | self.assertEqual(output[0].sensor, 'System Temp') 24 | self.assertEqual(output[0].sensor_type, 'temperature') 25 | self.assertEqual(output[0].reading, 28) 26 | self.assertEqual(output[0].unit, 'C') 27 | self.assertEqual(output[0].status, 'ok') 28 | self.assertEqual(output[1].sensor, 'CPU Temp') 29 | self.assertEqual(output[1].sensor_type, 'temperature') 30 | self.assertEqual(output[1].reading, 0) 31 | self.assertEqual(output[1].unit, 'unspecified') 32 | self.assertEqual(output[1].status, 'ok') 33 | self.assertEqual(output[2].sensor, 'FAN 1') 34 | self.assertEqual(output[2].sensor_type, 'fan') 35 | self.assertEqual(output[2].reading, 3825) 36 | self.assertEqual(output[2].unit, 'RPM') 37 | self.assertEqual(output[2].status, 'ok') 38 | 39 | #Function to test the output of the expected chassis output 40 | def checkChassisData(self,output): 41 | self.assertEqual(output.system_power, 'on') 42 | self.assertFalse(output.power_overload) 43 | self.assertEqual(output.power_interlock, 'inactive') 44 | self.assertFalse(output.main_power_fault) 45 | self.assertFalse(output.power_control_fault) 46 | self.assertEqual(output.power_restore_policy, 'always-off') 47 | self.assertEqual(output.last_power_event, 'command') 48 | self.assertEqual(output.chassis_intrusion, 'inactive') 49 | self.assertEqual(output.front_panel_lockout, 'inactive') 50 | self.assertFalse(output.drive_fault) 51 | self.assertFalse(output.cooling_fan_fault) 52 | 53 | #Function to test the output of the expected Disk Info data 54 | def checkDiskTotInfoData(self, output, package_installed): 55 | if package_installed == False: 56 | self.assertEqual(output[0].total_read_bytes, 0) 57 | self.assertEqual(output[0].disk_name, None) 58 | self.assertEqual(output[0].total_write_bytes, 0) 59 | else: 60 | self.assertEqual(output[0].total_read_bytes, 3165) 61 | self.assertEqual(output[0].disk_name, 'sda') 62 | self.assertEqual(output[0].total_write_bytes, 10788) 63 | self.assertEqual(output[1].total_read_bytes, 1025) 64 | self.assertEqual(output[1].disk_name, 'dm-0') 65 | self.assertEqual(output[1].total_write_bytes, 58147) 66 | 67 | #Function to the Disk data for the diff's 68 | def checkDiskInfoData(self, output, package_installed): 69 | if package_installed == False: 70 | self.assertEqual(output[0].read_bytes, 0) 71 | self.assertEqual(output[0].disk_name, 'N/A') 72 | self.assertEqual(output[0].write_bytes, 0) 73 | else: 74 | self.assertEqual(output[0].read_bytes, 0) 75 | self.assertEqual(output[0].disk_name, 'sda') 76 | self.assertEqual(output[0].write_bytes, 0) 77 | self.assertEqual(output[1].read_bytes, 0) 78 | self.assertEqual(output[1].disk_name, 'dm-0') 79 | self.assertEqual(output[1].write_bytes, 0) 80 | -------------------------------------------------------------------------------- /src/scons/monitoring/ipmi/monitoring.sandesh: -------------------------------------------------------------------------------- 1 | struct IpmiSensor { 2 | 1: string sensor 3 | 2: string status 4 | 3: u64 reading 5 | 4: string unit 6 | 5: string sensor_type 7 | } 8 | 9 | struct IpmiChassis_status_info { 10 | 1: string system_power 11 | 2: bool power_overload 12 | 3: string power_interlock 13 | 4: bool main_power_fault 14 | 5: bool power_control_fault 15 | 6: string power_restore_policy 16 | 7: string last_power_event 17 | 8: string chassis_intrusion 18 | 9: string front_panel_lockout 19 | 10: bool drive_fault 20 | 11: bool cooling_fan_fault 21 | } 22 | 23 | struct Disk { 24 | 1: string disk_name 25 | 2: optional u64 read_bytes 26 | 3: optional u64 write_bytes 27 | } 28 | 29 | struct Disk_totals { 30 | 1: string disk_name 31 | 2: optional u64 total_read_bytes 32 | 3: optional u64 total_write_bytes 33 | } 34 | 35 | struct network_info { 36 | 1: optional u64 tx_bytes 37 | 2: optional u64 tx_packets 38 | 3: optional u64 rx_bytes 39 | 4: optional u64 rx_packets 40 | 5: optional string interface_name 41 | } 42 | 43 | struct network_info_totals { 44 | 1: optional u64 total_tx_bytes 45 | 2: optional u64 total_tx_packets 46 | 3: optional u64 total_rx_bytes 47 | 4: optional u64 total_rx_packets 48 | 5: optional string interface_name 49 | } 50 | 51 | struct resource_info { 52 | 1: optional double cpu_usage_percentage 53 | 2: optional double mem_usage_mb 54 | 3: optional double mem_usage_percent 55 | } 56 | 57 | struct physical_disk_view { 58 | 1: string disk_name 59 | 2: optional u64 disk_size_kb 60 | 3: optional u64 disk_used_kb 61 | 4: optional u64 disk_available_kb 62 | 5: optional u32 disk_used_percentage 63 | } 64 | 65 | struct file_system_view { 66 | 1: string fs_name 67 | 2: optional u64 size_kb 68 | 3: optional u64 used_kb 69 | 4: optional u64 available_kb 70 | 5: optional u32 used_percentage 71 | 6: optional string mountpoint 72 | 7: optional string type 73 | /** @display_name:Server Monitoring File System Stats Info*/ 74 | 8: optional list physical_disks (tags=".disk_name,.disk_used_percentage") 75 | } 76 | 77 | struct ServerMonitoringInfo { 78 | 1: string name (key="ObjectServerTable") 79 | 2: optional bool deleted 80 | /** @display_name:Server Monitoring Sensor Stats Info*/ 81 | 3: optional list sensor_stats (tags=".sensor,.sensor_type") 82 | 4: optional IpmiChassis_status_info chassis_state 83 | /** @display_name:Server Monitoring Disk Stats Info*/ 84 | 5: optional list disk_usage_stats (tags=".disk_name") 85 | 6: optional list disk_usage_totals 86 | 7: optional list network_info_totals 87 | /** @display_name:Server Monitoring File System View Stats Info*/ 88 | 8: optional list file_system_view_stats (tags="name:.fs_name,.used_percentage") 89 | } 90 | 91 | uve sandesh ServerMonitoringInfoUve { 92 | 1: ServerMonitoringInfo data 93 | } 94 | 95 | struct ServerMonitoringSummary { 96 | 1: string name (key="ObjectServerTable") 97 | 2: optional bool deleted 98 | /** @display_name:Server Monitoring Resource Stats Info*/ 99 | 3: optional resource_info resource_info_stats (tags="") 100 | /** @display_name:Server Monitoring Interface Stats Info*/ 101 | 4: optional list network_info_stats (tags=".interface_name") 102 | } 103 | 104 | uve sandesh ServerMonitoringSummaryUve { 105 | 1: ServerMonitoringSummary data 106 | } 107 | 108 | objectlog sandesh IpmiSystemEventLog { 109 | 1: string name (key="ObjectServerTable") 110 | 2: u64 event_id 111 | 3: string ipmi_timestamp 112 | 4: string sensor_name 113 | 5: string sensor_type 114 | 6: string ipmi_message 115 | } 116 | -------------------------------------------------------------------------------- /docker/contrail-sm/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | 3 | MAINTAINER Nitish Krishna nitishk@juniper.net 4 | 5 | COPY docker/contrail-sm/entrypoint.sh / 6 | 7 | # Setup systemd 8 | 9 | RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \ 10 | systemd-tmpfiles-setup.service ] || rm -f $i; done); \ 11 | rm -f /lib/systemd/system/multi-user.target.wants/*;\ 12 | rm -f /etc/systemd/system/*.wants/*;\ 13 | rm -f /lib/systemd/system/local-fs.target.wants/*; \ 14 | rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ 15 | rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ 16 | rm -f /lib/systemd/system/basic.target.wants/*;\ 17 | rm -f /lib/systemd/system/anaconda.target.wants/*; 18 | 19 | # Create required folders 20 | RUN mkdir -p /opt/contrail/server_manager \ 21 | /etc/contrail_smgr/ \ 22 | /var/log/contrail-server-manager/ \ 23 | /var/log/contrail-server-manager/provision/ \ 24 | /var/www/html/contrail/ \ 25 | /var/www/html/contrail/images/ \ 26 | /var/www/html/kickstarts/ \ 27 | /var/www/html/contrail/config_file/ \ 28 | /var/www/html/thirdparty_packages/pip_repo \ 29 | /etc/mail/ 30 | 31 | # Copy SM Code 32 | COPY src/server_manager/ /opt/contrail/server_manager/ 33 | COPY src/contrail_smgr/cobbler/*template* /etc/contrail_smgr/cobbler/ 34 | COPY src/contrail_smgr/cobbler/*conf* /etc/contrail_smgr/cobbler/ 35 | COPY src/smgr_cliff_client/ /var/tmp/build/smgr_cliff_client/ 36 | COPY src/smgr_cliff_client/servermanagerclient /etc/contrail/servermanagerclient 37 | COPY src/smgr_cliff_client/smgrcliapp/sm-client-config.ini /etc/contrail/sm-client-config.ini 38 | #COPY src/smgr_cliff_client/server-manager-client /opt/contrail/bin/server-manager-client 39 | #COPY src/smgr_cliff_client/servermanagercli/* /usr/local/lib/python2.7/dist-packages/servermanagercli/ 40 | 41 | #RUN yum -y install epel-release 42 | RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 43 | RUN yum -y install centos-release-openstack-ocata 44 | 45 | RUN yum install -y initscripts\ 46 | net-tools \ 47 | python2-pip \ 48 | python2-gevent \ 49 | dhcp \ 50 | httpd \ 51 | httpd-devel \ 52 | mod_ssl\ 53 | fence-agents \ 54 | python-devel \ 55 | ntp \ 56 | autoconf \ 57 | gcc \ 58 | bind \ 59 | tftp \ 60 | wget \ 61 | sendmail \ 62 | syslinux \ 63 | gcc-c++ \ 64 | libcurl-devel \ 65 | openssl-devel \ 66 | zlib-devel \ 67 | ipmitool \ 68 | createrepo \ 69 | mod_wsgi \ 70 | tftp-server \ 71 | python2-django \ 72 | python-simplejson \ 73 | python2-requests \ 74 | reprepro \ 75 | python-netaddr \ 76 | python-yaml \ 77 | python-paramiko \ 78 | python2-xmltodict \ 79 | python2-crypto \ 80 | python-paste \ 81 | ansible \ 82 | python2-oslo-config \ 83 | python2-urllib3 \ 84 | python-ipaddress \ 85 | python-websocket-client \ 86 | ceph-common \ 87 | python-cliff \ 88 | python-configparser \ 89 | file \ 90 | && pip install --upgrade pip 91 | 92 | RUN pip install setuptools configparser 93 | 94 | RUN cd /var/tmp/build/smgr_cliff_client/ && /usr/bin/python setup.py sdist 95 | RUN cd /var/tmp/build/smgr_cliff_client/dist/ && tar zxf servermanagercli-*.tar.gz 96 | RUN cd /var/tmp/build/smgr_cliff_client/dist/servermanagercli-* && /usr/bin/python setup.py install --root=/ --install-scripts /opt/contrail/bin/ 97 | 98 | # Mount common volumes 99 | VOLUME ["/sys/fs/cgroup"] 100 | 101 | EXPOSE 9001 102 | EXPOSE 9002 103 | WORKDIR /opt/contrail/server_manager/ 104 | ENTRYPOINT ["/entrypoint.sh"] 105 | #CMD ["/usr/sbin/init"] 106 | CMD ["python", "/opt/contrail/server_manager/server_mgr_main.py", "-c", "/opt/contrail/server_manager/sm-config.ini"] 107 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/bootup_dhcp.template.u: -------------------------------------------------------------------------------- 1 | # ****************************************************************** 2 | # Cobbler managed dhcpd.conf file 3 | # 4 | # generated from cobbler dhcp.conf template ($date) 5 | # Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes 6 | # in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be 7 | # overwritten. 8 | # 9 | # ****************************************************************** 10 | 11 | ddns-update-style interim; 12 | 13 | allow booting; 14 | allow bootp; 15 | 16 | ignore client-updates; 17 | set vendorclass = option vendor-class-identifier; 18 | 19 | subnet __$SUBNETADDRESS__ netmask __$SUBNETMASK__ { 20 | option routers __$SUBNETGATEWAY__; 21 | option subnet-mask __$SUBNETMASK__; 22 | option domain-name-servers __$IPADDRESS__; 23 | option domain-search "__$DOMAIN__"; 24 | option domain-name "__$DOMAIN__"; 25 | option ntp-servers $next_server; 26 | default-lease-time 21600; 27 | max-lease-time 43200; 28 | next-server $next_server; 29 | filename "/pxelinux.0"; 30 | on commit { 31 | set clip = binary-to-ascii(10, 8, ".", leased-address); 32 | set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6)); 33 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "commit", clip, clhw); 34 | set ClientHost = pick-first-value(host-decl-name, 35 | option fqdn.hostname, 36 | option host-name, 37 | "none"); 38 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "commit", clip, clhw, ClientHost); 39 | } 40 | on release { 41 | set clip = binary-to-ascii(10, 8, ".", leased-address); 42 | set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6)); 43 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "release", clip, clhw); 44 | set ClientHost = pick-first-value(host-decl-name, 45 | option fqdn.hostname, 46 | option host-name, 47 | "none"); 48 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "release", clip, clhw, ClientHost); 49 | } 50 | on expiry { 51 | set clip = binary-to-ascii(10, 8, ".", leased-address); 52 | set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6)); 53 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "expiry", clip, clhw); 54 | set ClientHost = pick-first-value(host-decl-name, 55 | option fqdn.hostname, 56 | option host-name, 57 | "none"); 58 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "expiry", clip, clhw, ClientHost); 59 | } 60 | } 61 | 62 | #for dhcp_tag in $dhcp_tags.keys(): 63 | ## group could be subnet if your dhcp tags line up with your subnets 64 | ## or really any valid dhcpd.conf construct ... if you only use the 65 | ## default dhcp tag in cobbler, the group block can be deleted for a 66 | ## flat configuration 67 | # group for Cobbler DHCP tag: $dhcp_tag 68 | group { 69 | #for mac in $dhcp_tags[$dhcp_tag].keys(): 70 | #set iface = $dhcp_tags[$dhcp_tag][$mac] 71 | host $iface.name { 72 | hardware ethernet $mac; 73 | #if $iface.ip_address: 74 | fixed-address $iface.ip_address; 75 | #end if 76 | #if $iface.hostname: 77 | option host-name "$iface.hostname"; 78 | #end if 79 | #if $iface.netmask: 80 | option subnet-mask $iface.netmask; 81 | #end if 82 | #if $iface.gateway: 83 | option routers $iface.gateway; 84 | #end if 85 | filename "$iface.filename"; 86 | ## Cobbler defaults to $next_server, but some users 87 | ## may like to use $iface.system.server for proxied setups 88 | next-server $next_server; 89 | ## next-server $iface.next_server; 90 | } 91 | #end for 92 | } 93 | #end for 94 | 95 | -------------------------------------------------------------------------------- /src/contrail_smgr/cobbler/dhcp.template.u.sample: -------------------------------------------------------------------------------- 1 | # ****************************************************************** 2 | # Cobbler managed dhcpd.conf file 3 | # 4 | # generated from cobbler dhcp.conf template ($date) 5 | # Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes 6 | # in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be 7 | # overwritten. 8 | # 9 | # ****************************************************************** 10 | 11 | ddns-update-style interim; 12 | 13 | allow booting; 14 | allow bootp; 15 | 16 | ignore client-updates; 17 | set vendorclass = option vendor-class-identifier; 18 | 19 | subnet 10.204.217.0 netmask 255.255.255.0 { 20 | option routers 10.204.217.254; 21 | option subnet-mask 255.255.255.0; 22 | option domain-name-servers $next_server, 8.8.8.8; 23 | option domain-search "englab.juniper.net", "juniper.net"; 24 | option domain-name "englab.juniper.net" ; 25 | option ntp-servers $next_server ; 26 | default-lease-time 21600; 27 | max-lease-time 43200; 28 | next-server $next_server; 29 | filename "/pxelinux.0"; 30 | 31 | on commit { 32 | set clip = binary-to-ascii(10, 8, ".", leased-address); 33 | set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6)); 34 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "commit", clip, clhw); 35 | set ClientHost = pick-first-value(host-decl-name, 36 | option fqdn.hostname, 37 | option host-name, 38 | "none"); 39 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "commit", clip, clhw, ClientHost); 40 | } 41 | 42 | on release { 43 | set clip = binary-to-ascii(10, 8, ".", leased-address); 44 | set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6)); 45 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "release", clip, clhw); 46 | set ClientHost = pick-first-value(host-decl-name, 47 | option fqdn.hostname, 48 | option host-name, 49 | "none"); 50 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "release", clip, clhw, ClientHost); 51 | } 52 | 53 | on expiry { 54 | set clip = binary-to-ascii(10, 8, ".", leased-address); 55 | set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6)); 56 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "expiry", clip, clhw); 57 | set ClientHost = pick-first-value(host-decl-name, 58 | option fqdn.hostname, 59 | option host-name, 60 | "none"); 61 | execute("/opt/contrail/server_manager/smgr_dhcp_event.py", "expiry", clip, clhw, ClientHost); 62 | } 63 | } 64 | 65 | #for dhcp_tag in $dhcp_tags.keys(): 66 | ## group could be subnet if your dhcp tags line up with your subnets 67 | ## or really any valid dhcpd.conf construct ... if you only use the 68 | ## default dhcp tag in cobbler, the group block can be deleted for a 69 | ## flat configuration 70 | # group for Cobbler DHCP tag: $dhcp_tag 71 | group { 72 | #for mac in $dhcp_tags[$dhcp_tag].keys(): 73 | #set iface = $dhcp_tags[$dhcp_tag][$mac] 74 | host $iface.name { 75 | hardware ethernet $mac; 76 | #if $iface.ip_address: 77 | fixed-address $iface.ip_address; 78 | #end if 79 | #if $iface.hostname: 80 | option host-name "$iface.hostname"; 81 | #end if 82 | #if $iface.netmask: 83 | option subnet-mask $iface.netmask; 84 | #end if 85 | #if $iface.gateway: 86 | option routers $iface.gateway; 87 | #end if 88 | filename "$iface.filename"; 89 | ## Cobbler defaults to $next_server, but some users 90 | ## may like to use $iface.system.server for proxied setups 91 | next-server $next_server; 92 | ## next-server $iface.next_server; 93 | } 94 | #end for 95 | } 96 | #end for 97 | 98 | --------------------------------------------------------------------------------