Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
539bae9
initial nat gateway branche
tischrei Nov 12, 2019
adf6243
added snat and dnat resource
tischrei Nov 12, 2019
4ad2644
dnat and snat proxy functions added
tischrei Nov 12, 2019
dcf6291
first running state
tischrei Nov 15, 2019
ecb94c8
gateway fixed
tischrei Nov 15, 2019
de41e07
linting corrections
tischrei Nov 15, 2019
2d10ad3
Minor changes, tested successfully
tischrei Nov 18, 2019
e1b927f
unittest nat.test_snat nat.test_dnat and nat.test_gateway added
tischrei Nov 19, 2019
03b6891
smn initialization
tischrei Nov 27, 2019
b197631
ces initalisation
tischrei Nov 27, 2019
baf7887
new ordering, alarm resource created
tischrei Dec 2, 2019
a711913
quota added and flake8 corrections
tischrei Dec 3, 2019
ba70444
flake8 issue
tischrei Dec 3, 2019
af7d504
minor changes to service
tischrei Dec 5, 2019
136de7c
fix service discovery
tischrei Dec 5, 2019
5c9183a
correcting some stuff
tischrei Dec 9, 2019
ef9f29e
correcting some stuff
tischrei Dec 9, 2019
3cbc607
delete favorit_metric
tischrei Dec 9, 2019
526889a
fix alarm.py
tischrei Dec 9, 2019
2467ef6
event data added and proxy first draft
tischrei Dec 11, 2019
1ea033b
translate response and fixed get_alarm
tischrei Dec 13, 2019
7abb59c
ces final sdk implementation and flake8 corrections
tischrei Dec 20, 2019
e820557
Merge branch 'master' into cloudeye
tischrei Dec 20, 2019
727b92e
unittests ces
tischrei Jan 10, 2020
113488b
ces init for OpenstackClient and alarm resource started
tischrei Jan 15, 2020
3dbffed
cli alarm improvements
tischrei Feb 13, 2020
01cae7c
some extensions
tischrei Feb 14, 2020
48aff8a
Merge branch 'master' into cloudeye
gtema Feb 27, 2020
4fe0fa0
merge branche master into cloudeye
tischrei Jul 28, 2020
5006a8e
Cleanup an minor changes to OSC alarm module
tischrei Jul 29, 2020
30869af
OSC alarm rule update
tischrei Jul 30, 2020
24b6d8f
enhance OCS alarm rule
tischrei Jul 31, 2020
be99752
first error solved
tischrei Aug 4, 2020
10c883b
minor fixes, starting documentation
tischrei Aug 4, 2020
35aa982
reworking OCS alarm resource
tischrei Aug 6, 2020
061d582
finish alarm.py
tischrei Aug 7, 2020
86a3cd5
CES metric OCS impl. started
tischrei Aug 7, 2020
d8e86a6
metric finished
tischrei Aug 18, 2020
5766c76
OSC quota implementation
tischrei Aug 19, 2020
3ff7e90
event data added to OCS
tischrei Aug 20, 2020
e5a4613
begin of metric data impl.
tischrei Aug 24, 2020
87ac62f
finish OSC part of CES
tischrei Aug 25, 2020
72e2128
CES SDK unit tests finished
tischrei Aug 26, 2020
6fa919d
Review changes
tischrei Sep 18, 2020
2cbb6e9
minor fix in alarm rule description
tischrei Sep 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions examples/ces/create_alarm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env python3
# 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.
'''
Create CloudEye alarm rule
'''
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


attrs = {
"alarm_name": "alarm-test",
"alarm_description": "Test Alarm description",
"metric": {
"namespace": "SYS.ECS",
"dimensions": [
{
"name": "instance_id",
"value": "33328f02-3814-422e-b688-bfdba93d4051"
},
{
"name": "instance_id",
"value": "04ab9572-8c9c-41b6-bcc8-51068463b123"
}
],
"metric_name": "network_outgoing"
},
"condition": {
"period": 300,
"filter": "average",
"comparison_operator": ">=",
"value": 6,
"unit": "B/s",
"count": 1
},
"alarm_enabled": True,
"alarm_action_enabled": True,
"alarm_level": 2,
"ok_actions": [
{
"type": "notification",
"notificationList": [
"urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd",
"urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error"]
}
],
"alarm_actions": [
{
"type": "notification",
"notificationList": [
"urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd",
"urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error"]
}
]
}


alarm = conn.ces.create_alarm(**attrs)
print(alarm)

