28
29
"quantum-plugin-openvswitch-agent",
29
30
"quantum-l3-agent",
30
31
"quantum-dhcp-agent",
34
"quantum-plugin-nicira"
40
39
"quantum-plugin-openvswitch-agent",
41
40
"quantum-l3-agent",
46
EXT_PORT_CONF = '/etc/init/ext-port.conf'
49
def get_os_version(package=None):
52
pkg = cache[package or 'quantum-common']
54
return apt.upstream_version(pkg.current_ver.ver_str)
59
if get_os_version('quantum-common') >= "2013.1":
60
for plugin in GATEWAY_AGENTS:
61
GATEWAY_AGENTS[plugin].append("quantum-metadata-agent")
46
63
DB_USER = "quantum"
47
64
QUANTUM_DB = "quantum"
48
65
KEYSTONE_SERVICE = "quantum"
50
69
QUANTUM_CONF = "/etc/quantum/quantum.conf"
51
70
L3_AGENT_CONF = "/etc/quantum/l3_agent.ini"
52
71
DHCP_AGENT_CONF = "/etc/quantum/dhcp_agent.ini"
72
METADATA_AGENT_CONF = "/etc/quantum/metadata_agent.ini"
73
NOVA_CONF = "/etc/nova/nova.conf"
79
'quantum-metadata-agent',
80
'quantum-plugin-openvswitch-agent'
88
METADATA_AGENT_CONF: [
89
'quantum-metadata-agent'
92
'quantum-plugin-openvswitch-agent'
54
99
RABBIT_USER = "nova"
55
100
RABBIT_VHOST = "nova"
90
135
'Deleting port {} from bridge {}'.format(port, name))
91
136
subprocess.check_call(["ovs-vsctl", "del-port", name, port])
92
137
subprocess.check_call(["ip", "link", "set", port, "down"])
140
SHARED_SECRET = "/etc/quantum/secret.txt"
143
def get_shared_secret():
145
if not os.path.exists(SHARED_SECRET):
146
secret = str(uuid.uuid4())
147
with open(SHARED_SECRET, 'w') as secret_file:
148
secret_file.write(secret)
150
with open(SHARED_SECRET, 'r') as secret_file:
151
secret = secret_file.read().strip()
155
def flush_local_configuration():
156
if os.path.exists('/usr/bin/quantum-netns-cleanup'):
158
"quantum-netns-cleanup",
159
"--config-file=/etc/quantum/quantum.conf"
161
for agent_conf in ['l3_agent.ini', 'dhcp_agent.ini']:
162
agent_cmd = list(cmd)
163
agent_cmd.append('--config-file=/etc/quantum/{}'\
165
subprocess.call(agent_cmd)
168
def install_ca(ca_cert):
169
with open('/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt',
171
crt.write(base64.b64decode(ca_cert))
172
subprocess.check_call(['update-ca-certificates', '--fresh'])
174
DHCP_AGENT = "DHCP Agent"
175
L3_AGENT = "L3 Agent"
178
def reassign_agent_resources(env):
179
''' Use agent scheduler API to detect down agents and re-schedule '''
180
from quantumclient.v2_0 import client
181
# TODO: Fixup for https keystone
182
auth_url = 'http://%(keystone_host)s:%(auth_port)s/v2.0' % env
183
quantum = client.Client(username=env['service_username'],
184
password=env['service_password'],
185
tenant_name=env['service_tenant'],
187
region_name=env['region'])
189
agents = quantum.list_agents(agent_type=DHCP_AGENT)
193
for agent in agents['agents']:
194
if not agent['alive']:
195
log('INFO', 'DHCP Agent %s down' % agent['id'])
197
quantum.list_networks_on_dhcp_agent(agent['id'])['networks']:
198
networks[network['id']] = agent['id']
200
dhcp_agents.append(agent['id'])
202
agents = quantum.list_agents(agent_type=L3_AGENT)
204
for agent in agents['agents']:
205
if not agent['alive']:
206
log('INFO', 'L3 Agent %s down' % agent['id'])
208
quantum.list_routers_on_l3_agent(agent['id'])['routers']:
209
routers[router['id']] = agent['id']
211
l3_agents.append(agent['id'])
214
for router_id in routers:
215
agent = index % len(l3_agents)
217
'Moving router %s from %s to %s' % \
218
(router_id, routers[router_id], l3_agents[agent]))
219
quantum.remove_router_from_l3_agent(l3_agent=routers[router_id],
221
quantum.add_router_to_l3_agent(l3_agent=l3_agents[agent],
222
body={'router_id': router_id})
226
for network_id in networks:
227
agent = index % len(dhcp_agents)
229
'Moving network %s from %s to %s' % \
230
(network_id, networks[network_id], dhcp_agents[agent]))
231
quantum.remove_network_from_dhcp_agent(dhcp_agent=networks[network_id],
232
network_id=network_id)
233
quantum.add_network_to_dhcp_agent(dhcp_agent=dhcp_agents[agent],
234
body={'network_id': network_id})
237
def do_openstack_upgrade():
239
plugin = config_get('plugin')
241
if plugin in GATEWAY_PKGS.keys():
242
pkgs += GATEWAY_PKGS[plugin]
244
pkgs.append('openvswitch-datapath-dkms')
245
cmd = ['apt-get', '-y',
246
'--option', 'Dpkg::Options::=--force-confold',
247
'--option', 'Dpkg::Options::=--force-confdef',
249
subprocess.check_call(cmd)