Skip to content

Commit

Permalink
PublicIps infos
Browse files Browse the repository at this point in the history
Signed-off-by: matthias.gatto <[email protected]>
  • Loading branch information
outscale-mgo committed May 20, 2024
1 parent 592de47 commit dfadfeb
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions osc_tui/mainForm.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,11 @@ def switch_to_volumes(self, _):
MODE = "Volumes"
self.reload()

def switch_to_public_ips(self, _):
global MODE
MODE = "PublicIps"
self.reload()

def switch_to_instances(self, _):
global MODE
MODE = "Vms"
Expand Down Expand Up @@ -440,6 +445,7 @@ def set_up_handlers(self):
self.add_handlers({"V": self.switch_to_volumes})
self.add_handlers({"I": self.switch_to_instances})
self.add_handlers({"M": self.switch_to_images})
self.add_handlers({"P": self.switch_to_public_ips})
self.add_handlers({"S": self.switch_to_security_grid})
self.add_handlers({"T": self.switch_to_nets})
self.add_handlers({"K": self.switch_to_keypairs})
Expand Down
38 changes: 38 additions & 0 deletions osc_tui/popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,43 @@ def ok():
F.edit()
form.current_grid.display()

def selectPublicIp(form, pip, form_color='STANDOUT'):
id = pip[0]
F = displayPopup(id, color=form_color)
F.preserve_selected_widget = True

def exit():
F.editing = False

F.on_ok = exit
info = F.add_widget(
oscscreen.ButtonPress,
name="INFO",
)

def info_pip():
exit()
F = displayPopupWide(name = "Public Ip Info id: " + id)
F.preserve_selected_widget = True

ft = F.add_widget(
oscscreen.Pager,
)
ips = main.GATEWAY.ReadPublicIps(form=form, Filters={"PublicIpIds": [id]})
ips = ips["PublicIps"][0]

ft.values = json.dumps(ips, indent=2).split("\n")

def ok():
exit()

F.on_ok = ok
F.edit()

info.whenPressed = info_pip
F.edit()
form.current_grid.display()


def editSecurityGroup(form, sg, form_color='STANDOUT'):
name = sg[1]
Expand Down Expand Up @@ -1286,6 +1323,7 @@ def showHelp(arg):
"Switch to Vms : I",
"Switch to Volumes : V",
"Switch to Images : M",
"Switch to PublicIps: P",
"Switch to Security : S",
"Switch to Nets : T",
"Switch to Keypairs : K\n",
Expand Down
6 changes: 6 additions & 0 deletions osc_tui/publicIps.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
from osc_tui import main
from osc_tui import popup
from osc_tui import selectableGrid

class publicIpsGrid(selectableGrid.SelectableGrid):
def __init__(self, screen, *args, **keywords):
super().__init__(screen, *args, **keywords)
self.col_titles = ["Id", "Public Ip", "Vm Id"]

def on_selection(line):
popup.selectPublicIp(self.form, line)

self.on_selection = on_selection

def refresh_call(self, name_filter=None):
groups = main.GATEWAY.ReadPublicIps(form=self.form)['PublicIps']
return groups
Expand Down

0 comments on commit dfadfeb

Please sign in to comment.