launcher_docker.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. """
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. "License"); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. """
  16. # configure the VM to set Docker, Weave network, run Ambari-agent inside the Docker
  17. # argv 1: the external IP of this VM
  18. # argv 2: the Weave IP of the Ambari-server
  19. # argv 3: the external IP of the Ambari-server
  20. # argv 4: the name of the cluster
  21. import sys
  22. from config import Config
  23. from cluster import Cluster
  24. if __name__ == "__main__":
  25. if len(sys.argv) < 5:
  26. print "configure the VM to set Docker, Weave network, run Ambari-agent inside the Docker"
  27. print "Args: <the external IP of this VM>"
  28. print " <the Weave IP of the Ambari-server>"
  29. print " <the external IP of the Ambari-server>"
  30. print " <the name of the cluster>"
  31. exit(1)
  32. Config.load()
  33. my_external_ip = sys.argv[1]
  34. server_weave_ip = sys.argv[2]
  35. server_external_ip = sys.argv[3]
  36. cluster_name = sys.argv[4]
  37. cluster = Cluster.load_from_json(cluster_name)
  38. vm_ip_list = []
  39. vm_ip_list.append(server_external_ip)
  40. # This will decide the topology of the Weave network.
  41. # This connect all agents to other agents,
  42. # which is not necessary, connecting to ambari-server and service server is enough.
  43. # for vm in cluster.ambari_agent_vm_list:
  44. # vm_ip_list.append(vm.external_ip)
  45. # This connect all agents to all service server
  46. for vm in cluster.service_server_vm_list:
  47. vm_ip_list.append(vm.external_ip)
  48. vm = cluster.get_agent_vm(my_external_ip)
  49. vm.run_docker(server_weave_ip, vm_ip_list)