summaryrefslogtreecommitdiff
path: root/server/core/Automating.php
diff options
context:
space:
mode:
Diffstat (limited to 'server/core/Automating.php')
-rw-r--r--server/core/Automating.php127
1 files changed, 127 insertions, 0 deletions
diff --git a/server/core/Automating.php b/server/core/Automating.php
new file mode 100644
index 0000000..7f2c654
--- /dev/null
+++ b/server/core/Automating.php
@@ -0,0 +1,127 @@
+<?php
+/**
+* File containing the Automating Class.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Evan Pisani 'yogg at epsina . com'
+*
+* @todo Complete the functions with errors detection and finish the descriptions
+*/
+
+include("CoreInterface.php");
+include("Image.php");
+include("Network.php");
+include("Compute.php");
+
+class automating implements Core{
+ /** @var App $app protected, contains the main app object */
+ protected $app;
+
+ /** @var OpenStack\Identity $libClass protected, contains the library Identity object */
+ protected $libClass;
+
+ /**
+ * Image constructor
+ *
+ * @param App $app the main app object
+ *
+ * @return Image
+ */
+ public function __construct($app){
+ if(!isset($app)){
+ $this->app->setOutput("Error", "Incorrect parameter app");
+ }
+ $this->app = $app;
+ $this->libClass = $app->getLibClass("Automating");
+ }
+
+ /**
+ * Execute an action
+ *
+ * @param String $action name of another function of this class
+ *
+ * @return void
+ */
+ public function action($action){
+ $this->{$action.""}();
+ }
+
+ /**
+ * Create a new image on a new server
+ *
+ * @param $name the name of the new image
+ * @param $falvor_id the id of the flavor it will be used to create the new server
+ *
+ * @return Image the new image created
+ */
+ private function createImageOnNewServer(){
+ try{
+ /* POURRI
+ $image = new Image($this->app);
+ $compute = new Compute($this->app);
+
+ $name = $this->app->getPostParam("name");
+ $falvor_id = $this->app->getPostParam("falvor_id"); // Compris entre 1 et 5 (1=petit serveur, 5=gros serveur)
+
+ $opt = Array();
+ $opt['name'] = $name;
+ $opt['visibility'] = 'public';
+ $opt['minDisk'] = 100; // A VOIR
+ $opt['minRam'] = 128; // A VOIR
+ $opt['protected'] = false;
+
+ $this->app->setPostParam("opt", $opt);
+
+ $image->action("createImage");
+ $res = json_decode($this->app->show(), true)["Images"];
+
+
+ $this->app->setPostParam("name", $name);
+ $this->app->setPostParam("imageId", $res['id']);
+ $this->app->setPostParam("flavorId", $falvor_id);
+
+ $compute->action("createServer");
+ */
+ }catch(BadResponseError $e){
+ $this->app->getErrorInstance()->BadResponseHandler($e);
+ }catch(UserInputError $e){
+ $this->app->getErrorInstance()->UserInputHandler($e);
+ }catch(BaseError $e){
+ $this->app->getErrorInstance()->BaseErrorHandler($e);
+ }catch(NotImplementedError $e){
+ $this->app->getErrorInstance()->NotImplementedHandler($e);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ //$this->app->setOutput("Auto", $res);
+ }
+
+
+ /**
+ * Create a new image on an existing server
+ *
+ * @param $name the name of the new image
+ * @param $server_id the id of the server
+ *
+ * @return Image the new image created
+ */
+ private function createImageOnServer(){
+ try{
+
+ }catch(BadResponseError $e){
+ $this->app->getErrorInstance()->BadResponseHandler($e);
+ }catch(UserInputError $e){
+ $this->app->getErrorInstance()->UserInputHandler($e);
+ }catch(BaseError $e){
+ $this->app->getErrorInstance()->BaseErrorHandler($e);
+ }catch(NotImplementedError $e){
+ $this->app->getErrorInstance()->NotImplementedHandler($e);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
+}
+
+?> \ No newline at end of file