Skip to content

Commit 82eafb5

Browse files
committed
Add interface and endpoint_override parameters
The interface parameter is needed to choose an endpoint by its type for the Neutron service from ServiceCatalog. The endpoint_override parameters is needed to force using of the given endpoint instead of endpoinds which are provided by ServiceCatalog.
1 parent 66dc242 commit 82eafb5

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

README.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,44 @@ Config file is a single yaml file. Configuration may be specified via --config o
3333
checkEveryMinutes: 1
3434
regions: ["region1"]
3535
36+
Regions with the ``openstack`` type can be configured without checking Keystone
37+
certificate with the ``insecure: false`` value, it also means that ``cacert``
38+
is optional and can be omitted.
39+
40+
By default, the Neutron endpoint with the ``public`` interface is used for
41+
security analyses. The type of endpoint can be changed by the ``interface``
42+
parameter with three available values ``public``, ``private`` and ``admin``:
43+
44+
.. code-block::
45+
46+
regions:
47+
- type: openstack
48+
name: region1
49+
insecure: false
50+
interface: admin
51+
credentials:
52+
auth_url: http://example.net:5000/
53+
username: admin
54+
password: admin
55+
tenant_name: admin
56+
57+
By some reasons, it is valuable not to use ServiceCatalog to determine
58+
the Neutron endpoint but specify it with some certain value. For this case
59+
the ``endpoint_override`` should be used:
60+
61+
.. code-block::
62+
63+
regions:
64+
- type: openstack
65+
name: region1
66+
insecure: false
67+
endpoint_override: http://example.net:9696/
68+
credentials:
69+
auth_url: http://example.net:5000/
70+
username: admin
71+
password: admin
72+
tenant_name: admin
73+
3674
Service configuration example
3775
*****************************
3876

etc/security-checker.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ regions:
1616
username: admin
1717
password: admin
1818
tenant_name: admin
19+
interface: admin
20+
21+
- type: openstack
22+
name: re3
23+
credentials:
24+
auth_url: http://example.com:5000/v2.0/
25+
username: admin
26+
password: admin
27+
tenant_name: admin
28+
endpoint_override: http://example.com:9696/
1929

2030
elastic:
2131
hosts:

security/config.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,15 @@
6464
"additionalProperties": False,
6565
},
6666
"cacert": {"type": "string"},
67-
"insecure": {"type": "boolean"}
67+
"insecure": {"type": "boolean"},
68+
"interface": {
69+
"type": "string",
70+
"oneOf": [
71+
{"enum": ["public", "internal", "admin"]},
72+
{"enum": ["publicURL", "internalURL", "adminURL"]},
73+
],
74+
},
75+
"endpoint_override": {"format": "uri"},
6876
},
6977
"required": ["type", "name", "credentials"],
7078
"additionalProperties": False,

security/plugins/secgroup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,11 @@ def discover(self, region):
6060
if cacert:
6161
sess_kwargs["verify"] = cacert
6262
sess = session.Session(**sess_kwargs)
63-
neutron = client.Client(session=sess)
63+
neutron = client.Client(
64+
interface=region.get("interface", "public"),
65+
endpoint_override=region.get("endpoint_override"),
66+
session=sess,
67+
)
6468
for sg in neutron.list_security_groups()["security_groups"]:
6569
LOG.debug("Checking security group %s", sg["name"])
6670
for rule in sg["security_group_rules"]:

0 commit comments

Comments
 (0)