Skip to content

Commit

Permalink
instance ephemeral IP test passes
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Oct 11, 2023
1 parent 4c8c5ea commit 5386043
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
4 changes: 2 additions & 2 deletions nexus/src/external_api/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ async fn ip_pool_associate(
path_params: Path<params::IpPoolPath>,
resource_assoc: TypedBody<params::IpPoolResource>,
// TODO: what does this return? Returning the association record seems silly
) -> Result<HttpResponseUpdatedNoContent, HttpError> {
) -> Result<HttpResponseCreated<views::IpPoolResource>, HttpError> {
let apictx = rqctx.context();
let handler = async {
let opctx = crate::context::op_context_for_external_api(&rqctx).await?;
Expand All @@ -1326,7 +1326,7 @@ async fn ip_pool_associate(
nexus
.ip_pool_associate_resource(&opctx, &pool_lookup, &resource_assoc)
.await?;
Ok(HttpResponseUpdatedNoContent())
Ok(HttpResponseCreated(views::IpPoolResource {}))
};
apictx.external_latencies.instrument_dropshot_handler(&rqctx, handler).await
}
Expand Down
2 changes: 1 addition & 1 deletion nexus/test-utils/src/resource_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub async fn create_ip_pool(
.await;

// make pool available for use anywhere in fleet
let _: () = object_create(
let _assoc: views::IpPoolResource = object_create(
client,
&format!("/v1/system/ip-pools/{pool_name}/associate"),
&params::IpPoolResource {
Expand Down
14 changes: 11 additions & 3 deletions nexus/tests/integration_tests/instances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ use omicron_common::api::external::InstanceNetworkInterface;
use omicron_common::api::external::InstanceState;
use omicron_common::api::external::Ipv4Net;
use omicron_common::api::external::Name;
use omicron_common::api::external::NameOrId;
use omicron_common::api::external::Vni;
use omicron_nexus::app::MAX_MEMORY_BYTES_PER_INSTANCE;
use omicron_nexus::app::MAX_VCPU_PER_INSTANCE;
Expand Down Expand Up @@ -3416,11 +3415,20 @@ async fn test_instance_ephemeral_ip_from_correct_pool(
name: pool_name.parse().unwrap(),
description: String::from("an ip pool"),
},
// silo: Some(NameOrId::Id(DEFAULT_SILO.id())),
// is_default: true,
},
)
.await;
let params = params::IpPoolResource {
resource_id: DEFAULT_SILO.id(),
resource_type: params::IpPoolResourceType::Silo,
is_default: true,
};
let assoc_url = format!("/v1/system/ip-pools/{pool_name}/associate");
let _ = NexusRequest::objects_post(client, &assoc_url, &params)
.authn_as(AuthnMode::PrivilegedUser)
.execute()
.await;

let silo_pool_range = IpRange::V4(
Ipv4Range::new(
std::net::Ipv4Addr::new(10, 2, 0, 1),
Expand Down
4 changes: 4 additions & 0 deletions nexus/types/src/external_api/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ pub struct IpPool {
pub identity: IdentityMetadata,
}

// TODO: placeholder response for IP pool associate POST
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct IpPoolResource {}

#[derive(Clone, Copy, Debug, Deserialize, Serialize, JsonSchema)]
pub struct IpPoolRange {
pub id: Uuid,
Expand Down
11 changes: 9 additions & 2 deletions openapi/nexus.json
Original file line number Diff line number Diff line change
Expand Up @@ -4606,8 +4606,15 @@
"required": true
},
"responses": {
"204": {
"description": "resource updated"
"201": {
"description": "successful creation",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/IpPoolResource"
}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
Expand Down

0 comments on commit 5386043

Please sign in to comment.