diff --git a/apps/api/network/ip_group.py b/apps/api/network/ip_group.py new file mode 100644 index 00000000..066f8753 --- /dev/null +++ b/apps/api/network/ip_group.py @@ -0,0 +1,14 @@ +# coding: utf-8 +from __future__ import (absolute_import, division, print_function, unicode_literals) + +from apps.api.apibase import ApiBase +from apps.api.apibase_backend import ApiBackendBase + + +class IpGroupBackendApi(ApiBackendBase): + def __init__(self): + super(IpGroupBackendApi, self).__init__() + self.resource_name = "ipaddress_group" + self.resource_workspace = "ipaddress_group" + self._flush_resobj() + self.resource_keys_config = None diff --git a/apps/controller/configer/defines.py b/apps/controller/configer/defines.py index b1a44a30..5deac20e 100644 --- a/apps/controller/configer/defines.py +++ b/apps/controller/configer/defines.py @@ -229,6 +229,31 @@ 'from_port', 'to_port', 'priority', 'nic_type'] } }, + "ipaddress_group": { + "apply": { + "path": "/terraform/v1/network/backend/ip_group/apply", + "method": "POST", + "notnull": ['name', 'provider', "region_id"], + "inputParameters": ['id', 'name', 'secret', 'provider', "addresses", "zone_id", "region_id", + 'asset_id', 'extend_info'], + "outputParameters": ["errorMessage", "errorCode", "id", "asset_id"] + }, + "destroy": { + "path": "/terraform/v1/network/backend/ip_group/destroy", + "method": "POST", + "notnull": ["id"], + "inputParameters": ["id"], + "outputParameters": ["errorMessage", "errorCode", "id"] + }, + "query": { + "path": "/terraform/v1/network/backend/ip_group/source", + "method": "POST", + "notnull": ["region_id", "provider"], + "inputParameters": ["region_id", 'secret', 'provider', 'asset_id', 'name', 'id'], + "outputParameters": ["region_id", 'secret', 'provider', 'asset_id', 'errorMessage', 'errorCode', 'name', + 'addresses'] + } + }, "nat": { "apply": { "path": "/terraform/v1/network/backend/nat/apply", diff --git a/apps/controller/configer/model_args.py b/apps/controller/configer/model_args.py index c97b25dc..3371e02f 100644 --- a/apps/controller/configer/model_args.py +++ b/apps/controller/configer/model_args.py @@ -42,6 +42,10 @@ "ip_protocol", "ports" ], + "ipaddress_group": [ + "name", + "addresses" + ], "nat": [ "name", "vpc_id", @@ -359,6 +363,9 @@ "route_entry": [ "asset_id" ], + "ipaddress_group": [ + "asset_id" + ], "security_group": [ "asset_id" ], @@ -517,6 +524,10 @@ "asset_id", "route_table_id" ], + "ipaddress_group": [ + "asset_id", + "name", + ], "security_group": [ "asset_id", "name", diff --git a/apps/controller/network/ip_group_controller.py b/apps/controller/network/ip_group_controller.py new file mode 100644 index 00000000..7640e0a8 --- /dev/null +++ b/apps/controller/network/ip_group_controller.py @@ -0,0 +1,27 @@ +# _ coding:utf-8 _*_ + +from __future__ import (absolute_import, division, print_function, unicode_literals) + +from apps.api.network.ip_group import IpGroupBackendApi +from apps.controller.backend_controller import BackendAddController +from apps.controller.backend_controller import BackendDeleteController +from apps.controller.backend_controller import BackendSourceController + + +class IpGroupAddController(BackendAddController): + allow_methods = ("POST",) + resource = IpGroupBackendApi() + + +class IpGroupDeleteController(BackendDeleteController): + name = "IpGroup" + resource_describe = "IpGroup" + allow_methods = ("POST",) + resource = IpGroupBackendApi() + + +class IpGroupSourceController(BackendSourceController): + name = "IpGroup" + resource_describe = "IpGroup" + allow_methods = ("POST",) + resource = IpGroupBackendApi() diff --git a/apps/controller/network/route.py b/apps/controller/network/route.py index 64d5c5af..2f6a524a 100644 --- a/apps/controller/network/route.py +++ b/apps/controller/network/route.py @@ -15,6 +15,7 @@ import security_group_controller import security_group_rule_controller import peer_connection_controller +import ip_group_controller from route_entry_controller import RouteEntryController from route_entry_controller import RouteEntryIdController @@ -38,6 +39,10 @@ url(r'^backend/vpc/destroy$', vpc_controller.VPCDeleteController()), url(r'^backend/vpc/source$', vpc_controller.VPCSourceController()), + url(r'^backend/ip_group/apply$', ip_group_controller.IpGroupAddController()), + url(r'^backend/ip_group/destroy$', ip_group_controller.IpGroupDeleteController()), + url(r'^backend/ip_group/source$', ip_group_controller.IpGroupSourceController()), + url(r'^subnet$', subnet_controller.SubnetController()), url(r'^subnet/(?P[\w-]+)$', subnet_controller.SubnetIdController()), url(r'^backend/subnet/apply$', subnet_controller.SubnetAddController()),