diff --git a/provisioning_example.sh b/provisioning_example.sh index c0d1157..5cd2199 100755 --- a/provisioning_example.sh +++ b/provisioning_example.sh @@ -12,26 +12,67 @@ cucchiaiata-cli v1.setting.source.create --source_name Cadoles --source_director #======================================================================================================= # Create a new user and set role 'server_rw' for the server dns.cadoles.com -cucchiaiata-cli v1.user.user.create --login gnunux --name gnunux --surname gnunux --email egarette@cadoles.com -cucchiaiata-cli v1.user.role.create --user_login gnunux --role_name 'server_rw' --role_attribute 'Server.ServerName' --role_attribute_value dns.cadoles.com +cucchiaiata-cli v1.user.user.create --login gnunux \ + --name gnunux \ + --surname gnunux \ + --email egarette@cadoles.com +cucchiaiata-cli v1.user.role.create --user_login gnunux \ + --role_name 'server_rw' \ + --role_attribute 'Server.ServerName' \ + --role_attribute_value dns.cadoles.com -# Sites and zone -# + = = = = = = = = = = = + -# " SITE site_cluster " -# " "---------+ -# " " | -# + = = = = = = = = = = = + +~~~~~~~~~~+ -# ! ZONE ! -# ! internet ! -# + = = = = = = = = = = = + +~~~~~~~~~~+ -# " SITE etab1 " | -# " "---------+ -# " " -# + = = = = = = = = = = = + -cucchiaiata-cli v1.infra.site.create --site_name site_cluster -cucchiaiata-cli v1.infra.site.create --site_name etab1 # Zone -cucchiaiata-cli v1.infra.zone.create --zone_name internet --sites_name site_cluster etab1 --network "192.168.1.0/24" --host_start "192.168.1.10" --host_end "192.168.1.100" --dns 192.168.1.1 --gateway 192.168.1.254 +# +~~~~~~~~~~+ +# ! ZONE ! +# ! internet ! +# +~~~~~~~~~~+ +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_end "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 +cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save + + +# Create the cluster cluster.cadoles.com +# +---------------------------+ +# | cluster.cadoles.com | +~~~~~~~~~~+ +# | +--------------------+ |-------! ZONE ! +# | | node1.cadoles.com |---|-------! internet ! +# | +--------------------+ | +~~~~~~~~~~+ +# +---------------------------+ +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 \ + --zones_name internet + +# configuration +S=$(cucchiaiata-cli v1.setting.session.cluster.start --cluster_name cluster.cadoles.com | jq -r .session_id) +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 + +# Organization, sites and zone +# + = = = = = = = = = = = = = = = = = = = = + +# " ORGANISATION cadoles.com " +# " + = = = = = = = = = = = + " +# " " SITE etab1 "----"----+ +~~~~~~~~~~+ +# " + = = = = = = = = = = = + " |___! ZONE ! +# " + = = = = = = = = = = = + " | ! internet ! +# " " SITE etab2 "----"----+ +~~~~~~~~~~+ +# " + = = = = = = = = = = = + " +# + = = = = = = = = = = = = = = = = = = = = + +cucchiaiata-cli v1.infra.organization.create --organization_name cadoles.com +cucchiaiata-cli v1.infra.site.create --site_name etab1 \ + --organization_name cadoles.com \ + --zones_name internet +cucchiaiata-cli v1.infra.site.create --site_name etab2 \ + --organization_name cadoles.com \ + --zones_name internet # Servermodels # -> base-fedora-32 (Cadoles) @@ -40,78 +81,62 @@ cucchiaiata-cli v1.infra.zone.create --zone_name internet --sites_name site_clus # '-> unbound (Cadoles) # '-> unbound (servermodel) ----, # | -# -> openssh (Cadoles) |--> unbound_etab1 (servermodel) +# -> openssh-server (Cadoles) |--> unbound_etab1 (servermodel) # '-> aca (servermodel) | # '-> etab1 (servermodel) ------' cucchiaiata-cli v1.setting.servermodel.create --servermodel_name sm_cluster --applicationservices base-fedora-32 cucchiaiata-cli v1.setting.servermodel.create --servermodel_name unbound --applicationservices unbound -cucchiaiata-cli v1.setting.servermodel.create --servermodel_name aca --applicationservices openssh +cucchiaiata-cli v1.setting.servermodel.create --servermodel_name aca --applicationservices openssh-server cucchiaiata-cli v1.setting.servermodel.create --servermodel_name etab1 --parents_name aca cucchiaiata-cli v1.setting.servermodel.create --servermodel_name unbound_etab1 --parents_name etab1 unbound -# Servers -# + = = = = = = = = = = = = = = = = = = = = = = = + -# " SITE site_cluster +-------------------+ " -# " | node1.cadoles.com |---------------+ -# " +-------------------+ " | -# + = = = = = = = = = = = = = = = = = = = = = = = + +~~~~~~~~~~+ -# ! ZONE ! -# ! internet ! -# + = = = = = = = = = = = = = = = = = = = = = = = + +~~~~~~~~~~+ -# " SITE etab1 +-------------------+ " | -# " | dns.cadoles.com |---------------+ -# " +-------------------+ " -# + = = = = = = = = = = = = = = = = = = = = = = = + - -# -> sm_cluster -# '-> node1.cadoles.com (server) -# -> unbound_etab1 -# '-> dns.cadoles.com (server) -cucchiaiata-cli v1.infra.server.create --server_name node1.cadoles.com --site_name site_cluster --zones_name internet --servermodel_name sm_cluster -cucchiaiata-cli v1.infra.server.create --server_name dns.cadoles.com --site_name etab1 --zones_name internet --servermodel_name unbound_etab1 - -# Create the cluster cluster.cadoles.com -# +-------------------------+ +-------------------------+ -# | Nodes | | VMs | -# | +--------------------+ | | +--------------------+ | -# | | node1.cadoles.com | | <---- | + dns.cadoles.com + | -# | +--------------------+ | | +--------------------+ | -# | | | | -# +-------------------------+ +-------------------------+ -cucchiaiata-cli v1.provider.factory.cluster.create --cluster_name cluster.cadoles.com --virtual_ip 192.168.1.1 --zone_name internet -cucchiaiata-cli v1.provider.factory.cluster.join --cluster_name cluster.cadoles.com --node_name node1.cadoles.com -cucchiaiata-cli v1.provider.factory.server.add --cluster_name cluster.cadoles.com --server dns.cadoles.com --cpu 0.2 --vcpu 2 --memory 2 - -#======================================================================================================= -# Configuration -#======================================================================================================= +# configuration # Servermodel ACA S=$(cucchiaiata-cli v1.setting.session.servermodel.start --servermodel_name aca| jq -r .session_id) -cucchiaiata-cli v1.setting.session.servermodel.configure --session_id "$S" --configuration.serveur_ssh.ssh_allow_networks admin.cadoles.com -cucchiaiata-cli v1.setting.session.servermodel.stop --session_id "$S" --save +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) -cucchiaiata-cli v1.setting.session.servermodel.configure --session_id "$S" --configuration.serveur_dns.unbound_local_zones cadoles.com \ - --configuration.reseau.unbound_route_address 192.168.1.2 \ - --configuration.serveur_dns.unbound_allowed_client_cidr 192.168.1.0/24 -cucchiaiata-cli v1.setting.session.servermodel.filter --session_id "$S" --namespace unbound -cucchiaiata-cli v1.setting.session.servermodel.configure --session_id "$S" --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.hostname_cadoles_com toto titi \ - --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.ip_cadoles_com 0 192.168.1.25 \ - --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.type_cadoles_com 1 CNAME \ - --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.cname_cadoles_com 1 toto.cadoles.com -cucchiaiata-cli v1.setting.session.servermodel.stop --session_id "$S" --save +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.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 \ + --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.ip_cadoles_com 0 192.168.1.25 \ + --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.type_cadoles_com 1 CNAME \ + --unbound.unbound_zone_cadoles_com.hostname_cadoles_com.cname_cadoles_com 1 toto.cadoles.com +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) -cucchiaiata-cli v1.setting.session.servermodel.configure --session_id "$S" --configuration.reseau.unbound_domain_name dns.cadoles.com -cucchiaiata-cli v1.setting.session.servermodel.stop --session_id "$S" --save +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 -# Server dns.cadoles.com +# Server +# + = = = = = = = = = = = = = = = = = = = = = = = + +# " SITE etab1 +-------------------+ " +~~~~~~~~~~+ +# " | dns.cadoles.com |----"------! ZONE ! +# " +-------------------+ " ! internet ! +# " " +~~~~~~~~~~+ +# + = = = = = = = = = = = = = = = = = = = = = = = + +# -> unbound_etab1 +# '-> dns.cadoles.com (server) +cucchiaiata-cli v1.infra.server.create --server_name dns.cadoles.com \ + --site_name etab1 \ + --cluster_name cluster.cadoles.com \ + --zones_name internet \ + --servermodel_name unbound_etab1 +# configuration S=$(cucchiaiata-cli v1.setting.session.server.start --server dns.cadoles.com | jq -r .session_id) -cucchiaiata-cli v1.setting.session.server.configure --session_id "$S" --configuration.reseau.unbound_ip_address_cidr 192.168.1.1/24 -cucchiaiata-cli v1.setting.session.server.validate --session_id $S -cucchiaiata-cli v1.setting.session.server.stop --session_id "$S" --save +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.validate --session_id $S +cucchiaiata-cli v1.setting.session.stop --session_id "$S" --save #======================================================================================================= # Deploy @@ -122,7 +147,7 @@ cucchiaiata-cli v1.setting.config.configuration.server.deploy --server dns.cadol cucchiaiata-cli v1.setting.template.generate --server dns.cadoles.com # Generate cluster's configurtion -#cucchiaiata-cli v1.provider.factory.configure -c cluster.cadoles.com -#cucchiaiata-cli v1.provider.factory.deploy --server dns.cadoles.com +#cucchiaiata-cli v1.provider.configure -c cluster.cadoles.com +#cucchiaiata-cli v1.provider.deploy --server dns.cadoles.com echo "fin" diff --git a/script/cucchiaiata-cli b/script/cucchiaiata-cli index 059538d..269b2e8 100755 --- a/script/cucchiaiata-cli +++ b/script/cucchiaiata-cli @@ -10,8 +10,8 @@ from cucchiaiata.i18n import _ def main(): try: - if len(argv) > 2 and argv[1] in ['v1.setting.session.server.configure', - 'v1.setting.session.servermodel.configure']: + if len(argv) > 2 and argv[1] in ['v1.setting.session.configure', + 'v1.setting.session.configure']: Configuration().get() else: parser = Parser() diff --git a/src/cucchiaiata/configuration.py b/src/cucchiaiata/configuration.py index a05dbce..6e4b18b 100644 --- a/src/cucchiaiata/configuration.py +++ b/src/cucchiaiata/configuration.py @@ -28,10 +28,10 @@ class Configuration(Common): smessage = self.message.split('.') version = smessage[0] type = smessage[-2] - url = '{}/{}/setting/{}/{}'.format(self.cucchiaiata_config.remote_url, + url = '{}/{}/setting/{}'.format(self.cucchiaiata_config.remote_url, version, - type, - self.session_id) + self.session_id, + ) tconfig = self.remote_json_to_config(url, ConfigAPI, )