Skip to content

Commit f6f8d11

Browse files
committed
Make some methods private
1 parent 6f1cc44 commit f6f8d11

11 files changed

Lines changed: 53 additions & 50 deletions

File tree

oca/group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class GroupPool(Pool):
4949
def __init__(self, client):
5050
super(GroupPool, self).__init__('GROUP_POOL', 'POOL', client)
5151

52-
def factory(self, xml):
52+
def _factory(self, xml):
5353
i = Group(xml, self.client)
54-
i.convert_types()
54+
i._convert_types()
5555
return i
5656

oca/host.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ class HostPool(Pool):
109109
def __init__(self, client):
110110
super(HostPool, self).__init__('HOST_POOL', 'HOST', client)
111111

112-
def factory(self, xml):
112+
def _factory(self, xml):
113113
h = Host(xml, self.client)
114-
h.convert_types()
114+
h._convert_types()
115115
return h
116116

oca/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ class ImagePool(Pool):
178178
def __init__(self, client):
179179
super(ImagePool, self).__init__('IMAGE_POOL', 'POOL', client)
180180

181-
def factory(self, xml):
181+
def _factory(self, xml):
182182
i = Image(xml, self.client)
183-
i.convert_types()
183+
i._convert_types()
184184
return i
185185

oca/pool.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ def __init__(self, xml=None):
4646
xml = ET.fromstring(xml)
4747
self.xml = xml
4848

49-
def initialize_xml(self, xml, root_element):
49+
def _initialize_xml(self, xml, root_element):
5050
self.xml = ET.fromstring(xml)
5151
if self.xml.tag != root_element.upper():
5252
self.xml = None
53-
self.convert_types()
53+
self._convert_types()
5454

5555
def __getitem__(self, key):
5656
value = self.xml.find(key.upper())
@@ -68,7 +68,7 @@ def __getattr__(self, name):
6868
except (IndexError, TypeError):
6969
raise AttributeError(name)
7070

71-
def convert_types(self):
71+
def _convert_types(self):
7272
for name, fun in self.XML_TYPES.items():
7373
if isinstance(fun, list):
7474
tag, cls = fun[0], fun[1]
@@ -102,11 +102,11 @@ def info(self, filter=-3, range_start=-1, range_end=-1, *args):
102102
self[:] = []
103103
data = self.client.call(self.METHODS['info'], filter,
104104
range_start, range_end, *args)
105-
self.initialize_xml(data, self.pool_name)
105+
self._initialize_xml(data, self.pool_name)
106106
for element in self.xml:
107-
self.append(self.factory(element))
107+
self.append(self._factory(element))
108108

109-
def factory(self):
109+
def _factory(self):
110110
pass
111111

112112
def get_by_id(self, id):
@@ -147,7 +147,7 @@ def new_with_id(cls, client, element_id):
147147

148148
def info(self, *args):
149149
data = self.client.call(self.METHODS['info'], self.id)
150-
self.initialize_xml(data, self.ELEMENT_NAME)
150+
self._initialize_xml(data, self.ELEMENT_NAME)
151151

