Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ossm configs #63

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions o-must-gather-1
Submodule o-must-gather-1 added at 3917bb
42 changes: 42 additions & 0 deletions omg/cmd/get/ossm/istiodr_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from tabulate import tabulate

from omg.common.helper import age, extract_labels

# Special function to output Istio DestinationRules-Configuration resource.
# We will create an array of array and then print if with tabulate
def istiodr_out(t, ns, res, output, show_type, show_labels):
output_dr = [[]]
# header
if ns == "_all":
output_dr[0].append("NAMESPACE")
output_dr[0].extend(["NAME", "HOST" "AGE"])
else:
output_dr[0].extend(["NAME", "HOST", "AGE"])
# DestinationRule
for d in res:
dr = d["res"]
row = []
# namespace (for --all-namespaces from all destinationRule(s))
if ns == "_all":
row.append(dr["metadata"]["namespace"])

# Print the destinationrule-name
if show_type:
row.append(t + "/" + dr["metadata"]["name"])
else:
row.append(dr["metadata"]["name"])

# Print the DestinationRule-host
row.append(dr["spec"]["host"])

# DestinationRule Age
try:
ct = str(dr["metadata"]["creationTimestamp"])
ts = d["gen_ts"]
row.append(age(ct, ts))
except:
row.append("Unknown")

output_dr.append(row)

print(tabulate(output_dr, tablefmt="plain"))
39 changes: 39 additions & 0 deletions omg/cmd/get/ossm/istiogw_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from tabulate import tabulate

from omg.common.helper import age, extract_labels

# Special function to output Istio Gateway-Configuration resource.
# We will create an array of array and then print if with tabulate
def istiogw_out(t, ns, res, output, show_type, show_labels):
output_gw = [[]]
# header
if ns == "_all":
output_gw[0].append("NAMESPACE")
output_gw[0].extend(["NAME", "AGE"])
else:
output_gw[0].extend(["NAME", "AGE"])
# Gateway
for g in res:
gw = g["res"]
row = []
# namespace (for --all-namespaces from all gateway(s))
if ns == "_all":
row.append(gw["metadata"]["namespace"])

# Print the gateway-name
if show_type:
row.append(t + "/" + gw["metadata"]["name"])
else:
row.append(gw["metadata"]["name"])

# Gateway Age
try:
ct = str(gw["metadata"]["creationTimestamp"])
ts = g["gen_ts"]
row.append(age(ct, ts))
except:
row.append("Unknown")

output_gw.append(row)

print(tabulate(output_gw, tablefmt="plain"))
48 changes: 48 additions & 0 deletions omg/cmd/get/ossm/istiose_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from tabulate import tabulate

from omg.common.helper import age, extract_labels

# Special function to output Istio ServiceEntry-Configuration resource.
# We will create an array of array and then print if with tabulate
def istiose_out(t, ns, res, output, show_type, show_labels):
output_se = [[]]
# header
if ns == "_all":
output_se[0].append("NAMESPACE")
output_se[0].extend(["NAME", "HOSTS", "LOCATION", "RESOLUTION", "AGE"])
else:
output_se[0].extend(["NAME", "HOSTS", "LOCATION", "RESOLUTION", "AGE"])
# ServiceEntry
for s in res:
se = s["res"]
row = []
# namespace (for --all-namespaces from all ServiceEntry(s))
if ns == "_all":
row.append(se["metadata"]["namespace"])

# Print the serviceentry-name
if show_type:
row.append(t + "/" + se["metadata"]["name"])
else:
row.append(se["metadata"]["name"])

# Print the ServiceEntry-host
row.append(se["spec"]["hosts"])

# Print the ServiceEntry-location
row.append(se["spec"]["location"])

# Print the ServiceEntry-resolution
row.append(se["spec"]["resolution"])

# ServiceEntry Age
try:
ct = str(se["metadata"]["creationTimestamp"])
ts = s["gen_ts"]
row.append(age(ct, ts))
except:
row.append("Unknown")

output_se.append(row)

print(tabulate(output_se, tablefmt="plain"))
39 changes: 39 additions & 0 deletions omg/cmd/get/ossm/istiosidecar_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from tabulate import tabulate

from omg.common.helper import age, extract_labels

# Special function to output Istio Sidecar-Configuration resource.
# We will create an array of array and then print if with tabulate
def istiosidecar_out(t, ns, res, output, show_type, show_labels):
output_s = [[]]
# header
if ns == "_all":
output_s[0].append("NAMESPACE")
output_s[0].extend(["NAME", "AGE"])
else:
output_s[0].extend(["NAME", "AGE"])
# Gateway
for s in res:
sidecar = s["res"]
row = []
# namespace (for --all-namespaces from all Sidecar(s))
if ns == "_all":
row.append(sidecar["metadata"]["namespace"])

# Print the Sidecar-name
if show_type:
row.append(t + "/" + sidecar["metadata"]["name"])
else:
row.append(sidecar["metadata"]["name"])

# Gateway Age
try:
ct = str(sidecar["metadata"]["creationTimestamp"])
ts = s["gen_ts"]
row.append(age(ct, ts))
except:
row.append("Unknown")

output_s.append(row)

