-
Notifications
You must be signed in to change notification settings - Fork 46
/
storage.py
140 lines (129 loc) · 6.42 KB
/
storage.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
import os
from netaddr import *
from fabric.api import *
from fabfile.config import testbed
from fabfile.utils.host import *
def get_storage_disk_config():
storage_info = getattr(testbed, 'storage_node_config', None)
storage_disk_node_list=[]
if storage_info:
for entry in storage_info.keys():
storage_host = get_control_host_string(entry)
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
if 'disks' in storage_info[entry].keys():
for disk_entry in storage_info[entry]['disks']:
storage_disk_node = sthostname + ':' + disk_entry
storage_disk_node_list.append(storage_disk_node)
if storage_disk_node_list == []:
storage_disk_node_list.append('none')
return (storage_disk_node_list)
#end get_storage_disk_config
def get_storage_ssd_disk_config():
storage_info = getattr(testbed, 'storage_node_config', None)
storage_ssd_disk_node_list=[]
if storage_info:
for entry in storage_info.keys():
storage_host = get_control_host_string(entry)
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
if 'ssd-disks' in storage_info[entry].keys():
for ssd_disk_entry in storage_info[entry]['ssd-disks']:
storage_ssd_disk_node = sthostname + ':' + ssd_disk_entry
storage_ssd_disk_node_list.append(storage_ssd_disk_node)
if storage_ssd_disk_node_list == []:
storage_ssd_disk_node_list.append('none')
return (storage_ssd_disk_node_list)
#end get_storage_disk_config
def get_storage_local_disk_config():
storage_info = getattr(testbed, 'storage_node_config', None)
storage_local_disk_node_list=[]
if storage_info:
for entry in storage_info.keys():
storage_host = get_control_host_string(entry)
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
if 'local-disks' in storage_info[entry].keys():
for local_disk_entry in storage_info[entry]['local-disks']:
storage_local_disk_node = sthostname + ':' + local_disk_entry
storage_local_disk_node_list.append(storage_local_disk_node)
if storage_local_disk_node_list == []:
storage_local_disk_node_list.append('none')
return (storage_local_disk_node_list)
#end get_storage_local_disk_config
def get_storage_local_ssd_disk_config():
storage_info = getattr(testbed, 'storage_node_config', None)
storage_local_ssd_disk_node_list=[]
if storage_info:
for entry in storage_info.keys():
storage_host = get_control_host_string(entry)
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
if 'local-ssd-disks' in storage_info[entry].keys():
for local_ssd_disk_entry in storage_info[entry]['local-ssd-disks']:
storage_local_ssd_disk_node = sthostname + ':' + local_ssd_disk_entry
storage_local_ssd_disk_node_list.append(storage_local_ssd_disk_node)
if storage_local_ssd_disk_node_list == []:
storage_local_ssd_disk_node_list.append('none')
return (storage_local_ssd_disk_node_list)
#end get_storage_local_disk_config
def get_storage_nfs_disk_config():
storage_info = getattr(testbed, 'storage_node_config', None)
storage_nfs_disk_node_list=[]
if storage_info:
for entry in storage_info.keys():
storage_host = get_control_host_string(entry)
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
if 'nfs' in storage_info[entry].keys():
for nfs_disk_entry in storage_info[entry]['nfs']:
storage_nfs_disk_node = sthostname + ':' + nfs_disk_entry
storage_nfs_disk_node_list.append(storage_nfs_disk_node)
if storage_nfs_disk_node_list == []:
storage_nfs_disk_node_list.append('none')
return (storage_nfs_disk_node_list)
#end get_storage_nfs_disk_config
def get_storage_journal_config():
storage_info = getattr(testbed, 'storage_node_config', None)
storage_journal_node_list=[]
if storage_info:
for entry in storage_info.keys():
storage_host = get_control_host_string(entry)
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
if 'journal' in storage_info[entry].keys():
for journal_entry in storage_info[entry]['journal']:
storage_journal_node = sthostname + ':' + journal_entry
storage_journal_node_list.append(storage_journal_node)
if storage_journal_node_list == []:
storage_journal_node_list.append('none')
return (storage_journal_node_list)
#end get_storage_journal_config
def get_storage_directory_config():
storage_info = getattr(testbed, 'storage_node_config', None)
storage_directory_node_list=[]
if storage_info:
for entry in storage_info.keys():
storage_host = get_control_host_string(entry)
for sthostname, sthostentry in zip(env.hostnames['all'], env.roledefs['all']):
if entry == sthostentry:
if 'directories' in storage_info[entry].keys():
for directory_entry in storage_info[entry]['directories']:
storage_directory_node = sthostname + ':' + directory_entry
storage_directory_node_list.append(storage_directory_node)
if storage_directory_node_list == []:
storage_directory_node_list.append('none')
return (storage_directory_node_list)
#end get_storage_directory_config
def get_from_testbed_dict( dictionary, key,default_value):
try:
val = env[dictionary][key]
except KeyError:
val = default_value
return val
def get_cinder_ha_vip():
ha_vip = get_from_testbed_dict('ha', 'internal_vip', None)
if ha_vip:
return ha_vip
return 'none'
#end get_cinder_ha_vip