example.py: undeploy action is functional
This commit is contained in:
parent
5e851460ec
commit
e0cf68a9f6
74
example.py
74
example.py
@ -23,63 +23,63 @@ def deploy():
|
||||
|
||||
signals.Connections.clear()
|
||||
|
||||
node1 = resource.create('node1', 'resources/ro_node/', {'ip':'10.0.0.3', 'ssh_key' : '/vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key', 'ssh_user':'vagrant'})
|
||||
node2 = resource.create('node2', 'resources/ro_node/', {'ip':'10.0.0.4', 'ssh_key' : '/vagrant/.vagrant/machines/solar-dev3/virtualbox/private_key', 'ssh_user':'vagrant'})
|
||||
node1 = resource.create('node1', 'resources/ro_node/', {'ip': '10.0.0.3', 'ssh_key': '/vagrant/.vagrant/machines/solar-dev2/virtualbox/private_key', 'ssh_user': 'vagrant'})
|
||||
node2 = resource.create('node2', 'resources/ro_node/', {'ip': '10.0.0.4', 'ssh_key': '/vagrant/.vagrant/machines/solar-dev3/virtualbox/private_key', 'ssh_user': 'vagrant'})
|
||||
|
||||
mariadb_service1 = resource.create('mariadb_service1', 'resources/mariadb_service', {'image':'mariadb', 'root_password' : 'mariadb', 'port' : 3306, 'ip': '', 'ssh_user': '', 'ssh_key': ''})
|
||||
keystone_db = resource.create('keystone_db', 'resources/mariadb_db/', {'db_name':'keystone_db', 'login_password':'', 'login_user':'root', 'login_port': '', 'ip':'', 'ssh_user':'', 'ssh_key':''})
|
||||
keystone_db_user = resource.create('keystone_db_user', 'resources/mariadb_user/', {'new_user_name' : 'keystone', 'new_user_password' : 'keystone', 'db_name':'', 'login_password':'', 'login_user':'root', 'login_port': '', 'ip':'', 'ssh_user':'', 'ssh_key':''})
|
||||
mariadb_service1 = resource.create('mariadb_service1', 'resources/mariadb_service', {'image': 'mariadb', 'root_password': 'mariadb', 'port': 3306, 'ip': '', 'ssh_user': '', 'ssh_key': ''})
|
||||
keystone_db = resource.create('keystone_db', 'resources/mariadb_db/', {'db_name': 'keystone_db', 'login_password': '', 'login_user': 'root', 'login_port': '', 'ip': '', 'ssh_user': '', 'ssh_key': ''})
|
||||
keystone_db_user = resource.create('keystone_db_user', 'resources/mariadb_user/', {'new_user_name': 'keystone', 'new_user_password': 'keystone', 'db_name': '', 'login_password': '', 'login_user': 'root', 'login_port': '', 'ip': '', 'ssh_user': '', 'ssh_key': ''})
|
||||
|
||||
keystone_config1 = resource.create('keystone_config1', 'resources/keystone_config/', {'config_dir' : '/etc/solar/keystone', 'ip':'', 'ssh_user':'', 'ssh_key':'', 'admin_token':'admin', 'db_password':'', 'db_name':'', 'db_user':'', 'db_host':'', 'db_port': ''})
|
||||
keystone_service1 = resource.create('keystone_service1', 'resources/keystone_service/', {'port': 5001, 'admin_port': 35357, 'image': '', 'ip':'', 'ssh_key':'', 'ssh_user':'', 'config_dir':''})
|
||||
keystone_config1 = resource.create('keystone_config1', 'resources/keystone_config/', {'config_dir': '/etc/solar/keystone', 'ip': '', 'ssh_user': '', 'ssh_key': '', 'admin_token': 'admin', 'db_password': '', 'db_name': '', 'db_user': '', 'db_host': '', 'db_port': ''})
|
||||
keystone_service1 = resource.create('keystone_service1', 'resources/keystone_service/', {'port': 5001, 'admin_port': 35357, 'image': '', 'ip': '', 'ssh_key': '', 'ssh_user': '', 'config_dir': ''})
|
||||
|
||||
keystone_config2 = resource.create('keystone_config2', 'resources/keystone_config/', {'config_dir' : '/etc/solar/keystone', 'ip':'', 'ssh_user':'', 'ssh_key':'', 'admin_token':'admin', 'db_password':'', 'db_name':'', 'db_user':'', 'db_host':'', 'db_port': ''})
|
||||
keystone_service2 = resource.create('keystone_service2', 'resources/keystone_service/', {'port': 5002, 'admin_port': 35357, 'image': '', 'ip':'', 'ssh_key':'', 'ssh_user':'', 'config_dir':''})
|
||||
keystone_config2 = resource.create('keystone_config2', 'resources/keystone_config/', {'config_dir': '/etc/solar/keystone', 'ip': '', 'ssh_user': '', 'ssh_key': '', 'admin_token': 'admin', 'db_password': '', 'db_name': '', 'db_user': '', 'db_host': '', 'db_port': ''})
|
||||
keystone_service2 = resource.create('keystone_service2', 'resources/keystone_service/', {'port': 5002, 'admin_port': 35357, 'image': '', 'ip': '', 'ssh_key': '', 'ssh_user': '', 'config_dir': ''})
|
||||
|
||||
|
||||
haproxy_keystone_config = resource.create('haproxy_keystone1_config', 'resources/haproxy_keystone_config/', {'name':'keystone_config', 'listen_port':5000, 'servers':[], 'ports':[]})
|
||||
haproxy_config = resource.create('haproxy_config', 'resources/haproxy', {'ip':'', 'ssh_key':'', 'ssh_user':'', 'configs_names':[], 'configs_ports':[], 'listen_ports':[], 'configs':[], 'config_dir': ''})
|
||||
haproxy_service = resource.create('haproxy_service', 'resources/docker_container/', {'image' : 'tutum/haproxy', 'ports': [], 'host_binds': [], 'volume_binds':[], 'ip':'', 'ssh_key':'', 'ssh_user':''})
|
||||
haproxy_keystone_config = resource.create('haproxy_keystone1_config', 'resources/haproxy_keystone_config/', {'name': 'keystone_config', 'listen_port':5000, 'servers':[], 'ports':[]})
|
||||
haproxy_config = resource.create('haproxy_config', 'resources/haproxy', {'ip': '', 'ssh_key': '', 'ssh_user': '', 'configs_names':[], 'configs_ports':[], 'listen_ports':[], 'configs':[], 'config_dir': ''})
|
||||
haproxy_service = resource.create('haproxy_service', 'resources/docker_container/', {'image': 'tutum/haproxy', 'ports': [], 'host_binds': [], 'volume_binds':[], 'ip': '', 'ssh_key': '', 'ssh_user': ''})
|
||||
|
||||
|
||||
####
|
||||
# connections
|
||||
####
|
||||
|
||||
#mariadb
|
||||
# mariadb
|
||||
signals.connect(node1, mariadb_service1)
|
||||
|
||||
#keystone db
|
||||
# keystone db
|
||||
signals.connect(node1, keystone_db)
|
||||
signals.connect(mariadb_service1, keystone_db, {'root_password':'login_password', 'port':'login_port'})
|
||||
signals.connect(mariadb_service1, keystone_db, {'root_password': 'login_password', 'port': 'login_port'})
|
||||
|
||||
# keystone_db_user
|
||||
signals.connect(node1, keystone_db_user)
|
||||
signals.connect(mariadb_service1, keystone_db_user, {'root_password':'login_password', 'port':'login_port'})
|
||||
signals.connect(keystone_db, keystone_db_user, {'db_name':'db_name'})
|
||||
signals.connect(mariadb_service1, keystone_db_user, {'root_password': 'login_password', 'port': 'login_port'})
|
||||
signals.connect(keystone_db, keystone_db_user, {'db_name': 'db_name'})
|
||||
|
||||
signals.connect(node1, keystone_config1)
|
||||
signals.connect(mariadb_service1, keystone_config1, {'ip':'db_host', 'port': 'db_port'})
|
||||
signals.connect(keystone_db_user, keystone_config1, {'db_name':'db_name', 'new_user_name':'db_user', 'new_user_password':'db_password'})
|
||||
signals.connect(mariadb_service1, keystone_config1, {'ip': 'db_host', 'port': 'db_port'})
|
||||
signals.connect(keystone_db_user, keystone_config1, {'db_name': 'db_name', 'new_user_name': 'db_user', 'new_user_password': 'db_password'})
|
||||
|
||||
signals.connect(node1, keystone_service1)
|
||||
signals.connect(keystone_config1, keystone_service1, {'config_dir': 'config_dir'})
|
||||
|
||||
signals.connect(node2, keystone_config2)
|
||||
signals.connect(mariadb_service1, keystone_config2, {'ip':'db_host', 'port': 'db_port'})
|
||||
signals.connect(keystone_db_user, keystone_config2, {'db_name':'db_name', 'new_user_name':'db_user', 'new_user_password':'db_password'})
|
||||
signals.connect(mariadb_service1, keystone_config2, {'ip': 'db_host', 'port': 'db_port'})
|
||||
signals.connect(keystone_db_user, keystone_config2, {'db_name': 'db_name', 'new_user_name': 'db_user', 'new_user_password': 'db_password'})
|
||||
|
||||
signals.connect(node2, keystone_service2)
|
||||
signals.connect(keystone_config2, keystone_service2, {'config_dir': 'config_dir'})
|
||||
|
||||
signals.connect(keystone_service1, haproxy_keystone_config, {'ip':'servers', 'port':'ports'})
|
||||
signals.connect(keystone_service2, haproxy_keystone_config, {'ip':'servers', 'port':'ports'})
|
||||
signals.connect(keystone_service1, haproxy_keystone_config, {'ip': 'servers', 'port': 'ports'})
|
||||
signals.connect(keystone_service2, haproxy_keystone_config, {'ip': 'servers', 'port': 'ports'})
|
||||
|
||||
signals.connect(node2, haproxy_config)
|
||||
signals.connect(haproxy_keystone_config, haproxy_config, {'listen_port': 'listen_ports', 'name':'configs_names', 'ports' : 'configs_ports', 'servers':'configs'})
|
||||
signals.connect(haproxy_keystone_config, haproxy_config, {'listen_port': 'listen_ports', 'name': 'configs_names', 'ports': 'configs_ports', 'servers': 'configs'})
|
||||
|
||||
signals.connect(node2, haproxy_service)
|
||||
signals.connect(haproxy_config, haproxy_service, {'listen_ports':'ports', 'config_dir':'host_binds'})
|
||||
signals.connect(haproxy_config, haproxy_service, {'listen_ports': 'ports', 'config_dir': 'host_binds'})
|
||||
|
||||
|
||||
has_errors = False
|
||||
@ -104,7 +104,7 @@ def deploy():
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
#run
|
||||
# run
|
||||
actions.resource_action(mariadb_service1, 'run')
|
||||
time.sleep(10)
|
||||
actions.resource_action(keystone_db, 'run')
|
||||
@ -117,16 +117,6 @@ def deploy():
|
||||
actions.resource_action(haproxy_service, 'run')
|
||||
|
||||
|
||||
#remove
|
||||
#actions.resource_action(haproxy_service, 'remove')
|
||||
#actions.resource_action(haproxy_config, 'remove')
|
||||
#actions.resource_action(keystone_service1, 'remove')
|
||||
#actions.resource_action(keystone_config1, 'remove')
|
||||
#actions.resource_action(keystone_db_user, 'remove')
|
||||
#actions.resource_action(keystone_db, 'remove')
|
||||
#actions.resource_action(mariadb_service1, 'remove')
|
||||
|
||||
|
||||
# test working configuration
|
||||
requests.get('http://%s:%s' % (keystone_service1.args['ip'].value, keystone_service1.args['port'].value))
|
||||
requests.get('http://%s:%s' % (keystone_service2.args['ip'].value, keystone_service2.args['port'].value))
|
||||
@ -140,9 +130,17 @@ def undeploy():
|
||||
db = get_db()
|
||||
|
||||
resources = map(resource.wrap_resource, db.get_list('resource'))
|
||||
resources = {r.name: r for r in resources}
|
||||
|
||||
for r in resources:
|
||||
actions.resource_action(r, 'remove')
|
||||
actions.resource_action(resources['haproxy_service'], 'remove')
|
||||
actions.resource_action(resources['haproxy_config'], 'remove')
|
||||
actions.resource_action(resources['keystone_service2'], 'remove')
|
||||
actions.resource_action(resources['keystone_config2'], 'remove')
|
||||
actions.resource_action(resources['keystone_service1'], 'remove')
|
||||
actions.resource_action(resources['keystone_config1'], 'remove')
|
||||
actions.resource_action(resources['keystone_db_user'], 'remove')
|
||||
actions.resource_action(resources['keystone_db'], 'remove')
|
||||
actions.resource_action(resources['mariadb_service1'], 'remove')
|
||||
|
||||
db.clear()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user