diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-03-17 00:52:38 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-03-17 00:52:38 -0500 |
commit | bbe669b761db4cb03fca2dbf9a7890d5a7e120af (patch) | |
tree | 580b71e39783a72c0416b65ef6714f454696e221 /hscript/network.cc | |
parent | 28c81a32aa59a9b2d39ddd7f86fb1d2677da32cc (diff) | |
download | horizon-bbe669b761db4cb03fca2dbf9a7890d5a7e120af.tar.gz horizon-bbe669b761db4cb03fca2dbf9a7890d5a7e120af.tar.bz2 horizon-bbe669b761db4cb03fca2dbf9a7890d5a7e120af.tar.xz horizon-bbe669b761db4cb03fca2dbf9a7890d5a7e120af.zip |
hscript: Add new netconfigtype key and associated tests
Not wired up to netaddress et al, but does parse properly.
Diffstat (limited to 'hscript/network.cc')
-rw-r--r-- | hscript/network.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/hscript/network.cc b/hscript/network.cc index 1750a60..a7b2bee 100644 --- a/hscript/network.cc +++ b/hscript/network.cc @@ -47,6 +47,39 @@ bool Network::execute() const { } +Key *NetConfigType::parseFromData(const std::string &data, int lineno, + int *errors, int *, const Script *script) { + std::string type = data; + ConfigSystem system; + + std::transform(type.cbegin(), type.cend(), type.begin(), ::tolower); + + if(type == "netifrc") { + system = Netifrc; + } else if(type == "eni") { + system = ENI; + } else { + if(errors) *errors += 1; + output_error("installfile:" + std::to_string(lineno), + "netconfigtype: invalid or missing config type", + "one of 'netifrc', 'eni' required"); + return nullptr; + } + + return new NetConfigType(script, lineno, system); +} + +bool NetConfigType::validate() const { + /* Validation takes place during parsing. */ + return true; +} + +bool NetConfigType::execute() const { + /* This key doesn't perform any action by itself. */ + return true; +} + + Key *NetAddress::parseFromData(const std::string &data, int lineno, int *errors, int *, const Script *script) { long elements = std::count(data.cbegin(), data.cend(), ' ') + 1; |