You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.5 KiB

  1. # import getpass
  2. # import os
  3. # import libcloud.security
  4. import time
  5. from libcloud.compute.providers import get_driver
  6. from libcloud.compute.types import Provider
  7. # reqs:
  8. # services: nova, glance, neutron
  9. # resources: 2 instances (m1.small), 2 floating ips (1 keypair, 2 security groups)
  10. # Please use 1-25 for X in username, project etc., as coordinated in the lab sessions
  11. # web service endpoint of the private cloud infrastructure
  12. auth_url = 'https://private-cloud2.informatik.hs-fulda.de:5000'
  13. # your username in OpenStack
  14. auth_username = 'CloudCompX'
  15. # your project in OpenStack
  16. project_name = 'CloudCompGrpX'
  17. # default region
  18. region_name = 'RegionOne'
  19. # domain to use, "default" for local accounts, "hsfulda" for LDAP of DVZ, e.g., using fdaiXXXX as auth_username
  20. domain_name = "default"
  21. ubuntu_image_name = "Ubuntu 14.04 - Trusty Tahr - 64-bit - Cloud Based Image"
  22. #ubuntu_image_name = "Ubuntu 18.04 - Bionic Beaver - 64-bit - Cloud Based Image"
  23. flavor_name = 'm1.small'
  24. network_name = "CloudCompGrpX-net"
  25. keypair_name = 'srieger-pub'
  26. pub_key_file = '~/.ssh/id_rsa.pub'
  27. api_1_ip = "192.168.0.x"
  28. services_ip = "192.168.0.y"
  29. def main():
  30. ###########################################################################
  31. #
  32. # get credentials
  33. #
  34. ###########################################################################
  35. # if "OS_PASSWORD" in os.environ:
  36. # auth_password = os.environ["OS_PASSWORD"]
  37. # else:
  38. # auth_password = getpass.getpass("Enter your OpenStack password:")
  39. auth_password = "demo"
  40. ###########################################################################
  41. #
  42. # create connection
  43. #
  44. ###########################################################################
  45. # libcloud.security.VERIFY_SSL_CERT = False
  46. provider = get_driver(Provider.OPENSTACK)
  47. conn = provider(auth_username,
  48. auth_password,
  49. ex_force_auth_url=auth_url,
  50. ex_force_auth_version='3.x_password',
  51. ex_tenant_name=project_name,
  52. ex_force_service_region=region_name,
  53. ex_domain_name=domain_name)
  54. ###########################################################################
  55. #
  56. # create worker instances
  57. #
  58. ###########################################################################
  59. userdata_worker = '''#!/usr/bin/env bash
  60. curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
  61. -i faafo -r worker -e 'http://%(api_1_ip)s' -m 'amqp://guest:guest@%(services_ip)s:5672/'
  62. ''' % {'api_1_ip': api_1_ip, 'services_ip': services_ip}
  63. # userdata-api-2 = '''#!/usr/bin/env bash
  64. # curl -L -s https://git.openstack.org/cgit/openstack/faafo/plain/contrib/install.sh | bash -s -- \
  65. # -i faafo -r worker -e 'http://%(api_2_ip)s' -m 'amqp://guest:guest@%(services_ip)s:5672/'
  66. # ''' % {'api_2_ip': api_2_ip, 'services_ip': services_ip}
  67. print('Starting new app-worker-3 instance and wait until it is running...')
  68. instance_worker_3 = conn.create_node(name='app-worker-3',
  69. image=image, size=flavor,
  70. networks=[network],
  71. ex_keyname=keypair_name,
  72. ex_userdata=userdata_worker,
  73. ex_security_groups=[worker_security_group])
  74. if __name__ == '__main__':
  75. main()