cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
s016_add_storages.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # @COPYRIGHT_begin
3 #
4 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # @COPYRIGHT_end
19 
20 import hashlib
21 from settings import STORAGES
22 from predefined.actions import *
23 from predefined.users import *
24 from predefined.macros import MACRO_GET_STORAGE_ID
25 
26 actions = []
27 actions.append(list_clusters)
28 
29 # Add storages
30 for storage in STORAGES:
31  actions.append({'u': u_admin,
32  'as_cmadmin': True,
33  'fname': 'storage.admin_cm.create',
34  'args': [{'capacity': 500000,
35  'name': storage['name'],
36  'dir': storage['dir'],
37  'address': storage['address']}]})
38 
39 actions.append(list_storages)
40 actions.append(list_nodes)
41 
42 # Mount them
43 for i in range(len(STORAGES)):
44  actions.append({'u': u_admin_cm,
45  'as_cmadmin': True,
46  'fname': 'storage.admin_cm.mount_rm',
47  'args': [MACRO_GET_STORAGE_ID(STORAGES[i]["name"])]})
48  actions.append({'u': u_admin_cm,
49  'as_cmadmin': True,
50  'fname': 'storage.admin_cm.mount',
51  'args': [{'node_id': '@r["nodes"][0]["id"]',
52  'storage_id': MACRO_GET_STORAGE_ID(STORAGES[i]["name"])}
53  ]})
54 
55 # Mount them again, CM and RM should not raise any error
56 for i in range(len(STORAGES)):
57  actions.append({'u': u_admin_cm,
58  'as_cmadmin': True,
59  'fname': 'storage.admin_cm.mount_rm',
60  'args': [MACRO_GET_STORAGE_ID(STORAGES[i]["name"])]})
61  actions.append({'u': u_admin_cm,
62  'as_cmadmin': True,
63  'fname': 'storage.admin_cm.mount',
64  'args': [{'node_id': '@r["nodes"][0]["id"]',
65  'storage_id': MACRO_GET_STORAGE_ID(STORAGES[i]["name"])}
66  ]})
67 
68 for i in range(len(STORAGES)):
69  actions.append({'u': u_admin_cm,
70  'as_cmadmin': True,
71  'fname': 'storage.admin_cm.unlock',
72  'args': [MACRO_GET_STORAGE_ID(STORAGES[i]["name"])]})
73  actions.append({'u': u_admin_cm,
74  'as_cmadmin': True,
75  'fname': 'storage.admin_cm.lock',
76  'args': [MACRO_GET_STORAGE_ID(STORAGES[i]["name"])]})
77  actions.append({'u': u_admin,
78  'fname': 'storage.admin_cm.unlock',
79  'args': [MACRO_GET_STORAGE_ID(STORAGES[i]["name"])]})
80