1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: nicolas |
5
|
|
|
* Date: 05/02/17 |
6
|
|
|
* Time: 14:32 |
7
|
|
|
*/ |
8
|
|
|
namespace Devgiants\Command; |
9
|
|
|
|
10
|
|
|
use Buzz\Message\Request; |
11
|
|
|
use Devgiants\Model\ApplicationCommand; |
12
|
|
|
use Devgiants\Configuration\ConfigurationManager; |
13
|
|
|
use Devgiants\Configuration\ApplicationConfiguration as AppConf; |
14
|
|
|
use Pimple\Container; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
17
|
|
|
|
18
|
|
|
class WanInfosCommand extends ApplicationCommand |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Wan command constructor. |
22
|
|
|
* |
23
|
|
|
* @param null|string $name |
24
|
|
|
* @param Container $container |
25
|
|
|
*/ |
26
|
|
|
public function __construct( $name, Container $container ) { |
27
|
|
|
parent::__construct( $name, $container ); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @inheritdoc |
32
|
|
|
*/ |
33
|
|
|
protected function configure() |
34
|
|
|
{ |
35
|
|
|
$this |
36
|
|
|
->setName('wan:infos') |
37
|
|
|
->setDescription('Read WAN infos') |
38
|
|
|
->setHelp("This command allows you to read livebox WAN infos") |
39
|
|
|
; |
40
|
|
|
|
41
|
|
|
parent::configure(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @inheritdoc |
46
|
|
|
*/ |
47
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
48
|
|
|
{ |
49
|
|
|
|
50
|
|
|
$ymlFile = $this->getConfigurationFile( $input ); |
51
|
|
|
|
52
|
|
|
if ( $ymlFile !== NULL && is_file( $ymlFile ) ) { |
53
|
|
|
|
54
|
|
|
// Structures check and configuration loading |
55
|
|
|
$configurationManager = new ConfigurationManager( $ymlFile ); |
56
|
|
|
$configuration = $configurationManager->load(); |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
// Execute request |
60
|
|
|
$response = $this->tools->createRequest( |
61
|
|
|
Request::METHOD_POST, |
62
|
|
|
"{$configuration[ AppConf::HOST[ AppConf::NODE_NAME ] ]}/ws", |
63
|
|
|
[ |
64
|
|
|
"service" => "NMC", |
65
|
|
|
"method" => "getWANStatus", |
66
|
|
|
"parameters" => [], |
67
|
|
|
] |
68
|
|
|
); |
69
|
|
|
$output->write($response->getContent() ); |
70
|
|
|
|
71
|
|
|
// Handle post command stuff |
72
|
|
|
parent::execute( $input, $output ); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
} |