Bulk copy files to /etc/neutron

This commit is contained in:
Corey Bryant 2015-04-13 18:56:12 +00:00
parent e81544c224
commit b8cd0419f0
2 changed files with 16 additions and 224 deletions

View File

@ -863,178 +863,19 @@ def git_pre_install():
def git_post_install(projects_yaml):
"""Perform post-install setup."""
src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
etc_configs = {
'api-paste': {
'src': os.path.join(src_etc, 'api-paste.ini'),
'dest': '/etc/neutron/api-paste.ini',
},
'dhcp_agent': {
'src': os.path.join(src_etc, 'dhcp_agent.ini'),
'dest': '/etc/neutron/dhcp_agent.ini',
},
'fwaas_driver': {
'src': os.path.join(src_etc, 'fwaas_driver.ini'),
'dest': '/etc/neutron/fwaas_driver.ini',
},
'l3_agent': {
'src': os.path.join(src_etc, 'l3_agent.ini'),
'dest': '/etc/neutron/l3_agent.ini',
},
'lbaas_agent': {
'src': os.path.join(src_etc, 'lbaas_agent.ini'),
'dest': '/etc/neutron/lbaas_agent.ini',
},
'metadata_agent': {
'src': os.path.join(src_etc, 'metadata_agent.ini'),
'dest': '/etc/neutron/metadata_agent.ini',
},
'metering_agent': {
'src': os.path.join(src_etc, 'metering_agent.ini'),
'dest': '/etc/neutron/metering_agent.ini',
},
'policy': {
'src': os.path.join(src_etc, 'policy.json'),
'dest': '/etc/neutron/policy.json',
},
'rootwrap': {
'src': os.path.join(src_etc, 'rootwrap.conf'),
'dest': '/etc/neutron/rootwrap.conf',
},
'vpn_agent': {
'src': os.path.join(src_etc, 'vpn_agent.ini'),
'dest': '/etc/neutron/vpn_agent.ini',
},
}
configs = [
{'src': src_etc,
'dest': '/etc/neutron'},
{'src': os.path.join(src_etc, 'neutron/plugins'),
'dest': '/etc/neutron/plugins'},
{'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
'dest': '/etc/neutron/rootwrap.d'},
]
for conf, files in etc_configs.iteritems():
if os.path.exists(files['src']):
shutil.copyfile(files['src'], files['dest'])
src_plugins = os.path.join(src_etc, 'neutron/plugins')
plugins_configs = {
'bigswitch': {
'src': os.path.join(src_plugins, 'bigswitch'),
'dest': '/etc/neutron/plugins/bigswitch',
},
'brocade': {
'src': os.path.join(src_plugins, 'brocade'),
'dest': '/etc/neutron/plugins/brocade',
},
'cisco': {
'src': os.path.join(src_plugins, 'cisco'),
'dest': '/etc/neutron/plugins/cisco',
},
'hyperv': {
'src': os.path.join(src_plugins, 'hyperv'),
'dest': '/etc/neutron/plugins/hyperv',
},
'ibm': {
'src': os.path.join(src_plugins, 'ibm'),
'dest': '/etc/neutron/plugins/ibm',
},
'metaplugin': {
'src': os.path.join(src_plugins, 'metaplugin'),
'dest': '/etc/neutron/plugins/metaplugin',
},
'midonet': {
'src': os.path.join(src_plugins, 'midonet'),
'dest': '/etc/neutron/plugins/midonet',
},
'ml2': {
'src': os.path.join(src_plugins, 'ml2'),
'dest': '/etc/neutron/plugins/ml2',
},
'mlnx': {
'src': os.path.join(src_plugins, 'mlnx'),
'dest': '/etc/neutron/plugins/mlnx',
},
'nec': {
'src': os.path.join(src_plugins, 'nec'),
'dest': '/etc/neutron/plugins/nec',
},
'nuage': {
'src': os.path.join(src_plugins, 'nuage'),
'dest': '/etc/neutron/plugins/nuage',
},
'oneconvergence': {
'src': os.path.join(src_plugins, 'oneconvergence'),
'dest': '/etc/neutron/plugins/oneconvergence',
},
'opencontrail': {
'src': os.path.join(src_plugins, 'opencontrail'),
'dest': '/etc/neutron/plugins/opencontrail',
},
'plumgrid': {
'src': os.path.join(src_plugins, 'plumgrid'),
'dest': '/etc/neutron/plugins/plumgrid',
},
'ryu': {
'src': os.path.join(src_plugins, 'ryu'),
'dest': '/etc/neutron/plugins/ryu',
},
'vmware': {
'src': os.path.join(src_plugins, 'vmware'),
'dest': '/etc/neutron/plugins/vmware',
},
}
for conf, dirs in plugins_configs.iteritems():
if os.path.exists(dirs['src']):
if os.path.exists(dirs['dest']):
shutil.rmtree(dirs['dest'])
shutil.copytree(dirs['src'], dirs['dest'])
src_rootwrap = os.path.join(src_etc, 'neutron/rootwrap.d')
rootwrap_configs = {
'debug-filters': {
'src': os.path.join(src_rootwrap, 'debug.filters'),
'dest': '/etc/neutron/rootwrap.d/debug.filters',
},
'dhcp-filters': {
'src': os.path.join(src_rootwrap, 'dhcp.filters'),
'dest': '/etc/neutron/rootwrap.d/dhcp.filters',
},
'ipset-firewall-filters': {
'src': os.path.join(src_rootwrap, 'ipset-firewall.filters'),
'dest': '/etc/neutron/rootwrap.d/ipset-firewall.filters',
},
'iptables-firewall-filters': {
'src': os.path.join(src_rootwrap, 'iptables-firewall.filters'),
'dest': '/etc/neutron/rootwrap.d/iptables-firewall.filters',
},
'l3-filters': {
'src': os.path.join(src_rootwrap, 'l3.filters'),
'dest': '/etc/neutron/rootwrap.d/l3.filters',
},
'lbaas-haproxy': {
'src': os.path.join(src_rootwrap, 'lbaas-haproxy.filters'),
'dest': '/etc/neutron/rootwrap.d/lbaas-haproxy.filters',
},
'linuxbridge-plugin': {
'src': os.path.join(src_rootwrap, 'linuxbridge-plugin.filters'),
'dest': '/etc/neutron/rootwrap.d/linuxbridge-plugin.filters',
},
'nec-plugin': {
'src': os.path.join(src_rootwrap, 'nec-plugin.filters'),
'dest': '/etc/neutron/rootwrap.d/nec-plugin.filters',
},
'openvswitch-plugin': {
'src': os.path.join(src_rootwrap, 'openvswitch-plugin.filters'),
'dest': '/etc/neutron/rootwrap.d/openvswitch-plugin.filters',
},
'ryu-plugin': {
'src': os.path.join(src_rootwrap, 'ryu-plugin.filters'),
'dest': '/etc/neutron/rootwrap.d/ryu-plugin.filters',
},
'vpnaas': {
'src': os.path.join(src_rootwrap, 'vpnaas.filters'),
'dest': '/etc/neutron/rootwrap.d/vpnaas.filters',
},
}
for conf, files in rootwrap_configs.iteritems():
if os.path.exists(files['src']):
shutil.copyfile(files['src'], files['dest'])
for c in configs:
if os.path.exists(c['dest']):
shutil.rmtree(c['dest'])
shutil.copytree(c['src'], c['dest'])
symlinks = [
{'src': '/usr/local/bin/neutron-rootwrap',

View File

@ -792,60 +792,11 @@ class TestQuantumAgentReallocation(CharmTestCase):
join.return_value = 'joined-string'
quantum_utils.git_post_install(projects_yaml)
expected = [
call('joined-string', '/etc/neutron/api-paste.ini'),
call('joined-string', '/etc/neutron/dhcp_agent.ini'),
call('joined-string', '/etc/neutron/fwaas_driver.ini'),
call('joined-string', '/etc/neutron/l3_agent.ini'),
call('joined-string', '/etc/neutron/lbaas_agent.ini'),
call('joined-string', '/etc/neutron/metadata_agent.ini'),
call('joined-string', '/etc/neutron/metering_agent.ini'),
call('joined-string', '/etc/neutron/policy.json'),
call('joined-string', '/etc/neutron/rootwrap.conf'),
call('joined-string', '/etc/neutron/vpn_agent.ini'),
call('joined-string', '/etc/neutron'),
call('joined-string', '/etc/neutron/plugins'),
call('joined-string', '/etc/neutron/rootwrap.d'),
]
copyfile.assert_has_calls(expected, any_order=True)
expected = [
call('joined-string', '/etc/neutron/plugins/bigswitch'),
call('joined-string', '/etc/neutron/plugins/brocade'),
call('joined-string', '/etc/neutron/plugins/cisco'),
call('joined-string', '/etc/neutron/plugins/hyperv'),
call('joined-string', '/etc/neutron/plugins/ibm'),
call('joined-string', '/etc/neutron/plugins/metaplugin'),
call('joined-string', '/etc/neutron/plugins/midonet'),
call('joined-string', '/etc/neutron/plugins/ml2'),
call('joined-string', '/etc/neutron/plugins/mlnx'),
call('joined-string', '/etc/neutron/plugins/nec'),
call('joined-string', '/etc/neutron/plugins/nuage'),
call('joined-string', '/etc/neutron/plugins/oneconvergence'),
call('joined-string', '/etc/neutron/plugins/opencontrail'),
call('joined-string', '/etc/neutron/plugins/plumgrid'),
call('joined-string', '/etc/neutron/plugins/ryu'),
call('joined-string', '/etc/neutron/plugins/vmware'),
]
copytree.assert_has_calls(expected, any_order=True)
expected = [
call('joined-string',
'/etc/neutron/rootwrap.d/dhcp.filters'),
call('joined-string',
'/etc/neutron/rootwrap.d/ipset-firewall.filters'),
call('joined-string',
'/etc/neutron/rootwrap.d/iptables-firewall.filters'),
call('joined-string',
'/etc/neutron/rootwrap.d/l3.filters'),
call('joined-string',
'/etc/neutron/rootwrap.d/lbaas-haproxy.filters'),
call('joined-string',
'/etc/neutron/rootwrap.d/linuxbridge-plugin.filters'),
call('joined-string',
'/etc/neutron/rootwrap.d/nec-plugin.filters'),
call('joined-string',
'/etc/neutron/rootwrap.d/openvswitch-plugin.filters'),
call('joined-string',
'/etc/neutron/rootwrap.d/ryu-plugin.filters'),
call('joined-string',
'/etc/neutron/rootwrap.d/vpnaas.filters'),
]
copyfile.assert_has_calls(expected, any_order=True)
copytree.assert_has_calls(expected)
expected = [
call('/usr/local/bin/neutron-rootwrap',
'/usr/bin/neutron-rootwrap'),