Browse Source

Fixed devstack for AWS

- Moved common functions for clouds in separate file
- Added boto3 dependency in requirements file

Change-Id: I9c93692eed47078c56eb91a247af5729cf56c84c
changes/04/639004/7
Pratik Shah 3 years ago
parent
commit
e7ffe3d333
  1. 47
      devstack/lib/common_functions
  2. 56
      devstack/lib/omni_aws
  3. 51
      devstack/lib/omni_gce
  4. 9
      devstack/plugin.sh
  5. 8
      devstack/settings
  6. 1
      requirements.txt

47
devstack/lib/common_functions

@ -0,0 +1,47 @@
#!/bin/bash
# Save trace setting
XTRACE=$(set +o | grep xtrace)
set +o xtrace
OMNI_DATA_DIR="/opt/stack/omni"
DIST_PACKAGES="/usr/local/lib/python2.7/dist-packages"
# Functions
# ------------
function copy_omni_files {
# Glance files
sudo cp -R $OMNI_DATA_DIR/glance/glance_store/_drivers/ /usr/local/lib/python2.7/dist-packages/glance_store/
# Cinder files
sudo cp -R $OMNI_DATA_DIR/cinder/volume/drivers/ /opt/stack/cinder/cinder/volume/
# Nova files
sudo cp -R $OMNI_DATA_DIR/nova/virt/ /opt/stack/nova/nova/
# Neutron files
sudo cp -R $OMNI_DATA_DIR/neutron/neutron/common/ /opt/stack/neutron/neutron/
sudo cp -R $OMNI_DATA_DIR/neutron/neutron/db/ /opt/stack/neutron/neutron/
sudo cp -R $OMNI_DATA_DIR/neutron/neutron/extensions/ /opt/stack/neutron/neutron/
sudo cp -R $OMNI_DATA_DIR/neutron/neutron/plugins/ml2/drivers/ /opt/stack/neutron/neutron/plugins/ml2/
sudo cp -R $OMNI_DATA_DIR/neutron/neutron/plugins/ml2/extensions/ /opt/stack/neutron/neutron/plugins/ml2/
sudo cp -R $OMNI_DATA_DIR/neutron/neutron/services/l3_router/ /opt/stack/neutron/neutron/services/
sudo neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head
# Credential manager client files
if [ "$OMNI_PROVIDER" == "aws" ]; then
sudo cp -R $OMNI_DATA_DIR/credsmgrclient $DIST_PACKAGES/
fi
}
function restart_services {
sudo systemctl restart devstack@g-api.service devstack@g-reg.service devstack@c-sch.service devstack@c-vol.service devstack@c-api.service devstack@n-cpu.service devstack@q-svc.service
}
# Restore xtrace
$XTRACE
## Local variables:
## mode: shell-script
## End:

56
devstack/lib/omni_aws

