rebuilt container launch process to offload nscontoller into standard container creation workflow
This commit is contained in:
@@ -36,30 +36,53 @@ def render_list():
|
||||
with st.form("create_container"):
|
||||
# Dropdown for VDC selection
|
||||
selected_vdc_name_create = st.selectbox("VDC", list(vdc_options.keys()))
|
||||
container_name = st.text_input("Container Name",value="my-container")
|
||||
docker_image = st.text_input("Docker Image", value="nginx")
|
||||
|
||||
container_name = st.text_input("Container Name", value="my-container")
|
||||
|
||||
# Suggestions for common images
|
||||
docker_image_options = ["nginx", "traefik/whoami:latest", "whoami81"]
|
||||
docker_image = st.selectbox(
|
||||
"Docker Image",
|
||||
options=docker_image_options + ["Custom..."],
|
||||
index=0
|
||||
)
|
||||
|
||||
# If 'Custom...' selected, let user input their own image
|
||||
if docker_image == "Custom...":
|
||||
docker_image = st.text_input("Custom Docker Image", value="")
|
||||
|
||||
# Port mapping (single)
|
||||
st.markdown("**Optional: Port Mapping**")
|
||||
internal_port = st.number_input("Internal Port", min_value=1, max_value=65535, step=1)
|
||||
external_port = st.number_input("External Port", min_value=1, max_value=65535, step=1)
|
||||
|
||||
submit = st.form_submit_button("Create Container Workload")
|
||||
|
||||
if submit and selected_vdc_name_create and container_name:
|
||||
# Use the selected VDC's ID
|
||||
vdc_id = vdc_options[selected_vdc_name_create]
|
||||
result = st.session_state.client.create_container({
|
||||
|
||||
container_payload = {
|
||||
"docker_image": docker_image,
|
||||
"container_name": container_name,
|
||||
"networks": "bridge" # Default network
|
||||
}
|
||||
|
||||
# Only add ports if both fields are non-zero
|
||||
if internal_port and external_port:
|
||||
container_payload["ports"] = [{"internal": int(internal_port), "external": int(external_port)}]
|
||||
|
||||
payload = {
|
||||
"vdc": vdc_id,
|
||||
"containers": [
|
||||
{
|
||||
"docker_image": docker_image,
|
||||
"container_name": container_name,
|
||||
"ports": [
|
||||
{"internal": 80, "external": 8080},
|
||||
{"internal": 443, "external": 8443}
|
||||
],
|
||||
"networks": "bridge"
|
||||
}
|
||||
]
|
||||
})
|
||||
"containers": [container_payload]
|
||||
}
|
||||
|
||||
result = st.session_state.client.create_container(payload)
|
||||
if result:
|
||||
st.success("Container workload created successfully!")
|
||||
|
||||
|
||||
|
||||
# List Container Workloads
|
||||
st.subheader("Existing Container Workloads")
|
||||
containers = st.session_state.client.get_containers()
|
||||
|
||||
Reference in New Issue
Block a user