Merge pull request #662 from mwhudson/autoinstall-network
apply network autoinstall config
This commit is contained in:
commit
91a79037a9
|
@ -13,6 +13,9 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
|
||||
from subiquitycore.async_helpers import schedule_task
|
||||
from subiquitycore.controllers.network import NetworkController
|
||||
|
||||
from subiquity.controller import SubiquityController
|
||||
|
@ -20,6 +23,7 @@ from subiquity.controller import SubiquityController
|
|||
|
||||
class NetworkController(NetworkController, SubiquityController):
|
||||
|
||||
ai_data = None
|
||||
autoinstall_key = "network"
|
||||
autoinstall_schema = {
|
||||
'type': 'object',
|
||||
|
@ -38,6 +42,36 @@ class NetworkController(NetworkController, SubiquityController):
|
|||
},
|
||||
}
|
||||
|
||||
def load_autoinstall_data(self, data):
|
||||
self.ai_data = data
|
||||
|
||||
def start(self):
|
||||
if self.ai_data is not None:
|
||||
self.apply_config()
|
||||
elif not self.interactive():
|
||||
self.initial_delay = schedule_task(self.delay())
|
||||
super().start()
|
||||
|
||||
async def delay(self):
|
||||
await asyncio.sleep(10)
|
||||
|
||||
async def apply_autoinstall_config(self):
|
||||
if self.ai_data is None:
|
||||
await self.initial_delay
|
||||
self.update_initial_configs()
|
||||
self.apply_config()
|
||||
await self.apply_config_task.wait()
|
||||
|
||||
def render_config(self):
|
||||
if self.ai_data is not None:
|
||||
r = self.ai_data
|
||||
if self.interactive():
|
||||
# If we're interactive, we want later renders to
|
||||
# incorporate any changes from the UI.
|
||||
self.ai_data = None
|
||||
return r
|
||||
return super().render_config()
|
||||
|
||||
def done(self):
|
||||
self.configured()
|
||||
super().done()
|
||||
|
|
|
@ -330,8 +330,11 @@ class NetworkController(BaseController):
|
|||
except subprocess.CalledProcessError as cp:
|
||||
log.info("deleting %s failed with %r", dev.name, cp.stderr)
|
||||
|
||||
def render_config(self):
|
||||
return self.model.render()
|
||||
|
||||
def _write_config(self):
|
||||
config = self.model.render()
|
||||
config = self.render_config()
|
||||
|
||||
log.debug("network config: \n%s",
|
||||
yaml.dump(sanitize_config(config), default_flow_style=False))
|
||||
|
|
Loading…
Reference in New Issue