From cb2e0a46dff0349400e02410f4cdecad2fc87db4 Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 29 Mar 2016 08:07:35 +0200 Subject: [PATCH 1/6] added script function and put in a layout of module-specific functions for automation to be called from objects of various classes of our app --- server/core/Automating.php | 38 ++++++++++++++++++++++++++------------ server/core/Compute.php | 12 ++++++------ 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/server/core/Automating.php b/server/core/Automating.php index 7f2c654..adad348 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -5,7 +5,7 @@ * @version 1.0 Initialisation of this file * @since 1.0 Core application's file * -* @author Evan Pisani 'yogg at epsina . com' +* @author Evan Pisani 'yogg at epsina . com' et bhupi * * @todo Complete the functions with errors detection and finish the descriptions */ @@ -16,25 +16,28 @@ 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; + protected $appCompute; + protected $appImage; + protected $appNetwork; + protected $appIdentity; /** - * Image constructor + * Our library's app constructor for all server app objects * - * @param App $app the main app object + * @param App $app the main app object, e.g. compute, image, network, etc. * - * @return Image + * @return */ public function __construct($app){ if(!isset($app)){ - $this->app->setOutput("Error", "Incorrect parameter app"); + $this->app->setOutput("Error", "Parameter app missing."); } - $this->app = $app; - $this->libClass = $app->getLibClass("Automating"); + $this->appCompute = $appCompute; + $this->appImage = $appImage; + $this->appNetwork = $appNetwork; + $this->appIdentity = $appIdentity; } /** @@ -48,6 +51,17 @@ class automating implements Core{ $this->{$action.""}(); } + public function script() + { + appImage->createImage(); + appImage->create_network(); + appImage->list_network_ids(); + appImage->create_subnet(); + appCompute->listFlavors(); + appCompute->listImages(); + appCompute->createServer(); + + } /** * Create a new image on a new server * @@ -124,4 +138,4 @@ class automating implements Core{ } } -?> \ No newline at end of file +?> diff --git a/server/core/Compute.php b/server/core/Compute.php index e72abf9..4a7fe6c 100755 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -170,7 +170,7 @@ class compute try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); + $this->app->setOutput("Error", "Server ID is missing!"); return; } $opt = array('id' => $serverId); @@ -204,7 +204,7 @@ class compute try{ $flavorId = $this->app->getPostParam("flavorId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Flavor ID is missing, son!"); + $this->app->setOutput("Error", "Flavor ID is missing!"); return; } $opt = array('id' => $flavorId); @@ -238,7 +238,7 @@ class compute try{ $imageId = $this->app->getPostParam("imageId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Image ID is missing, son!"); + $this->app->setOutput("Error", "Image ID is missing!"); return; } $opt = array('id' => $imageId); @@ -274,7 +274,7 @@ class compute $imageId = $this->app->getPostParam("imageId"); $flavorId = $this->app->getPostParam("flavorId"); if(!isset($name) || !isset($imageId) || !isset($flavorId)){ - $this->app->setOutput("Error", "No, we don't let you create a server without a name OR image ID OR flavor ID."); + $this->app->setOutput("Error", "Server name OR image ID OR flavor ID is missing."); return; } $opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId); @@ -353,7 +353,7 @@ class compute try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); + $this->app->setOutput("Error", "Server ID is missing!"); return; } $opt = array('id' => $serverId); @@ -422,7 +422,7 @@ class compute try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); + $this->app->setOutput("Error", "Server ID is missing!"); return; } $opt = array('id' => $serverId); From d27f9248b2b8ef2829f14ba1331a9ba6dfbe8ed0 Mon Sep 17 00:00:00 2001 From: stupidon Date: Wed, 30 Mar 2016 11:06:03 +0200 Subject: [PATCH 2/6] added passage of parameters to the create functions in the script --- server/core/.Image.php.swp | Bin 0 -> 16384 bytes server/core/Automating.php | 8 ++++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 server/core/.Image.php.swp diff --git a/server/core/.Image.php.swp b/server/core/.Image.php.swp new file mode 100644 index 0000000000000000000000000000000000000000..68e866c5894d6f0ca5ef9061f7cdee15b4a7ea7c GIT binary patch literal 16384 zcmeI3U2I%O700I(0!vA$h{^*(>cm*`+S>KzqXj~etrItCxA`Q+txz19@x5bv;@x|1 z?!D^|8K*6k;H5kvK&20r0Hs1mZ4cLu@Q;n&&G5N{F@DFjho8B}V+VIJ7RAj#xxPn5 z{XR?k{iX8GojX3htzRw1&L#pYeiTvZh_na8?eA;wsXgJy-Pnbu$6E5z{CdH=2deG`m}Ta0R>$UIH(ICqM`S@Ik=9_4hIM5AX+Y8N2|#3(kSBgR|f?D1jo_0mxJa`d24$cA(oCXhoG8h5FU=Z96ZUfJ~m$7eyuYs?CCO8Bh1Rn)|FEI93@E7nW z@C)!7_#Su~G{L9AcJS(Z82bYFEC_)D`@kNs6I^~bW4{5v1}}g!;7;(%O^jUx&w+1& z7>t7|_z-yGU5s4?Uj>uk5peCDj9mcd!80HRK6nsp1s?`iZ-qU;_ra6kB$xo70vy}| zUdB531~?69O&kI@`{DMp>WJ8xEAAJOJP?L{$Oq-{3M&)}gYle-%2g2rxv-}fWG*pR;kiO>ewJ_)6tKrUMCB& zSU&r(m*i}@l^-;x>&hwdAXE$3WWBml*;P(|XwijLs@v{tu%nJOV>p)LfZp2!B|f0H zEmtlVb!=mInad>%DH^~Arsmj*UHctAtF_rr4pEoGeCuBBHS2Y=JJk%2=VZ53UaoRU zzK~>hY;rBeG@qEL-G{~I*-x2%c6=peBna++kIzYGo*U;Q>JirHY_lP~I5KWXk0tAO zdzs=0d=4%1K!l@4M zi)S0Onr5Vspv)Q3OII^(B(=xH(NO^z+QitpP9rD|YQ4)}n9%YY~$gVK63OiPc)f+04 z2+Y2je7)jQ&Goz|(*e=@!cZ(1wY)f7UctSD4375eTH3?Am?2J+%(}ojGfM!PZEc-Y zG$@FqUR#4nj``zw+w(ZBtl~h@+-_<<)ASrVHF@?VB?FCA03Qow+zdUg=Nu38GrdT$ z%rPoGo&1X{u1dar>}XNLxj=HqNk>Kd#SoE?R4z6)Gbm z7#Aff@`(?87@4nZc8$r z(H`LrT|%sg1546r#@G@bHyvB0jn*BGjHW1=oWu4qQ#Ah2Om1ss*sA0b|Lrw{uDaF? zp6QLyX|<^-oO9T@O$S#Xs&q4JVP6pF0cls&z!}TYlKa!Av39L}^a|psZ1Tf2sWfk) zZ>~RlFuB-av?%0b3nIkglHNn~e)43^g;&L~)~biI$+j(#Xgb{^tpfywB3$Na6Qc{K zRo&Jj^vrga4rDFC9fKo*OfLiDo$(#irS|@O9R3M@0yRe12tOh`++nGNWBC}@qYI2- z^nI2}$dycEv}NhxUJl*mr%{iaNyhq2VV! zDdLMNo-?O*#9b5{SB21o&nQntbGo`KBPUeG1;NnxZ%j1fIUJk^7O)$St4Mf?4=ww% zvs}bn1~_R2AH{-c4B7g4;z+)Ibeo>Etl5VmbXAum6z|4IL9|I$B%SLttjt7@>e<|LFTGz+@&A*EAI~GMr1<}S8|=M=`2O?YQE&om0hbWV z{}enAo&u-9E^q@eJH_m{1A|xegN`MZh_naxdn0y{P!(zZs5pp( zGJe`Tjt*Pa4|b1eNyw7P$Q!~njdDRIYB8xG(-UP3x{^J%2>(zrX&ANA1(b{!Od8wl zfKGm!4vV&IO1T@;*Ieh;R9D~ddunS+`Y3BEP~b=ZB2zh1tE>A%vV+v5X( z_*6iUQz%ff0Y8&e(FVguYcizg(xjA`4wA<+*#}dR>_@TUMx#_S*zR639q1}nK02_g zt2JyyN!mi0G>2J$M&H&1_id66!?sF#?b|4+q}z1mRLrI@>#RoUp`wna+fyr)hQM@X zQ!7ax!i<6+Mefi3nxq4bvS`J}Og1KIl8(ZLzB3BBL>pGF*(e!Bk2bosetPostParam("A_REMPLIR_PAR_Evan","VALEUR"); appImage->createImage(); appImage->create_network(); appImage->list_network_ids(); appImage->create_subnet(); - appCompute->listFlavors(); - appCompute->listImages(); + appCompute->listFlavors(); //to show all flavors with detail. + appCompute->listImages(); //to show all images with detail and to verify that the image was created successfully by the call above. + appCompute->setPostParam("name","Test"); + appCompute->setPostParam("imageId","CREATED_ABOVE"); + appCompute->setPostParam("flavorId","1"); appCompute->createServer(); } From 646af6fd4d14c5b5edb1372e5f68ed9bdc35b3d2 Mon Sep 17 00:00:00 2001 From: stupidon Date: Wed, 30 Mar 2016 11:07:35 +0200 Subject: [PATCH 3/6] removed swap file for image --- server/core/.Image.php.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 server/core/.Image.php.swp diff --git a/server/core/.Image.php.swp b/server/core/.Image.php.swp deleted file mode 100644 index 68e866c5894d6f0ca5ef9061f7cdee15b4a7ea7c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeI3U2I%O700I(0!vA$h{^*(>cm*`+S>KzqXj~etrItCxA`Q+txz19@x5bv;@x|1 z?!D^|8K*6k;H5kvK&20r0Hs1mZ4cLu@Q;n&&G5N{F@DFjho8B}V+VIJ7RAj#xxPn5 z{XR?k{iX8GojX3htzRw1&L#pYeiTvZh_na8?eA;wsXgJy-Pnbu$6E5z{CdH=2deG`m}Ta0R>$UIH(ICqM`S@Ik=9_4hIM5AX+Y8N2|#3(kSBgR|f?D1jo_0mxJa`d24$cA(oCXhoG8h5FU=Z96ZUfJ~m$7eyuYs?CCO8Bh1Rn)|FEI93@E7nW z@C)!7_#Su~G{L9AcJS(Z82bYFEC_)D`@kNs6I^~bW4{5v1}}g!;7;(%O^jUx&w+1& z7>t7|_z-yGU5s4?Uj>uk5peCDj9mcd!80HRK6nsp1s?`iZ-qU;_ra6kB$xo70vy}| zUdB531~?69O&kI@`{DMp>WJ8xEAAJOJP?L{$Oq-{3M&)}gYle-%2g2rxv-}fWG*pR;kiO>ewJ_)6tKrUMCB& zSU&r(m*i}@l^-;x>&hwdAXE$3WWBml*;P(|XwijLs@v{tu%nJOV>p)LfZp2!B|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P~b=ZB2zh1tE>A%vV+v5X( z_*6iUQz%ff0Y8&e(FVguYcizg(xjA`4wA<+*#}dR>_@TUMx#_S*zR639q1}nK02_g zt2JyyN!mi0G>2J$M&H&1_id66!?sF#?b|4+q}z1mRLrI@>#RoUp`wna+fyr)hQM@X zQ!7ax!i<6+Mefi3nxq4bvS`J}Og1KIl8(ZLzB3BBL>pGF*(e!Bk2bo Date: Wed, 30 Mar 2016 11:56:26 +0200 Subject: [PATCH 4/6] ajout parametres dans Automating --- server/core/Automating.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server/core/Automating.php b/server/core/Automating.php index df6e829..1eef72c 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -53,13 +53,19 @@ class automating implements Core{ public function script() { - appImage->setPostParam("A_REMPLIR_PAR_Evan","VALEUR"); + $opt = Array(); + $opt['name'] = getPostParam('name'); + + appImage->setPostParam('opt' $opt); appImage->createImage(); - appImage->create_network(); - appImage->list_network_ids(); - appImage->create_subnet(); + + appNetwork->create_network(); + appnetwork->list_network_ids(); + appNetwork->create_subnet(); + appCompute->listFlavors(); //to show all flavors with detail. appCompute->listImages(); //to show all images with detail and to verify that the image was created successfully by the call above. + appCompute->setPostParam("name","Test"); appCompute->setPostParam("imageId","CREATED_ABOVE"); appCompute->setPostParam("flavorId","1"); From 957d9c4dccc53c63e83cb33f81218593489a8e7c Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Wed, 30 Mar 2016 12:14:11 +0200 Subject: [PATCH 5/6] verif tests image --> OK --- server/Test/imageTests.php | 39 ++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php index 4adec08..a99fbd7 100644 --- a/server/Test/imageTests.php +++ b/server/Test/imageTests.php @@ -14,7 +14,7 @@ $opt['name'] = "Test"; $opt['tags'] = ['test', 'openstack']; //$opt['containerFormat'] = 'ami'; //$opt['diskFormat'] = 'iso'; -$opt['visibility'] = 'public'; +//$opt['visibility'] = 'public'; $opt['minDisk'] = 1; $opt['protected'] = false; $opt['minRam'] = 10; @@ -25,30 +25,39 @@ $retCreate = json_decode($App->show(), true)["Images"]; $idNew = $retCreate['id']; */ -/* -// Delete Image -$App->setPostParam('id', $idNew); -$image->action("deleteImage"); -*/ + + // Liste images $image->action("listImage"); $im = $App->show(); $images = json_decode($im, true)["Images"]; -echo "List images :
"; +$res; +echo "List images :

