added image cheksum

This commit is contained in:
2025-03-18 14:41:31 +10:30
parent 5eeaa90e1d
commit 827e9b4455
3 changed files with 12 additions and 4 deletions
+3 -1
View File
@@ -41,6 +41,7 @@ def validate_image_data(data, is_update=False):
'location_type': str,
'os_family': str,
'os_version': str,
'checksum': str,
}
for field, field_type in optional_fields.items():
if field in data and not isinstance(data[field], field_type):
@@ -65,7 +66,8 @@ def add_image():
size=validated_data['size'],
location_type=validated_data.get('location_type'),
os_family=validated_data.get('os_family'),
os_version=validated_data.get('os_version')
os_version=validated_data.get('os_version'),
checksum=validated_data.get('checksum')
)
db.session.add(instance)
db.session.commit()
+1
View File
@@ -141,6 +141,7 @@ class Image(BaseModel):
size = Column(Float, nullable=False)
os_family = Column(String, nullable=True)
os_version = Column(String, nullable=True)
checksum = Column(String, nullable=True)
# Relationship to Volume
volumes = relationship("Volume", back_populates="image")
+8 -3
View File
@@ -15,6 +15,7 @@ def render_list():
location_type = st.selectbox("Location Type", ["url", "local"])
os_family = st.text_input("OS Family")
os_version = st.text_input("OS Version")
checksum = st.text_input("Checksum")
submit = st.form_submit_button("Create Image")
if submit and location and size:
@@ -23,7 +24,8 @@ def render_list():
"size": size,
"location_type": location_type,
"os_family": os_family,
"os_version": os_version
"os_version": os_version,
"checksum": checksum
})
if result:
st.success(f"Image created successfully!")
@@ -69,7 +71,7 @@ def render_detail():
st.session_state.view_type = 'list'
st.rerun()
st.header("Image Details")
col1, col2 = st.columns(2)
with col1:
@@ -82,6 +84,7 @@ def render_detail():
st.markdown(f"**Last Updated:** {format_timestamp(image['updated_at'])}")
st.markdown(f"**OS Family:** {image.get('os_family', 'N/A')}")
st.markdown(f"**OS Version:** {image.get('os_version', 'N/A')}")
st.markdown(f"**Checksum:** {image.get('checksum', 'N/A')}")
# Edit Image Form
with st.expander("Edit Image"):
@@ -91,6 +94,7 @@ def render_detail():
new_location_type = st.selectbox("Location Type", ["url", "local"], index=0 if image.get('location_type') == "url" else 1)
new_os_family = st.text_input("OS Family", value=image.get('os_family', ''))
new_os_version = st.text_input("OS Version", value=image.get('os_version', ''))
new_checksum = st.text_input("Checksum", value=image.get('checksum', ''))
submit = st.form_submit_button("Update Image")
if submit:
@@ -99,7 +103,8 @@ def render_detail():
"size": new_size,
"location_type": new_location_type,
"os_family": new_os_family,
"os_version": new_os_version
"os_version": new_os_version,
"checksum": new_checksum
})
if result:
st.success("Image updated successfully!")