Browse Source

fixed demos for new private-cloud environment, added description and comments, added support for Ubuntu 18.04, replaced removed faafo repo with local copy

master
Sebastian Rieger 5 years ago
parent
commit
2441bb4fac
  1. 5
      demo1-getting-started.py
  2. 43
      demo2-instance-with-init-script.py
  3. 49
      demo3-microservice.py
  4. 48
      demo4-scale-out-add-worker.py
  5. 25
      demo4-scale-out-destroy.py
  6. 52
      demo4-scale-out.py

5
demo1-getting-started.py

@ -15,9 +15,10 @@ from libcloud.compute.types import Provider
group_number = 30 group_number = 30
######################################################################################################################## ########################################################################################################################
# #
# no changes necessary below this line
# no changes necessary below this line in this example
# #
######################################################################################################################## ########################################################################################################################
@ -35,7 +36,7 @@ ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
# default region # default region
region_name = 'RegionOne' region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for LDAP of DVZ, e.g., using fdaiXXXX as auth_username
# domain to use, "default" for local accounts, "hsfulda" for RZ LDAP, e.g., using fdaiXXXX as auth_username
domain_name = "default" domain_name = "default"

43
demo2-instance-with-init-script.py

@ -4,28 +4,39 @@
from libcloud.compute.providers import get_driver from libcloud.compute.providers import get_driver
from libcloud.compute.types import Provider from libcloud.compute.types import Provider
# Please use 1-25 for X in username, project etc., as coordinated in the lab sessions
# Please use 1-29 for X in the following variable to specify your group number. (will be used for the username,
# project etc., as coordinated in the lab sessions)
group_number = 30
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
# your username in OpenStack # your username in OpenStack
auth_username = 'CloudCompX'
auth_username = 'CloudComp' + str(group_number)
# your project in OpenStack # your project in OpenStack
project_name = 'CloudCompGrpX'
project_name = 'CloudComp' + str(group_number)
# A network in the project the started instance will be attached to
project_network = 'CloudComp' + str(group_number) + '-net'
# default region
region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for LDAP of DVZ, e.g., using fdaiXXXX as auth_username
domain_name = "default"
# The image to look for and use for the started instance
ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
# The public key to be used for SSH connection, please make sure, that you have the corresponding private key
#
# id_rsa.pub should look like this (standard sshd pubkey format):
# ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAw+J...F3w2mleybgT1w== user@HOSTNAME
ubuntu_image_name = "Ubuntu 14.04 - Trusty Tahr - 64-bit - Cloud Based Image"
keypair_name = 'srieger-pub'
pub_key_file = '~/.ssh/id_rsa.pub'
flavor_name = 'm1.small' flavor_name = 'm1.small'
network_name = "CloudCompGrpX-net"
keypair_name = 'srieger-pub'
pub_key_file = '~/.ssh/id_rsa.pub'
# default region
region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for RZ LDAP, e.g., using fdaiXXXX as auth_username
domain_name = "default"
def main(): def main():
@ -76,7 +87,7 @@ def main():
networks = conn.ex_list_networks() networks = conn.ex_list_networks()
network = '' network = ''
for net in networks: for net in networks:
if net.name == network_name:
if net.name == project_network:
network = net network = net
########################################################################### ###########################################################################
@ -133,7 +144,7 @@ def main():
########################################################################### ###########################################################################
userdata = '''#!/usr/bin/env bash userdata = '''#!/usr/bin/env bash
curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \
-i faafo -i messaging -r api -r worker -r demo -i faafo -i messaging -r api -r worker -r demo
''' '''
@ -202,6 +213,10 @@ def main():
print('The Fractals app will be deployed to http://{}'.format(actual_ip_address)) print('The Fractals app will be deployed to http://{}'.format(actual_ip_address))
print('You can use ssh to login to the instance using your private key. After login, you can list available '
'fractals using "faafo list". To request the generation of new fractals, you can use "faafo create". '
'You can also see other options to use the faafo example cloud service using "faafo -h".')
if __name__ == '__main__': if __name__ == '__main__':
main() main()

49
demo3-microservice.py