"; foreach($images as $i){ - echo $i['name']."
"; // Nom + $name = $i['name']; + if(strcmp($name,"Test") == 0) + { + $res = $i['id']; + } + echo $name."
"; // Nom echo $i['status']."
"; // Status $id = $i['id']; // Id echo $id."
"; - foreach ($i['tags'] as $tag) { // Tags + /*foreach ($i['tags'] as $tag) { // Tags echo $tag."
"; - } + }*/ echo "
"; } +// Delete Image + /* +$App->setPostParam('id', $res); +$image->action("deleteImage"); +*/ +/* // Details images echo "Détail image :
"; $App->setPostParam('id', $id); @@ -56,7 +65,7 @@ $image->action("detailsImage"); $retDetails = json_decode($App->show(), true)["Images"]; echo $retDetails['id']."
"; echo "
"; - +*/ /* // Download image @@ -66,18 +75,20 @@ $image->action("downloadImage"); // Desactivate Images +/* echo "Desactivate image :
"; echo $id."
"; $App->setPostParam('id', $id); $err = $image->action("desactivateImage"); echo "
"; +*/ +// Reactivate Images /* -// Resactivate Images echo $id."
"; -$App->setPostParam('id', $id); -$err = $image->action("resactivateImage"); +$App->setPostParam('id', $res); +$image->action("reactivateImage"); */ From 1fdc1a19ce180e4db111354cbedc436a15dd803c Mon Sep 17 00:00:00 2001 From: Apache Date: Wed, 30 Mar 2016 12:40:30 +0200 Subject: [PATCH 6/6] Reactivation Token time management --- server/core/LibOverride/genTokenOptions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 4733c5a..1fbee06 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -51,9 +51,9 @@ class genTokenOptions } public function checkToken(){ - //error_log($this->backup['time'], 0); - //return $this->backup['time'] > time(); - return true; + //error_log(print_r($this->backup['time'], true), 0); + return $this->backup['time'] > time(); + //return true; } public function genIdentityToken(){ @@ -386,7 +386,7 @@ class genTokenOptions $token->catalog = new Models\Catalog($this->httpClient, $api); $token->catalog->services = []; - error_log(print_r($Saved["catalog"], true), 0); + //error_log(print_r($Saved["catalog"], true), 0); foreach($Saved["catalog"] as $key => $service){ $tmp = new Models\Service($this->httpClient, $api);