diff --git a/plugins/global_000.py b/plugins/global_000.py index 54905a4d5..78957a606 100644 --- a/plugins/global_000.py +++ b/plugins/global_000.py @@ -56,6 +56,18 @@ def initConfig(controllerObject): "USE_DEFAULT" : False, "NEED_CONFIRM" : False, "CONDITION" : False }, + {"CMD_OPTION" : "os-swift-install", + "USAGE" : "Install Swift?", + "PROMPT" : "Install Swift?", + "OPTION_LIST" : ["y", "n"], + "VALIDATION_FUNC" : validate.validateOptions, + "DEFAULT_VALUE" : "n", + "MASK_INPUT" : False, + "LOOSE_VALIDATION": False, + "CONF_NAME" : "CONFIG_OS_SWIFT_INSTALL", + "USE_DEFAULT" : False, + "NEED_CONFIRM" : False, + "CONDITION" : False }, ] groupDict = { "GROUP_NAME" : "GLOBAL", diff --git a/plugins/swift_600.py b/plugins/swift_600.py new file mode 100644 index 000000000..9e541324e --- /dev/null +++ b/plugins/swift_600.py @@ -0,0 +1,113 @@ +""" +Installs and configures an openstack dashboard +""" + +import logging +import os +import uuid + +import engine_validators as validate +import basedefs +import common_utils as utils +from ospluginutils import NovaConfig, getManifestTemplate, appendManifestFile + +# Controller object will be initialized from main flow +controller = None + +# Plugin name +PLUGIN_NAME = "OS-DASHBOARD" +PLUGIN_NAME_COLORED = utils.getColoredText(PLUGIN_NAME, basedefs.BLUE) + +logging.debug("plugin %s loaded", __name__) + +def initConfig(controllerObject): + global controller + controller = controllerObject + logging.debug("Adding Openstack dashboard configuration") + paramsList = [ + {"CMD_OPTION" : "os-swift-proxy", + "USAGE" : "Hostname of the Swift Proxy server", + "PROMPT" : "Hostname of the Swift Proxy server", + "OPTION_LIST" : [], + "VALIDATION_FUNC" : validate.validatePing, + "DEFAULT_VALUE" : "localhost", + "MASK_INPUT" : False, + "LOOSE_VALIDATION": True, + "CONF_NAME" : "CONFIG_SWIFT_PROXY", + "USE_DEFAULT" : False, + "NEED_CONFIRM" : False, + "CONDITION" : False }, + {"CMD_OPTION" : "os-swift-storage", + "USAGE" : "Hostname of the Swift Storage servers (comma seperated)", + "PROMPT" : "Hostname of the Swift Storage servers (comma seperated)", + "OPTION_LIST" : [], + "VALIDATION_FUNC" : validate.validateMultiPing, + "DEFAULT_VALUE" : "localhost", + "MASK_INPUT" : False, + "LOOSE_VALIDATION": True, + "CONF_NAME" : "CONFIG_SWIFT_STORAGE", + "USE_DEFAULT" : False, + "NEED_CONFIRM" : False, + "CONDITION" : False }, + ] + + groupDict = { "GROUP_NAME" : "OSSWIFT", + "DESCRIPTION" : "OpenStack Swift Config paramaters", + "PRE_CONDITION" : "CONFIG_OS_SWIFT_INSTALL", + "PRE_CONDITION_MATCH" : "y", + "POST_CONDITION" : False, + "POST_CONDITION_MATCH" : True} + + controller.addGroup(groupDict, paramsList) + + +def initSequences(controller): + if controller.CONF['CONFIG_OS_SWIFT_INSTALL'] != 'y': + return + + steps = [ + {'title': 'Adding Swift Keystone Manifest entries', 'functions':[createkeystonemanifest]}, + {'title': 'Creating OS Swift builder Manifests', 'functions':[createbuildermanifest]}, + {'title': 'Creating OS Swift proxy Manifests', 'functions':[createproxymanifest]}, + {'title': 'Creating OS Swift storage Manifests', 'functions':[createstoragemanifest]}, + {'title': 'Creating OS Swift Common Manifests', 'functions':[createcommonmanifest]}, + ] + controller.addSequence("Installing OpenStack Dashboard", [], [], steps) + +def createkeystonemanifest(): + manifestfile = "%s_keystone.pp"%controller.CONF['CONFIG_KEYSTONE_HOST'] + manifestdata = getManifestTemplate("keystone_swift.pp") + appendManifestFile(manifestfile, manifestdata) + +# The ring file should be built and distributed befor the storage services +# come up. Specifically the replicator crashes if the ring isn't present +def createbuildermanifest(): + # TODO : put this on the proxy server, will need to change this later + manifestfile = "%s_ring_swift.pp"%controller.CONF['CONFIG_SWIFT_PROXY'] + manifestdata = getManifestTemplate("swift_builder.pp") + + # Add each device to the ring + for host in controller.CONF["CONFIG_SWIFT_STORAGE"].split(","): + manifestdata = manifestdata + '\n@@ring_object_device { "%s:6000/1":\n zone => 1,\n weight => 1, }'%host + manifestdata = manifestdata + '\n@@ring_container_device { "%s:6001/1":\n zone => 1,\n weight => 1, }'%host + manifestdata = manifestdata + '\n@@ring_account_device { "%s:6002/1":\n zone => 1,\n weight => 1, }'%host + + appendManifestFile(manifestfile, manifestdata) + +def createproxymanifest(): + manifestfile = "%s_swift.pp"%controller.CONF['CONFIG_SWIFT_PROXY'] + manifestdata = getManifestTemplate("swift_proxy.pp") + appendManifestFile(manifestfile, manifestdata) + +def createstoragemanifest(): + for host in controller.CONF["CONFIG_SWIFT_STORAGE"].split(","): + controller.CONF["CONFIG_SWIFT_STORAGE_CURRENT"] = host + manifestfile = "%s_swift.pp"%host + manifestdata = getManifestTemplate("swift_storage.pp") + appendManifestFile(manifestfile, manifestdata) + +def createcommonmanifest(): + for manifestfile in controller.CONF['CONFIG_MANIFESTFILES']: + if manifestfile.endswith("_swift.pp"): + data = getManifestTemplate("swift_common.pp") + appendManifestFile(os.path.split(manifestfile)[1], data) diff --git a/puppet/templates/keystone_swift.pp b/puppet/templates/keystone_swift.pp new file mode 100644 index 000000000..3e551fb8b --- /dev/null +++ b/puppet/templates/keystone_swift.pp @@ -0,0 +1,4 @@ +class { 'swift::keystone::auth': + address => '%(CONFIG_SWIFT_PROXY)s', + password => 'ChangeMe', +} diff --git a/puppet/templates/swift_builder.pp b/puppet/templates/swift_builder.pp new file mode 100644 index 000000000..37ad9d3af --- /dev/null +++ b/puppet/templates/swift_builder.pp @@ -0,0 +1,8 @@ + +class { 'swift::ringbuilder': + part_power => '18', + replicas => '1', + min_part_hours => 1, + require => Class['swift'], +} + diff --git a/puppet/templates/swift_common.pp b/puppet/templates/swift_common.pp new file mode 100644 index 000000000..46349df7b --- /dev/null +++ b/puppet/templates/swift_common.pp @@ -0,0 +1,9 @@ + +class { 'ssh::server::install': } + +class { 'swift': + # not sure how I want to deal with this shared secret + swift_hash_suffix => 'swift_shared_secret', + package_ensure => latest, +} + diff --git a/puppet/templates/swift_proxy.pp b/puppet/templates/swift_proxy.pp new file mode 100644 index 000000000..d9b0533e8 --- /dev/null +++ b/puppet/templates/swift_proxy.pp @@ -0,0 +1,51 @@ + +package { 'curl': ensure => present } + +class { 'memcached': +} + +class { 'swift::proxy': + proxy_local_net_ip => '%(CONFIG_SWIFT_PROXY)s', + pipeline => [ +# 'catch_errors', + 'healthcheck', + 'cache', +# 'ratelimit', +# 'swift3', +# 's3token', + 'authtoken', + 'keystone', + 'proxy-server' + ], + account_autocreate => true, +} + +# configure all of the middlewares +class { [ + 'swift::proxy::catch_errors', + 'swift::proxy::healthcheck', + 'swift::proxy::cache', + 'swift::proxy::swift3', +]: } +class { 'swift::proxy::ratelimit': + clock_accuracy => 1000, + max_sleep_time_seconds => 60, + log_sleep_time_seconds => 0, + rate_buffer_seconds => 5, + account_ratelimit => 0 +} +class { 'swift::proxy::s3token': + # assume that the controller host is the swift api server + auth_host => $controller_node_public, + auth_port => '35357', +} +class { 'swift::proxy::keystone': + operator_roles => ['admin', 'SwiftOperator'], +} +class { 'swift::proxy::authtoken': + admin_user => 'swift', + admin_tenant_name => 'services', + admin_password => $swift_user_password, + # assume that the controller host is the swift api server + auth_host => $controller_node_public, +} diff --git a/puppet/templates/swift_storage.pp b/puppet/templates/swift_storage.pp new file mode 100644 index 000000000..241a10be5 --- /dev/null +++ b/puppet/templates/swift_storage.pp @@ -0,0 +1,24 @@ + +$swift_zone = 1 +include role_swift_storage + + +class role_swift_storage { + + # create xfs partitions on a loopback device and mount them + swift::storage::loopback { ['1']: + base_dir => '/srv/loopback-device', + mnt_base_dir => '/srv/node', + require => Class['swift'], + } + + # install all swift storage servers together + class { 'swift::storage::all': + storage_local_net_ip => '%(CONFIG_SWIFT_STORAGE_CURRENT)s', + } + + # collect resources for synchronizing the ring databases + Swift::Ringsync<<||>> + +} +