-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnodes.py
143 lines (130 loc) · 5.39 KB
/
nodes.py
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import os
def generateIPs(networkName):
resource = {
"name": networkName,
"parentpool": "/oracle/public/ippool",
"permanent": "true"
}
return resource
def generateStorageVols(ocp_user, osImage, boot_vol_name, app_data_vol_name, boot_vol_size, data_vol_size):
resource = [
{
"name": ocp_user + "/" + boot_vol_name,
"bootable": "true",
"imagelist": osImage,
"properties": ["/oracle/public/storage/default"],
"size": boot_vol_size
},
{
"name": ocp_user + "/" + app_data_vol_name,
"properties": ["/oracle/public/storage/latency"],
"size": data_vol_size
}
]
return resource
def generateInstanceNode(opc_domain, ocp_user, location, sshKey, vmType, securityList, hostname, boot_disk,
app_data_disk, ip_label, node_ip_addr, opscenter_ip_addr, sshKeyPath, index, nodeCount, cassandraPasswd):
publicKey = open(sshKeyPath, 'r').read()
cmd = 'echo "' + publicKey + '" >> ~/.ssh/authorized_keys'
resource = {
"shape": vmType,
"boot_order": [1],
"label": hostname,
"name": ocp_user + "/" + hostname,
"attributes": {
"userdata": {
"pre-bootstrap": {
"failonerror": "false",
"script": [
# Store the publicKey in /home/opc/.ssh/ folder
"cd /home/opc",
cmd,
"curl https://raw.githubusercontent.com/DSPN/oracle-public-cloud-dse/LCM/extensions/node.sh --output node.sh",
"chmod +x node.sh",
"./node.sh occ ",
"mkfs -t ext3 /dev/xvdc",
"mkdir /mnt/data1",
"mount /dev/xvdc /mnt/data1",
"echo '/dev/xvdc\t\t/mnt/data1\t\text3\tdefault\t\t0 0' | tee -a /etc/fstab",
"mkdir -p /mnt/data1/data",
"mkdir -p /mnt/data1/saved_caches",
"mkdir -p /mnt/data1/commitlog",
"chmod -R 777 /mnt/data1",
# lcm -> addNode.py opscenter_ip_addr 'test_cluster' location unique_node_id private_ip_addr seed_node_ip_addr num_nodes_in_location
"rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm",
"yum -y install python setuptools python-pip",
"pip install requests",
"pip install argparse",
"wget https://github.com/DSPN/install-datastax-ubuntu/archive/5.5.3.zip",
"unzip 5.5.3.zip",
"cd install-datastax-ubuntu-5.5.3/bin/lcm/",
"./addNode.py --opsc-ip " + opscenter_ip_addr + " " + "--clustername test_cluster" + " --dcname " + location + " --nodeid " + str(index) + " --privip " +
"`hostname -I`" + " --pubip " + node_ip_addr + " --dcsize " + str(nodeCount) + " --rack rack1" + " --dbpasswd " + cassandraPasswd
]
},
"packages": ["wget", "git"]
}
},
"networking": {
"eth0": {
"seclists": [ ocp_user + "/" + securityList ],
"nat": "ipreservation:" + ip_label
}
},
"sshkeys": [ocp_user + "/" + sshKey],
"storage_attachments": [
{
"index": 1,
"volume": ocp_user + "/" + boot_disk
},
{
"index": 2,
"volume": ocp_user + "/" + app_data_disk
}
]
}
return resource
def generateInstanceOpsCenter(opc_domain, ocp_user, sshKey, vmType, securityList, hostname, boot_disk, app_data_disk,
ip_label, seed_node_ip_addr):
resource = {
"shape": vmType,
"boot_order": [1],
"label": hostname,
"name": ocp_user + "/" + hostname,
"attributes": {
"userdata": {
"pre-bootstrap": {
"failonerror": "false",
"script": [
"cd /home/opc",
"curl https://raw.githubusercontent.com/DSPN/oracle-public-cloud-dse/LCM/extensions/opsCenter.sh --output opsCenter.sh",
"chmod +x opsCenter.sh",
"mkfs -t ext3 /dev/xvdc",
"mkdir /mnt/data1",
"mount /dev/xvdc /mnt/data1",
"echo '/dev/xvdc\t\t/mnt/data1\t\text3\tdefault\t\t0 0' | tee -a /etc/fstab",
"./opsCenter.sh occ " + seed_node_ip_addr
]
},
"packages": ["wget"]
}
},
"networking": {
"eth0": {
"seclists": [ ocp_user + "/" + securityList ],
"nat": "ipreservation:" + ip_label
}
},
"sshkeys": [ocp_user + "/" + sshKey],
"storage_attachments": [
{
"index": 1,
"volume": ocp_user + "/" + boot_disk
},
{
"index": 2,
"volume": ocp_user + "/" + app_data_disk
}
]
}
return resource