forked from linode/linode_api4-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk.py
More file actions
52 lines (40 loc) · 1.39 KB
/
Copy pathdisk.py
File metadata and controls
52 lines (40 loc) · 1.39 KB
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
from .dbase import DerivedBase
from .base import Property
class Disk(DerivedBase):
api_endpoint = '/linodes/{linode_id}/disks/{id}'
derived_url_path = 'disks'
parent_id_name='linode_id'
properties = {
'id': Property(identifier=True),
'created': Property(is_datetime=True),
'label': Property(mutable=True),
'size': Property(),
'status': Property(),
'type': Property(),
'updated': Property(is_datetime=True),
'linode_id': Property(identifier=True),
}
def duplicate(self):
result = self._client.post(Disk.api_endpoint, model=self, data={})
if not 'disk' in result:
return result
d = Disk(self._client, result['disk']['id'], self.linode_id)
d._populate(result['disk'])
return d
def reset_root_password(self, root_password=None):
rpass = root_password
if not rpass:
from linode.objects.linode import Linode
rpass = Linode.generate_root_password()
params = {
'password': rpass,
}
result = self._client.post(Disk.api_endpoint, model=self, data=params)
if not 'disk' in result:
if not root_password:
return result, rpass
return result
self._populate(result['disk'])
if not root_password:
return True, rpass
return True