@ -8,29 +8,39 @@ from libcloud.compute.types import Provider
# services: nova, glance, neutron # services: nova, glance, neutron
# resources: 2 instances, 2 floating ips (1 keypair, 2 security groups) # resources: 2 instances, 2 floating ips (1 keypair, 2 security groups)
# Please use 1-25 for X in username, project etc., as coordinated in the lab sessions
# Please use 1-29 for X in the following variable to specify your group number. (will be used for the username,
# project etc., as coordinated in the lab sessions)
group_number = 30
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
# your username in OpenStack # your username in OpenStack
auth_username = 'CloudCompX'
auth_username = 'CloudComp' + str(group_number)
# your project in OpenStack # your project in OpenStack
project_name = 'CloudCompGrpX'
project_name = 'CloudComp' + str(group_number)
# A network in the project the started instance will be attached to
project_network = 'CloudComp' + str(group_number) + '-net'
# default region
region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for LDAP of DVZ, e.g., using fdaiXXXX as auth_username
domain_name = "default"
# The image to look for and use for the started instance
ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
# The public key to be used for SSH connection, please make sure, that you have the corresponding private key
#
# id_rsa.pub should look like this (standard sshd pubkey format):
# ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAw+J...F3w2mleybgT1w== user@HOSTNAME
ubuntu_image_name = "Ubuntu 14.04 - Trusty Tahr - 64-bit - Cloud Based Image"
#ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
keypair_name = 'srieger-pub'
pub_key_file = '~/.ssh/id_rsa.pub'
flavor_name = 'm1.small' flavor_name = 'm1.small'
network_name = "CloudCompGrpX-net"
keypair_name = 'srieger-pub'
pub_key_file = '~/.ssh/id_rsa.pub'
# default region
region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for RZ LDAP, e.g., using fdaiXXXX as auth_username
domain_name = "default"
def main(): def main():
@ -82,7 +92,7 @@ def main():
networks = conn.ex_list_networks() networks = conn.ex_list_networks()
network = '' network = ''
for net in networks: for net in networks:
if net.name == network_name:
if net.name == project_network:
network = net network = net
########################################################################### ###########################################################################
@ -161,14 +171,13 @@ def main():
# Thanks to Stefan Friedmann for finding this fix ;) # Thanks to Stefan Friedmann for finding this fix ;)
userdata = '''#!/usr/bin/env bash userdata = '''#!/usr/bin/env bash
curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \
-i messaging -i faafo -r api -i messaging -i faafo -r api
rabbitmqctl add_user faafo guest rabbitmqctl add_user faafo guest
rabbitmqctl set_user_tags faafo administrator rabbitmqctl set_user_tags faafo administrator
rabbitmqctl set_permissions -p / faafo ".*" ".*" ".*" rabbitmqctl set_permissions -p / faafo ".*" ".*" ".*"
''' '''
print('Starting new app-controller instance and wait until it is running...') print('Starting new app-controller instance and wait until it is running...')
instance_controller_1 = conn.create_node(name='app-controller', instance_controller_1 = conn.create_node(name='app-controller',
image=image, image=image,
@ -221,8 +230,8 @@ def main():
########################################################################### ###########################################################################
userdata = '''#!/usr/bin/env bash userdata = '''#!/usr/bin/env bash
curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
-i faafo -r worker -e 'http://%(ip_controller)s' -m 'amqp://guest:guest@%(ip_controller)s:5672/'
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \
-i faafo -r worker -e 'http://%(ip_controller)s' -m 'amqp://faafo:guest@%(ip_controller)s:5672/'
''' % {'ip_controller': ip_controller} ''' % {'ip_controller': ip_controller}
print('Starting new app-worker-1 instance and wait until it is running...') print('Starting new app-worker-1 instance and wait until it is running...')
@ -256,6 +265,10 @@ def main():
conn.ex_attach_floating_ip_to_node(instance_worker_1, unused_floating_ip) conn.ex_attach_floating_ip_to_node(instance_worker_1, unused_floating_ip)
print('The worker will be available for SSH at %s' % unused_floating_ip.ip_address) print('The worker will be available for SSH at %s' % unused_floating_ip.ip_address)
print('You can use ssh to login to the controller using your private key. After login, you can list available '
'fractals using "faafo list". To request the generation of new fractals, you can use "faafo create". '
'You can also see other options to use the faafo example cloud service using "faafo -h".')
if __name__ == '__main__': if __name__ == '__main__':
main() main()

48
demo4-scale-out-add-worker.py

@ -10,30 +10,39 @@ from libcloud.compute.types import Provider
# services: nova, glance, neutron # services: nova, glance, neutron
# resources: 2 instances (m1.small), 2 floating ips (1 keypair, 2 security groups) # resources: 2 instances (m1.small), 2 floating ips (1 keypair, 2 security groups)
# Please use 1-25 for X in username, project etc., as coordinated in the lab sessions
# Please use 1-29 for X in the following variable to specify your group number. (will be used for the username,
# project etc., as coordinated in the lab sessions)
group_number = 30
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
# your username in OpenStack # your username in OpenStack
auth_username = 'CloudCompX'
auth_username = 'CloudComp' + str(group_number)
# your project in OpenStack # your project in OpenStack
project_name = 'CloudCompGrpX'
# default region
region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for LDAP of DVZ, e.g., using fdaiXXXX as auth_username
domain_name = "default"
project_name = 'CloudComp' + str(group_number)
# A network in the project the started instance will be attached to
project_network = 'CloudComp' + str(group_number) + '-net'
ubuntu_image_name = "Ubuntu 14.04 - Trusty Tahr - 64-bit - Cloud Based Image"
#ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
flavor_name = 'm1.small'
# The image to look for and use for the started instance
ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
network_name = "CloudCompGrpX-net"
# The public key to be used for SSH connection, please make sure, that you have the corresponding private key
#
# id_rsa.pub should look like this (standard sshd pubkey format):
# ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAw+J...F3w2mleybgT1w== user@HOSTNAME
keypair_name = 'srieger-pub' keypair_name = 'srieger-pub'
pub_key_file = '~/.ssh/id_rsa.pub' pub_key_file = '~/.ssh/id_rsa.pub'
flavor_name = 'm1.small'
# default region
region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for RZ LDAP, e.g., using fdaiXXXX as auth_username
domain_name = "default"
def main(): def main():
@ -87,7 +96,7 @@ def main():
networks = conn.ex_list_networks() networks = conn.ex_list_networks()
network = '' network = ''
for net in networks: for net in networks:
if net.name == network_name:
if net.name == project_network:
network = net network = net
########################################################################### ###########################################################################
@ -158,13 +167,13 @@ def main():
########################################################################### ###########################################################################
userdata_worker = '''#!/usr/bin/env bash userdata_worker = '''#!/usr/bin/env bash
curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
-i faafo -r worker -e 'http://%(api_1_ip)s' -m 'amqp://guest:guest@%(services_ip)s:5672/'
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \
-i faafo -r worker -e 'http://%(api_1_ip)s' -m 'amqp://faafo:guest@%(services_ip)s:5672/'
''' % {'api_1_ip': api_1_ip, 'services_ip': services_ip} ''' % {'api_1_ip': api_1_ip, 'services_ip': services_ip}
# userdata-api-2 = '''#!/usr/bin/env bash # userdata-api-2 = '''#!/usr/bin/env bash
# curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
# -i faafo -r worker -e 'http://%(api_2_ip)s' -m 'amqp://guest:guest@%(services_ip)s:5672/'
# curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \
# -i faafo -r worker -e 'http://%(api_2_ip)s' -m 'amqp://faafo:guest@%(services_ip)s:5672/'
# ''' % {'api_2_ip': api_2_ip, 'services_ip': services_ip} # ''' % {'api_2_ip': api_2_ip, 'services_ip': services_ip}
print('Starting new app-worker-3 instance and wait until it is running...') print('Starting new app-worker-3 instance and wait until it is running...')
@ -175,5 +184,6 @@ def main():
ex_userdata=userdata_worker, ex_userdata=userdata_worker,
ex_security_groups=[worker_security_group]) ex_security_groups=[worker_security_group])
if __name__ == '__main__': if __name__ == '__main__':
main() main()

25
demo4-scale-out-destroy.py

@ -10,30 +10,25 @@ from libcloud.compute.types import Provider
# services: nova, glance, neutron # services: nova, glance, neutron
# resources: 2 instances (m1.small), 2 floating ips (1 keypair, 2 security groups) # resources: 2 instances (m1.small), 2 floating ips (1 keypair, 2 security groups)
# Please use 1-25 for X in username, project etc., as coordinated in the lab sessions
# Please use 1-29 for X in the following variable to specify your group number. (will be used for the username,
# project etc., as coordinated in the lab sessions)
group_number = 30
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
# your username in OpenStack # your username in OpenStack
auth_username = 'CloudCompX'
auth_username = 'CloudComp' + str(group_number)
# your project in OpenStack # your project in OpenStack
project_name = 'CloudCompGrpX'
project_name = 'CloudComp' + str(group_number)
# default region # default region
region_name = 'RegionOne' region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for LDAP of DVZ, e.g., using fdaiXXXX as auth_username
# domain to use, "default" for local accounts, "hsfulda" for RZ LDAP, e.g., using fdaiXXXX as auth_username
domain_name = "default" domain_name = "default"
ubuntu_image_name = "Ubuntu 14.04 - Trusty Tahr - 64-bit - Cloud Based Image"
#ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
flavor_name = 'm1.small'
network_name = "CloudCompGrpX-net"
keypair_name = 'srieger-pub'
pub_key_file = '~/.ssh/id_rsa.pub'
def main(): def main():
########################################################################### ###########################################################################

52
demo4-scale-out.py

