From c2a5b1880c19c1490c42eb40a6a15ce2bc64b9e9 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 5 Feb 2016 00:07:31 +0100 Subject: Request Analyse reviewed, Server Initialisation Reviewed, Core Class Interface Created, App created --- server/core/App.php | 68 +++++++++++++++++++++++++++++ server/core/CoreInterface.php | 7 +++ server/core/Identity.php | 27 ++++++++---- server/core/LibOverride/genTokenOptions.php | 22 +++++++--- 4 files changed, 109 insertions(+), 15 deletions(-) create mode 100755 server/core/App.php create mode 100755 server/core/CoreInterface.php mode change 100644 => 100755 server/core/Identity.php (limited to 'server/core') diff --git a/server/core/App.php b/server/core/App.php new file mode 100755 index 0000000..45f6922 --- /dev/null +++ b/server/core/App.php @@ -0,0 +1,68 @@ +tokenPost = NULL; + $this->tokenClass = new genTokenOptions($args); + $this->openstack = new OpenStack\OpenStack([]); + $this->pluginsApi = plugin_api::getInstance(); + $this->output = array(); + + } + + public function setToken($token){ + + $this->tokenPost = $token; + $this->tokenClass->loadBackup($his->tokenPost); + + } + + public function getLibClass($service){ + + switch($service){ + case "Identity": + if($tokenPost == NULL) $tokenClass->genIdentityToken(); + $opt = $tokenClass->getOptions($service); + return $this->openstack->identityV3($opt); + break; + } + + } + + public function authenticate(){ + + try{ + $this->tokenClass->genIdentityToken(); + $this->tokenClass->genComputeToken(); + $this->tokenClass->genImageToken(); + $this->tokenClass->genNetworkToken(); + + $this->setOutput("token", $this->tokenClass->getBackup()); + }catch(Exception $e){ + echo $e; + exit(); + } + + } + + public function setOutput($key, $out){ + + $this->output[$key] = $out; + + } + + public function show(){ + echo json_encode($this->output); + } + +} \ No newline at end of file diff --git a/server/core/CoreInterface.php b/server/core/CoreInterface.php new file mode 100755 index 0000000..ed0d959 --- /dev/null +++ b/server/core/CoreInterface.php @@ -0,0 +1,7 @@ +oidentity = $ostack->identityV3(); - $this->plugins = $apiP; + $this->app = $app; + if($app->getOptions("Identity")) + $this->libClass = $app->getLibClass("Identity"); } + public function action($action){ + + //To be Complete + + } + public function genToken(){ - global $Args; - $token = $this->oidentity->generateToken($Args); - return $token; - } + + //To be Complete + + } } diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 81ecfc8..58b87c1 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -81,7 +81,7 @@ class genTokenOptions $options['catalogType'] = 'false'; $options['region'] = 'RegionOne'; - $this->backup['Identity'] = unserialize($opt); + $this->backup['Identity'] = $opt; $token = $this->unserializeToken($this->backup['Identity']['token']); $baseUrl = $this->backup['Identity']['baseUrl']; @@ -129,7 +129,7 @@ class genTokenOptions $options['catalogType'] = 'image'; $options['region'] = 'RegionOne'; - $this->backup['Image'] = unserialize($opt); + $this->backup['Image'] = $opt; $token = $this->unserializeToken($this->backup['Image']['token']); $baseUrl = $this->backup['Image']['baseUrl']; @@ -176,7 +176,7 @@ class genTokenOptions $options['catalogType'] = 'network'; $options['region'] = 'RegionOne'; - $this->backup['Network'] = unserialize($opt); + $this->backup['Network'] = $opt; $token = $this->unserializeToken($this->backup['Network']['token']); $baseUrl = $this->backup['Network']['baseUrl']; @@ -224,7 +224,7 @@ class genTokenOptions $options['catalogType'] = 'compute'; $options['region'] = 'RegionOne'; - $this->backup['Compute'] = unserialize($opt); + $this->backup['Compute'] = $opt; $token = $this->unserializeToken($this->backup['Compute']['token']); $baseUrl = $this->backup['Compute']['baseUrl']; @@ -242,8 +242,18 @@ class genTokenOptions $this->optionsGlobal['Compute'] = $options; } - public function getBackup($service){ - return serialize($this->backup[$service]); + public function getBackup(){ + return serialize($this->backup); + } + + public function loadBackup($back){ + + $backup = unserialize($back); + loadComputeBackup($backup["Compute"]); + loadIdentityBackup($backup["Identity"]); + loadImageBackup($backup["Image"]); + loadNetworkBackup($backup["Network"]); + } public function getOptions($service){ -- cgit v1.2.3 From ee36719e20e6a72ca07849d4a2fea32c6ca9734f Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 7 Feb 2016 10:29:12 +0100 Subject: Add commentaries for errors managing --- server/core/Image.php | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 4 deletions(-) (limited to 'server/core') diff --git a/server/core/Image.php b/server/core/Image.php index d345034..b83d155 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -31,8 +31,10 @@ class Image { public function create_image(array $opt){ // VOIR SI MAUVAIS TYPE $options = Array(); - if(isset($opt['name'])){ // string, rendre le nom obligatoire - $options['name'] = $opt['name']; + if(isset($opt['name'])){ // string, rendre le nom obligatoire, vérifier nom pas déjà pris + } + else{ + //ERROR } if(isset($opt['id'])){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn $options['id'] = $opt['id']; @@ -71,6 +73,7 @@ class Image { * List images */ public function list_images(){ + // vérifier si au moins une image $service = $this->oidentity; $images = $service->listImages(); return $images; @@ -84,6 +87,7 @@ class Image { * **/ public function image_details($id){ + //vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); return $image; @@ -99,6 +103,7 @@ class Image { * options for the image creation **/ public function update_image($id, array $opt){ + //vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $options = Array(); @@ -134,6 +139,8 @@ class Image { * identifier of the image **/ public function delete_image($id){ + // si protected = true, demander de le mettre a false + // vérifier existence image $service = $this->oidentity; $service->getImage($id)->delete(); } @@ -145,6 +152,7 @@ class Image { * identifier of the image **/ public function reactivate_image($id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $image->reactivate(); @@ -157,6 +165,7 @@ class Image { * identifier of the image **/ public function desactivate_image($id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $image->deactivate(); @@ -172,6 +181,7 @@ class Image { * path of the image **/ public function upload_image($id, $file_name){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); // A VOIR @@ -183,12 +193,101 @@ class Image { * * @param string $id * identifier of the image - */ - public function download_image($id){ + **/ + public function download_image($id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $stream = $image->downloadData(); return $stream; } + + /** + * Add a member to image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + **/ + public function add_member($image_id, $member_id){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe + $service = $this->oidentity; + $member_id = $service>getImage($image_id)->addMember($member_id); + } + + + /** + * List members of an image + * + * @param string $image_id + * identifier of the image + **/ + public function list_member($image_id, $member_id){ + // vérifier existence image + $service = $this->oidentity; + $image = $service->getImage($image_id); + $members = $image->listMembers(); + return $members; + } + + /** + * Show details of a member of an image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + **/ + public function detail_member($image_id, $member_id){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe + $service = $this->oidentity; + $member = $service>getImage($image_id)->getMember($member_id); + return $member; + } + + /** + * Remove a member of an image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + **/ + public function remove_member($image_id, $member_id){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe + $service = $this->oidentity; + $service>getImage($image_id)->getMember($member_id)->delete(); + } + + /** + * Update a member of an image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + * + * @param string $status + * new status for the member + **/ + public function update_member($image_id, $member_id, $status){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe + $service = $this->oidentity; + $member = $service>getImage($image_id)->getMember($member_id)->updateStatus($status); + } + } ?> -- cgit v1.2.3 From 1cd1ae92f414573942262f65dc1644e8ff9bb8f6 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Sun, 7 Feb 2016 22:42:33 +0100 Subject: Structure identity Class, beginning of descriptions. --- server/core/Identity.php | 929 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 920 insertions(+), 9 deletions(-) (limited to 'server/core') diff --git a/server/core/Identity.php b/server/core/Identity.php index d607957..7b6293c 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -1,28 +1,939 @@ ] + * + * @return identity + */ public function __construct($app){ $this->app = $app; - if($app->getOptions("Identity")) $this->libClass = $app->getLibClass("Identity"); - } + } - public function action($action){ + $credentials = array(); + + /** + * Add a credential for the given user/project. + * + * Create a secret/access pair for use with ec2 style auth. + * This operation will generates a new set of credentials that map the user/project pair. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["addCredential"] = function(){ - //To be Complete } - public function genToken(){ - - //To be Complete + /** + * List the credentials for a given user. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["listCredentials"] = function(){ + + + } + + /** + * Retrieve a user’s access/secret pair by the access key. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["showCredential"] = function(){ + + + } + + /** + * Update a user’s access/secret pair. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["updateCredential"] = function(){ + + + } + + /** + * Delete a user’s access/secret pair. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["deleteCredential"] = function(){ + + + } + + $domains = array(); + + /** + * Add a domain to an OpenStack instance. + * + * @throws [Type] [] + * + * @return void + */ + $domains["addDomain"] = function(){ + + + } + + /** + * Retrieve the different domain's list. + * + * @throws [Type] [] + * + * @return void + */ + $domains["listDomains"] = function(){ + + + } + + /** + * Retrieve the details of a given domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["showDomain"] = function(){ + + + } + + /** + * Update the given domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["updateDomain"] = function(){ + + + } + + /** + * Delete the given domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["deleteDomain"] = function(){ + + + } + + /** + * Retrieve the different roles of a given user in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["listRolesDomainUser"] = function(){ + + + } + + /** + * Grant a role to a given user in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["grantRoleDomainUser"] = function(){ + + + } + + /** + * Verify that a user has a given role in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["checkRoleDomainUser"] = function(){ + + + } + + /** + * Delete a role for a given user in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["revokeRoleDomainUser"] = function(){ + + + } + + /** + * Retrieve the roles of a given group in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["listRolesDomainGroup"] = function(){ + + + } + + /** + * Add a role to a given group in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["grantRoleDomainGroup"] = function(){ + + + } + + /** + * Verify that a role is associated with a given group in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["checkRoleDomainGroup"] = function(){ + + + } + + /** + * Delete a role for a given group in a domain. + * + * A *description*, that can span multiple lines, to go _in-depth_ into the details of this element + * and to provide some background information or textual references. + * + * @param string $myArgument With a *description* of this argument, these may also + * span multiple lines. + * + * @throws [Type] [] + * + * @return void + */ + $domains["revokeRoleDomainGroup"] = function(){ + + + } + + $endpoints = array(); + + /** + * Add an endpoint to the Openstack instance + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["addEndpoint"] = function(){ + + + } + + /** + * Retrieve the endpoint for the given id + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["getEndpoint"] = function(){ + + + } + + /** + * Retrieve the list of the different endpoints + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["listEndpoints"] = function(){ + + + } + + /** + * Update a given endpoint + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["updateEndpoint"] = function(){ + + + } + + /** + * Delete a given endpoint + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["deleteEndpoint"] = function(){ + + + } + + $groups = array(); + + /** + * Add a group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["addGroup"] = function(){ + + + } + + /** + * Retrieve the group's list. + * + * @throws [Type] [] + * + * @return void + */ + $groups["listGroups"] = function(){ + + + } + + /** + * Retrieve the details of a given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["showGroup"] = function(){ + + + } + + /** + * Update a given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["updateGroup"] = function(){ + + + } + + /** + * Delete the given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["deleteGroup"] = function(){ + + + } + + /** + * Retrieve the users of a given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["listGroupUsers"] = function(){ + + + } + + /** + * Add a user to a group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["addGroupUser"] = function(){ + + + } + + /** + * Remove a user from a given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["removeGroupUser"] = function(){ + + + } + + /** + * Check if a group contains a given user. + * + * @throws [Type] [] + * + * @return void + */ + $groups["checkGroupUser"] = function(){ + + + } + + $policies = array(); + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["addPolicies"] = function(){ + + + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["listPolicies"] = function(){ + + + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["showPolicie"] = function(){ + + + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["updatePolicies"] = function(){ + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["deletePolicies"] = function(){ + + + } + + $projects = array(); + + /** + * Add a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["addProject"] = function(){ + + + } + + /** + * Retrieve the different projects. + * + * @throws [Type] [] + * + * @return void + */ + $projects["listProjects"] = function(){ + + + } + + /** + * Retrieve the details of a given project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["showProject"] = function(){ + + + } + + /** + * Update a given project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["updateProject"] = function(){ + + + } + + /** + * Delete a given project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["deleteProject"] = function(){ + + + } + + /** + * List the roles of a given user in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["listRolesProjectUser"] = function(){ + + + } + + /** + * Grant a role to an user in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["grantRoleProjectUser"] = function(){ + + + } + + /** + * Check if a given user has a role in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["checkRoleProjectUser"] = function(){ + + + } + + /** + * Delete a role for a given user in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["revokeRoleProjectUser"] = function(){ + + + } + + /** + * List the roles of a group in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["listRolesProjectGroup"] = function(){ + + + } + + /** + * Add a role to a group in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["grantRoleProjectGroup"] = function(){ + + + } + + /** + * Check if a group has a given role in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["checkRoleProjectGroup"] = function(){ + + + } + + /** + * Delete a role for a group in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["revokeRoleProjectGroup"] = function(){ + + + } + + $roles = array(); + + /** + * Add a role. + * + * @throws [Type] [] + * + * @return void + */ + $roles["addRole"] = function(){ + + + } + + /** + * List the different roles + * + * @throws [Type] [] + * + * @return void + */ + $roles["listRoles"] = function(){ + + + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $roles["listRoleAssignements"] = function(){ + + + } + + $services = array(); + + /** + * Add a service. + * + * @throws [Type] [] + * + * @return void + */ + $services["addService"] = function(){ + + + } + + /** + * Retrieve the different services. + * + * @throws [Type] [] + * + * @return void + */ + $services["listServices"] = function(){ + + + } + + /** + * Retrieve the details for a given service. + * + * @throws [Type] [] + * + * @return void + */ + $services["showService"] = function(){ + + + } + + /** + * Delete a given service. + * + * @throws [Type] [] + * + * @return void + */ + $services["deleteService"] = function(){ + + + } + + $tokens = array(); + + /** + * Generate a new token for a given user id. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["genTokenUserID"] = function(){ + + + } + + /** + * Generate a new token for a given user name. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["genTokenUserName"] = function(){ + + + } + + /** + * Generate a new token from another token ID. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["geneTokenID"] = function(){ + + + } + + /** + * Generate a new token scoped by a project ID. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["genTokenScopedProjectID"] = function(){ + + + } + + /** + * Generate a new token scoped by a project name. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["genTokenScopedProjectName"] = function(){ + + + } + + /** + * Check if a token is validate. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["validateToken"] = function(){ + + + } + + /** + * Delete a given token. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["revokeToken"] = function(){ + + + } + + $users = array(); + + /** + * Add a new user. + * + * @throws [Type] [] + * + * @return void + */ + $users["addUser"] = function(){ + + + } + + /** + * Retrieve the different users. + * + * @throws [Type] [] + * + * @return void + */ + $users["listUsers"] = function(){ + + + } + + /** + * Retrieve the details of a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["showUser"] = function(){ + + + } + + /** + * Update a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["updateUser"] = function(){ + + + } + + /** + * Delete a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["deleteUser"] = function(){ + + + } + + /** + * Retrieve the groups which contains a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["listUserGroups"] = function(){ + + + } + + /** + * Retrieve the projects which contains a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["listUserProjects"] = function(){ + + + } + + $actions["Credentials"] = $credentials; + $actions["Domains"] = $domains; + $actions["Endpoints"] = $endpoints; + $actions["Groups"] = $groups; + $actions["Policies"] = $policies; + $actions["Projects"] = $projects; + $actions["Roles"] = $roles; + $actions["Services"] = $services; + $actions["Tokens"] = $tokens; + $actions["Users"] = $users; } -- cgit v1.2.3