Browse Source

fix PR after review

nico 8 years ago
parent
commit
55840b88d6

+ 18 - 15
kalliope/core/ResourcesManager.py

@@ -52,21 +52,7 @@ class ResourcesManager(object):
 
             # check the content of the cloned repo
             if self.is_neuron_ok():
-                # rename the folder
-                new_neuron_path = self._rename_temp_neuron_folder()
-                install_file_path = new_neuron_path + os.sep + INSTALL_FILE_NAME
-                Utils.print_info("Starting neuron installation")
-                # ask the sudo password
-                pswd = getpass.getpass('Sudo password:')
-                ansible_neuron_parameters = {
-                    "task_file": install_file_path,
-                    "sudo": True,
-                    "sudo_user": "root",
-                    "sudo_password": pswd
-                }
-                neuron = Neuron(name="ansible_playbook", parameters=ansible_neuron_parameters)
-                NeuronLauncher.start_neuron(neuron)
-                Utils.print_success("Neuron %s installed" % self.dna_file["neuron_name"])
+                self.install_neuron()
 
     def is_settings_ok(self):
         """
@@ -142,3 +128,20 @@ class ResourcesManager(object):
             Utils.print_warning("The neuron %s already exist in the resource directory" % neuron_name)
             # remove the cloned repo
             shutil.rmtree(self.tmp_path)
+
+    def install_neuron(self):
+        # rename the folder
+        new_neuron_path = self._rename_temp_neuron_folder()
+        install_file_path = new_neuron_path + os.sep + INSTALL_FILE_NAME
+        Utils.print_info("Starting neuron installation")
+        # ask the sudo password
+        pswd = getpass.getpass('Sudo password:')
+        ansible_neuron_parameters = {
+            "task_file": install_file_path,
+            "sudo": True,
+            "sudo_user": "root",
+            "sudo_password": pswd
+        }
+        neuron = Neuron(name="ansible_playbook", parameters=ansible_neuron_parameters)
+        NeuronLauncher.start_neuron(neuron)
+        Utils.print_success("Neuron %s installed" % self.dna_file["neuron_name"])

+ 2 - 2
kalliope/neurons/ansible_playbook/README.md

@@ -13,7 +13,7 @@ This neuron can be used to perform complex operation with all [modules available
 
 | parameter     | required | default | choices      | comment                                                                                                                          |
 |---------------|----------|---------|--------------|----------------------------------------------------------------------------------------------------------------------------------|
-| task_file     | YES      |         |              | path to the Playbook file that contain tasks                                                                                     |
+| task_file     | YES      |         |              | path to the Playbook file that contains tasks                                                                                    |
 | sudo          | NO       | FALSE   | True | False | If the playbook will require root privileges (become=true) , this must be set to True and sudo_user and password set accordingly |
 | sudo_user     | NO       |         |              | The target user with admin privileges. In most of case "root"                                                                    |
 | sudo_password | NO       |         |              | The password of the sudo_user                                                                                                    |
@@ -61,7 +61,7 @@ Content of the playbook. This playbook will use the [URI module](http://docs.ans
 
 ### Playbook with admin privileges
 
-In some cases, a playbook require sudo right to perform admin operations like installing a package.
+In some cases, a playbook requires sudo right to perform admin operations like installing a package.
 In this case, you must give to the neuron the login and password of the user which has admin privileges.
 ```
   - name: "Ansible-root"

+ 0 - 1
kalliope/neurons/ansible_playbook/ansible_playbook.py

@@ -18,7 +18,6 @@ class Ansible_playbook(NeuronModule):
 
         self.task_file = kwargs.get('task_file', None)
         self.sudo = kwargs.get('sudo', False)
-        print self.sudo
         self.sudo_user = kwargs.get('sudo_user', False)
         self.sudo_password = kwargs.get('sudo_password', False)