Skip to content

Commit

Permalink
volumes edit 2(and feature complet)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Dec 12, 2022
1 parent 3f57555 commit a346ae2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions osc_tui/popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ def editVolume(form, volume, form_color='STANDOUT'):
type = volume[1]
size = volume[2]
vm_id = volume[4]
#device_name = volume[5]
#iops = volume[6]

F = displayPopup(
name="{} ({}), {}gib, linked to: {}".format(id, type, size, vm_id))
Expand Down
27 changes: 22 additions & 5 deletions osc_tui/volumesGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def __init__(self, screen, *args, **keywords):
'Size (Gb)',
'Subregion',
'Linked To',
"Device Name"]
"Device Name",
'iops']

def on_selection(line):
popup.editVolume(self.form, line)
Expand All @@ -33,26 +34,28 @@ def refresh_call(self, name_filter=None):

def refresh(self):
groups = main.do_search(self.data.copy(), ['VolumeId', 'VolumeType',
'Size', 'SubregionName'])
'Size', 'SubregionName', 'Iops'])
values = list()
for g in groups:
VolLink = g["LinkedVolumes"]
VmId = VolLink[0]["VmId"] if VolLink else "Unlinked"
DName = VolLink[0]["DeviceName"] if VolLink else "No Dev Today"
values.append([g["VolumeId"], g["VolumeType"],
g["Size"], g['SubregionName'], VmId, DName])
g["Size"], g['SubregionName'], VmId, DName, g['Iops'] if 'Iops' in g else '??'])
self.values = values


class VolumeEdit(oscscreen.FormBaseNew):
volume=None
size=10
size_wid=None
iops=None
LIST_THRESHOLD=4

def __init__(self, *args, **keywords):
self.volume = keywords["volume"]
self.size = self.volume[2]
self.iops = self.volume[6]
self.type = self.volume[1]
super().__init__(*args, **keywords)

Expand All @@ -67,9 +70,16 @@ def back(self):

def update(self):
id=self.volume[0]
iops_dst = self.iops_wid.get_value() if self.iops != self.iops_wid.get_value() else None
t = self.type_wid.get_values()[self.type_wid.get_value()]
if iops_dst:
if iops_dst.isnumeric() == False or t == 'standard':
iops_dst = None
else:
iops_dst = int(iops_dst)
main.GATEWAY.UpdateVolume(VolumeId=id,
VolumeType=self.type_wid.get_values()[self.type_wid.get_value()],
Size=int(self.size_wid.get_value()))
VolumeType=t,
Size=int(self.size_wid.get_value()), Iops=iops_dst)
self.back()

def create(self):
Expand All @@ -81,6 +91,13 @@ def create(self):
value=str(self.size)
)

self.iops_wid = self.add_widget(
oscscreen.TitleText,
relx=self.LIST_THRESHOLD,
name="iops",
value=str(self.iops)
)

tval = None
i = 0
type_values = ['standard', 'gp2', 'io1']
Expand Down

0 comments on commit a346ae2

Please sign in to comment.