# OSC command
'''
openstack --os-cloud otc ces alarm create --description "Test Alarm" \
--namespace SYS.ECS \
--dimension name=instance_id,value=33328f02-3814-422e-b688-bfdba93d4123 \
--dimension name=instance_id,value=33328f02-3814-422e-b688-bfdba93d4052 \
--metric-name "network_outgoing" --period '300' --filter average \
--comparison-operator '>=' --value '6' --unit 'B/s' --count '1' \
--enabled True --action-enabled True --level 2 --ok-action-type notification \
--ok-action-notification-list \
'urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd' \
--ok-action-notification-list \
'urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error' \
--alarm-action-type notification --alarm-action-notification-list \
'urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd' \
--alarm-action-notification-list \
'urn:smn:eu-de:16d53a84a13b49529d2e2c3646691222:Error' alarm-test
'''
61 changes: 61 additions & 0 deletions examples/ces/create_metric_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python3
# 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.
'''
Add CloudEye metric data
'''
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

# not working due to lag of compatible API: list instead of proper JSON
attrs = [
{
"metric": {
"namespace": "MINE.APP",
"dimensions": [
{
"name": "instance_id",
"value": "33328f02-3814-422e-b688-bfdba93d4050"
}
],
"metric_name": "cpu_util"
},
"ttl": 172800,
"collect_time": 1598266684000,
"type": "int",
"value": 60,
"unit": "%"
},
{
"metric": {
"namespace": "MINE.APP",
"dimensions": [
{
"name": "instance_id",
"value": "33328f02-3814-422e-b688-bfdba93d4050"
}
],
"metric_name": "cpu_util"
},
"ttl": 172800,
"collect_time": 1598266685000,
"type": "int",
"value": 70,
"unit": "%"
}
]


data = conn.ces.create_metric_data(**attrs)
print(data)
25 changes: 25 additions & 0 deletions examples/ces/delete_alarm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
# 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.
"""
Delete CloudEye alarm rule
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


alarm = 'al1596533022051EZVV2nlZ8'
alarm = conn.ces.find_alarm(alarm)
alarm = conn.ces.delete_alarm(alarm)
print(alarm)
24 changes: 24 additions & 0 deletions examples/ces/find_alarm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3
# 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.
"""
Find CloudEye alarm rule by name or ID
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


alarm = 'alarm_id_or_name'
alarm = conn.ces.find_alarm(alarm)
print(alarm)
24 changes: 24 additions & 0 deletions examples/ces/get_alarm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3
# 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.
"""
Find CloudEye alarm rule by ID
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


alarm = 'alarm_id'
alarm = conn.ces.get_alarm(alarm)
print(alarm)
23 changes: 23 additions & 0 deletions examples/ces/list_alarms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# 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.
"""
List all CloudEye alarm rules
"""
import openstack


openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

for alarm in conn.ces.alarms():
print(alarm)
32 changes: 32 additions & 0 deletions examples/ces/list_event_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
# 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.
"""
List all CloudEye event data
"""
import openstack


openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


query = {
'namespace': 'SYS.ECS',
'type': 'instance_host_info',
'dim.0': 'instance_id,6e83e6e7-3bf4-4b5b-b390-e80447ef1234', # key, value
'from': '1596067200', # unix timestamp in ms
'to': '1597929178' # unix timestamp in ms
}

for data in conn.ces.event_data(**query):
print(data)
34 changes: 34 additions & 0 deletions examples/ces/list_metric_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3
# 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.
"""
List all CloudEye metric data
"""
import openstack


openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


query = {
'namespace': 'SYS.ECS',
'metric_name': 'cpu_util',
'from': '1556625600000', # unix timestamp in ms
'to': '1556632800000', # unix timestamp in ms
'period': 1,
'filter': 'avg',
'dim.0': 'instance_id,6e83e6e7-3bf4-4b5b-b390-e80447ef5733', # key, value
}

for data in conn.ces.metric_data(**query):
print(data)
23 changes: 23 additions & 0 deletions examples/ces/list_metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# 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.
"""
List all CloudEye metrics
"""
import openstack


openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

for metric in conn.ces.metrics():
print(metric)
23 changes: 23 additions & 0 deletions examples/ces/list_quotas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env python3
# 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.
"""
List all CloudEye quotas
"""
import openstack


openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')

for quota in conn.ces.quotas():
print(quota)
25 changes: 25 additions & 0 deletions examples/ces/switch_alarm_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
# 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.
"""
Disable / Enable CloudEye alarm state
"""
import openstack

openstack.enable_logging(True)
conn = openstack.connect(cloud='otc')


alarm = 'alarm_name_or_id'
alarm = conn.ces.find_alarm(alarm)
alarm = conn.ces.switch_alarm_state(alarm)
print(alarm)
Empty file.
Loading