print(tabulate(output_s, tablefmt="plain"))
48 changes: 48 additions & 0 deletions omg/cmd/get/ossm/istiovs_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from tabulate import tabulate

from omg.common.helper import age, extract_labels

# Special function to output Istio VirtualServices-Configuration resource.
# We will create an array of array and then print if with tabulate
def istiovs_out(t, ns, res, output, show_type, show_labels):
output_vs = [[]]
# header
if ns == "_all":
print ("This feature is in works")
print ("Use 'omg get vs -n <namespace-name>'")
quit()
#output_vs[0].append("NAMESPACE")
#output_vs[0].extend(["NAME", "GATEWAYS", "HOSTS", "AGE"])
else:
output_vs[0].extend(["NAME", "GATEWAYS", "HOSTS", "AGE"])
# VirtualServices
for v in res:
vs = v["res"]
row = []
# namespace (for --all-namespaces from all virtualservices(s))
if ns == "_all":
row.append(vs["metadata"]["namespace"])

# Print the virtualservice-name
if show_type:
row.append(t + "/" + vs["metadata"]["name"])
else:
row.append(vs["metadata"]["name"])

# Print the VirtualService Gateways:
row.append(vs["spec"]["gateways"])

# Print the VirtualService Hosts:
row.append(vs["spec"]["hosts"])

# VirtualService Age
try:
ct = str(vs["metadata"]["creationTimestamp"])
ts = v["gen_ts"]
row.append(age(ct, ts))
except:
row.append("Unknown")

output_vs.append(row)

print(tabulate(output_vs, tablefmt="plain"))
63 changes: 63 additions & 0 deletions omg/cmd/get/ossm/smcp_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
from tabulate import tabulate

from omg.common.helper import age, extract_labels

# Special function to output SMCP or ServiceMeshControlPlane resource
# We will create an array of array and then print if with tabulate
def smcp_out(t, ns, res, output, show_type, show_labels):
output_smcp = [[]]
# header
if ns == "_all":
output_smcp[0].append("NAMESPACE")
output_smcp[0].extend(["NAME", "READY", "STATUS", "PROFILES", "VERSION", "AGE" ])
else:
output_smcp[0].extend(["NAME", "READY", "STATUS", "PROFILES", "VERSION", "AGE" ])
# SMCP
for s in res:
smcp = s["res"]
row = []
# namespace (for --all-namespaces from all SMCP(s))
if ns == "_all":
row.append(smcp["metadata"]["namespace"])

# Print the SMCP-name
if show_type:
row.append(t + "/" + smcp["metadata"]["name"])
else:
row.append(smcp["metadata"]["name"])

# Print the current SMCP ready components.
row.append(smcp["status"]["annotations"]["readyComponentCount"])

# Print the current SMCP status.
# Output the whole conditions in status list.
status = smcp["status"]["conditions"]

# compr & compnr variable to traverse through the status list and extract ["reason"] if the ["message"] condition matches.
compr = ''
compnr = ''
for message in status:
if message["message"] == "All component deployments are Available" and message["type"] == "Ready" and message["status"] == "True":
compr = (message["reason"])
row.append(compr)
elif message["status"] == "False":
compnr = (message["reason"])
row.append(compnr)
# SMCP Profiles
row.append(smcp["spec"]["profiles"])

# SMCP Version
row.append(smcp["status"]["chartVersion"])

# SMCP Age
try:
ct = str(smcp["metadata"]["creationTimestamp"])
ts = s["gen_ts"]
row.append(age(ct, ts))
except:
row.append("Unknown")

output_smcp.append(row)

print(tabulate(output_smcp, tablefmt="plain"))
51 changes: 51 additions & 0 deletions omg/cmd/get/ossm/smmr_out.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- coding: utf-8 -*-
from tabulate import tabulate

from omg.common.helper import age, extract_labels


# Special function to output SMMR or Service Mesh Member Roll resource
# We will create an array of array and then print if with tabulate
def smmr_out(t, ns, res, output, show_type, show_labels):
output_smmr = [[]]
# header
if ns == "_all":
output_smmr[0].append("NAMESPACE")
output_smmr[0].extend(["NAME", "READY", "STATUS", "AGE"])
else:
output_smmr[0].extend(["NAME", "READY", "STATUS", "AGE"])
# SMMR
for s in res:
smmr = s["res"]
row = []
# namespace (for --all-namespaces from all SMMR(s))
if ns == "_all":
row.append(smmr["metadata"]["namespace"])

# Print the SMMR-name
if show_type:
row.append(t + "/" + smmr["metadata"]["name"])
else:
row.append(smmr["metadata"]["name"])

# Print the current SMMR ready components.
row.append(smmr["status"]["annotations"]["configuredMemberCount"])

# Print the current SMMR status.
# Output the current conditions in status list.
status = smmr["status"]["conditions"]

for st in status:
row.append(st["reason"])

# SMCP Age
try:
ct = str(smmr["metadata"]["creationTimestamp"])
ts = s["gen_ts"]
row.append(age(ct, ts))
except:
row.append("Unknown")

output_smmr.append(row)

print(tabulate(output_smmr, tablefmt="plain"))
Loading