This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
initialize.py
176 lines (145 loc) · 6.15 KB
/
initialize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Copyright (c) 2011 OpenStack, LLC.
# All Rights Reserved.
#
# 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.
import unittest
import os
import time
import socket
from nose.plugins.skip import SkipTest
from proboscis import test
from proboscis.asserts import fail
from proboscis.decorators import time_out
from tests.util.services import Service
from tests.util.services import start_proc
from tests.util.services import WebService
from trove.tests.config import CONFIG
FAKE = CONFIG.fake_mode
START_SERVICES = (not FAKE) and CONFIG.values.get('start_services', False)
START_NOVA_NETWORK = (START_SERVICES and
not CONFIG.values.get('neutron_enabled',
False))
KEYSTONE_ALL = CONFIG.values.get('keystone_use_combined', True)
USE_NOVA_VOLUME = CONFIG.values.get('use_nova_volume', False)
dbaas_image = None
instance_name = None
success_statuses = ["build", "active"]
def dbaas_url():
return str(CONFIG.values.get("dbaas_url"))
def nova_url():
return str(CONFIG.values.get("nova_client")['url'])
class Daemon(object):
"""Starts a daemon."""
def __init__(self, alternate_path=None, conf_file_name=None,
extra_cmds=None, service_path_root=None, service_path=None):
# The path to the daemon bin if the other one doesn't work.
self.alternate_path = alternate_path
self.extra_cmds = extra_cmds or []
# The name of a test config value which points to a conf file.
self.conf_file_name = conf_file_name
# The name of a test config value, which is inserted into the service_path.
self.service_path_root = service_path_root
# The first path to the daemon bin we try.
self.service_path = service_path or "%s"
def run(self):
# Print out everything to make it
print("Looking for config value %s..." % self.service_path_root)
print(CONFIG.values[self.service_path_root])
path = self.service_path % CONFIG.values[self.service_path_root]
print("Path = %s" % path)
if not os.path.exists(path):
path = self.alternate_path
if path is None:
fail("Could not find path to %s" % self.service_path_root)
conf_path = str(CONFIG.values[self.conf_file_name])
cmds = CONFIG.python_cmd_list() + [path] + self.extra_cmds + \
[conf_path]
print("Running cmds: %s" % cmds)
self.service = Service(cmds)
if not self.service.is_service_alive():
self.service.start()
@test(groups=["services.initialize"],
enabled=START_SERVICES and (not KEYSTONE_ALL))
def start_keystone_all():
"""Starts the Keystone API."""
Daemon(service_path_root="usr_bin_dir",
service_path="%s/keystone-all",
extra_cmds=['--config-file'],
conf_file_name="keystone_conf").run()
@test(groups=["services.initialize", "services.initialize.glance"],
enabled=START_SERVICES)
def start_glance_registry():
"""Starts the Glance Registry."""
Daemon(alternate_path="/usr/bin/glance-registry",
conf_file_name="glance_reg_conf",
service_path_root="usr_bin_dir",
service_path="%s/glance-registry").run()
@test(groups=["services.initialize", "services.initialize.glance"],
depends_on=[start_glance_registry], enabled=START_SERVICES)
def start_glance_api():
"""Starts the Glance API."""
Daemon(alternate_path="/usr/bin/glance-api",
conf_file_name="glance_reg_conf",
service_path_root="usr_bin_dir",
service_path="%s/glance-api").run()
@test(groups=["services.initialize"], depends_on_classes=[start_glance_api],
enabled=START_NOVA_NETWORK)
def start_nova_network():
"""Starts the Nova Network Service."""
Daemon(service_path_root="usr_bin_dir",
service_path="%s/nova-network",
extra_cmds=['--config-file='],
conf_file_name="nova_conf").run()
@test(groups=["services.initialize"], enabled=START_SERVICES)
def start_scheduler():
"""Starts the Scheduler Service."""
Daemon(service_path_root="usr_bin_dir",
service_path="%s/nova-scheduler",
extra_cmds=['--config-file='],
conf_file_name="nova_conf").run()
@test(groups=["services.initialize"],
depends_on_classes=[start_glance_api],
enabled=START_SERVICES)
def start_compute():
"""Starts the Nova Compute Service."""
Daemon(service_path_root="usr_bin_dir",
service_path="%s/nova-compute",
extra_cmds=['--config-file='],
conf_file_name="nova_conf").run()
@test(groups=["services.initialize"], depends_on_classes=[start_scheduler],
enabled=START_SERVICES and USE_NOVA_VOLUME)
def start_volume():
"""Starts the Nova Compute Service."""
Daemon(service_path_root="usr_bin_dir",
service_path="%s/nova-volume",
extra_cmds=['--config-file='],
conf_file_name="nova_conf").run()
@test(groups=["services.initialize"],
depends_on_classes=[start_glance_api, start_nova_network, start_compute,
start_volume],
enabled=START_SERVICES)
def start_nova_api():
"""Starts the Nova Compute Service."""
Daemon(service_path_root="usr_bin_dir",
service_path="%s/nova-api",
extra_cmds=['--config-file='],
conf_file_name="nova_conf").run()
@test(groups=["services.initialize"],
depends_on_classes=[start_nova_api],
enabled=START_SERVICES)
def start_trove_api():
"""Starts the Trove Service."""
Daemon(service_path_root="usr_bin_dir",
service_path="%s/trove-api",
extra_cmds=['--config-file='],
conf_file_name="trove_conf").run()