@ -4,36 +4,38 @@
XTRACE=$(set +o | grep xtrace)
set +o xtrace
OMNI_DATA_DIR="/opt/stack/omni"
DIST_PACKAGES="/usr/local/lib/python2.7/dist-packages"
ENTRY_POINT="$DIST_PACKAGES/glance_store-*.dist-info/entry_points.txt"
NEUTRON_ENTRY_POINT="/opt/stack/neutron/neutron.egg-info/entry_points.txt"
ML2_CONF="/etc/neutron/plugins/ml2/ml2_conf.ini"
# Functions
# ------------
function set_aws_keys_and_region {
local conf_file=$1
iniset $conf_file AWS secret_key ${AWS_SECRET_KEY}
iniset $conf_file AWS access_key ${AWS_ACCESS_KEY}
iniset $conf_file AWS region_name ${AWS_REGION_NAME}
}
function configure_glance {
iniset $GLANCE_API_CONF AWS secret_key ${SECRET_KEY}
iniset $GLANCE_API_CONF AWS access_key ${ACCESS_KEY}
iniset $GLANCE_API_CONF AWS region_name ${REGION_NAME}
set_aws_keys_and_region $GLANCE_API_CONF
iniset $GLANCE_API_CONF DEFAULT show_multiple_locations True
iniset $GLANCE_API_CONF glance_store default_store aws
iniset $GLANCE_API_CONF glance_store stores aws
sudo crudini --set $ENTRY_POINT glance_store.drivers glance.store.aws.Store glance_store._drivers.aws:Store
sudo crudini --set $ENTRY_POINT glance_store.drivers aws glance_store._drivers.aws:Store
value=$(sed -n "/, 'aws'/p" $DIST_PACKAGES/glance_store/backend.py)
if [[ $value == "" ]]; then
sudo sed -i -e "s/, 'vsphere'/, 'vsphere', 'aws'/g" $DIST_PACKAGES/glance_store/backend.py
fi
sudo cp $OMNI_DATA_DIR/glance/glance_store/_drivers/aws.py /usr/local/lib/python2.7/dist-packages/glance_store/_drivers/
sudo systemctl restart devstack@g-api.service devstack@g-reg.service
}
function configure_cinder {
iniset $CINDER_CONF AWS secret_key ${SECRET_KEY}
iniset $CINDER_CONF AWS access_key ${ACCESS_KEY}
iniset $CINDER_CONF AWS region_name ${REGION_NAME}
iniset $CINDER_CONF AWS az ${AVAILABILITY_ZONE}
set_aws_keys_and_region $CINDER_CONF
iniset $CINDER_CONF AWS az ${AWS_AVAILABILITY_ZONE}
iniset $CINDER_CONF AWS volume_driver ${AWS_CINDER_DRIVER}
iniset $CINDER_CONF DEFAULT enable_force_upload ${ENABLE_FORCE_UPLOAD}
iniset $CINDER_CONF DEFAULT enabled_backends AWS
@ -41,50 +43,34 @@ function configure_cinder {
iniset $CINDER_CONF DEFAULT os_privileged_user_name ${CINDER_USER}
iniset $CINDER_CONF DEFAULT default_volume_type AWS
iniset $CINDER_CONF DEFAULT os_region_name AWS
sudo cp -R $OMNI_DATA_DIR/cinder/volume/drivers/aws/ /opt/stack/cinder/cinder/volume/drivers/
sudo systemctl restart devstack@c-sch.service devstack@c-vol.service devstack@c-api.service
}
function configure_nova {
iniset $NOVA_CONF AWS secret_key ${SECRET_KEY}
iniset $NOVA_CONF AWS access_key ${ACCESS_KEY}
iniset $NOVA_CONF AWS region_name ${REGION_NAME}
set_aws_keys_and_region $NOVA_CONF
iniset $NOVA_CONF DEFAULT compute_driver ${AWS_COMPUTE_DRIVER}
iniset $NOVA_CONF DEFAULT glance_api_insecure True
iniset $NOVA_CONF DEFAULT cinder_api_insecure True
iniset $NOVA_CONF DEFAULT vnc_enabled True
iniset $NOVA_CONF DEFAULT osapi_compute_extension ${COMPUTE_EXTENSION}
iniset $NOVA_CONF DEFAULT force_dhcp_release True
sudo cp -R $OMNI_DATA_DIR/nova/virt/ec2/ /opt/stack/nova/nova/virt/
sudo systemctl restart devstack@n-cpu.service
}
function configure_neutron {
iniset $NEUTRON_CONF AWS secret_key ${SECRET_KEY}
iniset $NEUTRON_CONF AWS access_key ${ACCESS_KEY}
iniset $NEUTRON_CONF AWS region_name ${REGION_NAME}
iniset $NEUTRON_CONF AWS az ${AVAILABILITY_ZONE}
set_aws_keys_and_region $NEUTRON_CONF
iniset $NEUTRON_CONF AWS az ${AWS_AVAILABILITY_ZONE}
iniset $NEUTRON_CONF DEFAULT core_plugin ${CORE_PLUGIN}
iniset $NEUTRON_CONF DEFAULT service_plugins ${AWS_SERVICE_PLUGIN}
iniset $NEUTRON_CONF nova region_name AWS
sudo rm -f /etc/neutron/plugins/ml2/ml2_conf.ini
touch /etc/neutron/plugins/ml2/ml2_conf.ini
sudo chown stack /etc/neutron/plugins/ml2/ml2_conf.ini
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers ${ML2_DRIVERS}
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types ${ML2_TENANT}
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks "*"
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vlan network_vlan_ranges ${ML2_VLAN_TYPE}
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers aws
iniset $ML2_CONF ml2 type_drivers ${ML2_DRIVERS}
iniset $ML2_CONF ml2 tenant_network_types ${ML2_TENANT}
iniset $ML2_CONF ml2_type_flat flat_networks "*"
iniset $ML2_CONF ml2_type_vlan network_vlan_ranges ${ML2_VLAN_TYPE}
iniset $ML2_CONF ml2 mechanism_drivers aws
iniset $ML2_CONF ml2 extension_drivers subnet_az
sudo crudini --set $NEUTRON_ENTRY_POINT neutron.ml2.mechanism_drivers aws neutron.plugins.ml2.drivers.aws.mechanism_aws:AwsMechanismDriver
sudo crudini --set $NEUTRON_ENTRY_POINT neutron.service_plugins aws_router neutron.services.l3_router.aws_router_plugin:AwsRouterPlugin
sudo cp -R $OMNI_DATA_DIR/neutron/neutron/plugins/ml2/drivers/aws/ /opt/stack/neutron/neutron/plugins/ml2/drivers/
sudo cp $OMNI_DATA_DIR/neutron/neutron/services/l3_router/aws_router_plugin.py /opt/stack/neutron/neutron/services/l3_router/
sudo cp $OMNI_DATA_DIR/neutron/neutron/common/* /opt/stack/neutron/neutron/common/
sudo systemctl restart devstack@q-svc.service
}
# Restore xtrace

51
devstack/lib/omni_gce

@ -4,36 +4,38 @@
XTRACE=$(set +o | grep xtrace)
set +o xtrace
OMNI_DATA_DIR="/opt/stack/omni"
DIST_PACKAGES="/usr/local/lib/python2.7/dist-packages"
ENTRY_POINT="$DIST_PACKAGES/glance_store-*.dist-info/entry_points.txt"
NEUTRON_ENTRY_POINT="/opt/stack/neutron/neutron.egg-info/entry_points.txt"
ML2_CONF="/etc/neutron/plugins/ml2/ml2_conf.ini"
# Functions
# ------------
function set_gce_details {
local conf_file=$1
iniset $conf_file GCE zone ${ZONE}
iniset $conf_file GCE project_id ${PROJECT}
iniset $conf_file GCE service_key_path ${SERVICE_KEY_PATH}
}
function configure_glance {
iniset $GLANCE_API_CONF GCE zone ${ZONE}
iniset $GLANCE_API_CONF GCE project_id ${PROJECT}
iniset $GLANCE_API_CONF GCE service_key_path ${SERVICE_KEY_PATH}
set_gce_details $GLANCE_API_CONF
iniset $GLANCE_API_CONF DEFAULT show_multiple_locations True
iniset $GLANCE_API_CONF glance_store default_store gce
iniset $GLANCE_API_CONF glance_store stores gce
sudo crudini --set $ENTRY_POINT glance_store.drivers glance.store.gce.Store glance_store._drivers.gce:Store
sudo crudini --set $ENTRY_POINT glance_store.drivers gce glance_store._drivers.gce:Store
value=$(sed -n "/, 'gce'/p" $DIST_PACKAGES/glance_store/backend.py)
if [[ $value == "" ]]; then
sudo sed -i -e "s/, 'vsphere'/, 'vsphere', 'gce'/g" $DIST_PACKAGES/glance_store/backend.py
fi
sudo cp $OMNI_DATA_DIR/glance/gce/gceutils.py /usr/local/lib/python2.7/dist-packages/glance_store/_drivers/
sudo cp $OMNI_DATA_DIR/glance/glance_store/_drivers/gce.py /usr/local/lib/python2.7/dist-packages/glance_store/_drivers/
sudo systemctl restart devstack@g-api.service devstack@g-reg.service
}
function configure_cinder {
iniset $CINDER_CONF GCE zone ${ZONE}
iniset $CINDER_CONF GCE project_id ${PROJECT}
set_gce_details $CINDER_CONF
iniset $CINDER_CONF GCE region ${REGION}
iniset $CINDER_CONF GCE service_key_path ${SERVICE_KEY_PATH}
iniset $CINDER_CONF GCE gce_pool_name gce
iniset $CINDER_CONF GCE gce_free_capacity_gb ${CAPACITY}
iniset $CINDER_CONF gce_total_capacity_gb ${CAPACITY}
@ -44,48 +46,33 @@ function configure_cinder {
iniset $CINDER_CONF DEFAULT os_privileged_user_name ${CINDER_USER}
iniset $CINDER_CONF DEFAULT default_volume_type GCE
iniset $CINDER_CONF DEFAULT os_region_name GCE
sudo cp -R $OMNI_DATA_DIR/cinder/volume/drivers/gce/ /opt/stack/cinder/cinder/volume/drivers/
sudo systemctl restart devstack@c-sch.service devstack@c-vol.service devstack@c-api.service
}
function configure_nova {
iniset $NOVA_CONF GCE zone ${ZONE}
iniset $NOVA_CONF GCE project_id ${PROJECT}
iniset $NOVA_CONF GCE service_key_path ${SERVICE_KEY_PATH}
set_gce_details $NOVA_CONF
iniset $NOVA_CONF DEFAULT compute_driver ${GCE_COMPUTE_DRIVER}
iniset $NOVA_CONF DEFAULT glance_api_insecure True
iniset $NOVA_CONF DEFAULT cinder_api_insecure True
iniset $NOVA_CONF DEFAULT vnc_enabled True
iniset $NOVA_CONF DEFAULT osapi_compute_extension ${COMPUTE_EXTENSION}
iniset $NOVA_CONF DEFAULT force_dhcp_release True
sudo cp -R $OMNI_DATA_DIR/nova/virt/gce/ /opt/stack/nova/nova/virt/
sudo systemctl restart devstack@n-cpu.service
}
function configure_neutron {
iniset $NEUTRON_CONF GCE zone ${ZONE}
iniset $NEUTRON_CONF GCE project_id ${PROJECT}
set_gce_details $NEUTRON_CONF
iniset $NEUTRON_CONF GCE region ${REGION}
iniset $NEUTRON_CONF GCE service_key_path ${SERVICE_KEY_PATH}
iniset $NEUTRON_CONF DEFAULT core_plugin ${CORE_PLUGIN}
iniset $NEUTRON_CONF DEFAULT service_plugins ${GCE_SERVICE_PLUGIN}
iniset $NEUTRON_CONF nova region_name GCE
sudo rm -f /etc/neutron/plugins/ml2/ml2_conf.ini
touch /etc/neutron/plugins/ml2/ml2_conf.ini
sudo chown stack /etc/neutron/plugins/ml2/ml2_conf.ini
iniset $ML2_CONF ml2 type_drivers ${ML2_DRIVERS}
iniset $ML2_CONF ml2 tenant_network_types ${ML2_TENANT}
iniset $ML2_CONF ml2_type_flat flat_networks "*"
iniset $ML2_CONF ml2_type_vlan network_vlan_ranges ${ML2_VLAN_TYPE}
iniset $ML2_CONF ml2 mechanism_drivers gce
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers ${ML2_DRIVERS}
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types ${ML2_TENANT}
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks "*"
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vlan network_vlan_ranges ${ML2_VLAN_TYPE}
iniset /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers gce
sudo crudini --set $NEUTRON_ENTRY_POINT neutron.ml2.mechanism_drivers gce neutron.plugins.ml2.drivers.gce.mech_gce:GceMechanismDriver
sudo crudini --set $NEUTRON_ENTRY_POINT neutron.service_plugins gce_router neutron.services.l3_router.gce_router_plugin:GceRouterPlugin
sudo cp -R $OMNI_DATA_DIR/neutron/neutron/plugins/ml2/drivers/gce/ /opt/stack/neutron/neutron/plugins/ml2/drivers/
sudo cp $OMNI_DATA_DIR/neutron/neutron/services/l3_router/gce_router_plugin.py /opt/stack/neutron/neutron/services/l3_router/
sudo cp $OMNI_DATA_DIR/neutron/neutron/common/* /opt/stack/neutron/neutron/common/
sudo systemctl restart devstack@q-svc.service
}
# Restore xtrace

9
devstack/plugin.sh

@ -3,19 +3,22 @@ set -x
cp /opt/stack/omni/devstack/lib/* $TOP_DIR/lib/
sudo apt-get install crudini -y
sudo pip install -r /opt/stack/omni/omni-requirements.txt
sudo pip install -r /opt/stack/omni/requirements.txt
if [[ "$1" == "stack" && "$2" == "pre-install" ]] && [ "$OMNI_PROVIDER" != "" ]; then
if [[ "$1" == "stack" && "$2" == "pre-install" ]]; then
if [ "$OMNI_PROVIDER" != "gce" ] && [ "$OMNI_PROVIDER" != "aws" ]; then
echo "$OMNI_PROVIDER is not supported"
exit 1
fi
fi
if [[ "$1" == "stack" && "$2" == "extra" ]] && [ "$OMNI_PROVIDER" != "" ]; then
if [[ "$1" == "stack" && "$2" == "extra" ]]; then
source $TOP_DIR/lib/omni_$OMNI_PROVIDER
source $TOP_DIR/lib/common_functions
configure_glance
configure_cinder
configure_nova
configure_neutron
copy_omni_files
restart_services
fi

8
devstack/settings

@ -19,10 +19,10 @@ GCE_COMPUTE_DRIVER=${GCE_COMPUTE_DRIVER:-gce.GCEDriver}
GCE_SERVICE_PLUGIN=${GCE_SERVICE_PLUGIN:-neutron.services.l3_router.gce_router_plugin.GceRouterPlugin}
# AWS specific variables
SECRET_KEY=${SECRET_KEY:-}
ACCESS_KEY=${ACCESS_KEY:-}
REGION_NAME=${REGION_NAME:-us-east-2}
AVAILABILITY_ZONE=${AVAILABILITY_ZONE:-us-east-2a}
AWS_SECRET_KEY=${AWS_SECRET_KEY:-}
AWS_ACCESS_KEY=${AWS_ACCESS_KEY:-}
AWS_REGION_NAME=${AWS_REGION_NAME:-us-east-2}
AWS_AVAILABILITY_ZONE=${AWS_AVAILABILITY_ZONE:-us-east-2a}
AWS_CINDER_DRIVER=${AWS_CINDER_DRIVER:-cinder.volume.drivers.aws.ebs.EBSDriver}
AWS_COMPUTE_DRIVER=${AWS_COMPUTE_DRIVER:-ec2.EC2Driver}
AWS_SERVICE_PLUGIN=${AWS_SERVICE_PLUGIN:-neutron.services.l3_router.aws_router_plugin.AwsRouterPlugin}

1
requirements.txt

@ -4,3 +4,4 @@ azure-mgmt-resource==1.1.0
azure-mgmt-storage==1.4.0
boto>=2.32.1 # MIT
ipaddr
boto3==1.7.84
Loading…
Cancel
Save