152152
def delete(self):
153153
'''

oca/template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def __init__(self, client):
100100

101101
#def info(self,
102102

103-
def factory(self, xml):
103+
def _factory(self, xml):
104104
i = VmTemplate(xml, self.client)
105-
i.convert_types()
105+
i._convert_types()
106106
return i

oca/tests/test_host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ def test_repr(self):
4343

4444
def test_host_share_repr(self):
4545
h = oca.Host(self.xml, self.client)
46-
h.convert_types()
46+
h._convert_types()
4747
share = h.host_share
4848
assert repr(share) == '<oca.vm.HostShare()>'

oca/tests/test_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_types(self):
8989

9090
def test_template(self):
9191
i = oca.Image(self.xml, self.client)
92-
i.convert_types()
92+
i._convert_types()
9393
assert isinstance(i.template, oca.pool.Template)
9494

9595
def test_chown(self):

oca/tests/test_virtualmachine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_raise_exception_Index_Error_when_using_brackets(self):
5555

5656
def test_convert_types(self):
5757
vm = oca.VirtualMachine(self.xml, self.client)
58-
vm.convert_types()
58+
vm._convert_types()
5959
assert vm.name == 'vm-example'
6060
assert vm.id == 6
6161
assert vm.last_poll == 1277729095
@@ -135,6 +135,6 @@ def test_resubmit(self):
135135

136136
def test_History_repr(self):
137137
vm = oca.VirtualMachine(self.xml, self.client)
138-
vm.convert_types()
138+
vm._convert_types()
139139
history = vm.history_records[0]
140140
assert repr(history) == '<oca.vm.History("seq=0")>'

oca/user.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ class UserPool(Pool):
7070
def __init__(self, client):
7171
super(UserPool, self).__init__('USER_POOL', 'POOL', client)
7272

73-
def factory(self, xml):
73+
def _factory(self, xml):
7474
u = User(xml, self.client)
75-
u.convert_types()
75+
u._convert_types()
7676
return u
7777

oca/vm.py

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def allocate(client, template):
108108
109109
Arguments
110110
111-
```template```
111+
``template``
112112
a string containing the template of the vm
113113
'''
114114
vm_id = client.call(VirtualMachine.METHODS['allocate'], template)
@@ -124,7 +124,7 @@ def deploy(self, host_id):
124124
125125
Arguments
126126
127-
```host_id```
127+
``host_id``
128128
the host id (hid) of the target host where the VM will be
129129
instantiated.
130130
'''
@@ -136,7 +136,7 @@ def migrate(self, dest_host):
136136
137137
Arguments
138138
139-
```dest_host```
139+
``dest_host``
140140
the target host id
141141
'''
142142
self.client.call(self.METHODS['migrate'], self.id, dest_host, False)
@@ -147,7 +147,7 @@ def live_migrate(self, dest_host):
147147
148148
Arguments
149149
150-
```dest_host```
150+
``dest_host``
151151
the target host id
152152
'''
153153
self.client.call(self.METHODS['migrate'], self.id, dest_host, True)
@@ -158,7 +158,7 @@ def save_disk(self, disk_id, dest_disk):
158158
159159
Arguments
160160
161-
```disk_id```
161+
``disk_id``
162162
disk id of the disk we want to save
163163
``dest_disk``
164164
image id where the disk will be saved.
@@ -235,37 +235,37 @@ def __repr__(self):
235235
def str_state(self):
236236
'''
237237
String representation of virtual machine state.
238-
One of 'INIT', 'PENDING', 'HOLD', 'ACTIVE', 'STOPPED', 'SUSPENDED',
239-
'DONE', 'FAILED'
238+
One of: INIT, PENDING, HOLD, ACTIVE, STOPPED, SUSPENDED,
239+
DONE, FAILED
240240
'''
241241
return self.VM_STATE[int(self.state)]
242242

243243
@property
244244
def short_state(self):
245245
'''
246246
Short string representation of virtual machine state.
247-
One of 'init', 'pend', 'hold', 'actv', 'stop', 'susp', 'done', 'fail'
247+
One of: init, pend, hold, actv, stop, susp, done, fail
248248
'''
249249
return self.SHORT_VM_STATES[self.str_state]
250250

251251
@property
252252
def str_lcm_state(self):
253253
'''
254254
String representation of virtual machine LCM state.
255-
One of 'LCM_INIT', 'PROLOG', 'BOOT', 'RUNNING', 'MIGRATE',
256-
'SAVE_STOP', 'SAVE_SUSPEND', 'SAVE_MIGRATE', 'PROLOG_MIGRATE',
257-
'PROLOG_RESUME', 'EPILOG_STOP', 'EPILOG', 'SHUTDOWN', 'CANCEL',
258-
'FAILURE', 'DELETE', 'UNKNOWN'
255+
One of: LCM_INIT, PROLOG, BOOT, RUNNING, MIGRATE,
256+
SAVE_STOP, SAVE_SUSPEND, SAVE_MIGRATE, PROLOG_MIGRATE,
257+
PROLOG_RESUME, EPILOG_STOP, EPILOG, SHUTDOWN, CANCEL,
258+
FAILURE, DELETE, UNKNOWN
259259
'''
260260
return self.LCM_STATE[int(self.lcm_state)]
261261

262262
@property
263263
def short_lcm_state(self):
264264
'''
265265
Short string representation of virtual machine LCM state.
266-
One of 'init', 'prol', 'boot', 'runn', 'migr', 'save', 'save',
267-
'save', 'migr', 'prol', 'epil', 'epil', 'shut', 'shut', 'fail',
268-
'dele', 'unkn'
266+
One of: init, prol, boot, runn, migr, save, save,
267+
save, migr, prol, epil, shut, shut, fail,
268+
dele, unkn
269269
'''
270270
return self.SHORT_LCM_STATES[self.str_lcm_state]
271271

@@ -278,9 +278,9 @@ class VirtualMachinePool(Pool):
278278
def __init__(self, client):
279279
super(VirtualMachinePool, self).__init__('VM_POOL', 'VM', client)
280280

281-
def factory(self, xml):
281+
def _factory(self, xml):
282282
vm = VirtualMachine(xml, self.client)
283-
vm.convert_types()
283+
vm._convert_types()
284284
return vm
285285

286286
def info(self, filter=-3, range_start=-1, range_end=-1, vm_state=-1):
@@ -297,17 +297,20 @@ def info(self, filter=-3, range_start=-1, range_end=-1, vm_state=-1):
297297
Range end ID. -1 for all
298298
299299
``vm_state``
300+
300301
VM state to filter by.
301-
-2 Any state, including DONE
302-
-1 Any state, except DONE (Defualt)
303-
0 INIT
304-
1 PENDING
305-
2 HOLD
306-
3 ACTIVE
307-
4 STOPPED
308-
5 SUSPENDED
309-
6 DONE
310-
7 FAILED
302+
303+
* \-2 Any state, including DONE
304+
* \-1 Any state, except DONE (Defualt)
305+
* 0 INIT
306+
* 1 PENDING
307+
* 2 HOLD
308+
* 3 ACTIVE
309+
* 4 STOPPED
310+
* 5 SUSPENDED
311+
* 6 DONE
312+
* 7 FAILED
313+
311314
'''
312315
super(VirtualMachinePool, self).info(filter, range_start,
313316
range_end, vm_state)

0 commit comments

Comments
 (0)