# plugin ```go import "github.com/Akilan1999/p2p-rendering-computation/plugin" ``` ## Index - [func CheckRunPlugin\(PluginName string, ID string\) error](<#CheckRunPlugin>) - [func DeletePlugin\(pluginname string\) error](<#DeletePlugin>) - [func DownloadPlugin\(pluginurl string\) error](<#DownloadPlugin>) - [func RunPluginContainer\(PluginName string, ContainerID string\) error](<#RunPluginContainer>) - [type ExecuteIP](<#ExecuteIP>) - [func \(e \*ExecuteIP\) ModifyHost\(p \*Plugin\) error](<#ExecuteIP.ModifyHost>) - [func \(e \*ExecuteIP\) RunAnsible\(p \*Plugin\) error](<#ExecuteIP.RunAnsible>) - [type Host](<#Host>) - [func ReadHost\(filename string\) \(\*Host, error\)](<#ReadHost>) - [type Plugin](<#Plugin>) - [func RunPlugin\(pluginName string, IPAddresses \[\]\*ExecuteIP\) \(\*Plugin, error\)](<#RunPlugin>) - [func SearchPlugin\(pluginname string\) \(\*Plugin, error\)](<#SearchPlugin>) - [func \(p \*Plugin\) AutoSetPorts\(containerID string\) error](<#Plugin.AutoSetPorts>) - [func \(p \*Plugin\) CopyToTmpPlugin\(\) error](<#Plugin.CopyToTmpPlugin>) - [func \(p \*Plugin\) ExecutePlugin\(\) error](<#Plugin.ExecutePlugin>) - [func \(p \*Plugin\) NumPorts\(\) error](<#Plugin.NumPorts>) - [type Plugins](<#Plugins>) - [func DetectPlugins\(\) \(\*Plugins, error\)](<#DetectPlugins>) ## func [CheckRunPlugin]() ```go func CheckRunPlugin(PluginName string, ID string) error ``` CheckRunPlugin Checks if the ID belongs to the group or container calls the plugin function the appropriate amount of times ## func [DeletePlugin]() ```go func DeletePlugin(pluginname string) error ``` DeletePlugin The following function deletes a plugin based on the plugin name provided. ## func [DownloadPlugin]() ```go func DownloadPlugin(pluginurl string) error ``` DownloadPlugin This functions downloads package from a git repo. ## func [RunPluginContainer]() ```go func RunPluginContainer(PluginName string, ContainerID string) error ``` RunPluginContainer Runs ansible plugin based on plugin name and container name which is derived from the tracked containers file We pass in the group ID as a parameter because when we modify the ports taken ## type [ExecuteIP]() ExecuteIP IP Address to execute Ansible instruction ```go type ExecuteIP struct { ContainerID string IPAddress string SSHPortNo string Success bool } ``` ### func \(\*ExecuteIP\) [ModifyHost]() ```go func (e *ExecuteIP) ModifyHost(p *Plugin) error ``` ModifyHost adds IP address , port no to the config file ### func \(\*ExecuteIP\) [RunAnsible]() ```go func (e *ExecuteIP) RunAnsible(p *Plugin) error ``` RunAnsible Executes based on credentials on the struct ## type [Host]() Host Struct for ansible host Generated from https://zhwt.github.io/yaml-to-go/ ```go type Host struct { All struct { Vars struct { AnsiblePythonInterpreter string `yaml:"ansible_python_interpreter"` } `yaml:"vars"` } `yaml:"all"` Main struct { Hosts struct { Host1 struct { AnsibleHost string `yaml:"ansible_host"` AnsiblePort int `yaml:"ansible_port"` AnsibleUser string `yaml:"ansible_user"` AnsibleSSHPass string `yaml:"ansible_ssh_pass"` AnsibleSudoPass string `yaml:"ansible_sudo_pass"` } `yaml:"host1"` } `yaml:"hosts"` } `yaml:"main"` } ``` ### func [ReadHost]() ```go func ReadHost(filename string) (*Host, error) ``` ReadHost Reads host file and adds ## type [Plugin]() Plugin Information about the plugins available ```go type Plugin struct { FolderName string PluginDescription string Execute []*ExecuteIP NumOfPorts int // contains filtered or unexported fields } ``` ### func [RunPlugin]() ```go func RunPlugin(pluginName string, IPAddresses []*ExecuteIP) (*Plugin, error) ``` RunPlugin Executes plugins based on the plugin name provided ### func [SearchPlugin]() ```go func SearchPlugin(pluginname string) (*Plugin, error) ``` SearchPlugin Detects plugin information based on the name provided on the parameter ### func \(\*Plugin\) [AutoSetPorts]() ```go func (p *Plugin) AutoSetPorts(containerID string) error ``` AutoSetPorts Automatically maps free ports to site.yml file ### func \(\*Plugin\) [CopyToTmpPlugin]() ```go func (p *Plugin) CopyToTmpPlugin() error ``` CopyToTmpPlugin This function would ensure that we create a copy of the plugin in the tmp directory, and it would be executed from there. This due to the reason of automating port allocation when running plugins ### func \(\*Plugin\) [ExecutePlugin]() ```go func (p *Plugin) ExecutePlugin() error ``` ExecutePlugin Function to execute plugins that are called ### func \(\*Plugin\) [NumPorts]() ```go func (p *Plugin) NumPorts() error ``` NumPorts Gets the Number the ports the plugin requires ## type [Plugins]() Plugins Array of all plugins detected ```go type Plugins struct { PluginsDetected []*Plugin } ``` ### func [DetectPlugins]() ```go func DetectPlugins() (*Plugins, error) ``` DetectPlugins Detects all the plugins available Generated by [gomarkdoc]()