add example basic resource generation scripts
Change-Id: Id7eac8a81d2e264727ce24c655808758446c1da2 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
419e44385c
commit
bf71876abf
57
scripts/generate-flavors.sh
Normal file
57
scripts/generate-flavors.sh
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2017, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
source openrc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Generate a set of typical flavors
|
||||||
|
for flavor in micro tiny mini small medium large xlarge heavy; do
|
||||||
|
NAME="m1.${flavor}"
|
||||||
|
ID="${ID:-0}"
|
||||||
|
RAM="${RAM:-256}"
|
||||||
|
DISK="${DISK:-1}"
|
||||||
|
VCPU="${VCPU:-1}"
|
||||||
|
SWAP="${SWAP:-0}"
|
||||||
|
EPHEMERAL="${EPHEMERAL:-0}"
|
||||||
|
nova flavor-delete "$ID" > /dev/null || echo "No Flavor with ID: [ $ID ] found to clean up"
|
||||||
|
nova flavor-create "$NAME" "$ID" "$RAM" "$DISK" "$VCPU" --swap "$SWAP" --is-public true --ephemeral "$EPHEMERAL" --rxtx-factor 1
|
||||||
|
let ID=ID+1
|
||||||
|
let RAM=RAM*2
|
||||||
|
if [ "$ID" -gt 5 ];then
|
||||||
|
let VCPU=VCPU*2
|
||||||
|
let DISK=DISK*2
|
||||||
|
let EPHEMERAL=256
|
||||||
|
let SWAP=4
|
||||||
|
elif [ "$ID" -gt 4 ];then
|
||||||
|
let VCPU=VCPU*2
|
||||||
|
let DISK=DISK*4+"$DISK"
|
||||||
|
let EPHEMERAL="$DISK/2"
|
||||||
|
let SWAP=4
|
||||||
|
elif [ "$ID" -gt 3 ];then
|
||||||
|
let VCPU=VCPU*2
|
||||||
|
let DISK=DISK*4+"$DISK"
|
||||||
|
let EPHEMERAL="$DISK/3"
|
||||||
|
let SWAP=4
|
||||||
|
elif [ "$ID" -gt 2 ];then
|
||||||
|
let VCPU=VCPU+"$VCPU/2"
|
||||||
|
let DISK=DISK*4
|
||||||
|
let EPHEMERAL="$DISK/3"
|
||||||
|
let SWAP=4
|
||||||
|
elif [ "$ID" -gt 1 ];then
|
||||||
|
let VCPU=VCPU+1
|
||||||
|
let DISK=DISK*2+"$DISK"
|
||||||
|
fi
|
||||||
|
done
|
51
scripts/generate-images.sh
Normal file
51
scripts/generate-images.sh
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2017, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
source openrc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Image upload function.
|
||||||
|
# Download an image, upload into glance, remove downloaded file.
|
||||||
|
function image_upload {
|
||||||
|
IMAGE_URL="${1}"
|
||||||
|
IMAGE_FILE="$(basename ${IMAGE_URL})"
|
||||||
|
IMAGE_NAME="${2}"
|
||||||
|
if [[ ! -f "${IMAGE_FILE}" ]]; then
|
||||||
|
wget "${IMAGE_URL}" -O "${IMAGE_FILE}" || (rm "${IMAGE_FILE}" && exit 1)
|
||||||
|
else
|
||||||
|
echo "file found ${IMAGE_FILE}"
|
||||||
|
fi
|
||||||
|
if [[ "$?" == 0 ]]; then
|
||||||
|
glance image-create --name "${IMAGE_NAME}" \
|
||||||
|
--container-format bare \
|
||||||
|
--disk-format qcow2 \
|
||||||
|
--visibility public \
|
||||||
|
--progress \
|
||||||
|
--file "${IMAGE_FILE}" && rm "${IMAGE_FILE}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Create some default images
|
||||||
|
# USAGE: image_upload $URL $NAME
|
||||||
|
image_upload http://uec-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img ubuntu-14.04-amd64
|
||||||
|
image_upload http://uec-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img ubuntu-16.04-amd64
|
||||||
|
image_upload http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 centos-7-amd64
|
||||||
|
image_upload http://cdimage.debian.org/cdimage/openstack/current/debian-9.2.0-openstack-amd64.qcow2 debian-9.2.0-amd64
|
||||||
|
image_upload http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img cirros-0.3.4-amd64
|
||||||
|
image_upload http://dfw.mirror.rackspace.com/fedora/releases/26/CloudImages/x86_64/images/Fedora-Cloud-Base-26-1.5.x86_64.qcow2 fedora-26-amd64
|
||||||
|
image_upload http://download.opensuse.org/repositories/Cloud:/Images:/Leap_42.3/images/openSUSE-Leap-42.3-OpenStack.x86_64.qcow2 opensuse-leap-42.3-amd64
|
77
scripts/generate-networks.sh
Normal file
77
scripts/generate-networks.sh
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2017, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
source openrc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Create a basic flat network
|
||||||
|
neutron net-create GATEWAY_NET \
|
||||||
|
--shared \
|
||||||
|
--router:external=True \
|
||||||
|
--provider:physical_network=flat \
|
||||||
|
--provider:network_type=flat
|
||||||
|
|
||||||
|
neutron subnet-create GATEWAY_NET 172.16.24.0/22 \
|
||||||
|
--name GATEWAY_NET_SUBNET \
|
||||||
|
--gateway 172.16.24.2 \
|
||||||
|
--allocation-pool start=172.16.25.201,end=172.16.25.255 \
|
||||||
|
--dns-nameservers list=true 172.16.24.2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Create a basic VXLAN network
|
||||||
|
neutron net-create PRIVATE_NET \
|
||||||
|
--shared \
|
||||||
|
--router:external=True \
|
||||||
|
--provider:network_type=vxlan \
|
||||||
|
--provider:segmentation_id 101
|
||||||
|
|
||||||
|
neutron subnet-create PRIVATE_NET 192.168.0.0/24 \
|
||||||
|
--name PRIVATE_NET_SUBNET
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Create a neutron router and wire it up to the GATEWAY_NET and PRIVATE_NET_SUBNET
|
||||||
|
ROUTER_ID="$(neutron router-create GATEWAY_NET_ROUTER | grep -w id | awk '{print $4}')"
|
||||||
|
neutron router-gateway-set \
|
||||||
|
"${ROUTER_ID}" \
|
||||||
|
"$(neutron net-list | awk '/GATEWAY_NET/ {print $2}')"
|
||||||
|
|
||||||
|
neutron router-interface-add \
|
||||||
|
"${ROUTER_ID}" \
|
||||||
|
"$(neutron subnet-list | awk '/PRIVATE_NET_SUBNET/ {print $2}')"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Neutron security group setup
|
||||||
|
for id in "$(neutron security-group-list -f yaml | awk '/- id\:/ {print $3}')"; do
|
||||||
|
# Allow ICMP
|
||||||
|
neutron security-group-rule-create --protocol icmp \
|
||||||
|
--direction ingress \
|
||||||
|
"$id" || true
|
||||||
|
# Allow all TCP
|
||||||
|
neutron security-group-rule-create --protocol tcp \
|
||||||
|
--port-range-min 1 \
|
||||||
|
--port-range-max 65535 \
|
||||||
|
--direction ingress \
|
||||||
|
"$id" || true
|
||||||
|
# Allow all UDP
|
||||||
|
neutron security-group-rule-create --protocol udp \
|
||||||
|
--port-range-min 1 \
|
||||||
|
--port-range-max 65535 -\
|
||||||
|
-direction ingress \
|
||||||
|
"$id" || true
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user