@ -10,29 +10,39 @@ from libcloud.compute.types import Provider
# services: nova, glance, neutron # services: nova, glance, neutron
# resources: 2 instances (m1.small), 2 floating ips (1 keypair, 2 security groups) # resources: 2 instances (m1.small), 2 floating ips (1 keypair, 2 security groups)
# Please use 1-25 for X in username, project etc., as coordinated in the lab sessions
# Please use 1-29 for X in the following variable to specify your group number. (will be used for the username,
# project etc., as coordinated in the lab sessions)
group_number = 30
# web service endpoint of the private cloud infrastructure # web service endpoint of the private cloud infrastructure
auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
auth_url = 'https://private-cloud.informatik.hs-fulda.de:5000'
# your username in OpenStack # your username in OpenStack
auth_username = 'CloudCompX'
auth_username = 'CloudComp' + str(group_number)
# your project in OpenStack # your project in OpenStack
project_name = 'CloudCompGrpX'
project_name = 'CloudComp' + str(group_number)
# A network in the project the started instance will be attached to
project_network = 'CloudComp' + str(group_number) + '-net'
# default region
region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for LDAP of DVZ, e.g., using fdaiXXXX as auth_username
domain_name = "default"
# The image to look for and use for the started instance
ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
ubuntu_image_name = "Ubuntu 14.04 - Trusty Tahr - 64-bit - Cloud Based Image"
#ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
# The public key to be used for SSH connection, please make sure, that you have the corresponding private key
#
# id_rsa.pub should look like this (standard sshd pubkey format):
# ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAw+J...F3w2mleybgT1w== user@HOSTNAME
keypair_name = 'srieger-pub'
pub_key_file = '~/.ssh/id_rsa.pub'
flavor_name = 'm1.small' flavor_name = 'm1.small'
network_name = "CloudCompGrpX-net"
keypair_name = 'srieger-pub'
pub_key_file = '~/.ssh/id_rsa.pub'
# default region
region_name = 'RegionOne'
# domain to use, "default" for local accounts, "hsfulda" for RZ LDAP, e.g., using fdaiXXXX as auth_username
domain_name = "default"
def main(): def main():
@ -86,7 +96,7 @@ def main():
networks = conn.ex_list_networks() networks = conn.ex_list_networks()
network = '' network = ''
for net in networks: for net in networks:
if net.name == network_name:
if net.name == project_network:
network = net network = net
########################################################################### ###########################################################################
@ -222,7 +232,7 @@ def main():
# Thanks to Stefan Friedmann for finding this fix ;) # Thanks to Stefan Friedmann for finding this fix ;)
userdata_service = '''#!/usr/bin/env bash userdata_service = '''#!/usr/bin/env bash
curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \
-i database -i messaging -i database -i messaging
rabbitmqctl add_user faafo guest rabbitmqctl add_user faafo guest
rabbitmqctl set_user_tags faafo administrator rabbitmqctl set_user_tags faafo administrator
@ -248,8 +258,8 @@ def main():
########################################################################### ###########################################################################
userdata_api = '''#!/usr/bin/env bash userdata_api = '''#!/usr/bin/env bash
curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
-i faafo -r api -m 'amqp://guest:guest@%(services_ip)s:5672/' \
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \
-i faafo -r api -m 'amqp://faafo:guest@%(services_ip)s:5672/' \
-d 'mysql+pymysql://faafo:password@%(services_ip)s:3306/faafo' -d 'mysql+pymysql://faafo:password@%(services_ip)s:3306/faafo'
''' % {'services_ip': services_ip} ''' % {'services_ip': services_ip}
@ -290,13 +300,13 @@ def main():
########################################################################### ###########################################################################
userdata_worker = '''#!/usr/bin/env bash userdata_worker = '''#!/usr/bin/env bash
curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
-i faafo -r worker -e 'http://%(api_1_ip)s' -m 'amqp://guest:guest@%(services_ip)s:5672/'
curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \
-i faafo -r worker -e 'http://%(api_1_ip)s' -m 'amqp://faafo:guest@%(services_ip)s:5672/'
''' % {'api_1_ip': api_1_ip, 'services_ip': services_ip} ''' % {'api_1_ip': api_1_ip, 'services_ip': services_ip}
# userdata_api-api-2 = '''#!/usr/bin/env bash # userdata_api-api-2 = '''#!/usr/bin/env bash
# curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
# -i faafo -r worker -e 'http://%(api_2_ip)s' -m 'amqp://guest:guest@%(services_ip)s:5672/'
# curl -L -s https://gogs.informatik.hs-fulda.de/srieger/cloud-computing-msc-ai-examples/raw/master/faafo/contrib/install.sh | bash -s -- \
# -i faafo -r worker -e 'http://%(api_2_ip)s' -m 'amqp://faafo:guest@%(services_ip)s:5672/'
# ''' % {'api_2_ip': api_2_ip, 'services_ip': services_ip} # ''' % {'api_2_ip': api_2_ip, 'services_ip': services_ip}
print('Starting new app-worker-1 instance and wait until it is running...') print('Starting new app-worker-1 instance and wait until it is running...')

Loading…
Cancel
Save