wip
This commit is contained in:
@@ -27,14 +27,13 @@ def edit_region(region_id):
|
||||
db.session.commit()
|
||||
return jsonify(success=True)
|
||||
|
||||
# TODO - Consider security, does the user have the right to query this region?
|
||||
# Can they see ALL the details or just the public data?
|
||||
@api_bp.route('/regions/<region_id>')
|
||||
def get_region(region_id):
|
||||
region = Region.query.get_or_404(region_id)
|
||||
return jsonify({
|
||||
'name': region.name,
|
||||
'id': region.id,
|
||||
'enabled': region.enabled,
|
||||
})
|
||||
return jsonify(region.to_json())
|
||||
|
||||
|
||||
|
||||
@app.route('/regions/<region_id>', methods=['DELETE'])
|
||||
|
||||
@@ -60,19 +60,22 @@ def enroll_workload_host():
|
||||
logger.debug(f"Enrollment data {data}")
|
||||
# TODO - Add a concept of 'region enrollment key's" so that new workers need to specify not only a region ID but also an enrollment key
|
||||
# Validate required fields
|
||||
required_fields = ['region_id', 'physical_identifier']
|
||||
required_fields = ['region_id', 'physical_identifier', 'region_enrollment_key']
|
||||
for field in required_fields:
|
||||
if field not in data:
|
||||
logger.error("Enrollment failed")
|
||||
return jsonify({'error': f'Missing required field: {field}'}), 400
|
||||
|
||||
|
||||
try:
|
||||
# Validate region_id
|
||||
region = Region.query.get(uuid.UUID(data['region_id']))
|
||||
if not region:
|
||||
logger.error("Invalid region_id")
|
||||
return jsonify({'error': 'Invalid region ID'}), 400
|
||||
|
||||
|
||||
if not str(region.enrollment_key)==data['region_enrollment_key']:
|
||||
logger.error(f"Supplied enrollment key{data['region_enrollment_key']} vs key in DB {region.enrollment_key}")
|
||||
return jsonify({'error': 'Invalid region enrollment key'}), 400
|
||||
|
||||
# Create WorkloadHost entry
|
||||
workload_host = WorkloadHost(
|
||||
|
||||
@@ -49,6 +49,8 @@ class Region(BaseModel):
|
||||
country = Column(String, nullable=False)
|
||||
advertised_address = Column(String, nullable=True)
|
||||
abbreviation = Column(String(16), nullable=False)
|
||||
enrollment_key = Column(UUID(as_uuid=True),default=uuid.uuid4, nullable=False)
|
||||
|
||||
|
||||
class VirtualDataCenter(BaseModel):
|
||||
__tablename__ = "vdcs"
|
||||
|
||||
+4
-1
@@ -9,4 +9,7 @@ pymysql
|
||||
flask_sqlalchemy
|
||||
flask_migrate
|
||||
websocket-client
|
||||
streamlit
|
||||
streamlit
|
||||
aiohttp
|
||||
asyncio
|
||||
docker
|
||||
@@ -130,6 +130,8 @@ def render_detail_view_network(network):
|
||||
st.markdown(f"**Created:** {network.get('created_at', 'Unknown')}")
|
||||
st.markdown(f"**IPv4 CIDR:** {network.get('ipv4_cidr', 'N/A')}")
|
||||
st.markdown(f"**IPv4 Gateway:** {network.get('ipv4_gateway', 'N/A')}")
|
||||
st.markdown(f"**Encapsulation Type:** {network.get('encapsulation', 'N/A')}")
|
||||
st.markdown(f"**VNI:** {network.get('vni', 'N/A')}")
|
||||
with col2:
|
||||
if network.get('updated_at'):
|
||||
st.markdown(f"**Last Updated:** {network['updated_at']}")
|
||||
@@ -170,11 +172,14 @@ def render_detail_view_region(region):
|
||||
st.header("Region Details")
|
||||
col1, col2 = st.columns(2)
|
||||
with col1:
|
||||
st.markdown("**Region ID**")
|
||||
st.code(f"{region['id']}")
|
||||
st.markdown(f"**Created:** {region.get('created_at', 'Unknown')}")
|
||||
st.markdown("**Region Enrollment Key**(Confidental)")
|
||||
st.code(f"{region['enrollment_key']}")
|
||||
with col2:
|
||||
if region.get('updated_at'):
|
||||
st.markdown(f"**Last Updated:** {region['updated_at']}")
|
||||
st.markdown(f"**Last Updated:** {region['updated_at']}")
|
||||
st.markdown(f"**Created:** {region.get('created_at', 'Unknown')}")
|
||||
|
||||
if region.get('description'):
|
||||
st.markdown(f"**Description:** {region['description']}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user