1 # Copyright 2018 Whitestack, LLC
2 # *************************************************************
4 # This file is part of OSM Monitoring module
5 # All Rights Reserved to Whitestack, LLC
7 # Licensed under the Apache License, Version 2.0 (the "License"); you may
8 # not use this file except in compliance with the License. You may obtain
9 # a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 # License for the specific language governing permissions and limitations
19 # For those usages not covered by the Apache License, Version 2.0 please
20 # contact: bdiaz@whitestack.com or glavado@whitestack.com
24 from osm_mon
.collector
.metric
import Metric
25 from osm_mon
.core
import database
26 from osm_mon
.core
.database
import VimCredentials
, VimCredentialsRepository
29 class CollectorUtils(Metric
):
32 def get_vim_type(vim_account_id
) -> str:
33 credentials
= CollectorUtils
.get_credentials(vim_account_id
)
34 config
= json
.loads(credentials
.config
)
35 if 'vim_type' in config
:
36 vim_type
= config
['vim_type']
37 return str(vim_type
.lower())
39 return str(credentials
.type)
42 def get_credentials(vim_account_id
) -> VimCredentials
:
45 with database
.db
.atomic():
46 return VimCredentialsRepository
.get(VimCredentials
.uuid
== vim_account_id
)
51 def is_verify_ssl(vim_credentials
: VimCredentials
):
52 vim_config
= json
.loads(vim_credentials
.config
)
53 return 'insecure' not in vim_config
or vim_config
['insecure'] is False