print '#######################################################################'
print '# OpenStack Juno Control Node Setup'
print '#######################################################################'
osicommon.log('Starting installation')
print ''

# Update, Upgrade, Add Repo
juno.base_system_update()

# Install INI path
iniPath = os.path.join(os.path.dirname(__file__), 'juno-install.ini')

# Get network addresses
managementNetworkInterface = osicommon.get_config_ini(iniPath, 'control', 'network_interface_management')
managementNetworkIP = osicommon.get_network_address(managementNetworkInterface)
osicommon.set_config_ini(iniPath, 'control', 'network_address_management', managementNetworkIP)
print ''
osicommon.log('Using network addresses:')
print '    Control Node Management Network Address: ' + str(managementNetworkIP)

# Install NTP
juno.install_ntp(managementNetworkIP)

# Install RabbitMQ
juno.install_rabbitmq()

# Install MySQL
mysqlPassword = osicommon.get_config_ini(iniPath, 'mysql', 'root_password')
juno.install_mysql(mysqlPassword)
# Install vlan
icehouse.install_vlan()

# Install bridge-utils
icehouse.install_bridgeutils()

# Install INI path
iniPath = os.path.join(os.path.dirname(__file__), 'icehouse-install.ini')

# Get network addresses
controlManagementNetworkIP = osicommon.get_config_ini(
    iniPath, 'control', 'network_address_management')
instanceNetworkInterface = osicommon.get_config_ini(
    iniPath, 'network', 'network_interface_instance')
instanceNetworkIP = osicommon.get_network_address(instanceNetworkInterface)
externalNetworkInterface = osicommon.get_config_ini(
    iniPath, 'network', 'network_interface_external')
internetNetworkInterface = osicommon.get_config_ini(
    iniPath, 'network', 'network_interface_internet')
providerExternalNetworkCIDR = osicommon.get_config_ini(
    iniPath, 'network', 'openstack_external_network')

print ''
osicommon.log('Using network addresses:')
print '    Control Node Management Network Address: ' + str(
    controlManagementNetworkIP)
print '    Network Node Instance Network Address: ' + str(instanceNetworkIP)
print '    Network Node External Network Interface: ' + str(
    externalNetworkInterface)
print '    Network Node Internet Network Interface: ' + str(
osicommon.set_sysctl('net.ipv4.conf.all.rp_filter', '0')
osicommon.set_sysctl('net.ipv4.conf.default.rp_filter', '0')

# Install vlan
icehouse.install_vlan()

# Install bridge-utils
icehouse.install_bridgeutils()

# Install INI path
iniPath = os.path.join(os.path.dirname(__file__), 'icehouse-install.ini')

# Get network addresses
managementNetworkInterface = osicommon.get_config_ini(
    iniPath, 'compute', 'network_interface_management')
managementNetworkIP = osicommon.get_network_address(managementNetworkInterface)
instanceNetworkInterface = osicommon.get_config_ini(
    iniPath, 'compute', 'network_interface_instance')
instanceNetworkIP = osicommon.get_network_address(instanceNetworkInterface)
controlManagementNetworkIP = osicommon.get_config_ini(
    iniPath, 'control', 'network_address_management')
print ''
osicommon.log('Using network addresses:')
print '    Control Node Management Network Address: ' + str(
    controlManagementNetworkIP)
print '    Compute Node Management Network Address: ' + str(
    managementNetworkIP)
print '    Compute Node Instance Network Address: ' + str(instanceNetworkIP)

# Install NTP
icehouse.install_ntp(controlManagementNetworkIP)
osicommon.set_sysctl('net.ipv4.conf.all.rp_filter', '0')
osicommon.set_sysctl('net.ipv4.conf.default.rp_filter', '0')

# Install vlan
icehouse.install_vlan()

# Install bridge-utils
icehouse.install_bridgeutils()

# Install INI path
iniPath = os.path.join(os.path.dirname(__file__), 'icehouse-install.ini')

# Get network addresses
controlManagementNetworkIP = osicommon.get_config_ini(iniPath, 'control', 'network_address_management')
instanceNetworkInterface = osicommon.get_config_ini(iniPath, 'network', 'network_interface_instance')
instanceNetworkIP = osicommon.get_network_address(instanceNetworkInterface)
externalNetworkInterface = osicommon.get_config_ini(iniPath, 'network', 'network_interface_external')
internetNetworkInterface = osicommon.get_config_ini(iniPath, 'network', 'network_interface_internet')
providerExternalNetworkCIDR = osicommon.get_config_ini(iniPath, 'network', 'openstack_external_network')

print ''
osicommon.log('Using network addresses:')
print '    Control Node Management Network Address: ' + str(controlManagementNetworkIP)
print '    Network Node Instance Network Address: ' + str(instanceNetworkIP)
print '    Network Node External Network Interface: ' + str(externalNetworkInterface)
print '    Network Node Internet Network Interface: ' + str(internetNetworkInterface)

# Install NTP
icehouse.install_ntp(controlManagementNetworkIP)

# Install Neutron