Makes service control ha aware, merge in trunk
This commit is contained in:
commit
8011d9a342
2
.project
2
.project
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>quantum</name>
|
||||
<name>quantum-gateway</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
|
||||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||
<path>/quantum/hooks</path>
|
||||
<path>/quantum-gateway/hooks</path>
|
||||
</pydev_pathproperty>
|
||||
</pydev_project>
|
||||
|
|
|
@ -28,15 +28,13 @@ In order to use Quantum with Openstack, you will need to deploy the
|
|||
nova-compute and nova-cloud-controller charms with the network-manager
|
||||
configuration set to 'Quantum':
|
||||
|
||||
nova-compute:
|
||||
network-manager: Quantum
|
||||
nova-cloud-controller:
|
||||
network-manager: Quantum
|
||||
|
||||
This decision must be made prior to deploying Openstack with Juju as
|
||||
Quantum is deployed baked into these charms from install onwards:
|
||||
|
||||
juju deploy --config config.yaml nova-compute
|
||||
juju deploy nova-compute
|
||||
juju deploy --config config.yaml nova-cloud-controller
|
||||
juju add-relation nova-compute nova-cloud-controller
|
||||
|
||||
|
|
11
config.yaml
11
config.yaml
|
@ -3,9 +3,8 @@ options:
|
|||
default: ovs
|
||||
type: string
|
||||
description: |
|
||||
Network configuration plugin to use to manage
|
||||
the quantum network across quantum and nova-compute
|
||||
nodes. Supported values include:
|
||||
Network configuration plugin to use for quantum.
|
||||
Supported values include:
|
||||
.
|
||||
ovs - OpenVSwitch
|
||||
ext-port:
|
||||
|
@ -13,13 +12,9 @@ options:
|
|||
description: |
|
||||
External port to use for routing of instance
|
||||
traffic to the external public network.
|
||||
region:
|
||||
type: string
|
||||
default: RegionOne
|
||||
description: |
|
||||
OpenStack region that this quantum service supports.
|
||||
openstack-origin:
|
||||
type: string
|
||||
default: cloud:precise-folsom
|
||||
description: |
|
||||
Optional configuration to support use of additional sources such as:
|
||||
.
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0
|
||||
|
||||
Files: *
|
||||
Copyright: 2012, Canonical Ltd.
|
||||
License: GPL-3
|
||||
|
||||
License: GPL-3
|
||||
On Debian GNU/Linux system you can find the complete text of the
|
||||
GPL-3 license in '/usr/share/common-licenses/GPL-3'
|
|
@ -167,14 +167,18 @@ def ha_relation_joined():
|
|||
# init services that will be clusterized. Used to disable init scripts
|
||||
# Used when resources have upstart jobs that are needed to be disabled.
|
||||
# resource_name:init_script_name
|
||||
init_services = {'res_quantum_dhcp_agent':'quantum-dhcp-agent',
|
||||
'res_quantum_l3_agent':'quantum-l3-agent'}
|
||||
init_services = {'res_quantum_dhcp_agent': 'quantum-dhcp-agent',
|
||||
'res_quantum_l3_agent': 'quantum-l3-agent'}
|
||||
|
||||
# Obtain resources
|
||||
resources = {'res_quantum_dhcp_agent':'ocf:openstack:quantum-agent-dhcp',
|
||||
'res_quantum_l3_agent':'ocf:openstack:quantum-agent-l3'}
|
||||
resource_params = {'res_quantum_dhcp_agent':'params config="/etc/quantum/quantum.conf" op monitor interval="5s" timeout="5s"',
|
||||
'res_quantum_l3_agent':'params config="/etc/quantum/quantum.conf" op monitor interval="5s" timeout="5s"'}
|
||||
resources = {'res_quantum_dhcp_agent': 'ocf:openstack:quantum-agent-dhcp',
|
||||
'res_quantum_l3_agent': 'ocf:openstack:quantum-agent-l3'}
|
||||
resource_params = {'res_quantum_dhcp_agent':
|
||||
'params config="/etc/quantum/quantum.conf"'
|
||||
' op monitor interval="5s" timeout="5s"',
|
||||
'res_quantum_l3_agent':
|
||||
'params config="/etc/quantum/quantum.conf"'
|
||||
' op monitor interval="5s" timeout="5s"'}
|
||||
|
||||
# TODO: colocate each service in different machine
|
||||
|
||||
|
|
|
@ -17,10 +17,12 @@ def do_hooks(hooks):
|
|||
hook = os.path.basename(sys.argv[0])
|
||||
|
||||
try:
|
||||
hooks[hook]()
|
||||
hook_func = hooks[hook]
|
||||
except KeyError:
|
||||
juju_log('INFO',
|
||||
"This charm doesn't know how to handle '{}'.".format(hook))
|
||||
else:
|
||||
hook_func()
|
||||
|
||||
|
||||
def install(*pkgs):
|
||||
|
@ -43,11 +45,9 @@ except ImportError:
|
|||
|
||||
try:
|
||||
import dns.resolver
|
||||
import dns.ipv4
|
||||
except ImportError:
|
||||
install('python-dnspython')
|
||||
import dns.resolver
|
||||
import dns.ipv4
|
||||
|
||||
|
||||
def render_template(template_name, context, template_dir=TEMPLATES_DIR):
|
||||
|
@ -63,9 +63,12 @@ deb http://ubuntu-cloud.archive.canonical.com/ubuntu {} main
|
|||
"""
|
||||
|
||||
CLOUD_ARCHIVE_POCKETS = {
|
||||
'folsom': 'precise-updates/folsom',
|
||||
'folsom/updates': 'precise-updates/folsom',
|
||||
'folsom/proposed': 'precise-proposed/folsom'
|
||||
'precise-folsom': 'precise-updates/folsom',
|
||||
'precise-folsom/updates': 'precise-updates/folsom',
|
||||
'precise-folsom/proposed': 'precise-proposed/folsom',
|
||||
'precise-grizzly': 'precise-updates/grizzly',
|
||||
'precise-grizzly/updates': 'precise-updates/grizzly',
|
||||
'precise-grizzly/proposed': 'precise-proposed/grizzly'
|
||||
}
|
||||
|
||||
|
||||
|
@ -206,9 +209,9 @@ def get_unit_hostname():
|
|||
def get_host_ip(hostname=unit_get('private-address')):
|
||||
try:
|
||||
# Test to see if already an IPv4 address
|
||||
dns.ipv4.inet_aton(hostname)
|
||||
socket.inet_aton(hostname)
|
||||
return hostname
|
||||
except dns.exception.SyntaxError:
|
||||
except socket.error:
|
||||
pass
|
||||
try:
|
||||
answers = dns.resolver.query(hostname, 'A')
|
||||
|
@ -219,16 +222,41 @@ def get_host_ip(hostname=unit_get('private-address')):
|
|||
return None
|
||||
|
||||
|
||||
CLUSTER_RESOURCES = {
|
||||
'quantum-dhcp-agent': 'res_quantum_dhcp_agent',
|
||||
'quantum-l3-agent': 'res_quantum_l3_agent'
|
||||
}
|
||||
|
||||
HAMARKER = '/var/lib/juju/haconfigured'
|
||||
|
||||
|
||||
def _service_ctl(service, action):
|
||||
if (os.path.exists(HAMARKER) and
|
||||
os.path.exists(os.path.join('/etc/init/',
|
||||
'{}.override'.format(service))) and
|
||||
service in CLUSTER_RESOURCES):
|
||||
hostname = str(subprocess.check_output(['hostname'])).strip()
|
||||
service_status = \
|
||||
subprocess.check_output(['crm', 'resource', 'show',
|
||||
CLUSTER_RESOURCES[service]])
|
||||
# Only restart if we are the node that owns the service
|
||||
if hostname in service_status:
|
||||
subprocess.check_call(['crm', 'resource', action,
|
||||
CLUSTER_RESOURCES[service]])
|
||||
else:
|
||||
subprocess.check_call(['service', service, action])
|
||||
|
||||
|
||||
def restart(*services):
|
||||
for service in services:
|
||||
subprocess.check_call(['service', service, 'restart'])
|
||||
_service_ctl(service, 'restart')
|
||||
|
||||
|
||||
def stop(*services):
|
||||
for service in services:
|
||||
subprocess.check_call(['service', service, 'stop'])
|
||||
_service_ctl(service, 'stop')
|
||||
|
||||
|
||||
def start(*services):
|
||||
for service in services:
|
||||
subprocess.check_call(['service', service, 'start'])
|
||||
_service_ctl(service, 'start')
|
||||
|
|
Loading…
Reference in New Issue