Skip to content

Commit

Permalink
Fix suse (crowbar#23)
Browse files Browse the repository at this point in the history
* Register monasca endpoints in Keystone

* Fix kibana url

* Rearrange helper functions
  • Loading branch information
samirjorina authored and jgrassler committed Mar 29, 2017
1 parent 60e5cdd commit 827ee80
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ DASHBOARDS = getattr(settings, 'GRAFANA_LINKS', GRAFANA_LINKS)
#]

ENABLE_KIBANA_BUTTON = getattr(settings, 'ENABLE_KIBANA_BUTTON', <%= @kibana_enabled ? "True" : "False" %>)
KIBANA_HOST = getattr(settings, 'KIBANA_HOST', '<%= @kibana_host %>')
# TODO: this needs to be fixed for clustered deployment
KIBANA_HOST = getattr(settings, 'KIBANA_HOST', 'http://<%= @kibana_host %>:5601/')

OPENSTACK_SSL_NO_VERIFY = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
OPENSTACK_SSL_CACERT = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
18 changes: 18 additions & 0 deletions chef/cookbooks/monasca/libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ def self.api_public_url(node)
"#{protocol}://#{host}:#{port}/v2.0"
end

def self.api_admin_url(node)
host = monasca_admin_host(node)
# SSL is not supported at this moment
# protocol = node[:monasca][:api][:ssl] ? "https" : "http"
protocol = "http"
port = node[:monasca][:api][:bind_port]
"#{protocol}://#{host}:#{port}/v2.0"
end

def self.api_internal_url(node)
host = get_host_for_monitoring_url(node)
# SSL is not supported at this moment
# protocol = node[:monasca][:api][:ssl] ? "https" : "http"
protocol = "http"
port = node[:monasca][:api][:bind_port]
"#{protocol}://#{host}:#{port}/v2.0"
end

def self.log_api_public_url(node)
host = monasca_public_host(node)
# SSL is not supported at this moment
Expand Down
75 changes: 62 additions & 13 deletions chef/cookbooks/monasca/recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,70 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# TODO: Fill this with code that deploys the Monasca backend services

### Example code for retrieving a database URL and keystone settings:
keystone_settings = KeystoneHelper.keystone_settings(node, @cookbook_name)

# keystone_settings = KeystoneHelper.keystone_settings(node, @cookbook_name),
register_auth_hash = {
user: keystone_settings["admin_user"],
password: keystone_settings["admin_password"],
tenant: keystone_settings["admin_tenant"]
}

# db_settings = fetch_database_settings
# db_conn_scheme = db_settings[:url_scheme]
keystone_register "monasca api wakeup keystone" do
protocol keystone_settings["protocol"]
insecure keystone_settings["insecure"]
host keystone_settings["internal_url_host"]
port keystone_settings["admin_port"]
auth register_auth_hash
action :wakeup
end

# if db_settings[:backend_name] == "mysql"
# db_conn_scheme = "mysql+pymysql"
# end
keystone_register "register monasca api user" do
protocol keystone_settings["protocol"]
insecure keystone_settings["insecure"]
host keystone_settings["internal_url_host"]
port keystone_settings["admin_port"]
auth register_auth_hash
user_name keystone_settings["service_user"]
user_password keystone_settings["service_password"]
tenant_name keystone_settings["service_tenant"]
action :add_user
end

# database_connection = "#{db_conn_scheme}://" \
# "#{node[:monasca][:db][:user]}" \
# ":#{node[:monasca][:db][:password]}" \
# "@#{db_settings[:address]}" \
# "/#{node[:monasca][:db][:database]}"
keystone_register "give monasca api user access" do
protocol keystone_settings["protocol"]
insecure keystone_settings["insecure"]
host keystone_settings["internal_url_host"]
port keystone_settings["admin_port"]
auth register_auth_hash
user_name keystone_settings["service_user"]
tenant_name keystone_settings["service_tenant"]
role_name "admin"
action :add_access
end

keystone_register "register monasca api service" do
protocol keystone_settings["protocol"]
insecure keystone_settings["insecure"]
host keystone_settings["internal_url_host"]
port keystone_settings["admin_port"]
auth register_auth_hash
service_name "monasca"
service_type "monitoring"
service_description "Monasca monitoring service"
action :add_service
end

keystone_register "register monasca api endpoint" do
protocol keystone_settings["protocol"]
insecure keystone_settings["insecure"]
host keystone_settings["internal_url_host"]
port keystone_settings["admin_port"]
auth register_auth_hash
endpoint_service "monasca"
endpoint_region keystone_settings["endpoint_region"]
endpoint_publicURL MonascaHelper.api_public_url(node)
endpoint_adminURL MonascaHelper.api_admin_url(node)
endpoint_internalURL MonascaHelper.api_internal_url(node)
action :add_endpoint_template
end

0 comments on commit 827ee80

Please sign in to comment.