forked from DSPN/oracle-public-cloud-dse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnodes.py
117 lines (111 loc) · 4 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
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, seed_node_ip_addr, opscenter_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/master/extensions/node.sh --output node.sh",
"chmod +x node.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",
"./node.sh occ " + seed_node_ip_addr + " " + location + " " + opscenter_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
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/master/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