another merge with master branch
diff --git a/.gitignore b/.gitignore
index a0d550c..3c86d00 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,9 @@
setup/*
setup/id_rsa/*
xos/configurations/frontend/Dockerfile
+xos/configurations/mcord/admin-openrc.sh
+xos/configurations/setup/*
+xos/configurations/common/*
xos/core/xoslib/karma-*
xos/core/xoslib/docs
xos/core/xoslib/coverage
diff --git a/containers/Makefile b/containers/Makefile
index a6aa744..92685e7 100644
--- a/containers/Makefile
+++ b/containers/Makefile
@@ -5,7 +5,6 @@
sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /root/setup/setup.yaml
sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /root/setup/nodes.yaml
sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /root/setup/images.yaml
- sudo docker exec containers_xos_1 cp /opt/xos/configurations/frontend/mocks/xos_mcord_config /opt/xos/xos_configuration/
nodes.yaml:
export SETUPDIR=.; bash ../xos/configurations/common/make-nodes-yaml.sh
@@ -15,29 +14,5 @@
.PHONY: local_containers
local_containers:
- cd xos; make devel
- cd synchronizer; make
-enter-xos:
- sudo docker exec -it containers_xos_1 bash
-
-enter-os:
- sudo docker exec -it containers_xos_synchronizer_openstack_1 bash
-
-enter-mc:
- sudo docker exec -it containers_xos_synchronizer_mcordservice1 bash
-
-upgrade_pkgs:
- sudo pip install httpie --upgrade
-
-rebuild_xos:
- make -C xos devel
-
-rebuild_synchronizer:
- make -C synchronizer
-
-stop:
- docker-compose stop
-
-rm:
- docker-compose stop; docker-compose rm
-
+ cd containers/xos; make devel
+ cd containers/synchronizer; make
diff --git a/containers/admin-openrc.sh b/containers/admin-openrc.sh
index 24cd509..f27fdac 100644
--- a/containers/admin-openrc.sh
+++ b/containers/admin-openrc.sh
@@ -1,8 +1,6 @@
# Replace with the OpenStack admin credentials for your cluster
-export OS_PROJECT_DOMAIN_ID=default
-export OS_USER_DOMAIN_ID=default
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
-export OS_PASSWORD=mcord
-export OS_AUTH_URL=http://10.102.81.3:35357/v2.0
+export OS_PASSWORD=admin
+export OS_AUTH_URL=http://localhost:35357/v2.0
diff --git a/containers/docker-compose.yml b/containers/docker-compose.yml
index 15d28a6..24596a3 100644
--- a/containers/docker-compose.yml
+++ b/containers/docker-compose.yml
@@ -14,18 +14,6 @@
volumes:
- .:/root/setup:ro
-xos_synchronizer_mcordservice:
- image: xosproject/xos-synchronizer-openstack
- command: bash -c "sleep 120; python /opt/xos/synchronizers/mcordservice/mcordservice-synchronizer.py -C /opt/xos/synchronizers/mcordservice/mcordservice_vtnconfig"
- labels:
- org.xosproject.kind: synchronizer
- org.xosproject.target: mcordservice
- links:
- - xos_db
- volumes:
- - ../setup/id_rsa/id_rsa:/opt/xos/synchronizers/mcordservice/mcordservice_private_key:ro # private key
- - ../setup:/root/setup:ro
-
# FUTURE
#xos_swarm_synchronizer:
# image: xosproject/xos-swarm-synchronizer
@@ -42,4 +30,3 @@
- "8000:8000"
volumes:
- .:/root/setup:ro
- - ../setup/id_rsa/id_rsa:/opt/xos/synchronizers/mcordservice/mcordservice_private_key:ro # private key
diff --git a/containers/images.yaml b/containers/images.yaml
deleted file mode 100644
index 90cbbb6..0000000
--- a/containers/images.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0
-
-imports:
- - custom_types/xos.yaml
-
-description: autogenerated nodes file
-
-topology_template:
- node_templates:
- mysite:
- type: tosca.nodes.Site
-
- MyDeployment:
- type: tosca.nodes.Deployment
- properties:
- flavors: m1.large, m1.medium, m1.small
- requirements:
diff --git a/containers/nodes.yaml b/containers/nodes.yaml
deleted file mode 100644
index 1f6ff45..0000000
--- a/containers/nodes.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0
-
-imports:
- - custom_types/xos.yaml
-
-description: autogenerated nodes file
-
-topology_template:
- node_templates:
- MyDeployment:
- type: tosca.nodes.Deployment
- mysite:
- type: tosca.nodes.Site
diff --git a/containers/xos/Dockerfile.devel b/containers/xos/Dockerfile.devel
index 1e2532f..5dc62a6 100644
--- a/containers/xos/Dockerfile.devel
+++ b/containers/xos/Dockerfile.devel
@@ -91,6 +91,5 @@
# Define working directory.
WORKDIR /opt/xos
-# RUN python /opt/xos/manage.py makemigrations mcordservice
# Define default command.
CMD update-ca-certificates && python /opt/xos/manage.py runserver 0.0.0.0:8000 --insecure --makemigrations
diff --git a/xos/configurations/common/mydeployment.yaml b/xos/configurations/common/mydeployment.yaml
index 6d64da6..66bb75d 100644
--- a/xos/configurations/common/mydeployment.yaml
+++ b/xos/configurations/common/mydeployment.yaml
@@ -16,15 +16,9 @@
m1.small:
type: tosca.nodes.Flavor
- m1.xlarge:
- type: tosca.nodes.Flavor
-
MyDeployment:
type: tosca.nodes.Deployment
requirements:
- - m1.xlarge:
- node: m1.xlarge
- relationship: tosca.relationships.SupportsFlavor
- m1.large:
node: m1.large
relationship: tosca.relationships.SupportsFlavor
diff --git a/xos/configurations/common/xos_common_config b/xos/configurations/common/xos_common_config
old mode 100755
new mode 100644
index f7f5784..76ba747
--- a/xos/configurations/common/xos_common_config
+++ b/xos/configurations/common/xos_common_config
@@ -6,7 +6,7 @@
name=xos
user=postgres
password=password
-host=66.201.46.26
+host=localhost
port=5432
[api]
@@ -37,9 +37,7 @@
images_directory=/opt/xos/images
dependency_graph=/opt/xos/model-deps
logfile=/var/log/xos_backend.log
-proxy_ssh=True
-proxy_ssh_key=/root/setup/node_key
-proxy_ssh_user=root
+save_ansible_output=True
[gui]
disable_minidashboard=True
@@ -47,7 +45,3 @@
branding_icon=/static/logo.png
branding_favicon=/static/favicon.png
branding_bg=/static/bg.jpg
-
-[networking]
-use_vtn=True
-
diff --git a/xos/configurations/devel/docker-compose.yml b/xos/configurations/devel/docker-compose.yml
index ce4dc19..9ef6fc7 100644
--- a/xos/configurations/devel/docker-compose.yml
+++ b/xos/configurations/devel/docker-compose.yml
@@ -17,33 +17,6 @@
- ../common/xos_common_config:/opt/xos/xos_configuration/xos_common_config:ro
- ./images:/opt/xos/images:ro
-xos_synchronizer_helloworldservice_complete:
- image: xosproject/xos-synchronizer-openstack
- command: bash -c "sleep 120; python /opt/xos/synchronizers/helloworldservice_complete/helloworldservice-synchronizer.py -C /opt/xos/synchronizers/helloworldservice_complete/helloworldservice_config"
- labels:
- org.xosproject.kind: synchronizer
- org.xosproject.target: helloworldservice_complete
- links:
- - xos_db
- extra_hosts:
- - ctl:${MYIP}
- volumes:
- - ../setup/id_rsa:/opt/xos/synchronizers/helloworldservice_complete/helloworldservice_complete_private_key:ro # private key
- - ../setup:/root/setup:ro
-
-xos_synchronizer_mcordservice:
- image: xosproject/xos-synchronizer-openstack
- command: bash -c "sleep 120; python /opt/xos/synchronizers/mcordservice/mcordservice-synchronizer.py -C /opt/xos/synchronizers/mcordservice/mcordservice_config"
- labels:
- org.xosproject.kind: synchronizer
- org.xosproject.target: mcordservice
- links:
- - xos_db
- extra_hosts:
- - ctl:${MYIP}
- volumes:
- - ../setup/id_rsa:/opt/xos/synchronizers/mcordservice/mcordservice_private_key:ro # private key
- - ../setup:/root/setup:ro
# FUTURE
#xos_swarm_synchronizer:
# image: xosproject/xos-swarm-synchronizer
diff --git a/xos/configurations/frontend/Makefile b/xos/configurations/frontend/Makefile
index 8a28faf..ede7608 100644
--- a/xos/configurations/frontend/Makefile
+++ b/xos/configurations/frontend/Makefile
@@ -4,13 +4,9 @@
sudo make -f ../common/Makefile.prereqs
sudo docker-compose up -d
bash ../common/wait_for_xos.sh
- # bash ../mcord/xos/initdb
sudo docker-compose run xos python /opt/xos/tosca/run.py none /opt/xos/configurations/common/fixtures.yaml
sudo docker-compose run xos python /opt/xos/tosca/run.py none /opt/xos/configurations/common/mydeployment.yaml
sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/configurations/frontend/sample.yaml
- # sudo docker-compose run xos python manage.py makemigrations mcordservice
- # sudo docker-compose run xos python manage.py syncdb
- # sudo docker-compose run xos python /opt/xos/tosca/run.py padmin@vicci.org /opt/xos/tosca/MCORDServiceN.yaml
containers:
cd ../../../containers/xos; make devel
diff --git a/xos/configurations/mcord/admin-openrc.sh b/xos/configurations/mcord/admin-openrc.sh
deleted file mode 100644
index 24cd509..0000000
--- a/xos/configurations/mcord/admin-openrc.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-# Replace with the OpenStack admin credentials for your cluster
-export OS_PROJECT_DOMAIN_ID=default
-export OS_USER_DOMAIN_ID=default
-export OS_TENANT_NAME=admin
-export OS_USERNAME=admin
-export OS_PASSWORD=mcord
-export OS_AUTH_URL=http://10.102.81.3:35357/v2.0
-
diff --git a/xos/configurations/setup/admin-openrc.sh b/xos/configurations/setup/admin-openrc.sh
deleted file mode 100644
index 24cd509..0000000
--- a/xos/configurations/setup/admin-openrc.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-# Replace with the OpenStack admin credentials for your cluster
-export OS_PROJECT_DOMAIN_ID=default
-export OS_USER_DOMAIN_ID=default
-export OS_TENANT_NAME=admin
-export OS_USERNAME=admin
-export OS_PASSWORD=mcord
-export OS_AUTH_URL=http://10.102.81.3:35357/v2.0
-
diff --git a/xos/configurations/setup/ceilometer_url b/xos/configurations/setup/ceilometer_url
deleted file mode 100644
index 9b52a64..0000000
--- a/xos/configurations/setup/ceilometer_url
+++ /dev/null
@@ -1 +0,0 @@
-http://127.0.0.1/xosmetering/
diff --git a/xos/configurations/setup/controller_settings b/xos/configurations/setup/controller_settings
deleted file mode 100644
index e69de29..0000000
--- a/xos/configurations/setup/controller_settings
+++ /dev/null
diff --git a/xos/configurations/setup/flat_net_name b/xos/configurations/setup/flat_net_name
deleted file mode 100644
index c8c6761..0000000
--- a/xos/configurations/setup/flat_net_name
+++ /dev/null
@@ -1 +0,0 @@
-private
\ No newline at end of file
diff --git a/xos/configurations/setup/id_rsa b/xos/configurations/setup/id_rsa
deleted file mode 100644
index c688622..0000000
--- a/xos/configurations/setup/id_rsa
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEpQIBAAKCAQEAwiKN1fSQ8DiFJmTWAWq1FhFfgOv05VGkkBUqnFYG2MUP3FEs
-ByAcByhY+NM2a/x0bfZy0vfvf+YC5hz4/kXkpOX8q8MQPJsa2ADnUYqNI6cNuCzD
-I0XSJbRdA1QubGBuVe0p/iZ4MnCEGQMJ+2VWhNBD+f2ndQWuDM1JDYoiz3cO61E9
-iVqlpjeMEPE3Vgz+nXtq/13h+v/j8HUtYQzO5YWg2kgh47GK8zA/F910izkFldff
-W92uBNQIgIKc3q8AqY7KMVaT3kP+CtFgbb7CNmRdNvLzkC2j6yx+KOZS20nM4A3W
-6mNm2OFgrRgXX1lFz84SiVyyP4N1aTo1+6X6BwIDAQABAoIBAQCg4lH5Bf03lx+B
-ef+AnRYFe9BR3znM8aQXY/M0LHbwHh/OzdZW8V1I8T8Ktr9bLpSurJbsD10D+XJd
-kZUn5HRf09lZ3wYNs9zDNbx97vyYl1DfWPk+uhY1+Qs8Pv9aAXBu9WTforHp2yUe
-NU6IcKsK1i3/dx7X9CURpu7rsZa3ptlLt+PlQe/XG8xmtgZ5D25wWy9iJqTEe7QP
-iWYI6+14Jsz7QIvVNn77fJAjBobNzmFVuquJzvMBAXqAPdMVSqkPwAU8HmPpCE7P
-AqaFxv2gMY0iJqa9VVB3Y0MUDJQ+XngcejLJl1tDDRAT66/O3rBReXL6NqOsE8dG
-QSv6mDxBAoGBAOrtDPDhkO/TYmhWEeOpbDh2C7/d2P2GHZ6IMqn80bIc+iLqqFxq
-9Nk0tFjJUfvZGzq5PKB+9Y3IQUwfsHb0Jn+4140iNcFdN/2J231Ggh0GapLbf7F0
-Eg/LOl56qlM+Eq8GnTdXe3Kifd0fXPVRsrQEeFElG6CZqbpZN8MFLYlFAoGBANOM
-wow+oWBVn+q9w7M7GVQ9L6Q0iIR5jrUe96LxNksbe4Rpghl1Qciy7bkibsRa/IAR
-Ol4aDrde53MHJkv8kXxnamdZGCY3/IrbmpHtl86rjIZtdPNumAaL7JGs4OT6dFyU
-6duzSYUAAx4J9hdBu4n86anE5G4iBpZmlc031hzbAoGAOfL7bDfX7rCv55jDlOrn
-3Q2RXGS27+KzT7W8+Z15hHwNX6uOmC1x9FpB2lzeskcdpmCnCdgHbk/le4edmdoj
-3QGVeiTkKax68TmeQMqxscMxasRmPTmqcubooQGVHi+DoFT7VvlnZCGc9nyUC5d5
-g1pO64VByV3eNi9nx91xHBkCgYEA0XH6J4nWkh8UDf/FIs0vPaS6Z1OPmcET1iSL
-vqocO+5Asw8WvIfIEqF8FSCPFB6VAWKNLB+WVFxEwDDi7LZpgAaPZTTjYOtrQDs9
-5J6b/wT/QxRZhq4HG+wq0uubWXjR/dt9UYRHFMO3UmVAXTQ6LdrVqLyEALn1VbDJ
-PX27oaMCgYEAkG9qrZgIan9T39E3Be5Tt8Myvy25vVESAb8ctODzmzyGtAsgr26r
-cO0U7f/naEGLkZVGpalqorVvGiZDYOPAoLTMm+/KI47GLz0T0eLjq5xOpWsixNrK
-F4CgrA0JozqQ9dILok88rScmzj4g5aUymfcm0HMTwgg2jh/a06OWL0w=
------END RSA PRIVATE KEY-----
diff --git a/xos/configurations/setup/id_rsa.pub b/xos/configurations/setup/id_rsa.pub
deleted file mode 100644
index 167f69e..0000000
--- a/xos/configurations/setup/id_rsa.pub
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCIo3V9JDwOIUmZNYBarUWEV+A6/TlUaSQFSqcVgbYxQ/cUSwHIBwHKFj40zZr/HRt9nLS9+9/5gLmHPj+ReSk5fyrwxA8mxrYAOdRio0jpw24LMMjRdIltF0DVC5sYG5V7Sn+JngycIQZAwn7ZVaE0EP5/ad1Ba4MzUkNiiLPdw7rUT2JWqWmN4wQ8TdWDP6de2r/XeH6/+PwdS1hDM7lhaDaSCHjsYrzMD8X3XSLOQWV199b3a4E1AiAgpzerwCpjsoxVpPeQ/4K0WBtvsI2ZF028vOQLaPrLH4o5lLbSczgDdbqY2bY4WCtGBdfWUXPzhKJXLI/g3VpOjX7pfoH root@controller
diff --git a/xos/configurations/setup/node_key b/xos/configurations/setup/node_key
deleted file mode 100644
index c688622..0000000
--- a/xos/configurations/setup/node_key
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEpQIBAAKCAQEAwiKN1fSQ8DiFJmTWAWq1FhFfgOv05VGkkBUqnFYG2MUP3FEs
-ByAcByhY+NM2a/x0bfZy0vfvf+YC5hz4/kXkpOX8q8MQPJsa2ADnUYqNI6cNuCzD
-I0XSJbRdA1QubGBuVe0p/iZ4MnCEGQMJ+2VWhNBD+f2ndQWuDM1JDYoiz3cO61E9
-iVqlpjeMEPE3Vgz+nXtq/13h+v/j8HUtYQzO5YWg2kgh47GK8zA/F910izkFldff
-W92uBNQIgIKc3q8AqY7KMVaT3kP+CtFgbb7CNmRdNvLzkC2j6yx+KOZS20nM4A3W
-6mNm2OFgrRgXX1lFz84SiVyyP4N1aTo1+6X6BwIDAQABAoIBAQCg4lH5Bf03lx+B
-ef+AnRYFe9BR3znM8aQXY/M0LHbwHh/OzdZW8V1I8T8Ktr9bLpSurJbsD10D+XJd
-kZUn5HRf09lZ3wYNs9zDNbx97vyYl1DfWPk+uhY1+Qs8Pv9aAXBu9WTforHp2yUe
-NU6IcKsK1i3/dx7X9CURpu7rsZa3ptlLt+PlQe/XG8xmtgZ5D25wWy9iJqTEe7QP
-iWYI6+14Jsz7QIvVNn77fJAjBobNzmFVuquJzvMBAXqAPdMVSqkPwAU8HmPpCE7P
-AqaFxv2gMY0iJqa9VVB3Y0MUDJQ+XngcejLJl1tDDRAT66/O3rBReXL6NqOsE8dG
-QSv6mDxBAoGBAOrtDPDhkO/TYmhWEeOpbDh2C7/d2P2GHZ6IMqn80bIc+iLqqFxq
-9Nk0tFjJUfvZGzq5PKB+9Y3IQUwfsHb0Jn+4140iNcFdN/2J231Ggh0GapLbf7F0
-Eg/LOl56qlM+Eq8GnTdXe3Kifd0fXPVRsrQEeFElG6CZqbpZN8MFLYlFAoGBANOM
-wow+oWBVn+q9w7M7GVQ9L6Q0iIR5jrUe96LxNksbe4Rpghl1Qciy7bkibsRa/IAR
-Ol4aDrde53MHJkv8kXxnamdZGCY3/IrbmpHtl86rjIZtdPNumAaL7JGs4OT6dFyU
-6duzSYUAAx4J9hdBu4n86anE5G4iBpZmlc031hzbAoGAOfL7bDfX7rCv55jDlOrn
-3Q2RXGS27+KzT7W8+Z15hHwNX6uOmC1x9FpB2lzeskcdpmCnCdgHbk/le4edmdoj
-3QGVeiTkKax68TmeQMqxscMxasRmPTmqcubooQGVHi+DoFT7VvlnZCGc9nyUC5d5
-g1pO64VByV3eNi9nx91xHBkCgYEA0XH6J4nWkh8UDf/FIs0vPaS6Z1OPmcET1iSL
-vqocO+5Asw8WvIfIEqF8FSCPFB6VAWKNLB+WVFxEwDDi7LZpgAaPZTTjYOtrQDs9
-5J6b/wT/QxRZhq4HG+wq0uubWXjR/dt9UYRHFMO3UmVAXTQ6LdrVqLyEALn1VbDJ
-PX27oaMCgYEAkG9qrZgIan9T39E3Be5Tt8Myvy25vVESAb8ctODzmzyGtAsgr26r
-cO0U7f/naEGLkZVGpalqorVvGiZDYOPAoLTMm+/KI47GLz0T0eLjq5xOpWsixNrK
-F4CgrA0JozqQ9dILok88rScmzj4g5aUymfcm0HMTwgg2jh/a06OWL0w=
------END RSA PRIVATE KEY-----
diff --git a/xos/configurations/setup/node_key.pub b/xos/configurations/setup/node_key.pub
deleted file mode 100644
index 167f69e..0000000
--- a/xos/configurations/setup/node_key.pub
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCIo3V9JDwOIUmZNYBarUWEV+A6/TlUaSQFSqcVgbYxQ/cUSwHIBwHKFj40zZr/HRt9nLS9+9/5gLmHPj+ReSk5fyrwxA8mxrYAOdRio0jpw24LMMjRdIltF0DVC5sYG5V7Sn+JngycIQZAwn7ZVaE0EP5/ad1Ba4MzUkNiiLPdw7rUT2JWqWmN4wQ8TdWDP6de2r/XeH6/+PwdS1hDM7lhaDaSCHjsYrzMD8X3XSLOQWV199b3a4E1AiAgpzerwCpjsoxVpPeQ/4K0WBtvsI2ZF028vOQLaPrLH4o5lLbSczgDdbqY2bY4WCtGBdfWUXPzhKJXLI/g3VpOjX7pfoH root@controller
diff --git a/xos/configurations/setup/nodes.yaml b/xos/configurations/setup/nodes.yaml
deleted file mode 100644
index 0b56159..0000000
--- a/xos/configurations/setup/nodes.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-tosca_definitions_version: tosca_simple_yaml_1_0
-
-imports:
- - custom_types/xos.yaml
-
-description: autogenerated nodes file
-
-topology_template:
- node_templates:
- MyDeployment:
- type: tosca.nodes.Deployment
- mysite:
- type: tosca.nodes.Site
- computeBBU2:
- type: tosca.nodes.Node
- requirements:
- - site:
- node: mysite
- relationship: tosca.relationships.MemberOfSite
- - deployment:
- node: MyDeployment
- relationship: tosca.relationships.MemberOfDeployment
diff --git a/xos/configurations/setup/padmin_public_key b/xos/configurations/setup/padmin_public_key
deleted file mode 100644
index 167f69e..0000000
--- a/xos/configurations/setup/padmin_public_key
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCIo3V9JDwOIUmZNYBarUWEV+A6/TlUaSQFSqcVgbYxQ/cUSwHIBwHKFj40zZr/HRt9nLS9+9/5gLmHPj+ReSk5fyrwxA8mxrYAOdRio0jpw24LMMjRdIltF0DVC5sYG5V7Sn+JngycIQZAwn7ZVaE0EP5/ad1Ba4MzUkNiiLPdw7rUT2JWqWmN4wQ8TdWDP6de2r/XeH6/+PwdS1hDM7lhaDaSCHjsYrzMD8X3XSLOQWV199b3a4E1AiAgpzerwCpjsoxVpPeQ/4K0WBtvsI2ZF028vOQLaPrLH4o5lLbSczgDdbqY2bY4WCtGBdfWUXPzhKJXLI/g3VpOjX7pfoH root@controller
diff --git a/xos/core/models/node.py b/xos/core/models/node.py
index 0977b81..f3ea303 100644
--- a/xos/core/models/node.py
+++ b/xos/core/models/node.py
@@ -13,7 +13,6 @@
site_deployment = models.ForeignKey(SiteDeployment, related_name='nodes')
site = models.ForeignKey(Site, null=True, blank=True, related_name='nodes')
tags = generic.GenericRelation(Tag)
-# default = models.BooleanField(default=False, help_text="make this a default node to use when creating new instances")
def __unicode__(self): return u'%s' % (self.name)
diff --git a/xos/core/models/service.py b/xos/core/models/service.py
index cece4a1..5854f4d 100644
--- a/xos/core/models/service.py
+++ b/xos/core/models/service.py
@@ -510,16 +510,12 @@
def pick(self):
from core.models import Node
-# nodes = list(Node.objects.all())
-# nodes = Node.objects.all()
-#MCORD
if not self.slice.default_node:
nodes = list(Node.objects.all())
nodes = sorted(nodes, key=lambda node: node.instances.all().count())
else:
nodes = list(Node.objects.filter(name = self.slice.default_node))
-#MCORD
if self.label:
nodes = nodes.filter(nodelabels__name=self.label)
diff --git a/xos/core/models/service.py.new b/xos/core/models/service.py.new
deleted file mode 100644
index d3b6a7d..0000000
--- a/xos/core/models/service.py.new
+++ /dev/null
@@ -1,791 +0,0 @@
-from django.db import models
-from core.models import PlCoreBase,SingletonModel,PlCoreBaseManager
-from core.models.plcorebase import StrippedCharField
-from xos.exceptions import *
-from operator import attrgetter
-import json
-
-COARSE_KIND="coarse"
-
-class AttributeMixin(object):
- # helper for extracting things from a json-encoded service_specific_attribute
- def get_attribute(self, name, default=None):
- if self.service_specific_attribute:
- attributes = json.loads(self.service_specific_attribute)
- else:
- attributes = {}
- return attributes.get(name, default)
-
- def set_attribute(self, name, value):
- if self.service_specific_attribute:
- attributes = json.loads(self.service_specific_attribute)
- else:
- attributes = {}
- attributes[name]=value
- self.service_specific_attribute = json.dumps(attributes)
-
- def get_initial_attribute(self, name, default=None):
- if self._initial["service_specific_attribute"]:
- attributes = json.loads(self._initial["service_specific_attribute"])
- else:
- attributes = {}
- return attributes.get(name, default)
-
- @classmethod
- def setup_simple_attributes(cls):
- for (attrname, default) in cls.simple_attributes:
- setattr(cls, attrname, property(lambda self, attrname=attrname, default=default: self.get_attribute(attrname, default),
- lambda self, value, attrname=attrname: self.set_attribute(attrname, value),
- None,
- attrname))
-
-class Service(PlCoreBase, AttributeMixin):
- # when subclassing a service, redefine KIND to describe the new service
- KIND = "generic"
-
- description = models.TextField(max_length=254,null=True, blank=True,help_text="Description of Service")
- enabled = models.BooleanField(default=True)
- kind = StrippedCharField(max_length=30, help_text="Kind of service", default=KIND)
- name = StrippedCharField(max_length=30, help_text="Service Name")
- versionNumber = StrippedCharField(max_length=30, help_text="Version of Service Definition")
- published = models.BooleanField(default=True)
- view_url = StrippedCharField(blank=True, null=True, max_length=1024)
- icon_url = StrippedCharField(blank=True, null=True, max_length=1024)
- public_key = models.TextField(null=True, blank=True, max_length=1024, help_text="Public key string")
- private_key_fn = StrippedCharField(blank=True, null=True, max_length=1024)
-
- # Service_specific_attribute and service_specific_id are opaque to XOS
- service_specific_id = StrippedCharField(max_length=30, blank=True, null=True)
- service_specific_attribute = models.TextField(blank=True, null=True)
-
- def __init__(self, *args, **kwargs):
- # for subclasses, set the default kind appropriately
- self._meta.get_field("kind").default = self.KIND
- super(Service, self).__init__(*args, **kwargs)
-
- @classmethod
- def get_service_objects(cls):
- return cls.objects.filter(kind = cls.KIND)
-
- @classmethod
- def get_deleted_service_objects(cls):
- return cls.deleted_objects.filter(kind = cls.KIND)
-
- @classmethod
- def get_service_objects_by_user(cls, user):
- return cls.select_by_user(user).filter(kind = cls.KIND)
-
- @classmethod
- def select_by_user(cls, user):
- if user.is_admin:
- return cls.objects.all()
- else:
- service_ids = [sp.slice.id for sp in ServicePrivilege.objects.filter(user=user)]
- return cls.objects.filter(id__in=service_ids)
-
- @property
- def serviceattribute_dict(self):
- attrs = {}
- for attr in self.serviceattributes.all():
- attrs[attr.name] = attr.value
- return attrs
-
- def __unicode__(self): return u'%s' % (self.name)
-
- def can_update(self, user):
- return user.can_update_service(self, allow=['admin'])
-
- def get_scalable_nodes(self, slice, max_per_node=None, exclusive_slices=[]):
- """
- Get a list of nodes that can be used to scale up a slice.
-
- slice - slice to scale up
- max_per_node - maximum numbers of instances that 'slice' can have on a single node
- exclusive_slices - list of slices that must have no nodes in common with 'slice'.
- """
-
- from core.models import Node, Instance # late import to get around order-of-imports constraint in __init__.py
-
- nodes = list(Node.objects.all())
-
- conflicting_instances = Instance.objects.filter(slice__in = exclusive_slices)
- conflicting_nodes = Node.objects.filter(instances__in = conflicting_instances)
-
- nodes = [x for x in nodes if x not in conflicting_nodes]
-
- # If max_per_node is set, then limit the number of instances this slice
- # can have on a single node.
- if max_per_node:
- acceptable_nodes = []
- for node in nodes:
- existing_count = node.instances.filter(slice=slice).count()
- if existing_count < max_per_node:
- acceptable_nodes.append(node)
- nodes = acceptable_nodes
-
- return nodes
-
- def pick_node(self, slice, max_per_node=None, exclusive_slices=[]):
- # Pick the best node to scale up a slice.
-
- nodes = self.get_scalable_nodes(slice, max_per_node, exclusive_slices)
- nodes = sorted(nodes, key=lambda node: node.instances.all().count())
- if not nodes:
- return None
- return nodes[0]
-
- def adjust_scale(self, slice_hint, scale, max_per_node=None, exclusive_slices=[]):
- from core.models import Instance # late import to get around order-of-imports constraint in __init__.py
-
- slices = [x for x in self.slices.all() if slice_hint in x.name]
- for slice in slices:
- while slice.instances.all().count() > scale:
- s = slice.instances.all()[0]
- # print "drop instance", s
- s.delete()
-
- while slice.instances.all().count() < scale:
- node = self.pick_node(slice, max_per_node, exclusive_slices)
- if not node:
- # no more available nodes
- break
-
- image = slice.default_image
- if not image:
- raise XOSConfigurationError("No default_image for slice %s" % slice.name)
-
- flavor = slice.default_flavor
- if not flavor:
- raise XOSConfigurationError("No default_flavor for slice %s" % slice.name)
-
- s = Instance(slice=slice,
- node=node,
- creator=slice.creator,
- image=image,
- flavor=flavor,
- deployment=node.site_deployment.deployment)
- s.save()
-
- # print "add instance", s
-
- def get_vtn_src_nets(self):
- nets=[]
- for slice in self.slices.all():
- for ns in slice.networkslices.all():
- if not ns.network:
- continue
-# if ns.network.template.access in ["direct", "indirect"]:
-# # skip access networks; we want to use the private network
-# continue
- if ns.network.name in ["wan_network", "lan_network"]:
- # we don't want to attach to the vCPE's lan or wan network
- # we only want to attach to its private network
- # TODO: fix hard-coding of network name
- continue
- for cn in ns.network.controllernetworks.all():
- if cn.net_id:
- net = {"name": ns.network.name, "net_id": cn.net_id}
- nets.append(net)
- return nets
-
- def get_vtn_nets(self):
- nets=[]
- for slice in self.slices.all():
- for ns in slice.networkslices.all():
- if not ns.network:
- continue
- if ns.network.template.access not in ["direct", "indirect"]:
- # skip anything that's not an access network
- continue
- for cn in ns.network.controllernetworks.all():
- if cn.net_id:
- net = {"name": ns.network.name, "net_id": cn.net_id}
- nets.append(net)
- return nets
-
- def get_vtn_dependencies_nets(self):
- provider_nets = []
- for tenant in self.subscribed_tenants.all():
- if tenant.provider_service:
- for net in tenant.provider_service.get_vtn_nets():
- if not net in provider_nets:
- provider_nets.append(net)
- return provider_nets
-
- def get_vtn_dependencies_ids(self):
- return [x["net_id"] for x in self.get_vtn_dependencies_nets()]
-
- def get_vtn_dependencies_names(self):
- return [x["name"]+"_"+x["net_id"] for x in self.get_vtn_dependencies_nets()]
-
- def get_vtn_src_ids(self):
- return [x["net_id"] for x in self.get_vtn_src_nets()]
-
- def get_vtn_src_names(self):
- return [x["name"]+"_"+x["net_id"] for x in self.get_vtn_src_nets()]
-
-
-class ServiceAttribute(PlCoreBase):
- name = models.CharField(help_text="Attribute Name", max_length=128)
- value = StrippedCharField(help_text="Attribute Value", max_length=1024)
- service = models.ForeignKey(Service, related_name='serviceattributes', help_text="The Service this attribute is associated with")
-
-class ServiceRole(PlCoreBase):
- ROLE_CHOICES = (('admin','Admin'),)
- role = StrippedCharField(choices=ROLE_CHOICES, unique=True, max_length=30)
-
- def __unicode__(self): return u'%s' % (self.role)
-
-class ServicePrivilege(PlCoreBase):
- user = models.ForeignKey('User', related_name='serviceprivileges')
- service = models.ForeignKey('Service', related_name='serviceprivileges')
- role = models.ForeignKey('ServiceRole',related_name='serviceprivileges')
-
- class Meta:
- unique_together = ('user', 'service', 'role')
-
- def __unicode__(self): return u'%s %s %s' % (self.service, self.user, self.role)
-
- def can_update(self, user):
- if not self.service.enabled:
- raise PermissionDenied, "Cannot modify permission(s) of a disabled service"
- return self.service.can_update(user)
-
- def save(self, *args, **kwds):
- if not self.service.enabled:
- raise PermissionDenied, "Cannot modify permission(s) of a disabled service"
- super(ServicePrivilege, self).save(*args, **kwds)
-
- def delete(self, *args, **kwds):
- if not self.service.enabled:
- raise PermissionDenied, "Cannot modify permission(s) of a disabled service"
- super(ServicePrivilege, self).delete(*args, **kwds)
-
- @classmethod
- def select_by_user(cls, user):
- if user.is_admin:
- qs = cls.objects.all()
- else:
- qs = cls.objects.filter(user=user)
- return qs
-
-class TenantRoot(PlCoreBase, AttributeMixin):
- """ A tenantRoot is one of the things that can sit at the root of a chain
- of tenancy. This object represents a node.
- """
-
- KIND= "generic"
- kind = StrippedCharField(max_length=30, default=KIND)
- name = StrippedCharField(max_length=255, help_text="name", blank=True, null=True)
-
- service_specific_attribute = models.TextField(blank=True, null=True)
- service_specific_id = StrippedCharField(max_length=30, blank=True, null=True)
-
- def __init__(self, *args, **kwargs):
- # for subclasses, set the default kind appropriately
- self._meta.get_field("kind").default = self.KIND
- super(TenantRoot, self).__init__(*args, **kwargs)
-
- def __unicode__(self):
- if not self.name:
- return u"%s-tenant_root-#%s" % (str(self.kind), str(self.id))
- else:
- return self.name
-
- def can_update(self, user):
- return user.can_update_tenant_root(self, allow=['admin'])
-
- def get_subscribed_tenants(self, tenant_class):
- ids = self.subscribed_tenants.filter(kind=tenant_class.KIND)
- return tenant_class.objects.filter(id__in = ids)
-
- def get_newest_subscribed_tenant(self, kind):
- st = list(self.get_subscribed_tenants(kind))
- if not st:
- return None
- return sorted(st, key=attrgetter('id'))[0]
-
- @classmethod
- def get_tenant_objects(cls):
- return cls.objects.filter(kind = cls.KIND)
-
- @classmethod
- def get_tenant_objects_by_user(cls, user):
- return cls.select_by_user(user).filter(kind = cls.KIND)
-
- @classmethod
- def select_by_user(cls, user):
- if user.is_admin:
- return cls.objects.all()
- else:
- tr_ids = [trp.tenant_root.id for trp in TenantRootPrivilege.objects.filter(user=user)]
- return cls.objects.filter(id__in=tr_ids)
-
-class Tenant(PlCoreBase, AttributeMixin):
- """ A tenant is a relationship between two entities, a subscriber and a
- provider. This object represents an edge.
-
- The subscriber can be a User, a Service, or a Tenant.
-
- The provider is always a Service.
-
- TODO: rename "Tenant" to "Tenancy"
- """
-
- CONNECTIVITY_CHOICES = (('public', 'Public'), ('private', 'Private'), ('na', 'Not Applicable'))
-
- # when subclassing a service, redefine KIND to describe the new service
- KIND = "generic"
-
- kind = StrippedCharField(max_length=30, default=KIND)
- provider_service = models.ForeignKey(Service, related_name='provided_tenants')
-
- # The next four things are the various type of objects that can be subscribers of this Tenancy
- # relationship. One and only one can be used at a time.
- subscriber_service = models.ForeignKey(Service, related_name='subscribed_tenants', blank=True, null=True)
- subscriber_tenant = models.ForeignKey("Tenant", related_name='subscribed_tenants', blank=True, null=True)
- subscriber_user = models.ForeignKey("User", related_name='subscribed_tenants', blank=True, null=True)
- subscriber_root = models.ForeignKey("TenantRoot", related_name="subscribed_tenants", blank=True, null=True)
-
- # Service_specific_attribute and service_specific_id are opaque to XOS
- service_specific_id = StrippedCharField(max_length=30, blank=True, null=True)
- service_specific_attribute = models.TextField(blank=True, null=True)
-
- # Connect_method is only used by Coarse tenants
- connect_method = models.CharField(null=False, blank=False, max_length=30, choices=CONNECTIVITY_CHOICES, default="na")
-
- def __init__(self, *args, **kwargs):
- # for subclasses, set the default kind appropriately
- self._meta.get_field("kind").default = self.KIND
- super(Tenant, self).__init__(*args, **kwargs)
-
- def __unicode__(self):
- return u"%s-tenant-%s" % (str(self.kind), str(self.id))
-
- @classmethod
- def get_tenant_objects(cls):
- return cls.objects.filter(kind = cls.KIND)
-
- @classmethod
- def get_tenant_objects_by_user(cls, user):
- return cls.select_by_user(user).filter(kind = cls.KIND)
-
- @classmethod
- def get_deleted_tenant_objects(cls):
- return cls.deleted_objects.filter(kind = cls.KIND)
-
- @property
- def tenantattribute_dict(self):
- attrs = {}
- for attr in self.tenantattributes.all():
- attrs[attr.name] = attr.value
- return attrs
-
- # helper function to be used in subclasses that want to ensure service_specific_id is unique
- def validate_unique_service_specific_id(self):
- if self.pk is None:
- if self.service_specific_id is None:
- raise XOSMissingField("subscriber_specific_id is None, and it's a required field", fields={"service_specific_id": "cannot be none"})
-
- conflicts = self.get_tenant_objects().filter(service_specific_id=self.service_specific_id)
- if conflicts:
- raise XOSDuplicateKey("service_specific_id %s already exists" % self.service_specific_id, fields={"service_specific_id": "duplicate key"})
-
- def save(self, *args, **kwargs):
- subCount = sum( [1 for e in [self.subscriber_service, self.subscriber_tenant, self.subscriber_user, self.subscriber_root] if e is not None])
- if (subCount > 1):
- raise XOSConflictingField("Only one of subscriber_service, subscriber_tenant, subscriber_user, subscriber_root should be set")
-
- super(Tenant, self).save(*args, **kwargs)
-
- def get_subscribed_tenants(self, tenant_class):
- ids = self.subscribed_tenants.filter(kind=tenant_class.KIND)
- return tenant_class.objects.filter(id__in = ids)
-
- def get_newest_subscribed_tenant(self, kind):
- st = list(self.get_subscribed_tenants(kind))
- if not st:
- return None
- return sorted(st, key=attrgetter('id'))[0]
-
-class Scheduler(object):
- # XOS Scheduler Abstract Base Class
- # Used to implement schedulers that pick which node to put instances on
-
- def __init__(self, slice):
- self.slice = slice
-
- def pick(self):
- # this method should return a tuple (node, parent)
- # node is the node to instantiate on
- # parent is for container_vm instances only, and is the VM that will
- # hold the container
-
- raise Exception("Abstract Base")
-
-class LeastLoadedNodeScheduler(Scheduler):
- # This scheduler always return the node with the fewest number of instances.
-
- def __init__(self, slice):
- super(LeastLoadedNodeScheduler, self).__init__(slice)
-
- def pick(self):
- from core.models import Node
-# nodes = list(Node.objects.all())
- if not self.slice.default_node:
- nodes = list(Node.objects.all())
- nodes = sorted(nodes, key=lambda node: node.instances.all().count())
- else:
- nodes = list(Node.objects.filter(name = self.slice.default_node))
- # TODO: logic to filter nodes by which nodes are up, and which
- # nodes the slice can instantiate on.
-# nodes = sorted(nodes, key=lambda node: node.instances.all().count())
- return [nodes[0], None]
-
-class ContainerVmScheduler(Scheduler):
- # This scheduler picks a VM in the slice with the fewest containers inside
- # of it. If no VMs are suitable, then it creates a VM.
-
- # this is a hack and should be replaced by something smarter...
- LOOK_FOR_IMAGES=["ubuntu-vcpe4", # ONOS demo machine -- preferred vcpe image
- "Ubuntu 14.04 LTS", # portal
- "Ubuntu-14.04-LTS", # ONOS demo machine
- "trusty-server-multi-nic", # CloudLab
- ]
-
- MAX_VM_PER_CONTAINER = 10
-
- def __init__(self, slice):
- super(ContainerVmScheduler, self).__init__(slice)
-
- @property
- def image(self):
- from core.models import Image
-
- look_for_images = self.LOOK_FOR_IMAGES
- for image_name in look_for_images:
- images = Image.objects.filter(name = image_name)
- if images:
- return images[0]
-
- raise XOSProgrammingError("No ContainerVM image (looked for %s)" % str(look_for_images))
-
- def make_new_instance(self):
- from core.models import Instance, Flavor
-
- flavors = Flavor.objects.filter(name="m1.small")
- if not flavors:
- raise XOSConfigurationError("No m1.small flavor")
-
- (node,parent) = LeastLoadedNodeScheduler(self.slice).pick()
-
- instance = Instance(slice = self.slice,
- node = node,
- image = self.image,
- creator = self.slice.creator,
- deployment = node.site_deployment.deployment,
- flavor = flavors[0],
- isolation = "vm",
- parent = parent)
- instance.save()
- # We rely on a special naming convention to identify the VMs that will
- # hole containers.
- instance.name = "%s-outer-%s" % (instance.slice.name, instance.id)
- instance.save()
- return instance
-
- def pick(self):
- from core.models import Instance, Flavor
-
- for vm in self.slice.instances.filter(isolation="vm"):
- avail_vms = []
- if (vm.name.startswith("%s-outer-" % self.slice.name)):
- container_count = Instance.objects.filter(parent=vm).count()
- if (container_count < self.MAX_VM_PER_CONTAINER):
- avail_vms.append( (vm, container_count) )
- # sort by least containers-per-vm
- avail_vms = sorted(avail_vms, key = lambda x: x[1])
- print "XXX", avail_vms
- if avail_vms:
- instance = avail_vms[0][0]
- return (instance.node, instance)
-
- instance = self.make_new_instance()
- return (instance.node, instance)
-
-class TenantWithContainer(Tenant):
- """ A tenant that manages a container """
-
- # this is a hack and should be replaced by something smarter...
- LOOK_FOR_IMAGES=["ubuntu-vcpe4", # ONOS demo machine -- preferred vcpe image
- "Ubuntu 14.04 LTS", # portal
- "Ubuntu-14.04-LTS", # ONOS demo machine
- "trusty-server-multi-nic", # CloudLab
- ]
-
- LOOK_FOR_CONTAINER_IMAGES=["docker-vcpe"]
-
- class Meta:
- proxy = True
-
- def __init__(self, *args, **kwargs):
- super(TenantWithContainer, self).__init__(*args, **kwargs)
- self.cached_instance=None
- self.orig_instance_id = self.get_initial_attribute("instance_id")
-
- @property
- def instance(self):
- from core.models import Instance
- if getattr(self, "cached_instance", None):
- return self.cached_instance
- instance_id=self.get_attribute("instance_id")
- if not instance_id:
- return None
- instances=Instance.objects.filter(id=instance_id)
- if not instances:
- return None
- instance=instances[0]
- instance.caller = self.creator
- self.cached_instance = instance
- return instance
-
- @instance.setter
- def instance(self, value):
- if value:
- value = value.id
- if (value != self.get_attribute("instance_id", None)):
- self.cached_instance=None
- self.set_attribute("instance_id", value)
-
- @property
- def external_hostname(self):
- return self.get_attribute("external_hostname", "")
-
- @external_hostname.setter
- def external_hostname(self, value):
- self.set_attribute("external_hostname", value)
-
- @property
- def external_container(self):
- return self.get_attribute("external_container", "")
-
- @external_container.setter
- def external_container(self, value):
- self.set_attribute("external_container", value)
-
- @property
- def creator(self):
- from core.models import User
- if getattr(self, "cached_creator", None):
- return self.cached_creator
- creator_id=self.get_attribute("creator_id")
- if not creator_id:
- return None
- users=User.objects.filter(id=creator_id)
- if not users:
- return None
- user=users[0]
- self.cached_creator = users[0]
- return user
-
- @creator.setter
- def creator(self, value):
- if value:
- value = value.id
- if (value != self.get_attribute("creator_id", None)):
- self.cached_creator=None
- self.set_attribute("creator_id", value)
-
- @property
- def image(self):
- from core.models import Image
- # Implement the logic here to pick the image that should be used when
- # instantiating the VM that will hold the container.
-
- slice = self.provider_service.slices.all()
- if not slice:
- raise XOSProgrammingError("provider service has no slice")
- slice = slice[0]
-
- if slice.default_isolation in ["container", "container_vm"]:
- look_for_images = self.LOOK_FOR_CONTAINER_IMAGES
- else:
- look_for_images = self.LOOK_FOR_IMAGES
-
- for image_name in look_for_images:
- images = Image.objects.filter(name = image_name)
- if images:
- return images[0]
-
- raise XOSProgrammingError("No VPCE image (looked for %s)" % str(look_for_images))
-
- def save_instance(self, instance):
- # Override this function to do custom pre-save or post-save processing,
- # such as creating ports for containers.
- instance.save()
-
- def pick_least_loaded_instance_in_slice(self, slices):
- for slice in slices:
- if slice.instances.all().count() > 0:
- for instance in slice.instances.all():
- #Pick the first instance that has lesser than 5 tenants
- if self.count_of_tenants_of_an_instance(instance) < 5:
- return instance
- return None
-
- #TODO: Ideally the tenant count for an instance should be maintained using a
- #many-to-one relationship attribute, however this model being proxy, it does
- #not permit any new attributes to be defined. Find if any better solutions
- def count_of_tenants_of_an_instance(self, instance):
- tenant_count = 0
- for tenant in self.get_tenant_objects().all():
- if tenant.get_attribute("instance_id", None) == instance.id:
- tenant_count += 1
- return tenant_count
-
- def manage_container(self):
- from core.models import Instance, Flavor
-
- if self.deleted:
- return
-
- if (self.instance is not None): # and (self.instance.image != self.image):
- self.instance.delete()
- self.instance = None
-
- if self.instance is None:
- if not self.provider_service.slices.count():
- raise XOSConfigurationError("The service has no slices")
-
- new_instance_created = False
- instance = None
- if self.get_attribute("use_same_instance_for_multiple_tenants", default=False):
- #Find if any existing instances can be used for this tenant
- slices = self.provider_service.slices.all()
- instance = self.pick_least_loaded_instance_in_slice(slices)
-
- if not instance:
- flavors = Flavor.objects.filter(name="m1.small")
- if not flavors:
- raise XOSConfigurationError("No m1.small flavor")
-
- slice = self.provider_service.slices.all()[0]
-
- if slice.default_isolation == "container_vm":
- (node, parent) = ContainerVmScheduler(slice).pick()
- else:
- (node, parent) = LeastLoadedNodeScheduler(slice).pick()
-
- instance = Instance(slice = slice,
- node = node,
-# image = slice.default_image,
- image = self.image,
- creator = self.creator,
- deployment = node.site_deployment.deployment,
-# flavor = flavors[0],
- flavor = slice.default_flavor,
- isolation = slice.default_isolation,
- parent = parent)
- self.save_instance(instance)
- new_instance_created = True
-
- try:
- self.instance = instance
- super(TenantWithContainer, self).save()
- except:
- if new_instance_created:
- instance.delete()
- raise
-
- def cleanup_container(self):
- if self.instance:
- if self.get_attribute("use_same_instance_for_multiple_tenants", default=False):
- #Delete the instance only if this is last tenant in that instance
- tenant_count = self.count_of_tenants_of_an_instance(self.instance)
- if tenant_count == 0:
- self.instance.delete()
- else:
- self.instance.delete()
- self.instance = None
-
- def save(self, *args, **kwargs):
- if (not self.creator) and (hasattr(self, "caller")) and (self.caller):
- self.creator = self.caller
- super(TenantWithContainer, self).save(*args, **kwargs)
-
-class CoarseTenant(Tenant):
- """ TODO: rename "CoarseTenant" --> "StaticTenant" """
- class Meta:
- proxy = True
-
- KIND = COARSE_KIND
-
- def save(self, *args, **kwargs):
- if (not self.subscriber_service):
- raise XOSValidationError("subscriber_service cannot be null")
- if (self.subscriber_tenant or self.subscriber_user):
- raise XOSValidationError("subscriber_tenant and subscriber_user must be null")
-
- super(CoarseTenant,self).save()
-
-class Subscriber(TenantRoot):
- """ Intermediate class for TenantRoots that are to be Subscribers """
-
- class Meta:
- proxy = True
-
- KIND = "Subscriber"
-
-class Provider(TenantRoot):
- """ Intermediate class for TenantRoots that are to be Providers """
-
- class Meta:
- proxy = True
-
- KIND = "Provider"
-
-class TenantAttribute(PlCoreBase):
- name = models.CharField(help_text="Attribute Name", max_length=128)
- value = models.TextField(help_text="Attribute Value")
- tenant = models.ForeignKey(Tenant, related_name='tenantattributes', help_text="The Tenant this attribute is associated with")
-
-class TenantRootRole(PlCoreBase):
- ROLE_CHOICES = (('admin','Admin'), ('access','Access'))
-
- role = StrippedCharField(choices=ROLE_CHOICES, unique=True, max_length=30)
-
- def __unicode__(self): return u'%s' % (self.role)
-
-class TenantRootPrivilege(PlCoreBase):
- user = models.ForeignKey('User', related_name="tenant_root_privileges")
- tenant_root = models.ForeignKey('TenantRoot', related_name="tenant_root_privileges")
- role = models.ForeignKey('TenantRootRole', related_name="tenant_root_privileges")
-
- class Meta:
- unique_together = ('user', 'tenant_root', 'role')
-
- def __unicode__(self): return u'%s %s %s' % (self.tenant_root, self.user, self.role)
-
- def save(self, *args, **kwds):
- if not self.user.is_active:
- raise PermissionDenied, "Cannot modify role(s) of a disabled user"
- super(TenantRootPrivilege, self).save(*args, **kwds)
-
- def can_update(self, user):
- return user.can_update_tenant_root_privilege(self)
-
- @classmethod
- def select_by_user(cls, user):
- if user.is_admin:
- return cls.objects.all()
- else:
- # User can see his own privilege
- trp_ids = [trp.id for trp in cls.objects.filter(user=user)]
-
- # A slice admin can see the SlicePrivileges for his Slice
- for priv in cls.objects.filter(user=user, role__role="admin"):
- trp_ids.extend( [trp.id for trp in cls.objects.filter(tenant_root=priv.tenant_root)] )
-
- return cls.objects.filter(id__in=trp_ids)
-
-
diff --git a/xos/core/models/service.py.old b/xos/core/models/service.py.old
deleted file mode 100644
index 1a1b6ef..0000000
--- a/xos/core/models/service.py.old
+++ /dev/null
@@ -1,785 +0,0 @@
-from django.db import models
-from core.models import PlCoreBase,SingletonModel,PlCoreBaseManager
-from core.models.plcorebase import StrippedCharField
-from xos.exceptions import *
-from operator import attrgetter
-import json
-
-COARSE_KIND="coarse"
-
-class AttributeMixin(object):
- # helper for extracting things from a json-encoded service_specific_attribute
- def get_attribute(self, name, default=None):
- if self.service_specific_attribute:
- attributes = json.loads(self.service_specific_attribute)
- else:
- attributes = {}
- return attributes.get(name, default)
-
- def set_attribute(self, name, value):
- if self.service_specific_attribute:
- attributes = json.loads(self.service_specific_attribute)
- else:
- attributes = {}
- attributes[name]=value
- self.service_specific_attribute = json.dumps(attributes)
-
- def get_initial_attribute(self, name, default=None):
- if self._initial["service_specific_attribute"]:
- attributes = json.loads(self._initial["service_specific_attribute"])
- else:
- attributes = {}
- return attributes.get(name, default)
-
- @classmethod
- def setup_simple_attributes(cls):
- for (attrname, default) in cls.simple_attributes:
- setattr(cls, attrname, property(lambda self, attrname=attrname, default=default: self.get_attribute(attrname, default),
- lambda self, value, attrname=attrname: self.set_attribute(attrname, value),
- None,
- attrname))
-
-class Service(PlCoreBase, AttributeMixin):
- # when subclassing a service, redefine KIND to describe the new service
- KIND = "generic"
-
- description = models.TextField(max_length=254,null=True, blank=True,help_text="Description of Service")
- enabled = models.BooleanField(default=True)
- kind = StrippedCharField(max_length=30, help_text="Kind of service", default=KIND)
- name = StrippedCharField(max_length=30, help_text="Service Name")
- versionNumber = StrippedCharField(max_length=30, help_text="Version of Service Definition")
- published = models.BooleanField(default=True)
- view_url = StrippedCharField(blank=True, null=True, max_length=1024)
- icon_url = StrippedCharField(blank=True, null=True, max_length=1024)
- public_key = models.TextField(null=True, blank=True, max_length=1024, help_text="Public key string")
- private_key_fn = StrippedCharField(blank=True, null=True, max_length=1024)
-
- # Service_specific_attribute and service_specific_id are opaque to XOS
- service_specific_id = StrippedCharField(max_length=30, blank=True, null=True)
- service_specific_attribute = models.TextField(blank=True, null=True)
-
- def __init__(self, *args, **kwargs):
- # for subclasses, set the default kind appropriately
- self._meta.get_field("kind").default = self.KIND
- super(Service, self).__init__(*args, **kwargs)
-
- @classmethod
- def get_service_objects(cls):
- return cls.objects.filter(kind = cls.KIND)
-
- @classmethod
- def get_deleted_service_objects(cls):
- return cls.deleted_objects.filter(kind = cls.KIND)
-
- @classmethod
- def get_service_objects_by_user(cls, user):
- return cls.select_by_user(user).filter(kind = cls.KIND)
-
- @classmethod
- def select_by_user(cls, user):
- if user.is_admin:
- return cls.objects.all()
- else:
- service_ids = [sp.slice.id for sp in ServicePrivilege.objects.filter(user=user)]
- return cls.objects.filter(id__in=service_ids)
-
- @property
- def serviceattribute_dict(self):
- attrs = {}
- for attr in self.serviceattributes.all():
- attrs[attr.name] = attr.value
- return attrs
-
- def __unicode__(self): return u'%s' % (self.name)
-
- def can_update(self, user):
- return user.can_update_service(self, allow=['admin'])
-
- def get_scalable_nodes(self, slice, max_per_node=None, exclusive_slices=[]):
- """
- Get a list of nodes that can be used to scale up a slice.
-
- slice - slice to scale up
- max_per_node - maximum numbers of instances that 'slice' can have on a single node
- exclusive_slices - list of slices that must have no nodes in common with 'slice'.
- """
-
- from core.models import Node, Instance # late import to get around order-of-imports constraint in __init__.py
-
- nodes = list(Node.objects.all())
-
- conflicting_instances = Instance.objects.filter(slice__in = exclusive_slices)
- conflicting_nodes = Node.objects.filter(instances__in = conflicting_instances)
-
- nodes = [x for x in nodes if x not in conflicting_nodes]
-
- # If max_per_node is set, then limit the number of instances this slice
- # can have on a single node.
- if max_per_node:
- acceptable_nodes = []
- for node in nodes:
- existing_count = node.instances.filter(slice=slice).count()
- if existing_count < max_per_node:
- acceptable_nodes.append(node)
- nodes = acceptable_nodes
-
- return nodes
-
- def pick_node(self, slice, max_per_node=None, exclusive_slices=[]):
- # Pick the best node to scale up a slice.
-
- nodes = self.get_scalable_nodes(slice, max_per_node, exclusive_slices)
- nodes = sorted(nodes, key=lambda node: node.instances.all().count())
- if not nodes:
- return None
- return nodes[0]
-
- def adjust_scale(self, slice_hint, scale, max_per_node=None, exclusive_slices=[]):
- from core.models import Instance # late import to get around order-of-imports constraint in __init__.py
-
- slices = [x for x in self.slices.all() if slice_hint in x.name]
- for slice in slices:
- while slice.instances.all().count() > scale:
- s = slice.instances.all()[0]
- # print "drop instance", s
- s.delete()
-
- while slice.instances.all().count() < scale:
- node = self.pick_node(slice, max_per_node, exclusive_slices)
- if not node:
- # no more available nodes
- break
-
- image = slice.default_image
- if not image:
- raise XOSConfigurationError("No default_image for slice %s" % slice.name)
-
- flavor = slice.default_flavor
- if not flavor:
- raise XOSConfigurationError("No default_flavor for slice %s" % slice.name)
-
- s = Instance(slice=slice,
- node=node,
- creator=slice.creator,
- image=image,
- flavor=flavor,
- deployment=node.site_deployment.deployment)
- s.save()
-
- # print "add instance", s
-
- def get_vtn_src_nets(self):
- nets=[]
- for slice in self.slices.all():
- for ns in slice.networkslices.all():
- if not ns.network:
- continue
-# if ns.network.template.access in ["direct", "indirect"]:
-# # skip access networks; we want to use the private network
-# continue
- if ns.network.name in ["wan_network", "lan_network"]:
- # we don't want to attach to the vCPE's lan or wan network
- # we only want to attach to its private network
- # TODO: fix hard-coding of network name
- continue
- for cn in ns.network.controllernetworks.all():
- if cn.net_id:
- net = {"name": ns.network.name, "net_id": cn.net_id}
- nets.append(net)
- return nets
-
- def get_vtn_nets(self):
- nets=[]
- for slice in self.slices.all():
- for ns in slice.networkslices.all():
- if not ns.network:
- continue
- if ns.network.template.access not in ["direct", "indirect"]:
- # skip anything that's not an access network
- continue
- for cn in ns.network.controllernetworks.all():
- if cn.net_id:
- net = {"name": ns.network.name, "net_id": cn.net_id}
- nets.append(net)
- return nets
-
- def get_vtn_dependencies_nets(self):
- provider_nets = []
- for tenant in self.subscribed_tenants.all():
- if tenant.provider_service:
- for net in tenant.provider_service.get_vtn_nets():
- if not net in provider_nets:
- provider_nets.append(net)
- return provider_nets
-
- def get_vtn_dependencies_ids(self):
- return [x["net_id"] for x in self.get_vtn_dependencies_nets()]
-
- def get_vtn_dependencies_names(self):
- return [x["name"]+"_"+x["net_id"] for x in self.get_vtn_dependencies_nets()]
-
- def get_vtn_src_ids(self):
- return [x["net_id"] for x in self.get_vtn_src_nets()]
-
- def get_vtn_src_names(self):
- return [x["name"]+"_"+x["net_id"] for x in self.get_vtn_src_nets()]
-
-
-class ServiceAttribute(PlCoreBase):
- name = models.CharField(help_text="Attribute Name", max_length=128)
- value = StrippedCharField(help_text="Attribute Value", max_length=1024)
- service = models.ForeignKey(Service, related_name='serviceattributes', help_text="The Service this attribute is associated with")
-
-class ServiceRole(PlCoreBase):
- ROLE_CHOICES = (('admin','Admin'),)
- role = StrippedCharField(choices=ROLE_CHOICES, unique=True, max_length=30)
-
- def __unicode__(self): return u'%s' % (self.role)
-
-class ServicePrivilege(PlCoreBase):
- user = models.ForeignKey('User', related_name='serviceprivileges')
- service = models.ForeignKey('Service', related_name='serviceprivileges')
- role = models.ForeignKey('ServiceRole',related_name='serviceprivileges')
-
- class Meta:
- unique_together = ('user', 'service', 'role')
-
- def __unicode__(self): return u'%s %s %s' % (self.service, self.user, self.role)
-
- def can_update(self, user):
- if not self.service.enabled:
- raise PermissionDenied, "Cannot modify permission(s) of a disabled service"
- return self.service.can_update(user)
-
- def save(self, *args, **kwds):
- if not self.service.enabled:
- raise PermissionDenied, "Cannot modify permission(s) of a disabled service"
- super(ServicePrivilege, self).save(*args, **kwds)
-
- def delete(self, *args, **kwds):
- if not self.service.enabled:
- raise PermissionDenied, "Cannot modify permission(s) of a disabled service"
- super(ServicePrivilege, self).delete(*args, **kwds)
-
- @classmethod
- def select_by_user(cls, user):
- if user.is_admin:
- qs = cls.objects.all()
- else:
- qs = cls.objects.filter(user=user)
- return qs
-
-class TenantRoot(PlCoreBase, AttributeMixin):
- """ A tenantRoot is one of the things that can sit at the root of a chain
- of tenancy. This object represents a node.
- """
-
- KIND= "generic"
- kind = StrippedCharField(max_length=30, default=KIND)
- name = StrippedCharField(max_length=255, help_text="name", blank=True, null=True)
-
- service_specific_attribute = models.TextField(blank=True, null=True)
- service_specific_id = StrippedCharField(max_length=30, blank=True, null=True)
-
- def __init__(self, *args, **kwargs):
- # for subclasses, set the default kind appropriately
- self._meta.get_field("kind").default = self.KIND
- super(TenantRoot, self).__init__(*args, **kwargs)
-
- def __unicode__(self):
- if not self.name:
- return u"%s-tenant_root-#%s" % (str(self.kind), str(self.id))
- else:
- return self.name
-
- def can_update(self, user):
- return user.can_update_tenant_root(self, allow=['admin'])
-
- def get_subscribed_tenants(self, tenant_class):
- ids = self.subscribed_tenants.filter(kind=tenant_class.KIND)
- return tenant_class.objects.filter(id__in = ids)
-
- def get_newest_subscribed_tenant(self, kind):
- st = list(self.get_subscribed_tenants(kind))
- if not st:
- return None
- return sorted(st, key=attrgetter('id'))[0]
-
- @classmethod
- def get_tenant_objects(cls):
- return cls.objects.filter(kind = cls.KIND)
-
- @classmethod
- def get_tenant_objects_by_user(cls, user):
- return cls.select_by_user(user).filter(kind = cls.KIND)
-
- @classmethod
- def select_by_user(cls, user):
- if user.is_admin:
- return cls.objects.all()
- else:
- tr_ids = [trp.tenant_root.id for trp in TenantRootPrivilege.objects.filter(user=user)]
- return cls.objects.filter(id__in=tr_ids)
-
-class Tenant(PlCoreBase, AttributeMixin):
- """ A tenant is a relationship between two entities, a subscriber and a
- provider. This object represents an edge.
-
- The subscriber can be a User, a Service, or a Tenant.
-
- The provider is always a Service.
-
- TODO: rename "Tenant" to "Tenancy"
- """
-
- CONNECTIVITY_CHOICES = (('public', 'Public'), ('private', 'Private'), ('na', 'Not Applicable'))
-
- # when subclassing a service, redefine KIND to describe the new service
- KIND = "generic"
-
- kind = StrippedCharField(max_length=30, default=KIND)
- provider_service = models.ForeignKey(Service, related_name='provided_tenants')
-
- # The next four things are the various type of objects that can be subscribers of this Tenancy
- # relationship. One and only one can be used at a time.
- subscriber_service = models.ForeignKey(Service, related_name='subscribed_tenants', blank=True, null=True)
- subscriber_tenant = models.ForeignKey("Tenant", related_name='subscribed_tenants', blank=True, null=True)
- subscriber_user = models.ForeignKey("User", related_name='subscribed_tenants', blank=True, null=True)
- subscriber_root = models.ForeignKey("TenantRoot", related_name="subscribed_tenants", blank=True, null=True)
-
- # Service_specific_attribute and service_specific_id are opaque to XOS
- service_specific_id = StrippedCharField(max_length=30, blank=True, null=True)
- service_specific_attribute = models.TextField(blank=True, null=True)
-
- # Connect_method is only used by Coarse tenants
- connect_method = models.CharField(null=False, blank=False, max_length=30, choices=CONNECTIVITY_CHOICES, default="na")
-
- def __init__(self, *args, **kwargs):
- # for subclasses, set the default kind appropriately
- self._meta.get_field("kind").default = self.KIND
- super(Tenant, self).__init__(*args, **kwargs)
-
- def __unicode__(self):
- return u"%s-tenant-%s" % (str(self.kind), str(self.id))
-
- @classmethod
- def get_tenant_objects(cls):
- return cls.objects.filter(kind = cls.KIND)
-
- @classmethod
- def get_tenant_objects_by_user(cls, user):
- return cls.select_by_user(user).filter(kind = cls.KIND)
-
- @classmethod
- def get_deleted_tenant_objects(cls):
- return cls.deleted_objects.filter(kind = cls.KIND)
-
- @property
- def tenantattribute_dict(self):
- attrs = {}
- for attr in self.tenantattributes.all():
- attrs[attr.name] = attr.value
- return attrs
-
- # helper function to be used in subclasses that want to ensure service_specific_id is unique
- def validate_unique_service_specific_id(self):
- if self.pk is None:
- if self.service_specific_id is None:
- raise XOSMissingField("subscriber_specific_id is None, and it's a required field", fields={"service_specific_id": "cannot be none"})
-
- conflicts = self.get_tenant_objects().filter(service_specific_id=self.service_specific_id)
- if conflicts:
- raise XOSDuplicateKey("service_specific_id %s already exists" % self.service_specific_id, fields={"service_specific_id": "duplicate key"})
-
- def save(self, *args, **kwargs):
- subCount = sum( [1 for e in [self.subscriber_service, self.subscriber_tenant, self.subscriber_user, self.subscriber_root] if e is not None])
- if (subCount > 1):
- raise XOSConflictingField("Only one of subscriber_service, subscriber_tenant, subscriber_user, subscriber_root should be set")
-
- super(Tenant, self).save(*args, **kwargs)
-
- def get_subscribed_tenants(self, tenant_class):
- ids = self.subscribed_tenants.filter(kind=tenant_class.KIND)
- return tenant_class.objects.filter(id__in = ids)
-
- def get_newest_subscribed_tenant(self, kind):
- st = list(self.get_subscribed_tenants(kind))
- if not st:
- return None
- return sorted(st, key=attrgetter('id'))[0]
-
-class Scheduler(object):
- # XOS Scheduler Abstract Base Class
- # Used to implement schedulers that pick which node to put instances on
-
- def __init__(self, slice):
- self.slice = slice
-
- def pick(self):
- # this method should return a tuple (node, parent)
- # node is the node to instantiate on
- # parent is for container_vm instances only, and is the VM that will
- # hold the container
-
- raise Exception("Abstract Base")
-
-class LeastLoadedNodeScheduler(Scheduler):
- # This scheduler always return the node with the fewest number of instances.
-
- def __init__(self, slice):
- super(LeastLoadedNodeScheduler, self).__init__(slice)
-
- def pick(self):
- from core.models import Node
- nodes = list(Node.objects.all())
-
- # TODO: logic to filter nodes by which nodes are up, and which
- # nodes the slice can instantiate on.
- nodes = sorted(nodes, key=lambda node: node.instances.all().count())
- return [nodes[0], None]
-
-class ContainerVmScheduler(Scheduler):
- # This scheduler picks a VM in the slice with the fewest containers inside
- # of it. If no VMs are suitable, then it creates a VM.
-
- # this is a hack and should be replaced by something smarter...
- LOOK_FOR_IMAGES=["ubuntu-vcpe4", # ONOS demo machine -- preferred vcpe image
- "Ubuntu 14.04 LTS", # portal
- "Ubuntu-14.04-LTS", # ONOS demo machine
- "trusty-server-multi-nic", # CloudLab
- ]
-
- MAX_VM_PER_CONTAINER = 10
-
- def __init__(self, slice):
- super(ContainerVmScheduler, self).__init__(slice)
-
- @property
- def image(self):
- from core.models import Image
-
- look_for_images = self.LOOK_FOR_IMAGES
- for image_name in look_for_images:
- images = Image.objects.filter(name = image_name)
- if images:
- return images[0]
-
- raise XOSProgrammingError("No ContainerVM image (looked for %s)" % str(look_for_images))
-
- def make_new_instance(self):
- from core.models import Instance, Flavor
-
- flavors = Flavor.objects.filter(name="m1.small")
- if not flavors:
- raise XOSConfigurationError("No m1.small flavor")
-
- (node,parent) = LeastLoadedNodeScheduler(self.slice).pick()
-
- instance = Instance(slice = self.slice,
- node = node,
- image = self.image,
- creator = self.slice.creator,
- deployment = node.site_deployment.deployment,
- flavor = flavors[0],
- isolation = "vm",
- parent = parent)
- instance.save()
- # We rely on a special naming convention to identify the VMs that will
- # hole containers.
- instance.name = "%s-outer-%s" % (instance.slice.name, instance.id)
- instance.save()
- return instance
-
- def pick(self):
- from core.models import Instance, Flavor
-
- for vm in self.slice.instances.filter(isolation="vm"):
- avail_vms = []
- if (vm.name.startswith("%s-outer-" % self.slice.name)):
- container_count = Instance.objects.filter(parent=vm).count()
- if (container_count < self.MAX_VM_PER_CONTAINER):
- avail_vms.append( (vm, container_count) )
- # sort by least containers-per-vm
- avail_vms = sorted(avail_vms, key = lambda x: x[1])
- print "XXX", avail_vms
- if avail_vms:
- instance = avail_vms[0][0]
- return (instance.node, instance)
-
- instance = self.make_new_instance()
- return (instance.node, instance)
-
-class TenantWithContainer(Tenant):
- """ A tenant that manages a container """
-
- # this is a hack and should be replaced by something smarter...
- LOOK_FOR_IMAGES=["ubuntu-vcpe4", # ONOS demo machine -- preferred vcpe image
- "Ubuntu 14.04 LTS", # portal
- "Ubuntu-14.04-LTS", # ONOS demo machine
- "trusty-server-multi-nic", # CloudLab
- ]
-
- LOOK_FOR_CONTAINER_IMAGES=["docker-vcpe"]
-
- class Meta:
- proxy = True
-
- def __init__(self, *args, **kwargs):
- super(TenantWithContainer, self).__init__(*args, **kwargs)
- self.cached_instance=None
- self.orig_instance_id = self.get_initial_attribute("instance_id")
-
- @property
- def instance(self):
- from core.models import Instance
- if getattr(self, "cached_instance", None):
- return self.cached_instance
- instance_id=self.get_attribute("instance_id")
- if not instance_id:
- return None
- instances=Instance.objects.filter(id=instance_id)
- if not instances:
- return None
- instance=instances[0]
- instance.caller = self.creator
- self.cached_instance = instance
- return instance
-
- @instance.setter
- def instance(self, value):
- if value:
- value = value.id
- if (value != self.get_attribute("instance_id", None)):
- self.cached_instance=None
- self.set_attribute("instance_id", value)
-
- @property
- def external_hostname(self):
- return self.get_attribute("external_hostname", "")
-
- @external_hostname.setter
- def external_hostname(self, value):
- self.set_attribute("external_hostname", value)
-
- @property
- def external_container(self):
- return self.get_attribute("external_container", "")
-
- @external_container.setter
- def external_container(self, value):
- self.set_attribute("external_container", value)
-
- @property
- def creator(self):
- from core.models import User
- if getattr(self, "cached_creator", None):
- return self.cached_creator
- creator_id=self.get_attribute("creator_id")
- if not creator_id:
- return None
- users=User.objects.filter(id=creator_id)
- if not users:
- return None
- user=users[0]
- self.cached_creator = users[0]
- return user
-
- @creator.setter
- def creator(self, value):
- if value:
- value = value.id
- if (value != self.get_attribute("creator_id", None)):
- self.cached_creator=None
- self.set_attribute("creator_id", value)
-
- @property
- def image(self):
- from core.models import Image
- # Implement the logic here to pick the image that should be used when
- # instantiating the VM that will hold the container.
-
- slice = self.provider_service.slices.all()
- if not slice:
- raise XOSProgrammingError("provider service has no slice")
- slice = slice[0]
-
- if slice.default_isolation in ["container", "container_vm"]:
- look_for_images = self.LOOK_FOR_CONTAINER_IMAGES
- else:
- look_for_images = self.LOOK_FOR_IMAGES
-
- for image_name in look_for_images:
- images = Image.objects.filter(name = image_name)
- if images:
- return images[0]
-
- raise XOSProgrammingError("No VPCE image (looked for %s)" % str(look_for_images))
-
- def save_instance(self, instance):
- # Override this function to do custom pre-save or post-save processing,
- # such as creating ports for containers.
- instance.save()
-
- def pick_least_loaded_instance_in_slice(self, slices):
- for slice in slices:
- if slice.instances.all().count() > 0:
- for instance in slice.instances.all():
- #Pick the first instance that has lesser than 5 tenants
- if self.count_of_tenants_of_an_instance(instance) < 5:
- return instance
- return None
-
- #TODO: Ideally the tenant count for an instance should be maintained using a
- #many-to-one relationship attribute, however this model being proxy, it does
- #not permit any new attributes to be defined. Find if any better solutions
- def count_of_tenants_of_an_instance(self, instance):
- tenant_count = 0
- for tenant in self.get_tenant_objects().all():
- if tenant.get_attribute("instance_id", None) == instance.id:
- tenant_count += 1
- return tenant_count
-
- def manage_container(self):
- from core.models import Instance, Flavor
-
- if self.deleted:
- return
-
- if (self.instance is not None) and (self.instance.image != self.image):
- self.instance.delete()
- self.instance = None
-
- if self.instance is None:
- if not self.provider_service.slices.count():
- raise XOSConfigurationError("The service has no slices")
-
- new_instance_created = False
- instance = None
- if self.get_attribute("use_same_instance_for_multiple_tenants", default=False):
- #Find if any existing instances can be used for this tenant
- slices = self.provider_service.slices.all()
- instance = self.pick_least_loaded_instance_in_slice(slices)
-
- if not instance:
- flavors = Flavor.objects.filter(name="m1.small")
- if not flavors:
- raise XOSConfigurationError("No m1.small flavor")
-
- slice = self.provider_service.slices.all()[0]
-
- if slice.default_isolation == "container_vm":
- (node, parent) = ContainerVmScheduler(slice).pick()
- else:
- (node, parent) = LeastLoadedNodeScheduler(slice).pick()
-
- instance = Instance(slice = slice,
- node = node,
- image = self.image,
- creator = self.creator,
- deployment = node.site_deployment.deployment,
- flavor = flavors[0],
- isolation = slice.default_isolation,
- parent = parent)
- self.save_instance(instance)
- new_instance_created = True
-
- try:
- self.instance = instance
- super(TenantWithContainer, self).save()
- except:
- if new_instance_created:
- instance.delete()
- raise
-
- def cleanup_container(self):
- if self.instance:
- if self.get_attribute("use_same_instance_for_multiple_tenants", default=False):
- #Delete the instance only if this is last tenant in that instance
- tenant_count = self.count_of_tenants_of_an_instance(self.instance)
- if tenant_count == 0:
- self.instance.delete()
- else:
- self.instance.delete()
- self.instance = None
-
- def save(self, *args, **kwargs):
- if (not self.creator) and (hasattr(self, "caller")) and (self.caller):
- self.creator = self.caller
- super(TenantWithContainer, self).save(*args, **kwargs)
-
-class CoarseTenant(Tenant):
- """ TODO: rename "CoarseTenant" --> "StaticTenant" """
- class Meta:
- proxy = True
-
- KIND = COARSE_KIND
-
- def save(self, *args, **kwargs):
- if (not self.subscriber_service):
- raise XOSValidationError("subscriber_service cannot be null")
- if (self.subscriber_tenant or self.subscriber_user):
- raise XOSValidationError("subscriber_tenant and subscriber_user must be null")
-
- super(CoarseTenant,self).save()
-
-class Subscriber(TenantRoot):
- """ Intermediate class for TenantRoots that are to be Subscribers """
-
- class Meta:
- proxy = True
-
- KIND = "Subscriber"
-
-class Provider(TenantRoot):
- """ Intermediate class for TenantRoots that are to be Providers """
-
- class Meta:
- proxy = True
-
- KIND = "Provider"
-
-class TenantAttribute(PlCoreBase):
- name = models.CharField(help_text="Attribute Name", max_length=128)
- value = models.TextField(help_text="Attribute Value")
- tenant = models.ForeignKey(Tenant, related_name='tenantattributes', help_text="The Tenant this attribute is associated with")
-
-class TenantRootRole(PlCoreBase):
- ROLE_CHOICES = (('admin','Admin'), ('access','Access'))
-
- role = StrippedCharField(choices=ROLE_CHOICES, unique=True, max_length=30)
-
- def __unicode__(self): return u'%s' % (self.role)
-
-class TenantRootPrivilege(PlCoreBase):
- user = models.ForeignKey('User', related_name="tenant_root_privileges")
- tenant_root = models.ForeignKey('TenantRoot', related_name="tenant_root_privileges")
- role = models.ForeignKey('TenantRootRole', related_name="tenant_root_privileges")
-
- class Meta:
- unique_together = ('user', 'tenant_root', 'role')
-
- def __unicode__(self): return u'%s %s %s' % (self.tenant_root, self.user, self.role)
-
- def save(self, *args, **kwds):
- if not self.user.is_active:
- raise PermissionDenied, "Cannot modify role(s) of a disabled user"
- super(TenantRootPrivilege, self).save(*args, **kwds)
-
- def can_update(self, user):
- return user.can_update_tenant_root_privilege(self)
-
- @classmethod
- def select_by_user(cls, user):
- if user.is_admin:
- return cls.objects.all()
- else:
- # User can see his own privilege
- trp_ids = [trp.id for trp in cls.objects.filter(user=user)]
-
- # A slice admin can see the SlicePrivileges for his Slice
- for priv in cls.objects.filter(user=user, role__role="admin"):
- trp_ids.extend( [trp.id for trp in cls.objects.filter(tenant_root=priv.tenant_root)] )
-
- return cls.objects.filter(id__in=trp_ids)
-
-
diff --git a/xos/synchronizers/helloworldservice_complete/helloworldservice_complete_private_key b/xos/synchronizers/helloworldservice_complete/helloworldservice_complete_private_key
deleted file mode 100644
index 427bf89..0000000
--- a/xos/synchronizers/helloworldservice_complete/helloworldservice_complete_private_key
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEowIBAAKCAQEAr7ezZV9wU4O9F/fMOsG9Zm0kIbjLGNsL/MJXuGlqw0SRRbkx
-YipvtP+pJmCzkHmnUFCE1BMVHcnCJRfhcwabF08c+t7H5mj6GPo/QKR7seLr2IKM
-jfG3846u3k2Oo8wNfy8HJ5g+bZFhBk+Z0scYkqQFDL0IW1JtWkl+Yu2VcZsiSJCq
-j+7XjjM1QoiDCyx3p6z/jHi5K1XIFxvQaeBddm3ICau2x6ezd5wnYjPaCANuwisJ
-KgmwSvX/lr8NZkjpETME+ghMPDq7KvXFZL9MCmv8IFe2fKVzIDqHkbgcZ/W0maed
-A/2y9p55B+SQmN3PXW1EhOXHH0SNP31ZS+N5dwIDAQABAoIBAGrudaN5ItgP0WDm
-kUgoYmQUgupqlF2531+fvNYigK/36BfwDRdaD8Sr2HncWynOfn0nos2UF0ObZiRA
-lhfzqynSISahsDCNLbVJhHiIICYum6uUNoii0njLGat6sxUGtifxrH7x7Pusfsji
-ZA+azV9fpRsNZip8zMMm+lyljE4nQbVZv09aExq0Mh2n+mH6OWS43mZ1N7TxWtgd
-MmtoLBAPoMiqXlCxZOcznptVR9hY7CSG0uOQUSui44DOXOyqEI7z57eoYM1hWmng
-Ery07Qr9BbEVl4epLaEyLIGXcUsUbcQz3kbXCg0NbXHiFtr0kdIVwJXHg5M9MAsf
-fDaxJZECgYEA29oLRkI+0L9rSErteaf4spo4FJAARWbsVM3uj1gKEClUUHklI97A
-UVTcOFC7Drr/rwqfHy8fQq9ASIMDnj+FulYQSMna3SLdkgsbNSDuesbG4wp6+chQ
-uSzZP1YtaYrjMxz6s8s/zmFkqAssyOuscsOhgF16945hc63GLro4GwUCgYEAzJv4
-eqWrY6Il7p/Oir4AJxbdfO50Oj1dECsFNZ1KhtA280FslW6Za+oUfD1+Xv13XRZP
-O62IvXXJT67NOq0rKVUixPJJFXQqSRU1QljLgREM6dqr4pS4NirkaPvGwuuej8I4
-dKLqVPcNxDSAXfMwR0KQu7+IVEdvzrw5hrsgg0sCgYB21YUClQwfCViT2uxBtelX
-oMRvWObMnLVhoW4xTQUjdzN7y/+nQ9/wFk5yojB55doOY09fK7lZ8iBtEWQDRZKj
-BaIHthP3M8FQD3DFZueAtbELR77xBLWdYgCLm6kwQ0JLfn6EcHgstbgSnPe4Iqsz
-3UqOd/jflrZWMLfOyhlJgQKBgCGCRa5oZWo6yvWKjHviZAoCz6E/OB+1nwEf2omO
-Sf9MKEOsakkKxOuMeXBjbcfGwP6owa8nW2aT3LVFDm1WoOPzAm+4sklmLeqsI33L
-JwDrNu8xlcbUzlpoqeGbolCX3+7xQuevKqthjoqcgo1gX368IxHsazpKPMBhyRYM
-nWWDAoGBANOG/59508uQqZvWtByA092ARXjEUYLgNTwDo1N4kM5zgV8NETtv7qs/
-P/ze2e88sI230jzbU3iq2OGjk6S1c6LHVG9QohZPwtnwTCeKRhSG+CYHMcXSLK7D
-xf4C0kAbPsaG5F0w3vbGTTF4uuGXyijOQSXMhiG4756VaMEGvb9k
------END RSA PRIVATE KEY-----
diff --git a/xos/synchronizers/helloworldservice_complete/helloworldservice_private_key b/xos/synchronizers/helloworldservice_complete/helloworldservice_private_key
deleted file mode 100644
index 427bf89..0000000
--- a/xos/synchronizers/helloworldservice_complete/helloworldservice_private_key
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEowIBAAKCAQEAr7ezZV9wU4O9F/fMOsG9Zm0kIbjLGNsL/MJXuGlqw0SRRbkx
-YipvtP+pJmCzkHmnUFCE1BMVHcnCJRfhcwabF08c+t7H5mj6GPo/QKR7seLr2IKM
-jfG3846u3k2Oo8wNfy8HJ5g+bZFhBk+Z0scYkqQFDL0IW1JtWkl+Yu2VcZsiSJCq
-j+7XjjM1QoiDCyx3p6z/jHi5K1XIFxvQaeBddm3ICau2x6ezd5wnYjPaCANuwisJ
-KgmwSvX/lr8NZkjpETME+ghMPDq7KvXFZL9MCmv8IFe2fKVzIDqHkbgcZ/W0maed
-A/2y9p55B+SQmN3PXW1EhOXHH0SNP31ZS+N5dwIDAQABAoIBAGrudaN5ItgP0WDm
-kUgoYmQUgupqlF2531+fvNYigK/36BfwDRdaD8Sr2HncWynOfn0nos2UF0ObZiRA
-lhfzqynSISahsDCNLbVJhHiIICYum6uUNoii0njLGat6sxUGtifxrH7x7Pusfsji
-ZA+azV9fpRsNZip8zMMm+lyljE4nQbVZv09aExq0Mh2n+mH6OWS43mZ1N7TxWtgd
-MmtoLBAPoMiqXlCxZOcznptVR9hY7CSG0uOQUSui44DOXOyqEI7z57eoYM1hWmng
-Ery07Qr9BbEVl4epLaEyLIGXcUsUbcQz3kbXCg0NbXHiFtr0kdIVwJXHg5M9MAsf
-fDaxJZECgYEA29oLRkI+0L9rSErteaf4spo4FJAARWbsVM3uj1gKEClUUHklI97A
-UVTcOFC7Drr/rwqfHy8fQq9ASIMDnj+FulYQSMna3SLdkgsbNSDuesbG4wp6+chQ
-uSzZP1YtaYrjMxz6s8s/zmFkqAssyOuscsOhgF16945hc63GLro4GwUCgYEAzJv4
-eqWrY6Il7p/Oir4AJxbdfO50Oj1dECsFNZ1KhtA280FslW6Za+oUfD1+Xv13XRZP
-O62IvXXJT67NOq0rKVUixPJJFXQqSRU1QljLgREM6dqr4pS4NirkaPvGwuuej8I4
-dKLqVPcNxDSAXfMwR0KQu7+IVEdvzrw5hrsgg0sCgYB21YUClQwfCViT2uxBtelX
-oMRvWObMnLVhoW4xTQUjdzN7y/+nQ9/wFk5yojB55doOY09fK7lZ8iBtEWQDRZKj
-BaIHthP3M8FQD3DFZueAtbELR77xBLWdYgCLm6kwQ0JLfn6EcHgstbgSnPe4Iqsz
-3UqOd/jflrZWMLfOyhlJgQKBgCGCRa5oZWo6yvWKjHviZAoCz6E/OB+1nwEf2omO
-Sf9MKEOsakkKxOuMeXBjbcfGwP6owa8nW2aT3LVFDm1WoOPzAm+4sklmLeqsI33L
-JwDrNu8xlcbUzlpoqeGbolCX3+7xQuevKqthjoqcgo1gX368IxHsazpKPMBhyRYM
-nWWDAoGBANOG/59508uQqZvWtByA092ARXjEUYLgNTwDo1N4kM5zgV8NETtv7qs/
-P/ze2e88sI230jzbU3iq2OGjk6S1c6LHVG9QohZPwtnwTCeKRhSG+CYHMcXSLK7D
-xf4C0kAbPsaG5F0w3vbGTTF4uuGXyijOQSXMhiG4756VaMEGvb9k
------END RSA PRIVATE KEY-----
diff --git a/xos/synchronizers/vbbu/steps/sync_vbbu.yaml.old b/xos/synchronizers/vbbu/steps/sync_vbbu.yaml.old
deleted file mode 100644
index 5c46908..0000000
--- a/xos/synchronizers/vbbu/steps/sync_vbbu.yaml.old
+++ /dev/null
@@ -1,23 +0,0 @@
----
-- hosts: {{ instance_name }}
- gather_facts: False
- connection: ssh
- user: ubuntu
- sudo: yes
- tasks:
-
- - name: write message
- shell: echo "{{ display_message }}" > /var/tmp/index.html
-
- - name: setup s1u interface config
- shell: ./start_3gpp_int.sh eth1 {{ s1u_tag }} {{ s1u_ip }}/24
-
- - name: setup s1mme interface config
- shell: ./start_3gpp_int.sh eth2 {{ s1mme_tag }} {{ s1mme_ip }}/24
-
- - name: setup rru interface config
- shell: ./start_3gpp_int.sh eth3 {{ rru_tag }} {{ rru_ip }}/24
-
-# - name: startup bbu
-# shell: /bin/sh -c /usr/sbin/start_bbu 0
-
diff --git a/xos/xos_configuration/xos_common_config b/xos/xos_configuration/xos_common_config
index b4c371d..2855816 100755
--- a/xos/xos_configuration/xos_common_config
+++ b/xos/xos_configuration/xos_common_config
@@ -37,15 +37,9 @@
images_directory=/opt/xos/images
dependency_graph=/opt/xos/model-deps
logfile=/var/log/xos_backend.log
-proxy_ssh=True
-proxy_ssh_key=/root/setup/node_key
-proxy_ssh_user=root
[gui]
disable_minidashboard=True
branding_name=Open Cloud
branding_icon=/static/logo.png
branding_favicon=/static/favicon.png
-
-[networking]
-use_vtn=True