1 # ============LICENSE_START=======================================================
2 # Copyright (c) 2021 AT&T Intellectual Property. All rights reserved.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # ============LICENSE_END=========================================================
17 from urllib.parse import urlsplit
18 import asyncio, aiohttp
23 self.check_period = 60
25 self.bind = urlsplit("//localhost:8080")
32 async def close(self):
37 def __init__(self, queue=None):
38 self.was_updated = False
39 self.was_gathered = False
40 self.client = MockClient()
44 self.policy_filters = []
47 async def update(self):
48 self.was_updated = True
51 async def gather(self):
52 self.was_gathered = True
53 print("got here GATHERED")
56 async def close(self):
57 self.client.closed = True
59 async def check_and_update(self):
62 async def get_policy_content(self, action="UPDATED"):
63 self.updates.append(action)
67 def __init__(self, raise_on_listpolicies=False, raise_on_getconfig=False):
70 self.raise_on_listpolicies = raise_on_listpolicies
71 self.raise_on_getconfig = raise_on_getconfig
73 async def close(self):
76 async def notificationhandler(self, callback, ids=[], filters=[]):
79 def supports_notifications(self):
82 async def list_policies(self, filters=[], ids=[]):
83 if self.raise_on_listpolicies:
84 raise aiohttp.ClientError
88 "DCAE.Config_MS_AGING_UVERSE_PROD_Tosca_HP_AGING_Model_cl55973_IT64_testAging.78.xml"
92 async def get_config(self, filters=[], ids=[]):
93 if self.raise_on_getconfig:
94 raise aiohttp.ClientError
98 "policyConfigMessage": "Config Retrieved!",
99 "policyConfigStatus": "CONFIG_RETRIEVED",
102 "service": "DCAE_HighlandPark_AgingConfig",
105 "policyName": "DCAE.AGING_UVERS_PROD_Tosca_HP_GOC_Model_cl55973_IT64_testAging",
106 "configName": "DCAE_HighlandPark_AgingConfig",
107 "templateVersion": "1607",
110 "policyScope": "resource=Test1,service=vSCP,type=configuration,closedLoopControlName=vSCP_F5_Firewall_d925ed73_7831_4d02_9545_db4e101f88f8",
116 "filter_clause": "event.faultFields.alarmCondition LIKE('%chrisluckenbaugh%')"
121 "prePublishAging": 40,
122 "preCorrelationAging": 20,
124 "policyNameWithPrefix": "DCAE.AGING_UVERSE_PSL_Tosca_HP_GOC_Model_cl55973_IT64_testAging",
126 "policyName": "DCAE.Config_MS_AGING_UVERSE_PROD_Tosca_HP_AGING_Model_cl55973_IT64_testAging.78.xml",
127 "policyType": "MicroService",
128 "policyVersion": "78",
129 "matchingConditions": {
132 "ConfigName": "DCAE_HighlandPark_AgingConfig",
133 "service": "DCAE_HighlandPark_AgingConfig",
137 "responseAttributes": {},
141 "policyConfigMessage": "Config Retrieved! ",
142 "policyConfigStatus": "CONFIG_RETRIEVED",
144 "config": "adlskjfadslkjf",
145 "policyName": "DCAE.Config_MS_AGING_UVERSE_PROD_Tosca_HP_AGING_Model_cl55973_IT64_testAging.78.xml",
146 "policyType": "MicroService",
147 "policyVersion": "78",
148 "matchingConditions": {
151 "ConfigName": "DCAE_HighlandPark_AgingConfig",
152 "service": "DCAE_HighlandPark_AgingConfig",
156 "responseAttributes": {},
171 def add_signal_handler(self, signal, handler):
172 self.handlers.append(signal)
174 def create_task(self, task):
175 self.tasks.append(task)
177 def run_until_complete(self, task):
178 loop = asyncio.new_event_loop()
179 asyncio.set_event_loop(loop)
180 loop.run_until_complete(task)
185 self.canceled = False