1 | <?php |
||
13 | class DockerRouting extends InstallerTask implements DependentChainProcessInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var ProcessRunner |
||
17 | */ |
||
18 | private $processRunner; |
||
19 | /** |
||
20 | * @var UserInteraction |
||
21 | */ |
||
22 | private $userInteraction; |
||
23 | /** |
||
24 | * @var PharFileExtractor |
||
25 | */ |
||
26 | private $fileExtractor; |
||
27 | /** |
||
28 | * @var Machine |
||
29 | */ |
||
30 | private $machine; |
||
31 | |||
32 | /** |
||
33 | * @param Machine $machine |
||
34 | * @param UserInteraction $userInteraction |
||
35 | * @param ProcessRunner $processRunner |
||
36 | * @param PharFileExtractor $fileExtractor |
||
37 | */ |
||
38 | public function __construct(Machine $machine, UserInteraction $userInteraction, ProcessRunner $processRunner, PharFileExtractor $fileExtractor) |
||
39 | { |
||
40 | $this->machine = $machine; |
||
41 | $this->userInteraction = $userInteraction; |
||
42 | $this->processRunner = $processRunner; |
||
43 | $this->fileExtractor = $fileExtractor; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function run() |
||
50 | { |
||
51 | $this->userInteraction->writeTitle('Configure routing for direct Docker containers access'); |
||
52 | |||
53 | $machineIp = $this->machine->getIp(); |
||
54 | |||
55 | $this->configureRouting($machineIp); |
||
56 | $this->addPermanentRouting($machineIp); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | public function dependsOn() |
||
63 | { |
||
64 | return ['machine']; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | public function getName() |
||
71 | { |
||
72 | return 'routing'; |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @param string $machineIp |
||
77 | * |
||
78 | * @throws ProcessFailedException |
||
79 | */ |
||
80 | private function configureRouting($machineIp) |
||
85 | |||
86 | /** |
||
87 | * @param string $machineIp |
||
88 | */ |
||
89 | private function addPermanentRouting($machineIp) |
||
103 | |||
104 | /** |
||
105 | * Resolve the network interface name for the given IP. |
||
106 | * |
||
107 | * @param string $machineIp |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | private function resolveNetworkInterface($machineIp) |
||
118 | } |
||
119 |