Permalink
Browse files

[cm] Updates with adding management services and configuring them

  • Loading branch information...
1 parent 182d766 commit 47708532596005a39d830e87033b545e8c1062b6 @ashrithr ashrithr committed Mar 19, 2014
Showing with 187 additions and 5 deletions.
  1. +187 −5 cm/manifests/api/cluster.pp
@@ -1,10 +1,15 @@
-define cm::api::cluster($cluster_version = 'CDH4', $api_version = 'v5') {
- include cm::params
+# * Creates cluster
+# * Creates management services
+# * Configures management services
+define cm::api::cluster($cluster_version = 'CDH4') {
+ require cm::api::params
+ require cm::api::management_databases
validate_re($cluster_version, 'CDH4|CDH3')
+ # Creates a cluster entity
curl { "create-cluster-${name}":
- domain => "http://${::cm::params::cm_server_host}:${::cm::params::cm_server_port}",
- post => "/api/${api_version}/clusters",
+ domain => "http://${::cm::params::cm_server_host}:${::cm::params::cm_api_port}",
+ post => "/api/${::cm::api::params::api_version}/clusters",
parameters => "{
'items' => [
'name' => '${name}',
@@ -16,9 +21,186 @@
password => $::cm::params::cm_password,
returns => '200',
only_if => {
- 'get' => "/api/${api_version}/clusters/${name}/commands",
+ 'get' => "/api/${::cm::api::params::api_version}/clusters/${name}/commands",
'returns' => '404' # the above url dont exist if the cluster is not created
},
log_to => "/var/log/ankus/cm_api/create_cluster_${name}"
}
+
+ # Creates a management service
+ curl { "create-mngt-service-${name}":
+ domain => "http://${::cm::params::cm_server_host}:${::cm::params::cm_api_port}",
+ put => "/api/${::cm::api::params::api_version}/cm/service",
+ parameters => "{}",
+ request_type => 'json',
+ username => $::cm::params::cm_username,
+ password => $::cm::params::cm_password,
+ returns => '200',
+ only_if => {
+ 'get' => "/api/${::cm::api::params::api_version}/cm/service",
+ 'returns' => '404'
+ },
+ log_to => "/var/log/ankus/cm_api/create_mngt_service_${name}"
+ }
+
+ # Enable specified management services
+ curl { "create-mngt-services-${name}":
+ domain => "http://${::cm::params::cm_server_host}:${::cm::params::cm_api_port}",
+ post => "/api/${::cm::api::params::api_version}/cm/service/roles",
+ parameters => "{
+ 'items' => [
+ {
+ 'name' => 'ACTIVITYMONITOR1',
+ 'type' => 'ACTIVITYMONITOR',
+ 'hostRef' => '${::cm::params::cm_server_host}'
+ },
+ {
+ 'name' => 'SERVICEMONITOR1',
+ 'type' => 'SERVICEMONITOR',
+ 'hostRef' => '${::cm::params::cm_server_host}'
+ },
+ {
+ 'name' => 'HOSTMONITOR1',
+ 'type' => 'HOSTMONITOR',
+ 'hostRef' => '${::cm::params::cm_server_host}'
+ },
+ {
+ 'name' => 'EVENTSERVER1',
+ 'type' => 'EVENTSERVER',
+ 'hostRef' => '${::cm::params::cm_server_host}'
+ },
+ {
+ 'name' => 'ALERTPUBLISHER1',
+ 'type' => 'ALERTPUBLISHER',
+ 'hostRef' => '${::cm::params::cm_server_host}'
+ }
+ ]
+ }",
+ request_type => 'json',
+ username => $::cm::params::cm_username,
+ password => $::cm::params::cm_password,
+ returns => '200',
+ only_if => {
+ 'get' => "/api/${::cm::api::params::api_version}/cm/service/roles",
+ 'returns' => '404'
+ },
+ log_to => "/var/log/ankus/cm_api/create_mngt_services_${name}"
+ }
+
+ # change the base properties for activity monitor
+ curl { "configure-activity-monitory-${name}":
+ domain => "http://${::cm::params::cm_server_host}:${::cm::params::cm_api_port}",
+ post => "/api/${::cm::api::params::api_version}/cm/service/roleConfigGroups/MGMT-ACTIVITYMONITOR-BASE/config",
+ parameters => "{
+ 'items' => [
+ {
+ 'name' => 'firehose_database_host',
+ 'value' => '${::cm::params::cm_server_host}'
+ },
+ {
+ 'name' => 'firehose_database_name',
+ 'value' => '${::cm::params::cm_amon_database_name}'
+ },
+ {
+ 'name' => 'firehose_database_user',
+ 'value' => '${::cm::params::cm_amon_database_user}'
+ },
+ {
+ 'name' => 'firehose_listen_port',
+ 'value' => '${::cm::params::cm_amon_listen_port}'
+ },
+ {
+ 'name' => 'firehose_database_type',
+ 'value' => '${::cm::params::cm_amon_database_type}'
+ },
+ {
+ 'name' => 'firehose_database_password',
+ 'value' => '${::cm::params::cm_amon_database_password}'
+ }
+ ]
+ }",
+ request_type => 'json',
+ username => $::cm::params::cm_username,
+ password => $::cm::params::cm_password,
+ returns => '200',
+ log_to => "/var/log/ankus/cm_api/configure_activity_monitor_${name}"
+ }
+
+ # change the base properties for service monitor
+ curl { "configure-service-monitory-${name}":
+ domain => "http://${::cm::params::cm_server_host}:${::cm::params::cm_api_port}",
+ post => "/api/${::cm::api::params::api_version}/cm/service/roleConfigGroups/MGMT-SERVICEMONITOR-BASE/config",
+ parameters => "{
+ 'items' => [
+ {
+ 'name' => 'firehose_database_host',
+ 'value' => '${::cm::params::cm_server_host}'
+ },
+ {
+ 'name' => 'firehose_database_name',
+ 'value' => '${::cm::params::cm_smon_database_name}'
+ },
+ {
+ 'name' => 'firehose_database_user',
+ 'value' => '${::cm::params::cm_smon_database_user}'
+ },
+ {
+ 'name' => 'firehose_listen_port',
+ 'value' => '${::cm::params::cm_smon_listen_port}'
+ },
+ {
+ 'name' => 'firehose_database_type',
+ 'value' => '${::cm::params::cm_smon_database_type}'
+ },
+ {
+ 'name' => 'firehose_database_password',
+ 'value' => '${::cm::params::cm_smon_database_password}'
+ }
+ ]
+ }",
+ request_type => 'json',
+ username => $::cm::params::cm_username,
+ password => $::cm::params::cm_password,
+ returns => '200',
+ log_to => "/var/log/ankus/cm_api/configure_service_monitor_${name}"
+ }
+
+ # change the base properties for host monitor
+ curl { "configure-host-monitor-${name}":
+ domain => "http://${::cm::params::cm_server_host}:${::cm::params::cm_api_port}",
+ post => "/api/${::cm::api::params::api_version}/cm/service/roleConfigGroups/MGMT-HOSTMONITOR-BASE/config",
+ parameters => "{
+ 'items' => [
+ {
+ 'name' => 'firehose_database_host',
+ 'value' => '${::cm::params::cm_server_host}'
+ },
+ {
+ 'name' => 'firehose_database_name',
+ 'value' => '${::cm::params::cm_hmon_database_name}'
+ },
+ {
+ 'name' => 'firehose_database_user',
+ 'value' => '${::cm::params::cm_hmon_database_user}'
+ },
+ {
+ 'name' => 'firehose_listen_port',
+ 'value' => '${::cm::params::cm_hmon_listen_port}'
+ },
+ {
+ 'name' => 'firehose_database_type',
+ 'value' => '${::cm::params::cm_hmon_database_type}'
+ },
+ {
+ 'name' => 'firehose_database_password',
+ 'value' => '${::cm::params::cm_hmon_database_password}'
+ }
+ ]
+ }",
+ request_type => 'json',
+ username => $::cm::params::cm_username,
+ password => $::cm::params::cm_password,
+ returns => '200',
+ log_to => "/var/log/ankus/cm_api/configure_host_monitor_${name}"
+ }
}

0 comments on commit 4770853

Please sign in to comment.