# 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 Keystone
keystoneDatabasePassword = osicommon.get_config_ini(iniPath, 'keystone', 'database_user_password')
juno.install_keystone(keystoneDatabasePassword, managementNetworkIP, mysqlPassword)

# Install Glance
glanceDatabasePassword = osicommon.get_config_ini(iniPath, 'glance', 'database_user_password')
juno.install_glance(glanceDatabasePassword, managementNetworkIP, mysqlPassword)
# Install INI path
iniPath = os.path.join(os.path.dirname(__file__), 'juno-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
juno.install_ntp(controlManagementNetworkIP)

# Install Neutron
neutronDatabasePassword = osicommon.get_config_ini(iniPath, 'neutron', 'database_user_password')
juno.install_neutron_on_network_node(neutronDatabasePassword, controlManagementNetworkIP, instanceNetworkIP, externalNetworkInterface, internetNetworkInterface, providerExternalNetworkCIDR)

print ''
osicommon.log('Finished installation')
print ''

# Install INI path
iniPath = os.path.join(os.path.dirname(__file__), "juno-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
juno.install_ntp(controlManagementNetworkIP)

# Install Nova
novaDatabasePassword = osicommon.get_config_ini(iniPath, "nova", "database_user_password")
juno.install_nova_on_compute_node(novaDatabasePassword, controlManagementNetworkIP, managementNetworkIP)

# Install Neutron
neutronDatabasePassword = osicommon.get_config_ini(iniPath, "neutron", "database_user_password")
juno.install_neutron_on_compute_node(neutronDatabasePassword, controlManagementNetworkIP, instanceNetworkIP)

print ""
osicommon.log("Finished installation")
print ""
# 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 Keystone
keystoneDatabasePassword = osicommon.get_config_ini(iniPath, 'keystone',
                                                    'database_user_password')
juno.install_keystone(keystoneDatabasePassword, managementNetworkIP,
                      mysqlPassword)

# Install Glance