Makes service control ha aware, merge in trunk

This commit is contained in:
James Page 2012-12-14 14:33:35 +00:00
commit 8011d9a342
8 changed files with 65 additions and 31 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>quantum</name> <name>quantum-gateway</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

View File

@ -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_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/quantum/hooks</path> <path>/quantum-gateway/hooks</path>
</pydev_pathproperty> </pydev_pathproperty>
</pydev_project> </pydev_project>

View File

@ -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 nova-compute and nova-cloud-controller charms with the network-manager
configuration set to 'Quantum': configuration set to 'Quantum':
nova-compute:
network-manager: Quantum
nova-cloud-controller: nova-cloud-controller:
network-manager: Quantum network-manager: Quantum
This decision must be made prior to deploying Openstack with Juju as This decision must be made prior to deploying Openstack with Juju as
Quantum is deployed baked into these charms from install onwards: 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 deploy --config config.yaml nova-cloud-controller
juju add-relation nova-compute nova-cloud-controller juju add-relation nova-compute nova-cloud-controller

View File

@ -3,9 +3,8 @@ options:
default: ovs default: ovs
type: string type: string
description: | description: |
Network configuration plugin to use to manage Network configuration plugin to use for quantum.
the quantum network across quantum and nova-compute Supported values include:
nodes. Supported values include:
. .
ovs - OpenVSwitch ovs - OpenVSwitch
ext-port: ext-port:
@ -13,13 +12,9 @@ options:
description: | description: |
External port to use for routing of instance External port to use for routing of instance
traffic to the external public network. traffic to the external public network.
region:
type: string
default: RegionOne
description: |
OpenStack region that this quantum service supports.
openstack-origin: openstack-origin:
type: string type: string
default: cloud:precise-folsom
description: | description: |
Optional configuration to support use of additional sources such as: Optional configuration to support use of additional sources such as:
. .

9
copyright Normal file
View File

@ -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'

View File

@ -167,14 +167,18 @@ def ha_relation_joined():
# init services that will be clusterized. Used to disable init scripts # init services that will be clusterized. Used to disable init scripts
# Used when resources have upstart jobs that are needed to be disabled. # Used when resources have upstart jobs that are needed to be disabled.
# resource_name:init_script_name # resource_name:init_script_name
init_services = {'res_quantum_dhcp_agent':'quantum-dhcp-agent', init_services = {'res_quantum_dhcp_agent': 'quantum-dhcp-agent',
'res_quantum_l3_agent':'quantum-l3-agent'} 'res_quantum_l3_agent': 'quantum-l3-agent'}
# Obtain resources # Obtain resources
resources = {'res_quantum_dhcp_agent':'ocf:openstack:quantum-agent-dhcp', resources = {'res_quantum_dhcp_agent': 'ocf:openstack:quantum-agent-dhcp',
'res_quantum_l3_agent':'ocf:openstack:quantum-agent-l3'} '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"', resource_params = {'res_quantum_dhcp_agent':
'res_quantum_l3_agent':'params config="/etc/quantum/quantum.conf" op monitor interval="5s" timeout="5s"'} '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 # TODO: colocate each service in different machine

View File

@ -17,10 +17,12 @@ def do_hooks(hooks):
hook = os.path.basename(sys.argv[0]) hook = os.path.basename(sys.argv[0])
try: try:
hooks[hook]() hook_func = hooks[hook]
except KeyError: except KeyError:
juju_log('INFO', juju_log('INFO',
"This charm doesn't know how to handle '{}'.".format(hook)) "This charm doesn't know how to handle '{}'.".format(hook))
else:
hook_func()
def install(*pkgs): def install(*pkgs):
@ -43,11 +45,9 @@ except ImportError:
try: try:
import dns.resolver import dns.resolver
import dns.ipv4
except ImportError: except ImportError:
install('python-dnspython') install('python-dnspython')
import dns.resolver import dns.resolver
import dns.ipv4
def render_template(template_name, context, template_dir=TEMPLATES_DIR): 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 = { CLOUD_ARCHIVE_POCKETS = {
'folsom': 'precise-updates/folsom', 'precise-folsom': 'precise-updates/folsom',
'folsom/updates': 'precise-updates/folsom', 'precise-folsom/updates': 'precise-updates/folsom',
'folsom/proposed': 'precise-proposed/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')): def get_host_ip(hostname=unit_get('private-address')):
try: try:
# Test to see if already an IPv4 address # Test to see if already an IPv4 address
dns.ipv4.inet_aton(hostname) socket.inet_aton(hostname)
return hostname return hostname
except dns.exception.SyntaxError: except socket.error:
pass pass
try: try:
answers = dns.resolver.query(hostname, 'A') answers = dns.resolver.query(hostname, 'A')
@ -219,16 +222,41 @@ def get_host_ip(hostname=unit_get('private-address')):
return None 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): def restart(*services):
for service in services: for service in services:
subprocess.check_call(['service', service, 'restart']) _service_ctl(service, 'restart')
def stop(*services): def stop(*services):
for service in services: for service in services:
subprocess.check_call(['service', service, 'stop']) _service_ctl(service, 'stop')
def start(*services): def start(*services):
for service in services: for service in services:
subprocess.check_call(['service', service, 'start']) _service_ctl(service, 'start')

View File

@ -1 +1 @@
34 43