jookies / jasmin-web

Jasmin web panel
Apache License 2.0
18 stars 21 forks source link

Added TelnetConnector, JasminGroupConnector #3

Closed sotoz closed 8 years ago

sotoz commented 9 years ago

Added TelnetConnector for telnet communication and JasminGroupConnector for proof of concept. A test.php exists that executes the commands. The program executes the commands and echoes out the response from jcli.

Must see if this initial architecture fits our demands so we can pull that on master and continue from there.

farirat commented 9 years ago

@sotoz thank you for this first contrib !

I've reviewed the PR commit and here's my feedback before merging to master:

1. Some organizational stuff:

2. Some api design stuff:

The class diagram looks pretty good, some points to pay attention for:

Here's an example of a JasminUser and JasminGroup objects following the rules i've described earlier:

<?php

class JasminObject extends JasminConnector
{
    public function getAll() 
    {
        $result = $this->telnet->doCommand($this->command.' -l');
        // Handle some exceptions, errors etc ...
        return $resultArray // Associative array is a must
    }

    public function save() 
    {
        $this->telnet->doCommand($this->command.' -a');

        foreach $property as $this->properties {
            $this->telnet->doCommand($property.' '.$this->{$property});
        }

        $this->telnet->doCommand('ok');

        // Handle some exceptions, errors etc ...
        // If everything went ok, return True
        return true
    }

    public function delete() 
    {
        $result = $this->telnet->doCommand($this->command.' -r '.$this->key);
        // Handle some exceptions, errors etc ...
        // If everything went ok, return True
        return true // Associative array is a must
    }

}

class JasminUser extends JasminObject
{
    var $command = 'user'
    var $key = ['uid']
    var $properties = ['username', 'uid', 'password', 'gid', ... etc]
}

class JasminGroup extends JasminObject
{
    var $command = 'group'
    var $key = ['gid']
    var $properties = ['gid']
}

That's just a demo code, it's not working :)

I'll wait for your feedback or commits to enrich this PR and then merge it to master.

Fourat

sotoz commented 9 years ago

Hello @zoufou It is great to contribute even a small part of this project. As I was hesitated to ask you for some advice in the first place (won't happen again :), I actually found your guidelines very helpful and you really read my mind on what my questions were! I totally understood your points and as I want to write as good code as I can, your advice will really help develop the project the right way.

For now, I will first implement changes on the API itself and the concrete classes as you suggested. When I'm done with that I will standardise the testing with phpunit and/or travis-ci.

Under what licence will the project be? Is the Apache License ok? Thank you again!

asgarciap commented 9 years ago

Hi guys! I can see @sotoz is in the way with the TelnetConnector part. For now I will create a Symfony Project to start with the REST API part and the composer installer. I will commit that later, so we can integrate with the "core" classes that @sotoz is developing. @sotoz let me know if you need help!

sotoz commented 9 years ago

@zoufou I tried adding the repo at travis-ci and as I can see it says "You require admin rights to enable these repositories". Should I fork the repo and work it on my own or we can enable it as it is?

farirat commented 9 years ago

Project added to travis-ci, please check.

As for license, i think it's better to keep Apache 2.0 just like Jasmin, do you have any other suggestions ?

sotoz commented 9 years ago

No, Apache 2.0 is great. We will keep using that for the jasmin-web.

Travis-ci got the project ok but I'm having some concerns with the travis.yml. Should I take the one that comes with jasmin? Will it work out of the box after adding the php section to test it on php?

farirat commented 9 years ago

for sure, it will not work out of the box :)

You need to set the right .travis-ci for this project, as it's a php project, different from Jasmin (python), you need to give the travis docs a read :)