From 00017de13c81f86d7669126f9d0093f3f0a86e6b Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 16 Nov 2020 08:12:02 +0100 Subject: [PATCH 1/2] update config --- provisioning_example.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/provisioning_example.sh b/provisioning_example.sh index 5cd2199..6f653e4 100755 --- a/provisioning_example.sh +++ b/provisioning_example.sh @@ -1,12 +1,6 @@ #!/usr/bin/env bash set -xe -#======================================================================================================= -# Import Cadoles seed -#======================================================================================================= - -cucchiaiata-cli v1.setting.source.create --source_name Cadoles --source_directory /usr/share/risotto/seed/cadoles - #======================================================================================================= # Infrastructure #======================================================================================================= @@ -31,7 +25,7 @@ cucchiaiata-cli v1.infra.zone.create --zone_name internet S=$(cucchiaiata-cli v1.setting.session.zone.start --zone_name internet | jq -r .session_id) cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.network.network "192.168.1.0/24" \ --configuration.network.host_start "192.168.1.10" \ - --configuration.network.host_end "192.168.1.100" \ + --configuration.network.host_stop "192.168.1.100" \ --configuration.network.dns 192.168.1.2 \ --configuration.network.gateway 192.168.1.254 cucchiaiata-cli v1.setting.session.validate --session_id $S @@ -47,7 +41,8 @@ cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save # +---------------------------+ cucchiaiata-cli v1.infra.cluster.create --cluster_name cluster.cadoles.com \ --zone_name internet -cucchiaiata-cli v1.infra.cluster.node.create --server_name node1.cadoles.com \ +cucchiaiata-cli v1.infra.cluster.node.create --node_name node1.cadoles.com \ + --cluster_name cluster.cadoles.com \ --zones_name internet # configuration @@ -100,7 +95,7 @@ cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save # Servermodel unbound S=$(cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name unbound| jq -r .session_id) cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.serveur_dns.unbound_local_zones cadoles.com \ - --configuration.reseau.unbound_route_address 192.168.1.2 \ + --configuration.reseau.unbound_route_address 192.168.1.254 \ --configuration.serveur_dns.unbound_allowed_client_cidr 192.168.1.0/24 cucchiaiata-cli v1.setting.session.filter --session_id "$S" --namespace unbound cucchiaiata-cli v1.setting.session.configure --session_id "$S" --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.hostname_cadoles_com toto titi \ @@ -129,6 +124,7 @@ cucchiaiata-cli v1.infra.server.create --server_name dns.cadoles.com \ --zones_name internet \ --servermodel_name unbound_etab1 # configuration +sleep 1 S=$(cucchiaiata-cli v1.setting.session.server.start --server dns.cadoles.com | jq -r .session_id) cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.reseau.unbound_ip_address_cidr 192.168.1.2/24 cucchiaiata-cli v1.setting.session.filter --session_id "$S" --namespace opennebula From 3d5d831a8c93bb2280c5ede2e65e218b1653ef3c Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 27 Mar 2021 22:17:39 +0100 Subject: [PATCH 2/2] add namespace when query configuration --- provisioning_example.sh | 39 ++++++++++++++++++++------------ src/cucchiaiata/configuration.py | 9 +++++--- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/provisioning_example.sh b/provisioning_example.sh index 6f653e4..cc81d2b 100755 --- a/provisioning_example.sh +++ b/provisioning_example.sh @@ -1,6 +1,17 @@ #!/usr/bin/env bash set -xe +function get_id() { + S=$($1) + V=$(echo $S|jq -r .session_id) + if [ $? = 0 ]; then + echo $V + else + echo $S + exit 1 + fi +} + #======================================================================================================= # Infrastructure #======================================================================================================= @@ -22,12 +33,12 @@ cucchiaiata-cli v1.user.role.create --user_login gnunux \ # +~~~~~~~~~~+ cucchiaiata-cli v1.infra.zone.create --zone_name internet # zone configuration -S=$(cucchiaiata-cli v1.setting.session.zone.start --zone_name internet | jq -r .session_id) -cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.network.network "192.168.1.0/24" \ - --configuration.network.host_start "192.168.1.10" \ - --configuration.network.host_stop "192.168.1.100" \ - --configuration.network.dns 192.168.1.2 \ - --configuration.network.gateway 192.168.1.254 +S=$(get_id "cucchiaiata-cli v1.setting.session.zone.start --zone_name internet") +cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.network "192.168.1.0/24" \ + --configuration.host_start "192.168.1.10" \ + --configuration.host_stop "192.168.1.100" \ + --configuration.dns 192.168.1.2 \ + --configuration.gateway 192.168.1.254 cucchiaiata-cli v1.setting.session.validate --session_id $S cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save @@ -46,7 +57,7 @@ cucchiaiata-cli v1.infra.cluster.node.create --node_name node1.cadoles.com \ --zones_name internet # configuration -S=$(cucchiaiata-cli v1.setting.session.cluster.start --cluster_name cluster.cadoles.com | jq -r .session_id) +S=$(get_id "cucchiaiata-cli v1.setting.session.cluster.start --cluster_name cluster.cadoles.com") cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.network.virtual_ip "192.168.1.1" cucchiaiata-cli v1.setting.session.validate --session_id $S cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save @@ -88,12 +99,12 @@ cucchiaiata-cli v1.setting.servermodel.create --servermodel_name unbound_etab1 - # configuration # Servermodel ACA -S=$(cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name aca| jq -r .session_id) +S=$(get_id "cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name aca") cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.serveur_ssh.ssh_allow_networks admin.cadoles.com cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save # Servermodel unbound -S=$(cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name unbound| jq -r .session_id) +S=$(get_id "cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name unbound") cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.serveur_dns.unbound_local_zones cadoles.com \ --configuration.reseau.unbound_route_address 192.168.1.254 \ --configuration.serveur_dns.unbound_allowed_client_cidr 192.168.1.0/24 @@ -105,7 +116,7 @@ cucchiaiata-cli v1.setting.session.configure --session_id "$S" --unbound.unbound cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save # Servermodel unbound_etab1 -S=$(cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name unbound_etab1 | jq -r .session_id) +S=$(get_id "cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name unbound_etab1") cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.reseau.unbound_domain_name dns.cadoles.com cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save @@ -125,12 +136,12 @@ cucchiaiata-cli v1.infra.server.create --server_name dns.cadoles.com \ --servermodel_name unbound_etab1 # configuration sleep 1 -S=$(cucchiaiata-cli v1.setting.session.server.start --server dns.cadoles.com | jq -r .session_id) +S=$(get_id "cucchiaiata-cli v1.setting.session.server.start --server dns.cadoles.com") cucchiaiata-cli v1.setting.session.configure --session_id "$S" --configuration.reseau.unbound_ip_address_cidr 192.168.1.2/24 cucchiaiata-cli v1.setting.session.filter --session_id "$S" --namespace opennebula -cucchiaiata-cli v1.setting.session.configure --session_id "$S" --opennebula.configuration.cpu 0.2 \ - --opennebula.configuration.vcpu 2 \ - --opennebula.configuration.memory 2 +cucchiaiata-cli v1.setting.session.configure --session_id "$S" --opennebula.cpu 0.2 \ + --opennebula.vcpu 2 \ + --opennebula.memory 2 cucchiaiata-cli v1.setting.session.validate --session_id $S cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save diff --git a/src/cucchiaiata/configuration.py b/src/cucchiaiata/configuration.py index 6e4b18b..ee998be 100644 --- a/src/cucchiaiata/configuration.py +++ b/src/cucchiaiata/configuration.py @@ -29,9 +29,9 @@ class Configuration(Common): version = smessage[0] type = smessage[-2] url = '{}/{}/setting/{}'.format(self.cucchiaiata_config.remote_url, - version, - self.session_id, - ) + version, + self.session_id, + ) tconfig = self.remote_json_to_config(url, ConfigAPI, ) @@ -65,8 +65,11 @@ class Configuration(Common): def get(self): parameters = self.get_parameters() tiramisu_config = self.configure_server() + option = next(tiramisu_config.option.list('all')) + namespace = option.option.path().split('.', 1)[0] parser = TiramisuCmdlineParser(tiramisu_config, self.prog, + root=namespace, unrestraint=True, fullpath=True) parser.parse_args(parameters,