99use Indatus \Assembler \Traits \StockerTrait ;
1010use Indatus \Assembler \Traits \ProvisionTrait ;
1111use Indatus \Assembler \Traits \PackagerTrait ;
12+ use Indatus \Assembler \Traits \DestroyerTrait ;
1213use Robo \Result ;
1314use Robo \Tasks ;
1415
@@ -26,6 +27,8 @@ class RoboFile extends Tasks
2627 use LoaderTrait;
2728 use ProvisionTrait;
2829 use PackagerTrait;
30+ use DestroyerTrait;
31+
2932
3033 /**
3134 * Retrieve, organize, and create instructions for materials related to a product line
@@ -222,15 +225,27 @@ public function assemblerMake(
222225 }
223226
224227 /**
225- * Provisions a fresh server
226- *
227- * @param string $hostname hostname of the box that you would like provisioned
228- * @param string $region region of where you would like the box provisioned
229- * @param string $size size of the box that you would like provisioned
230- * @param string $image name of the image that you would like provisioned
231- * @param bool $backups turn on backups
232- * @param bool $ipv6 turn on ipv6 features
233- * @param bool $privateNetworking turn on private networking
228+ * Destroys the cloud server
229+ * @param $id the id of the cloud server being destroyed
230+ * @return Result
231+ */
232+ public function destroy ($ id )
233+ {
234+ return $ this ->taskDestroyServer ($ id )
235+ ->run ();
236+ }
237+
238+
239+ /**
240+ * Provision a fresh server
241+ * @param $hostname
242+ * @param string $region
243+ * @param string $size
244+ * @param string $image
245+ * @param bool $backups
246+ * @param bool $ipv6
247+ * @param bool $privateNetworking
248+ * @return Result
234249 */
235250 public function provision (
236251 $ hostname ,
@@ -241,16 +256,7 @@ public function provision(
241256 $ ipv6 = false ,
242257 $ privateNetworking = false
243258 ) {
244- $ configuration = new Configuration ;
245- try {
246- $ apiToken = $ configuration ->apiToken ();
247- } catch (NoProviderTokenException $ exception ) {
248- $ this ->say ("Couldn't find a well-formed provider token in the provisioning config file. " );
249- exit ;
250- }
251- $ this ->taskProvisionServer (
252- $ apiToken ,
253- $ configuration ->sshKeys (),
259+ $ result = $ this ->taskProvisionServer (
254260 $ hostname ,
255261 $ region ,
256262 $ size ,
@@ -259,5 +265,8 @@ public function provision(
259265 $ ipv6 ,
260266 $ privateNetworking
261267 )->run ();
268+ $ data = $ result ->getData ();
269+ $ this ->say ("Provisioned server with id of: $ data ->id " );
270+ return $ result ;
262271 }
263272}
0 commit comments