Mysql Openstack Stored Procedures: различия между версиями
Материал из noname.com.ua
Перейти к навигацииПерейти к поискуSirmax (обсуждение | вклад) |
Sirmax (обсуждение | вклад) |
||
Строка 56: | Строка 56: | ||
FOR EACH ROW BEGIN |
FOR EACH ROW BEGIN |
||
SET @tt_json = (SELECT json_object(created_at,updated_at,id,user_id,project_id,image_ref,hostname,reservation_id,uuid,deleted ) FROM instances WHERE uuid = NEW.uuid LIMIT 1); |
SET @tt_json = (SELECT json_object(created_at,updated_at,id,user_id,project_id,image_ref,hostname,reservation_id,uuid,deleted ) FROM instances WHERE uuid = NEW.uuid LIMIT 1); |
||
+ | |||
SET @tt_resu = (SELECT http_post(CONCAT('http://127.0.0.1:8081/', NEW.id), @tt_json)); |
SET @tt_resu = (SELECT http_post(CONCAT('http://127.0.0.1:8081/', NEW.id), @tt_json)); |
||
+ | SET @tt_resu = (SELECT http_post(CONCAT('http://172.16.169.34:8080/', NEW.id), @tt_json)); |
||
⚫ | |||
+ | |||
+ | |||
⚫ | |||
END | |
END | |
||
DELIMITER ; |
DELIMITER ; |
||
+ | |||
+ | |||
</PRE> |
</PRE> |
||
Строка 73: | Строка 79: | ||
FOR EACH ROW BEGIN |
FOR EACH ROW BEGIN |
||
SET @tt_json = (SELECT json_object(created_at,updated_at,id,user_id,project_id,image_ref,hostname,reservation_id,uuid,deleted ) FROM instances WHERE uuid = OLD.uuid LIMIT 1); |
SET @tt_json = (SELECT json_object(created_at,updated_at,id,user_id,project_id,image_ref,hostname,reservation_id,uuid,deleted ) FROM instances WHERE uuid = OLD.uuid LIMIT 1); |
||
+ | |||
SET @tt_resu = (SELECT http_post(CONCAT('http://127.0.0.1:8081/', OLD.id), @tt_json)); |
SET @tt_resu = (SELECT http_post(CONCAT('http://127.0.0.1:8081/', OLD.id), @tt_json)); |
||
+ | SET @tt_resu = (SELECT http_post(CONCAT('http://172.16.169.34:8080/', OLD.id), @tt_json)); |
||
⚫ | |||
+ | |||
⚫ | |||
END | |
END | |
||
DELIMITER ; |
DELIMITER ; |
||
Строка 89: | Строка 98: | ||
FOR EACH ROW BEGIN |
FOR EACH ROW BEGIN |
||
SET @tt_json = (SELECT json_object(created_at,updated_at,id,user_id,project_id,image_ref,hostname,reservation_id,uuid,deleted ) FROM instances WHERE uuid= OLD.uuid LIMIT 1); |
SET @tt_json = (SELECT json_object(created_at,updated_at,id,user_id,project_id,image_ref,hostname,reservation_id,uuid,deleted ) FROM instances WHERE uuid= OLD.uuid LIMIT 1); |
||
+ | |||
SET @tt_resu = (SELECT http_post(CONCAT('http://127.0.0.1:8081/', OLD.uuid), @tt_json)); |
SET @tt_resu = (SELECT http_post(CONCAT('http://127.0.0.1:8081/', OLD.uuid), @tt_json)); |
||
+ | SET @tt_resu = (SELECT http_post(CONCAT('http://172.16.169.34:8080/', OLD.id), @tt_json)); |
||
⚫ | |||
+ | |||
+ | |||
⚫ | |||
END | |
END | |
||
DELIMITER ; |
DELIMITER ; |
||
Строка 99: | Строка 112: | ||
<PRE> |
<PRE> |
||
+ | DROP TABLE IF EXISTS httplog; |
||
− | |||
CREATE TABLE `httplog` |
CREATE TABLE `httplog` |
||
( |
( |
||
− | `request` varchar( |
+ | `request` varchar(512) DEFAULT NULL, |
− | `response` varchar( |
+ | `response` varchar(512) DEFAULT NULL, |
`seq` int(10) unsigned NOT NULL AUTO_INCREMENT, |
`seq` int(10) unsigned NOT NULL AUTO_INCREMENT, |
||
`local_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
`local_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
Версия 15:11, 1 сентября 2016
openstack --os-identity-api-version 2 project create openstack --os-identity-api-version 2 project list +----------------------------------+----------+ | ID | Name | +----------------------------------+----------+ | 3cd08ae190564da49ad9838039e566b4 | admin | | 5e1d89c540764153970ffbe8ad3403d5 | services | | ed43deaf0b944723af84732e481504dd | project1 | +----------------------------------+----------+ openstack --os-identity-api-version 2 user create --project project1 --password user1 user1 +------------+----------------------------------+ | Field | Value | +------------+----------------------------------+ | email | None | | enabled | True | | id | 7759b1b8b1f2489ba869f6ff4c4b26cd | | name | user1 | | project_id | ed43deaf0b944723af84732e481504dd | | username | user1 | +------------+----------------------------------+ openstack --os-identity-api-version 2 role list +----------------------------------+-----------------+ | ID | Name | +----------------------------------+-----------------+ | 107d9c20c6fd44859a273015128f5020 | admin | | 3518209f468a40618eea71eede882c4f | heat_stack_user | | 9fe2ff9ee4384b1894a90878d3e92bab | _member_ | | e556e1a095684c8ea2ab8ec10f87500b | SwiftOperator | +----------------------------------+-----------------+ root@node-1:~# openstack --os-identity-api-version 2 role add --user 7759b1b8b1f2489ba869f6ff4c4b26cd --project project1 admin +-----------+----------------------------------+ | Field | Value | +-----------+----------------------------------+ | domain_id | None | | id | 107d9c20c6fd44859a273015128f5020 | | name | admin | +-----------+----------------------------------+
DELIMITER | DROP TRIGGER IF EXISTS nova_instances_insert; CREATE TRIGGER nova_instances_insert AFTER INSERT ON instances FOR EACH ROW BEGIN SET @tt_json = (SELECT json_object(created_at,updated_at,id,user_id,project_id,image_ref,hostname,reservation_id,uuid,deleted ) FROM instances WHERE uuid = NEW.uuid LIMIT 1); SET @tt_resu = (SELECT http_post(CONCAT('http://127.0.0.1:8081/', NEW.id), @tt_json)); SET @tt_resu = (SELECT http_post(CONCAT('http://172.16.169.34:8080/', NEW.id), @tt_json)); INSERT INTO httplog(request,response) values( @tt_json, @tt_resu); END | DELIMITER ;
DELIMITER | DROP TRIGGER IF EXISTS nova_instances_before_update; CREATE TRIGGER nova_instances_before_update BEFORE UPDATE ON instances FOR EACH ROW BEGIN SET @tt_json = (SELECT json_object(created_at,updated_at,id,user_id,project_id,image_ref,hostname,reservation_id,uuid,deleted ) FROM instances WHERE uuid = OLD.uuid LIMIT 1); SET @tt_resu = (SELECT http_post(CONCAT('http://127.0.0.1:8081/', OLD.id), @tt_json)); SET @tt_resu = (SELECT http_post(CONCAT('http://172.16.169.34:8080/', OLD.id), @tt_json)); INSERT INTO httplog(request,response) values( @tt_json, @tt_resu); END | DELIMITER ;
DELIMITER | DROP TRIGGER IF EXISTS nova_instances_after_update; CREATE TRIGGER nova_instances_after_update AFTER UPDATE ON instances FOR EACH ROW BEGIN SET @tt_json = (SELECT json_object(created_at,updated_at,id,user_id,project_id,image_ref,hostname,reservation_id,uuid,deleted ) FROM instances WHERE uuid= OLD.uuid LIMIT 1); SET @tt_resu = (SELECT http_post(CONCAT('http://127.0.0.1:8081/', OLD.uuid), @tt_json)); SET @tt_resu = (SELECT http_post(CONCAT('http://172.16.169.34:8080/', OLD.id), @tt_json)); INSERT INTO httplog(request,response) values( @tt_json, @tt_resu); END | DELIMITER ;
DROP TABLE IF EXISTS httplog; CREATE TABLE `httplog` ( `request` varchar(512) DEFAULT NULL, `response` varchar(512) DEFAULT NULL, `seq` int(10) unsigned NOT NULL AUTO_INCREMENT, `local_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`seq`) );
Ссылки
- https://habrahabr.ru/post/37693/ - триггера