1 # Copyright 2020 Canonical Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from charmhelpers
.core
.hookenv
import (
22 def get_service_ip(endpoint
):
24 info
= network_get(endpoint
, relation_id())
25 if 'ingress-addresses' in info
:
26 addr
= info
['ingress-addresses'][0]
30 log("No ingress-addresses: {}".format(info
))
31 except Exception as e
:
32 log("Caught exception checking for service IP: {}".format(e
))
37 def is_pod_up(endpoint
):
38 """Check to see if the pod of a relation is up.
40 application-vimdb: 19:29:10 INFO unit.vimdb/0.juju-log network info
43 - 10.1.1.105 is the address of the application pod.
44 - 10.152.183.199 is the service cluster ip
52 'address': '10.1.1.105',
59 'ingress-addresses': [
66 info
= network_get(endpoint
, relation_id())
68 # Check to see if the pod has been assigned it's internal and
70 for ingress
in info
['ingress-addresses']: