-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathprovisionator.py
More file actions
68 lines (49 loc) · 1.71 KB
/
provisionator.py
File metadata and controls
68 lines (49 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
#
# (c) Copyright 2015 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import sys
from cm_api.api_client import ApiException
import cluster
import cm
import config
import mgmt
import util
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
LOG = logging.getLogger(__name__)
def provision(config):
try:
# Open a connection to CM and get a CM object
api = util.get_api_handle(config)
# Get dictionary of hostname to host ids
host_id_map = util.host_id_map(config, api)
# Update CM config
cm.update_config(config, api)
# Update CM license
cm.update_license(config, api)
# Update all hosts configuration
cm.update_hosts_config(config, api)
# Create Cloudera Management Services
mgmt.add_or_update(config, api, host_id_map)
# Add cluster and services
cluster.add_or_update(config, api, host_id_map)
except ApiException, e:
logging.error("Error: %s" % e)
if __name__ == "__main__":
if len(sys.argv) < 2:
logging.fatal("No configuration file specified")
sys.exit(-1)
config = config.read_config(sys.argv[1])
provision(config)