__init__.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. from lib.compose.object import ServiceVolume, ServiceDataVolume, ServicePort
  2. from lib.compose.services.cluster_service import ClusterService, ComposeServiceInitService, ClusterCommonService
  3. from lib.compose.services.mysql import MysqlService
  4. from lib.compose.services.etcd import EtcdService
  5. from lib.compose.services.climc import ClimcService
  6. from lib.compose.services.kubeserver import KubeServerService
  7. from lib.compose.services.web import WebService
  8. from lib.compose.services.influxdb import InfluxdbService
  9. from lib.compose import options
  10. SVC_KEYSTONE = "keystone"
  11. SVC_PORT_KEYSTONE = 30500
  12. SVC_PORT_KEYSTONE_2 = 30357
  13. SVC_REGION = "region"
  14. SVC_PORT_REGION = 30888
  15. SVC_SCHEDULER = "scheduler"
  16. SVC_PORT_SCHEDULER = 30887
  17. SVC_SCHEDULEDTASK = "scheduledtask"
  18. SVC_PORT_SCHEDULEDTASK = 30978
  19. SVC_GLANCE = "glance"
  20. SVC_PORT_GLANCE = 30292
  21. SVC_ESXI_AGENT = "esxi-agent"
  22. SVC_PORT_ESXI_AGENT = 30883
  23. SVC_APIGATEWAY = "apigateway"
  24. SVC_PORT_APIGATEWAY = 30300
  25. SVC_WEBCONSOLE = "webconsole"
  26. SVC_PORT_WEBCONSOLE = 30899
  27. SVC_YUNIONCONF = "yunionconf"
  28. SVC_PORT_YUNIONCONF = 30889
  29. SVC_ANSIBLESERVER = "ansibleserver"
  30. SVC_PORT_ANSIBLESERVER = 30890
  31. SVC_MONITOR = "monitor"
  32. SVC_PORT_MONITOR = 30093
  33. SVC_LOGGER = "logger"
  34. SVC_PORT_LOGGER = 30999
  35. SVC_NOTIFY = "notify"
  36. SVC_PORT_NOTIFY = 30777
  37. SVC_CLOUDMON = "cloudmon"
  38. SVC_PORT_CLOUDMON = 30931
  39. SVC_CLOUDID = "cloudid"
  40. SVC_PORT_CLOUDID = 30893
  41. def new_cloud_service(name, version, port,
  42. db_svc=None,
  43. keystone_svc=None,
  44. depend_svc=None,
  45. disable_auto_sync_table=False):
  46. return ClusterCommonService(name, version, db_svc,
  47. port=port, keystone_svc=keystone_svc,
  48. depend_svc=depend_svc,
  49. disable_auto_sync_table=disable_auto_sync_table)
  50. def new_keystone_service(version, db_svc, etcd_svc):
  51. svc = new_cloud_service(SVC_KEYSTONE, version, SVC_PORT_KEYSTONE, db_svc)
  52. if options.has_public_ip():
  53. svc.add_port(ServicePort(SVC_PORT_KEYSTONE_2, SVC_PORT_KEYSTONE_2))
  54. svc.depend_on_health(etcd_svc)
  55. return svc
  56. def new_region_service(version, db_svc, keystone_svc):
  57. return new_cloud_service(SVC_REGION, version, SVC_PORT_REGION, db_svc,
  58. keystone_svc)
  59. def new_scheduler_service(version, db_svc, region_svc):
  60. svc = new_cloud_service(SVC_SCHEDULER, version, SVC_PORT_SCHEDULER, db_svc,
  61. depend_svc=region_svc,
  62. disable_auto_sync_table=True)
  63. return svc
  64. def new_scheduledtask_service(version, db_svc, region_svc):
  65. svc = new_cloud_service(SVC_SCHEDULEDTASK, version, SVC_PORT_SCHEDULEDTASK, db_svc,
  66. depend_svc=region_svc,
  67. disable_auto_sync_table=True)
  68. return svc
  69. def new_glance_service(version, db_svc, keystone_svc, hostdeployer_svc):
  70. svc = new_cloud_service(SVC_GLANCE, version, SVC_PORT_GLANCE, db_svc, keystone_svc, depend_svc=hostdeployer_svc)
  71. svc.add_volume(ServiceDataVolume(svc.YUNION_GLANCE_DATA_PATH))
  72. svc.add_volume(ServiceDataVolume(svc.YUNION_RUN_ONECLOUD_PATH))
  73. return svc
  74. def new_esxi_agent_service(version, keystone_svc, region_svc):
  75. svc = new_cloud_service(SVC_ESXI_AGENT, version, SVC_PORT_ESXI_AGENT, keystone_svc=keystone_svc,
  76. depend_svc=region_svc)
  77. svc.add_volume(ServiceDataVolume(svc.YUNION_RUN_VMWARE_PATH))
  78. svc.add_volume(ServiceDataVolume(svc.YUNION_RUN_ONECLOUD_PATH))
  79. svc.add_volume(ServiceDataVolume(svc.YUNION_CLOUD_PATH))
  80. return svc
  81. def new_apigateway_service(version, keystone_svc, depend_svc):
  82. return new_cloud_service(SVC_APIGATEWAY, version, SVC_PORT_APIGATEWAY, keystone_svc=keystone_svc,
  83. depend_svc=depend_svc)
  84. def new_webconsole_service(version, db_svc, keystone_svc):
  85. return new_cloud_service(SVC_WEBCONSOLE, version, SVC_PORT_WEBCONSOLE, db_svc, keystone_svc)
  86. def new_yunionconf_service(version, db_svc, keystone):
  87. return new_cloud_service(SVC_YUNIONCONF, version, SVC_PORT_YUNIONCONF, db_svc, keystone)
  88. def new_ansibleserver_service(version, db_svc, keystone_svc):
  89. return new_cloud_service(SVC_ANSIBLESERVER, version, SVC_PORT_ANSIBLESERVER, db_svc, keystone_svc)
  90. def new_monitor_service(version, db_svc, region_svc):
  91. svc = new_cloud_service(SVC_MONITOR, version, SVC_PORT_MONITOR, db_svc, depend_svc=region_svc)
  92. return svc
  93. def new_logger_service(version, db_svc, keystone_svc):
  94. return new_cloud_service(SVC_LOGGER, version, SVC_PORT_LOGGER, db_svc, keystone_svc)
  95. def new_notify_service(version, db_svc, keystone_svc):
  96. return new_cloud_service(SVC_NOTIFY, version, SVC_PORT_NOTIFY, db_svc, keystone_svc)
  97. def new_cloudid_service(version, db_svc, region_svc):
  98. return new_cloud_service(SVC_CLOUDID, version, SVC_PORT_CLOUDID, db_svc, depend_svc=region_svc)
  99. def new_cloudmon_service(version, keystone_svc):
  100. return new_cloud_service(SVC_CLOUDMON, version, SVC_PORT_CLOUDMON, keystone_svc=keystone_svc)