Browse Source
Related patchset in kuryr-libnetwork: https://review.openstack.org/#/c/337350/ Implements blueprint code-refactoring Change-Id: I91a402a159817462535e77296217a9dd7eb0fd08changes/84/336784/12
44 changed files with 23 additions and 5174 deletions
@ -1,4 +0,0 @@
|
||||
{ |
||||
"Name": "kuryr", |
||||
"Addr": "http://127.0.0.1:2377" |
||||
} |
@ -1,16 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr import utils |
||||
|
||||
|
||||
app = utils.make_json_app(__name__) |
@ -1,35 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import endpoint_create |
||||
from kuryr.schemata import endpoint_delete |
||||
from kuryr.schemata import join |
||||
from kuryr.schemata import leave |
||||
from kuryr.schemata import network_create |
||||
from kuryr.schemata import network_delete |
||||
from kuryr.schemata import release_address |
||||
from kuryr.schemata import release_pool |
||||
from kuryr.schemata import request_address |
||||
from kuryr.schemata import request_pool |
||||
|
||||
|
||||
# Aliases for schemata in each module |
||||
ENDPOINT_CREATE_SCHEMA = endpoint_create.ENDPOINT_CREATE_SCHEMA |
||||
ENDPOINT_DELETE_SCHEMA = endpoint_delete.ENDPOINT_DELETE_SCHEMA |
||||
JOIN_SCHEMA = join.JOIN_SCHEMA |
||||
LEAVE_SCHEMA = leave.LEAVE_SCHEMA |
||||
NETWORK_CREATE_SCHEMA = network_create.NETWORK_CREATE_SCHEMA |
||||
NETWORK_DELETE_SCHEMA = network_delete.NETWORK_DELETE_SCHEMA |
||||
RELEASE_ADDRESS_SCHEMA = release_address.RELEASE_ADDRESS_SCHEMA |
||||
RELEASE_POOL_SCHEMA = release_pool.RELEASE_POOL_SCHEMA |
||||
REQUEST_ADDRESS_SCHEMA = request_address.REQUEST_ADDRESS_SCHEMA |
||||
REQUEST_POOL_SCHEMA = request_pool.REQUEST_POOL_SCHEMA |
@ -1,249 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
EPSILON_PATTERN = '^$' |
||||
IPV4_PATTERN_BASE = (u'((25[0-5]|2[0-4][0-9]|1?[0-9]?[0-9])\\.){3}' |
||||
u'(25[0-5]|2[0-4][0-9]|1?[0-9]?[0-9])') |
||||
IPV4_PATTERN = EPSILON_PATTERN + u'|^' + IPV4_PATTERN_BASE + u'$' |
||||
CIDRV4_PATTERN = EPSILON_PATTERN + '|^(' + IPV4_PATTERN_BASE + \ |
||||
u'(/(1[0-2][0-8]|[1-9]?[0-9]))' + u')$' |
||||
|
||||
IPV6_PATTERN_BASE = (u'(' |
||||
u'([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|' |
||||
u'([0-9a-fA-F]{1,4}:){1,7}:|' |
||||
u'([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|' |
||||
u'([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|' |
||||
u'([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|' |
||||
u'([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|' |
||||
u'([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|' |
||||
u'[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|' |
||||
u':((:[0-9a-fA-F]{1,4}){1,7}|:)|' |
||||
u'fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|' |
||||
u'::(ffff(:0{1,4}){0,1}:){0,1}' |
||||
u'((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}' |
||||
u'(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|' |
||||
u'([0-9a-fA-F]{1,4}:){1,4}:' |
||||
u'((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}' |
||||
u'(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))') |
||||
IPV6_PATTERN = EPSILON_PATTERN + u'|^' + IPV6_PATTERN_BASE + u'$' |
||||
CIDRV6_PATTERN = EPSILON_PATTERN + u'|^(' + IPV6_PATTERN_BASE + \ |
||||
u'(/(1[0-2][0-8]|[1-9]?[0-9]))' + u')$' |
||||
IPV4_OR_IPV6_PATTERN = IPV4_PATTERN + u'|^' + IPV6_PATTERN_BASE + u'$' |
||||
UUID_BASE = u'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' |
||||
UUID_PATTERN = EPSILON_PATTERN + u'|' + UUID_BASE |
||||
|
||||
COMMONS = { |
||||
u'description': u'Common data schemata shared among other schemata.', |
||||
u'links': [], |
||||
u'title': u'Kuryr Common Data Schema Definitions', |
||||
u'properties': { |
||||
u'options': {u'$ref': u'/schemata/commons#/definitions/options'}, |
||||
u'mac': {u'$ref': u'/schemata/commons#/definitions/mac'}, |
||||
u'cidrv6': {u'$ref': u'/schemata/commons#/definitions/cidrv6'}, |
||||
u'interface': {u'$ref': u'/schemata/commons#/definitions/interface'}, |
||||
u'cidr': {u'$ref': u'/schemata/commons#/definitions/cidr'}, |
||||
u'id': {u'$ref': u'/schemata/commons#/definitions/id'}, |
||||
u'uuid': {u'$ref': u'/schemata/commons#/definitions/uuid'}, |
||||
u'ipv4': {u'$ref': u'/schemata/commons#/definitions/ipv4'}, |
||||
u'ipv4_or_ipv6': { |
||||
u'$ref': u'/schemata/commons#/definitions/ipv4_or_ipv6'} |
||||
}, |
||||
u'definitions': { |
||||
u'options': { |
||||
u'type': [u'object', u'null'], |
||||
u'description': u'Options.', |
||||
u'example': {} |
||||
}, |
||||
u'mac': { |
||||
u'pattern': (EPSILON_PATTERN + u'|' |
||||
u'^((?:[0-9a-f]{2}:){5}[0-9a-f]{2}|' |
||||
u'(?:[0-9A-F]{2}:){5}[0-9A-F]{2})$'), |
||||
u'type': u'string', |
||||
u'description': u'A MAC address.', |
||||
u'example': u'aa:bb:cc:dd:ee:ff' |
||||
}, |
||||
u'cidrv6': { |
||||
u'pattern': CIDRV6_PATTERN, |
||||
u'type': u'string', |
||||
u'description': u'A IPv6 CIDR of the subnet' |
||||
}, |
||||
u'interface': { |
||||
u'properties': { |
||||
u'ID': { |
||||
u'description': u'Index of the interface', |
||||
u'type': u'number', |
||||
}, |
||||
u'AddressIPv6': { |
||||
u'description': u'IPv6 CIDR', |
||||
u'$ref': u'#/definitions/commons/definitions/cidrv6' |
||||
}, |
||||
u'MacAddress': { |
||||
u'description': u'MAC address', |
||||
u'$ref': u'#/definitions/commons/definitions/mac' |
||||
}, |
||||
u'Address': { |
||||
u'description': u'IPv4 CIDR', |
||||
u'$ref': u'#/definitions/commons/definitions/cidr' |
||||
} |
||||
}, |
||||
u'type': [u'object', u'null'], |
||||
u'description': u'Interface used in requests against Endpoints.', |
||||
u'example': { |
||||
u'AddressIPv6': u'fe80::f816:3eff:fe20:57c3/64', |
||||
u'MacAddress': u'fa:16:3e:20:57:c3', |
||||
u'Address': u'192.168.1.42/24' |
||||
} |
||||
}, |
||||
u'cidr': { |
||||
u'pattern': CIDRV4_PATTERN, |
||||
u'type': u'string', |
||||
u'description': u'A IPv4 CIDR of the subnet.', |
||||
u'example': u'10.0.0.0/24' |
||||
}, |
||||
u'id': { |
||||
u'pattern': u'^([0-9a-f]{64})$', |
||||
u'type': u'string', |
||||
u'description': u'256 bits ID value of Docker.', |
||||
u'example': |
||||
u'51c75a2515d47edecc3f720bb541e287224416fb66715eb7802011d6ffd499f1' |
||||
}, |
||||
u'ipv4': { |
||||
u'pattern': IPV4_PATTERN, |
||||
u'type': u'string', |
||||
u'description': u'An IPv4 address', |
||||
u'example': u'10.0.0.1' |
||||
}, |
||||
u'ipv4datum': { |
||||
u'description': u'IPv4 data', |
||||
u'required': [ |
||||
u'AddressSpace', u'Pool'], |
||||
u'type': u'object', |
||||
u'example': { |
||||
u'AddressSpace': u'foo', |
||||
u'Pool': u'192.168.42.0/24', |
||||
u'Gateway': u'192.168.42.1/24', |
||||
u'AuxAddresses': { |
||||
u'web': u'192.168.42.2', |
||||
u'db': u'192.168.42.3' |
||||
} |
||||
}, |
||||
u'properties': { |
||||
u'AddressSpace': { |
||||
u'description': u'The name of the address space.', |
||||
u'type': u'string', |
||||
u'example': u'foo', |
||||
}, |
||||
u'Pool': { |
||||
u'description': u'A range of IP Addresses requested in ' |
||||
u'CIDR format address/mask.', |
||||
u'$ref': u'#/definitions/commons/definitions/cidr' |
||||
}, |
||||
u'Gateway': { |
||||
u'description': u'Optionally, the IPAM driver may provide ' |
||||
u'a Gateway for the subnet represented by ' |
||||
u'the Pool.', |
||||
u'$ref': u'#/definitions/commons/definitions/cidr', |
||||
}, |
||||
u'AuxAddresses': { |
||||
u'description': u'A list of pre-allocated ip-addresses ' |
||||
u'with an associated identifier as ' |
||||
u'provided by the user to assist network ' |
||||
u'driver if it requires specific ' |
||||
u'ip-addresses for its operation.', |
||||
u'type': u'object', |
||||
u'patternProperties': { |
||||
u'.+': { |
||||
u'description': u'key-value pair of the ID and ' |
||||
u'the IP address', |
||||
u'$ref': u'#/definitions/commons/definitions/ipv4' |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
u'ipv6': { |
||||
u'pattern': IPV6_PATTERN, |
||||
u'type': u'string', |
||||
u'description': u'An IPv6 address.', |
||||
u'example': u'fe80::f816:3eff:fe20:57c4' |
||||
}, |
||||
u'ipv6datum': { |
||||
u'description': u'IPv6 data', |
||||
u'required': [ |
||||
u'AddressSpace', u'Pool', u'Gateway'], |
||||
u'type': u'object', |
||||
u'example': { |
||||
u'AddressCpace': u'bar', |
||||
u'Pool': u'fe80::/64', |
||||
u'Gateway': u'fe80::f816:3eff:fe20:57c3/64', |
||||
u'AuxAddresses': { |
||||
u'web': u'fe80::f816:3eff:fe20:57c4', |
||||
u'db': u'fe80::f816:3eff:fe20:57c5' |
||||
} |
||||
}, |
||||
u'properties': { |
||||
u'AddressSpace': { |
||||
u'description': u'The name of the address space.', |
||||
u'type': u'string', |
||||
u'example': u'foo', |
||||
}, |
||||
u'Pool': { |
||||
u'description': u'A range of IP Addresses requested in ' |
||||
u'CIDR format address/mask.', |
||||
u'$ref': u'#/definitions/commons/definitions/cidrv6' |
||||
}, |
||||
u'Gateway': { |
||||
u'description': u'Optionally, the IPAM driver may provide ' |
||||
u'a Gateway for the subnet represented by ' |
||||
u'the Pool.', |
||||
u'$ref': u'#/definitions/commons/definitions/cidrv6', |
||||
}, |
||||
u'AuxAddresses': { |
||||
u'description': u'A list of pre-allocated ip-addresses ' |
||||
u'with an associated identifier as ' |
||||
u'provided by the user to assist network ' |
||||
u'driver if it requires specific ' |
||||
u'ip-addresses for its operation.', |
||||
u'type': u'object', |
||||
u'patternProperties': { |
||||
u'.+': { |
||||
u'description': u'key-vavule pair of the ID and ' |
||||
u'the IP address', |
||||
u'$ref': u'#/definitions/commons/definitions/ipv6' |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
u'ipv4_or_ipv6': { |
||||
u'pattern': IPV4_OR_IPV6_PATTERN, |
||||
u'type': u'string', |
||||
u'description': u'An IPv4 or IPv6 address.', |
||||
u'example': u'fe80::f816:3eff:fe20:57c4' |
||||
}, |
||||
u'sandbox_key': { |
||||
u'pattern': u'^(/var/run/docker/netns/[0-9a-f]{12})$', |
||||
u'type': u'string', |
||||
u'description': u'Sandbox information of netns.', |
||||
u'example': '/var/run/docker/netns/12bbda391ed0' |
||||
}, |
||||
u'uuid': { |
||||
u'pattern': UUID_PATTERN, |
||||
u'type': u'string', |
||||
u'description': u'uuid of neutron resources.', |
||||
u'example': 'dfe39822-ad5e-40bd-babd-3954113b3687' |
||||
} |
||||
}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
u'id': u'schemata/commons' |
||||
} |
@ -1,48 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import commons |
||||
|
||||
ENDPOINT_CREATE_SCHEMA = { |
||||
u'links': [{ |
||||
u'method': u'POST', |
||||
u'href': u'/NetworkDriver.CreateEndpoint', |
||||
u'description': u'Create an Endpoint', |
||||
u'rel': u'self', |
||||
u'title': u'Create' |
||||
}], |
||||
u'title': u'Create endpoint', |
||||
u'required': [u'NetworkID', u'EndpointID', u'Options', u'Interface'], |
||||
u'definitions': {u'commons': {}}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
u'properties': { |
||||
u'NetworkID': { |
||||
u'description': u'Network ID', |
||||
u'$ref': u'#/definitions/commons/definitions/id' |
||||
}, |
||||
u'Interface': { |
||||
u'$ref': u'#/definitions/commons/definitions/interface', |
||||
u'description': u'Interface information' |
||||
}, |
||||
u'Options': { |
||||
u'description': u'Options', |
||||
u'$ref': u'#/definitions/commons/definitions/options' |
||||
}, |
||||
u'EndpointID': { |
||||
u'description': u'Endpoint ID', |
||||
u'$ref': u'#/definitions/commons/definitions/id' |
||||
} |
||||
} |
||||
} |
||||
|
||||
ENDPOINT_CREATE_SCHEMA[u'definitions'][u'commons'] = commons.COMMONS |
@ -1,40 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import commons |
||||
|
||||
ENDPOINT_DELETE_SCHEMA = { |
||||
u'links': [{ |
||||
u'method': u'POST', |
||||
u'href': u'/NetworkDriver.DeleteEndpoint', |
||||
u'description': u'Delete an Endpoint', |
||||
u'rel': u'self', |
||||
u'title': u'Delete' |
||||
}], |
||||
u'title': u'Delete endpoint', |
||||
u'required': [u'NetworkID', u'EndpointID'], |
||||
u'definitions': {u'commons': {}}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
u'properties': { |
||||
u'NetworkID': { |
||||
u'description': u'Network ID', |
||||
u'$ref': u'#/definitions/commons/definitions/id' |
||||
}, |
||||
u'EndpointID': { |
||||
u'description': u'Endpoint ID', |
||||
u'$ref': u'#/definitions/commons/definitions/id' |
||||
} |
||||
} |
||||
} |
||||
|
||||
ENDPOINT_DELETE_SCHEMA[u'definitions'][u'commons'] = commons.COMMONS |
@ -1,52 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata.commons import COMMONS |
||||
|
||||
|
||||
JOIN_SCHEMA = { |
||||
u'links': [{ |
||||
u'method': u'POST', |
||||
u'href': u'/NetworkDriver.Join', |
||||
u'description': u'Join the network', |
||||
u'rel': u'self', |
||||
u'title': u'Create' |
||||
}], |
||||
u'title': u'Join endpoint', |
||||
u'required': [ |
||||
u'NetworkID', |
||||
u'EndpointID', |
||||
u'SandboxKey' |
||||
], |
||||
u'properties': { |
||||
u'NetworkID': { |
||||
u'description': u'Network ID', |
||||
u'$ref': u'#/definitions/commons/definitions/id' |
||||
}, |
||||
u'SandboxKey': { |
||||
u'description': u'Sandbox Key', |
||||
u'$ref': u'#/definitions/commons/definitions/sandbox_key' |
||||
}, |
||||
u'Options': { |
||||
u'$ref': u'#/definitions/commons/definitions/options' |
||||
}, |
||||
u'EndpointID': { |
||||
u'description': u'Endpoint ID', |
||||
u'$ref': u'#/definitions/commons/definitions/id' |
||||
} |
||||
}, |
||||
u'definitions': {u'commons': {}}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
} |
||||
|
||||
JOIN_SCHEMA[u'definitions'][u'commons'] = COMMONS |
@ -1,24 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import endpoint_delete |
||||
|
||||
|
||||
LEAVE_SCHEMA = endpoint_delete.ENDPOINT_DELETE_SCHEMA |
||||
LEAVE_SCHEMA[u'title'] = u'Leave endpoint' |
||||
LEAVE_SCHEMA[u'links'] = [{ |
||||
u'method': u'POST', |
||||
u'href': u'/NetworkDriver.Leave', |
||||
u'description': u'Unbinds the endpoint from the container.', |
||||
u'rel': u'self', |
||||
u'title': u'Leave' |
||||
}] |
@ -1,55 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import commons |
||||
|
||||
NETWORK_CREATE_SCHEMA = { |
||||
u'links': [{ |
||||
u'method': u'POST', |
||||
u'href': u'/NetworkDriver.CreateNetwork', |
||||
u'description': u'Create a Network', |
||||
u'rel': u'self', |
||||
u'title': u'Create' |
||||
}], |
||||
u'title': u'Create network', |
||||
u'required': [u'NetworkID', u'IPv4Data', u'IPv6Data'], |
||||
u'definitions': {u'commons': {}}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
u'properties': { |
||||
u'NetworkID': { |
||||
u'description': u'ID of a Network to be created', |
||||
u'$ref': u'#/definitions/commons/definitions/id' |
||||
}, |
||||
u'IPv4Data': { |
||||
u'description': u'IPv4 data for the network', |
||||
u'type': u'array', |
||||
u'items': { |
||||
u'$ref': u'#/definitions/commons/definitions/ipv4datum' |
||||
} |
||||
}, |
||||
u'IPv6Data': { |
||||
u'description': u'IPv6 data for the network', |
||||
u'type': u'array', |
||||
u'items': { |
||||
u'$ref': u'#/definitions/commons/definitions/ipv6datum' |
||||
} |
||||
}, |
||||
u'Options': { |
||||
u'type': [u'object', u'null'], |
||||
u'description': u'Options', |
||||
u'example': {} |
||||
} |
||||
} |
||||
} |
||||
|
||||
NETWORK_CREATE_SCHEMA[u'definitions'][u'commons'] = commons.COMMONS |
@ -1,36 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import commons |
||||
|
||||
NETWORK_DELETE_SCHEMA = { |
||||
u'links': [{ |
||||
u'method': u'POST', |
||||
u'href': u'/NetworkDriver.DeleteNetwork', |
||||
u'description': u'Delete a Network', |
||||
u'rel': u'self', |
||||
u'title': u'Delete' |
||||
}], |
||||
u'title': u'Delete network', |
||||
u'required': [u'NetworkID'], |
||||
u'definitions': {u'commons': {}}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
u'properties': { |
||||
u'NetworkID': { |
||||
u'description': u'ID of the Network ID to be deleted', |
||||
u'$ref': u'#/definitions/commons/definitions/id' |
||||
} |
||||
} |
||||
} |
||||
|
||||
NETWORK_DELETE_SCHEMA[u'definitions'][u'commons'] = commons.COMMONS |
@ -1,41 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import commons |
||||
|
||||
RELEASE_ADDRESS_SCHEMA = { |
||||
u'links': [{ |
||||
u'method': u'POST', |
||||
u'href': u'/IpamDriver.ReleaseAddress', |
||||
u'description': u'Release an ip address', |
||||
u'rel': u'self', |
||||
u'title': u'Release' |
||||
}], |
||||
u'title': u'Release an IP', |
||||
u'required': [u'PoolID', u'Address'], |
||||
u'definitions': {u'commons': {}}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
u'properties': { |
||||
u'PoolID': { |
||||
u'description': u'neutron uuid of allocated subnetpool', |
||||
u'$ref': u'#/definitions/commons/definitions/uuid' |
||||
}, |
||||
u'Address': { |
||||
u'description': u'Address in IP(v4 or v6) form', |
||||
u'$ref': u'#/definitions/commons/definitions/ipv4_or_ipv6' |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
RELEASE_ADDRESS_SCHEMA[u'definitions'][u'commons'] = commons.COMMONS |
@ -1,36 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import commons |
||||
|
||||
RELEASE_POOL_SCHEMA = { |
||||
u'links': [{ |
||||
u'method': u'POST', |
||||
u'href': u'/IpamDriver.ReleasePool', |
||||
u'description': u'Release an ip pool', |
||||
u'rel': u'self', |
||||
u'title': u'Release' |
||||
}], |
||||
u'title': u'Release an IP pool', |
||||
u'required': [u'PoolID'], |
||||
u'definitions': {u'commons': {}}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
u'properties': { |
||||
u'PoolID': { |
||||
u'description': u'neutron ID of allocated subnetpool', |
||||
u'$ref': u'#/definitions/commons/definitions/uuid' |
||||
} |
||||
} |
||||
} |
||||
|
||||
RELEASE_POOL_SCHEMA[u'definitions'][u'commons'] = commons.COMMONS |
@ -1,47 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import commons |
||||
|
||||
REQUEST_ADDRESS_SCHEMA = { |
||||
u'links': [{ |
||||
u'method': u'POST', |
||||
u'href': u'/IpamDriver.RequestAddress', |
||||
u'description': u'Allocate an ip addresses', |
||||
u'rel': u'self', |
||||
u'title': u'Create' |
||||
}], |
||||
u'title': u'Create an IP', |
||||
u'required': [u'PoolID', u'Address', u'Options'], |
||||
u'definitions': {u'commons': {}}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
u'properties': { |
||||
u'PoolID': { |
||||
u'description': u'neutron uuid of allocated subnetpool', |
||||
u'$ref': u'#/definitions/commons/definitions/uuid' |
||||
}, |
||||
u'Address': { |
||||
u'description': u'Preferred address in regular IP form.', |
||||
u'example': u'10.0.0.1', |
||||
u'$ref': u'#/definitions/commons/definitions/ipv4_or_ipv6' |
||||
}, |
||||
u'Options': { |
||||
u'type': [u'object', u'null'], |
||||
u'description': u'Options', |
||||
u'example': {} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
REQUEST_ADDRESS_SCHEMA[u'definitions'][u'commons'] = commons.COMMONS |
@ -1,58 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.schemata import commons |
||||
|
||||
REQUEST_POOL_SCHEMA = { |
||||
u'links': [{ |
||||
u'method': u'POST', |
||||
u'href': u'/IpamDriver.RequestPool', |
||||
u'description': u'Allocate pool of ip addresses', |
||||
u'rel': u'self', |
||||
u'title': u'Create' |
||||
}], |
||||
u'title': u'Create pool', |
||||
u'required': [u'AddressSpace', u'Pool', u'SubPool', u'V6'], |
||||
u'definitions': {u'commons': {}}, |
||||
u'$schema': u'http://json-schema.org/draft-04/hyper-schema', |
||||
u'type': u'object', |
||||
u'properties': { |
||||
u'AddressSpace': { |
||||
u'description': u'The name of the address space.', |
||||
u'type': u'string', |
||||
u'example': u'foo', |
||||
}, |
||||
u'Pool': { |
||||
u'description': u'A range of IP Addresses represented in ' |
||||
u'CIDR format address/mask.', |
||||
u'$ref': u'#/definitions/commons/definitions/cidr' |
||||
}, |
||||
u'SubPool': { |
||||
u'description': u'A subset of IP range from Pool in' |
||||
u'CIDR format address/mask.', |
||||
u'$ref': u'#/definitions/commons/definitions/cidr' |
||||
}, |
||||
u'Options': { |
||||
u'type': [u'object', u'null'], |
||||
u'description': u'Options', |
||||
u'example': {}, |
||||
}, |
||||
u'V6': { |
||||
u'description': u'If set to "True", requesting IPv6 pool and ' |
||||
u'vice-versa.', |
||||
u'type': u'boolean', |
||||
u'example': False |
||||
} |
||||
} |
||||
} |
||||
|
||||
REQUEST_POOL_SCHEMA[u'definitions'][u'commons'] = commons.COMMONS |
@ -1,36 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
import sys |
||||
|
||||
from oslo_log import log |
||||
|
||||
from kuryr import app |
||||
from kuryr.common import config |
||||
from kuryr import controllers |
||||
|
||||
|
||||
config.init(sys.argv[1:]) |
||||
controllers.neutron_client() |
||||
controllers.check_for_neutron_ext_support() |
||||
controllers.check_for_neutron_ext_tag() |
||||
|
||||
log.setup(config.CONF, 'Kuryr') |
||||
|
||||
|
||||
def start(): |
||||
port = int(config.CONF.kuryr_uri.split(':')[-1]) |
||||
app.run("0.0.0.0", port) |
||||
|
||||
|
||||
if __name__ == '__main__': |
||||
start() |
@ -1,31 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
import docker |
||||
|
||||
from oslotest import base |
||||
|
||||
from kuryr import controllers |
||||
|
||||
|
||||
class KuryrBaseTest(base.BaseTestCase): |
||||
"""Basic class for Kuryr fullstack testing |
||||
|
||||
This class has common code shared for Kuryr fullstack testing |
||||
including the various clients (docker, neutron) and common |
||||
setup/cleanup code. |
||||
""" |
||||
def setUp(self): |
||||
super(KuryrBaseTest, self).setUp() |
||||
self.docker_client = docker.Client( |
||||
base_url='tcp://0.0.0.0:2375') |
||||
self.neutron_client = controllers.get_neutron_client() |
@ -1,88 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
from kuryr.tests.fullstack import kuryr_base |
||||
from kuryr import utils |
||||
|
||||
|
||||
class ContainerTest(kuryr_base.KuryrBaseTest): |
||||
"""Test Container related operations |
||||
|
||||
Test container connect/disconnect from docker to Neutron |
||||
""" |
||||
def setUp(self): |
||||
super(ContainerTest, self).setUp() |
||||
self.docker_client.pull(repository='busybox', tag='1') |
||||
|
||||
fake_ipam = { |
||||
"Driver": "kuryr", |
||||
"Options": {}, |
||||
"Config": [ |
||||
{ |
||||
"Subnet": "10.3.0.0/16", |
||||
"IPRange": "10.3.0.0/24", |
||||
"Gateway": "10.3.0.1" |
||||
} |
||||
] |
||||
} |
||||
net_name = utils.get_random_string(8) |
||||
res = self.docker_client.create_network(name=net_name, |
||||
driver='kuryr', |
||||
ipam=fake_ipam) |
||||
self.net_id = res.get('Id') |
||||
|
||||
networks = self.neutron_client.list_networks( |
||||
tags=utils.make_net_tags(self.net_id)) |
||||
self.assertEqual(1, len(networks['networks'])) |
||||
self.neutron_net_id = networks['networks'][0]['id'] |
||||
|
||||
def tearDown(self): |
||||
self.docker_client.remove_network(self.net_id) |
||||
networks = self.neutron_client.list_networks( |
||||
tags=utils.make_net_tags(self.net_id)) |
||||
self.assertEqual(0, len(networks['networks'])) |
||||
super(ContainerTest, self).tearDown() |
||||
|
||||
def test_connect_disconnect_container(self): |
||||
# Test if support connect/disconnect operations |
||||
container_name = utils.get_random_string(8) |
||||
container = self.docker_client.create_container( |
||||
image='busybox:1', |
||||
command='/bin/sleep 600', |
||||
hostname='kuryr_test_container', |
||||
name=container_name) |
||||
warn_msg = container.get('Warning') |
||||
container_id = container.get('Id') |
||||
self.assertIsNone(warn_msg, 'Warn in creating container') |
||||
self.assertIsNotNone(container_id, 'Create container id must not ' |
||||
'be None') |
||||
self.docker_client.start(container=container_id) |
||||
self.docker_client.connect_container_to_network(container_id, |
||||
self.net_id) |
||||
ports = self.neutron_client.list_ports( |
||||
network_id=self.neutron_net_id) |
||||
# A dhcp port gets created as well; dhcp is enabled by default |
||||
self.assertEqual(2, len(ports['ports'])) |
||||
self.docker_client.disconnect_container_from_network(container_id, |
||||
self.net_id) |
||||
ports = self.neutron_client.list_ports( |
||||
network_id=self.neutron_net_id) |
||||
self.assertEqual(1, len(ports['ports'])) |
||||
self.docker_client.stop(container=container_id) |
||||
|
||||
# TODO(banix) Stopping the container is enough for the |
||||
# container to get disconnected from the network. Therefore, |
||||
# the following is not necessary for this test. The problem |
||||
# with removing container is not related to the networking |
||||
# but we should find out how the container can be removed. |
||||
# self.docker_client.remove_container(container=container_id, |
||||
# force=True) |
@ -1,125 +0,0 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may |
||||
# not use this file except in compliance with the License. You may obtain |
||||
# a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
||||
# License for the specific language governing permissions and limitations |
||||
# under the License. |
||||
|
||||
|
||||
from kuryr.tests.fullstack import kuryr_base |
||||
from kuryr import utils |
||||
|
||||
|
||||
class NetworkTest(kuryr_base.KuryrBaseTest): |
||||
"""Test Networks operation |
||||
|
||||
Test networks creation/deletion from docker to Neutron |
||||
""" |
||||
def test_create_delete_network_with_kuryr_driver(self): |
||||
"""Create and Delete docker network with Kuryr |
||||
|
||||
This method creates a docker network with Kuryr driver |
||||
and tests it was created in Neutron. |
||||
It then deletes the docker network and tests that it was |
||||
deleted from Neutron. |
||||
""" |
||||
fake_ipam = { |
||||
"Driver": "kuryr", |
||||
"Options": {}, |
||||
"Config": [ |
||||
{ |
||||
"Subnet": "10.0.0.0/16", |
||||
"IPRange": "10.0.0.0/24", |
||||
"Gateway": "10.0.0.1" |
||||
} |
||||
] |
||||
} |
||||
net_name = utils.get_random_string(8) |
||||
res = self.docker_client.create_network(name=net_name, driver='kuryr', |
||||
ipam=fake_ipam) |
||||
net_id = res['Id'] |
||||
network = self.neutron_client.list_networks( |
||||
tags=utils.make_net_tags(net_id)) |
||||
self.assertEqual(1, len(network['networks'])) |
||||
self.docker_client.remove_network(net_id) |
||||
network = self.neutron_client.list_networks( |
||||
tags=utils.make_net_tags(net_id)) |
||||
self.assertEqual(0, len(network['networks'])) |
||||
|
||||
def test_create_delete_network_without_kuryr_driver(self): |
||||
"""Create and Delete docker network without Kuryr |
||||
|
||||
This method create a docker network with the default |
||||
docker driver, It tests that it was created correctly, but |
||||
not added to Neutron |
||||
""" |
||||
net_name = utils.get_random_string(8) |
||||
res = self.docker_client.create_network(name=net_name) |
||||
net_id = res['Id'] |
||||
network = self.neutron_client.list_networks( |
||||
tags=utils.make_net_tags(net_id)) |
||||
self.assertEqual(0, len(network['networks'])) |
||||
docker_networks = self.docker_client.networks() |
||||
network_found = False |
||||
for docker_net in docker_networks: |
||||
if docker_net['Id'] == net_id: |
||||
network_found = True |
||||
self.assertTrue(network_found) |
||||
self.docker_client.remove_network(net_id) |
||||
|
||||
def test_create_network_with_same_name(self): |
||||
"""Create docker network with same name |
||||
|
||||
Create two docker networks with same name, |
||||
delete them and see that neutron networks are |
||||
deleted as well |
||||
""" |
||||
fake_ipam_1 = { |
||||
"Driver": "kuryr", |
||||
"Options": {}, |
||||
"Config": [ |
||||
{ |
||||
"Subnet": "10.1.0.0/16", |
||||
"IPRange": "10.1.0.0/24", |
||||
"Gateway": "10.1.0.1" |
||||
} |
||||
] |
||||
} |
||||
fake_ipam_2 = { |
||||
"Driver": "kuryr", |
||||
"Options": {}, |
||||
"Config": [ |
||||
{ |
||||
"Subnet": "10.2.0.0/16", |
||||
"IPRange": "10.2.0.0/24", |
||||
"Gateway": "10.2.0.1" |
||||
} |
||||
] |
||||
} |
||||
net_name = utils.get_random_string(8) |
||||
res = self.docker_client.create_network(name=net_name, driver='kuryr', |
||||
ipam=fake_ipam_1) |
||||
net_id1 = res['Id'] |
||||
|
||||
res = self.docker_client.create_network(name=net_name, driver='kuryr', |
||||
ipam=fake_ipam_2) |
||||
net_id2 = res['Id'] |
||||
network = self.neutron_client.list_networks( |
||||
tags=utils.make_net_tags(net_id1)) |
||||
self.assertEqual(1, len(network['networks'])) |
||||
network = self.neutron_client.list_networks( |
||||
tags=utils.make_net_tags(net_id2)) |
||||
self.assertEqual(1, len(network['networks'])) |
||||
self.docker_client.remove_network(net_id1) |
||||
self.docker_client.remove_network(net_id2) |
||||
network = self.neutron_client.list_networks( |
||||
tags=utils.make_net_tags(net_id1)) |
||||
self.assertEqual(0, len(network['networks'])) |
||||
network = self.neutron_client.list_networks( |
||||
tags=utils.make_net_tags(net_id2)) |
||||
self.assertEqual(0, len(network['networks'])) |