upd!
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
import streamlit as st
|
||||
import pandas as pd
|
||||
|
||||
def render():
|
||||
resource = st.session_state.selected_resource
|
||||
resource_type = st.session_state.selected_resource_type
|
||||
|
||||
if not resource:
|
||||
st.warning("No resource selected.")
|
||||
return
|
||||
|
||||
print(f"Resource type: {resource_type}")
|
||||
|
||||
if resource_type == 'universe':
|
||||
render_detail_view_universe(resource)
|
||||
elif resource_type == 'project':
|
||||
render_detail_view_project(resource)
|
||||
elif resource_type == 'vdc':
|
||||
render_detail_view_vdc(resource)
|
||||
elif resource_type == 'region':
|
||||
render_detail_view_region(resource)
|
||||
elif resource_type == 'network':
|
||||
render_detail_view_network(resource)
|
||||
elif resource_type == 'container':
|
||||
render_detail_view_container(resource)
|
||||
elif resource_type == 'VirtualMachine':
|
||||
render_detail_view_virtual_machine(resource)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import streamlit as st
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import streamlit as st
|
||||
from streamlit_server.utils.helpers import format_timestamp
|
||||
import uuid
|
||||
|
||||
def render_list():
|
||||
st.header("Workload Host Management")
|
||||
|
||||
# Create Workload Host Form
|
||||
with st.expander("Create New Workload Host"):
|
||||
with st.form("create_workload_host"):
|
||||
name = st.text_input("Workload Host Name")
|
||||
region_id = st.text_input("Region ID")
|
||||
secret_key = st.text_input("Secret Key", value=str(uuid.uuid4()))
|
||||
system_manufacturer = st.text_input("System Manufacturer")
|
||||
system_model = st.text_input("System Model")
|
||||
physical_identifier = st.text_input("Physical Identifier")
|
||||
dcim_identifier = st.text_input("DCIM Identifier")
|
||||
installed_date = st.date_input("Installed Date")
|
||||
installed_status = st.text_input("Installed Status")
|
||||
hostname = st.text_input("Hostname")
|
||||
available_for_scheduling = st.checkbox("Available for Scheduling", value=True)
|
||||
placement_priority = st.number_input("Placement Priority", value=100)
|
||||
submit = st.form_submit_button("Create Workload Host")
|
||||
|
||||
if submit and name and region_id:
|
||||
result = st.session_state.client.create_workload_host(
|
||||
name=name,
|
||||
region_id=region_id,
|
||||
secret_key=secret_key,
|
||||
system_manufacturer=system_manufacturer,
|
||||
system_model=system_model,
|
||||
physical_identifier=physical_identifier,
|
||||
dcim_identifier=dcim_identifier,
|
||||
installed_date=installed_date,
|
||||
installed_status=installed_status,
|
||||
hostname=hostname,
|
||||
available_for_scheduling=available_for_scheduling,
|
||||
placement_priority=placement_priority
|
||||
)
|
||||
if result:
|
||||
st.success(f"Workload Host '{name}' created successfully!")
|
||||
|
||||
# List Workload Hosts
|
||||
st.subheader("Existing Workload Hosts")
|
||||
workload_hosts = st.session_state.client.get_workload_hosts()
|
||||
|
||||
if workload_hosts:
|
||||
for host in workload_hosts:
|
||||
with st.container():
|
||||
col1, col2, col3 = st.columns([3, 1, 1])
|
||||
with col1:
|
||||
st.markdown(f"### {host['name']}")
|
||||
st.text(f"Hostname: {host['hostname']}")
|
||||
st.text(f"Region ID: {host['region_id']}")
|
||||
with col2:
|
||||
st.text(f"ID: {host['id'][:8]}...")
|
||||
with col3:
|
||||
if st.button("View Details", key=f"view_{host['id']}"):
|
||||
st.session_state.selected_resource = host
|
||||
st.session_state.view_type = 'detail'
|
||||
st.session_state.selected_resource_type = 'workload_host'
|
||||
st.rerun() # Force Streamlit to rerun the script
|
||||
|
||||
def render_detail():
|
||||
host_id = st.session_state.selected_resource['id']
|
||||
workload_host = st.session_state.client.get_workload_host(host_id)
|
||||
|
||||
st.title(f"Workload Host: {workload_host['name']}")
|
||||
if st.button("Back to list view"):
|
||||
st.session_state.view_type = 'list'
|
||||
st.rerun()
|
||||
|
||||
st.header("Workload Host Details")
|
||||
col1, col2 = st.columns(2)
|
||||
with col1:
|
||||
st.markdown(f"**ID:** `{workload_host['id']}`")
|
||||
st.markdown(f"**Hostname:** `{workload_host['hostname']}`")
|
||||
# Make Region ID clickable
|
||||
if st.button(f"**Region ID:** `{workload_host['region_id']}`"):
|
||||
st.session_state.selected_resource = {"id": workload_host['region_id']}
|
||||
st.session_state.view_type = 'detail'
|
||||
st.session_state.selected_resource_type = 'region'
|
||||
st.switch_page("streamlit_server/views/regions.py")
|
||||
|
||||
st.markdown(f"**System Manufacturer:** `{workload_host['system_manufacturer']}`")
|
||||
st.markdown(f"**System Model:** `{workload_host['system_model']}`")
|
||||
with col2:
|
||||
st.markdown(f"**Physical Identifier:** `{workload_host['physical_identifier']}`")
|
||||
st.markdown(f"**DCIM Identifier:** `{workload_host['dcim_identifier']}`")
|
||||
st.markdown(f"**Installed Status:** `{workload_host['installed_status']}`")
|
||||
st.markdown(f"**Available for Scheduling:** `{workload_host['available_for_scheduling']}`")
|
||||
st.markdown(f"**Placement Priority:** `{workload_host['placement_priority']}`")
|
||||
|
||||
|
||||
|
||||
# Display OVS Bridges
|
||||
st.subheader("Attached OVS Bridges")
|
||||
ovs_bridges = st.session_state.client.get_ovs_bridges_for_host(host_id)
|
||||
if ovs_bridges:
|
||||
for bridge in ovs_bridges:
|
||||
st.markdown(f"- **{bridge['ovs_bridge_name']}**")
|
||||
else:
|
||||
st.info("No OVS bridges attached to this host.")
|
||||
|
||||
# Display Workloads
|
||||
st.subheader("Assigned Workloads")
|
||||
workloads = st.session_state.client.get_workloads_for_host(host_id)
|
||||
if workloads:
|
||||
for workload in workloads:
|
||||
st.markdown(f"- **{workload['name']}** (ID: `{workload['id']}`)")
|
||||
else:
|
||||
st.info("No workloads assigned to this host.")
|
||||
|
||||
# Display Fixed Resources
|
||||
st.subheader("Fixed Resources")
|
||||
fixed_resources = st.session_state.client.get_fixed_resources_for_host(host_id)
|
||||
if fixed_resources:
|
||||
for resource in fixed_resources:
|
||||
st.markdown(f"- **{resource['type']}** (Model: `{resource['model']}`, Manufacturer: `{resource['manufacturer']}`)")
|
||||
else:
|
||||
st.info("No fixed resources attached to this host.")
|
||||
|
||||
# Display Pooled Resources
|
||||
st.subheader("Pooled Resources")
|
||||
pooled_resources = st.session_state.client.get_pooled_resources_for_host(host_id)
|
||||
if pooled_resources:
|
||||
for resource in pooled_resources:
|
||||
st.markdown(f"- **{resource['resource_type']}** (Total: `{resource['total_quantity']}`, In Use: `{resource['quantity_in_use']}`, Available: `{resource['quantity_available']}`)")
|
||||
else:
|
||||
st.info("No pooled resources attached to this host.")
|
||||
|
||||
|
||||
if st.session_state.view_type == 'detail' and st.session_state.selected_resource_type == 'workload_host':
|
||||
render_detail()
|
||||
else:
|
||||
render_list()
|
||||
Reference in New Issue
Block a user