@@ -55,22 +55,6 @@ impl HivelocityDeployer {
5555 hardware,
5656 }
5757 }
58-
59- pub async fn undeploy ( & self , input : HivelocityUndeployInput ) -> Option < Error > {
60- let scope = match input {
61- HivelocityUndeployInput :: BareMetal { device_id } => {
62- format ! ( "bare-metal-devices/{device_id}" )
63- }
64- HivelocityUndeployInput :: Compute { device_id } => format ! ( "compute/{device_id}" ) ,
65- } ;
66- self . client
67- . delete ( format ! ( "https://core.hivelocity.net/api/v2/{scope}" ) )
68- . header ( "X-API-KEY" , self . api_key . clone ( ) )
69- . send ( )
70- . await
71- . err ( )
72- . map ( Error :: ReqwestError )
73- }
7458}
7559
7660impl XnodeDeployer for HivelocityDeployer {
@@ -81,7 +65,7 @@ impl XnodeDeployer for HivelocityDeployer {
8165 input : DeployInput ,
8266 ) -> Result < DeployOutput < Self :: ProviderOutput > , Error > {
8367 log:: info!(
84- "Deploying Xnode with configuration {input:?} on {hardware:?}" ,
68+ "Hivelocity deployment of {input:?} on {hardware:?} started " ,
8569 hardware = self . hardware
8670 ) ;
8771 let mut response = match & self . hardware {
@@ -125,6 +109,7 @@ impl XnodeDeployer for HivelocityDeployer {
125109 . header ( "X-API-KEY" , self . api_key . clone ( ) )
126110 . send ( )
127111 . await
112+ . and_then ( |response| response. error_for_status ( ) )
128113 . map_err ( Error :: ReqwestError ) ?
129114 . json :: < serde_json:: Value > ( )
130115 . await
@@ -197,6 +182,30 @@ impl XnodeDeployer for HivelocityDeployer {
197182 log:: info!( "Hivelocity deployment succeeded: {output:?}" ) ;
198183 Ok ( output)
199184 }
185+
186+ async fn undeploy ( & self , xnode : DeployOutput < Self :: ProviderOutput > ) -> Option < Error > {
187+ let device_id = xnode. provider . device_id ;
188+ log:: info!( "Undeploying hivelocity device {device_id} started" , ) ;
189+ let scope = match self . hardware {
190+ HivelocityHardware :: BareMetal { .. } => "bare-metal-devices" ,
191+ HivelocityHardware :: Compute { .. } => "compute" ,
192+ } ;
193+ if let Err ( e) = self
194+ . client
195+ . delete ( format ! (
196+ "https://core.hivelocity.net/api/v2/{scope}/{device_id}"
197+ ) )
198+ . header ( "X-API-KEY" , self . api_key . clone ( ) )
199+ . send ( )
200+ . await
201+ . and_then ( |response| response. error_for_status ( ) )
202+ {
203+ return Some ( Error :: ReqwestError ( e) ) ;
204+ }
205+
206+ log:: info!( "Undeploying hivelocity device {device_id} succeeded" ) ;
207+ None
208+ }
200209}
201210
202211#[ derive( Debug ) ]
0 commit comments