nuage-neutron payload libraries

This commit is contained in:
Subbarayudu Mukkamala
2014-10-03 20:12:04 -07:00
parent 103563e30a
commit 59e24272d8
5 changed files with 60 additions and 22 deletions

16
hooks/charmhelpers/contrib/openstack/context.py Normal file → Executable file
View File

@@ -642,6 +642,20 @@ class NeutronContext(OSContextGenerator):
return ovs_ctxt
def nuage_ctxt(self):
driver = neutron_plugin_attribute(self.plugin, 'driver',
self.network_manager)
config = neutron_plugin_attribute(self.plugin, 'config',
self.network_manager)
nuage_ctxt = {
'core_plugin': driver,
'neutron_plugin': 'vsp',
'neutron_security_groups': self.neutron_security_groups,
'local_ip': unit_private_ip(),
'config': config
}
return nuage_ctxt
def nvp_ctxt(self):
driver = neutron_plugin_attribute(self.plugin, 'driver',
self.network_manager)
@@ -706,6 +720,8 @@ class NeutronContext(OSContextGenerator):
if self.plugin == 'ovs':
ctxt.update(self.ovs_ctxt())
elif self.plugin == 'vsp':
ctxt.update(self.nuage_ctxt())
elif self.plugin in ['nvp', 'nsx']:
ctxt.update(self.nvp_ctxt())
elif self.plugin == 'n1kv':

14
hooks/charmhelpers/contrib/openstack/neutron.py Normal file → Executable file
View File

@@ -142,6 +142,20 @@ def neutron_plugins():
'server_packages': ['neutron-server',
'neutron-plugin-cisco'],
'server_services': ['neutron-server']
},
'vsp': {
'config': '/etc/neutron/plugins/nuage/nuage_plugin.ini',
'driver': 'neutron.plugins.nuage.plugin.NuagePlugin',
'contexts': [
context.SharedDBContext(user=config('neutron-database-user'),
database=config('neutron-database'),
relation_prefix='neutron',
ssl_dir=NEUTRON_CONF_DIR)],
'services': [],
'packages': [],
'server_packages': ['neutron-server',
'neutron-plugin-nuage'],
'server_services': ['neutron-server']
}
}
if release >= 'icehouse':

View File

@@ -47,11 +47,7 @@ from neutron_api_utils import (
migrate_neutron_database,
register_configs,
restart_map,
NEUTRON_CONF,
api_port,
CLUSTER_RES,
do_openstack_upgrade,
update_config_file
update_config_file,
setup_ipv6
)
from neutron_api_context import get_l2population
@@ -76,6 +72,7 @@ from charmhelpers.contrib.network.ip import (
is_ipv6
)
import charmhelpers.contrib.archive as archive
from charmhelpers.fetch.archiveurl import ArchiveUrlFetchHandler
hooks = Hooks()
CONFIGS = register_configs()
@@ -110,13 +107,17 @@ def install():
if config('neutron-plugin') is 'vsp':
archive.install()
archive.create_archive(ARCHIVE)
archive.include_deb(ARCHIVE, 'payload')
archive.configure_local_source(ARCHIVE)
if config('neutron-plugin-repository-url') is not None:
handler = ArchiveUrlFetchHandler()
path = handler.install(config('neutron-plugin-repository-url'))
archive.include_deb(ARCHIVE, path)
else:
archive.include_deb(ARCHIVE, 'payload')
archive.configure_local_source(ARCHIVE)
# Install configured packages
#nuage_dependencies = "nuage-neutron nuagenetlib neutron-plugin-nuage"
packages += "nuage-neutron"
packages += "nuagenetlib"
packages += config('vsp-packages').split()
apt_update()
apt_install(packages, fatal=True)
@@ -152,12 +153,18 @@ def config_changed():
raise ConfigurationError('vsd-server not specified')
vsd_server = config('vsd-server')
update_config_file(vsd_config_file, 'server', vsd_server)
#update_config_file(vsd_config_file, 'serverauth', config('vsd-auth'))
#update_config_file(vsd_config_file, 'serverssl', config('vsd-auth-ssl'))
#update_config_file(vsd_config_file, 'organization', config('vsd-organization'))
#update_config_file(vsd_config_file, 'base_uri', config('vsd-base-uri'))
#update_config_file(vsd_config_file, 'auth_resource', config('vsd-auth-resource'))
#update_config_file(vsd_config_file, 'default_net_partition_name', config('vsd-netpart-name'))
if config('vsd-auth'):
update_config_file(vsd_config_file, 'serverauth', config('vsd-auth'))
if config('vsd-auth-ssl'):
update_config_file(vsd_config_file, 'serverssl', config('vsd-auth-ssl'))
if config('vsd-organization'):
update_config_file(vsd_config_file, 'organization', config('vsd-organization'))
if config('vsd-base-uri'):
update_config_file(vsd_config_file, 'base_uri', config('vsd-base-uri'))
if config('vsd-auth-resource'):
update_config_file(vsd_config_file, 'auth_resource', config('vsd-auth-resource'))
if config('vsd-netpart-name'):
update_config_file(vsd_config_file, 'default_net_partition_name', config('vsd-netpart-name'))
@hooks.hook('amqp-relation-joined')

9
hooks/neutron_api_utils.py Normal file → Executable file
View File

@@ -213,10 +213,7 @@ def do_openstack_upgrade(configs):
migrate_neutron_database()
def update_config_file(config_file, key, value):
"""Updates or append configuration
as key value pairs """
#config_file = '/etc/default/openvswitch-switch'
#config_file = config('vrs-config-file')
"""Updates or append configuration as key value pairs """
insert_config = key + "=" + value
with open(config_file, "r+") as vrs_file:
mm = mmap.mmap(vrs_file.fileno(), 0)
@@ -226,14 +223,14 @@ def update_config_file(config_file, key, value):
match = re.search(search_str, mm, re.MULTILINE)
if match is not None:
start_index = match.start()
end_index = mm.find("\n", start_index)
end_index = mm.find("\n", match.end())
if end_index != -1:
origSize = end_index - start_index
if newSize > origSize:
newFileSize = origFileSize + len(insert_config) - origSize
mm.resize(newFileSize)
mm[start_index + newSize:] = mm[end_index:origFileSize]
else:
elif newSize < origSize:
insert_config += (" " * (int(origSize) - int(newSize)))
newSize = origSize
mm[start_index:start_index+newSize] = insert_config