Skip to content
This repository was archived by the owner on Jun 12, 2021. It is now read-only.

Commit f353692

Browse files
committed
adding logging
1 parent a80a4ac commit f353692

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

boot-scripts/lib/kubernetes-node-router.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,36 +63,42 @@ def getAvailabilityZone():
6363
global MY_AZ
6464
if MY_AZ is None:
6565
MY_AZ = metaData("placement/availability-zone")
66+
log("MY_AZ set to %s" % MY_AZ)
6667
return MY_AZ
6768

6869
def getRegion():
69-
return getAvailabilityZone()[:-1]
70+
myRegion = getAvailabilityZone()[:-1]
71+
log("region: %s" % myRegion)
72+
return myRegion
7073

7174
def getInstanceId():
7275
## cached
7376
global INSTANCE_ID
7477
if INSTANCE_ID == None:
7578
INSTANCE_ID = metaData("instance-id")
79+
log("INSTANCE_ID: %s" % INSTANCE_ID)
7680
return INSTANCE_ID
7781

7882
def getSubnetById(subnetid):
7983
## cached
8084
subnet_filters = [['subnet-id', subnetid]]
8185
subnet = VPC.get_all_subnets(filters=subnet_filters)[0]
82-
log('got a subnet: %s' % subnet.id)
86+
log('my subnet: %s' % subnet.id)
8387
return subnet
8488

8589
def getMyVPCId():
8690
global MY_VPC_ID
8791
if MY_VPC_ID == None:
8892
MY_VPC_ID = getMe().vpc_id
93+
log("MY_VPC_ID: %s" % MY_VPC_ID)
8994
return MY_VPC_ID
9095

9196
def getMySubnets():
9297
global MY_SUBNETS
9398
if MY_SUBNETS == None:
9499
az_subnet_filters = [['availability-zone', getAvailabilityZone()],['vpc-id', getMyVPCId()]]
95100
MY_SUBNETS = VPC.get_all_subnets(filters=az_subnet_filters)
101+
log("MY_SUBNETS: %s" % MY_SUBNETS)
96102
return MY_SUBNETS
97103

98104
def getMyAsgName():
@@ -105,17 +111,23 @@ def getMyASGSubnets():
105111
global MY_ASG_SUBNETS
106112
if MY_ASG_SUBNETS == None:
107113
MY_ASG_SUBNETS = []
114+
log("AUTOSCALE.get_all_groups -> %s" %s AUTOSCALE.get_all_groups())
108115
for subnetId in AUTOSCALE.get_all_groups([getMyAsgName()])[0].vpc_zone_identifier.split(","):
116+
log(" subnetId: %s" % subnetId)
109117
MY_ASG_SUBNETS.append(getSubnetById(subnetId))
110118
return MY_ASG_SUBNETS
111119

112120
def getMyRouteTables(subnet):
113121
## this cannot be cached beacuse we need to keep checking the route tables
114122
rt_filters = [['vpc-id', getMyVPCId()], ['association.subnet-id', subnet.id]]
115-
return VPC.get_all_route_tables(filters=rt_filters)
123+
myRouteTables = VPC.get_all_route_tables(filters=rt_filters)
124+
log("myRouteTables: %s" % myRouteTables)
125+
return myRouteTables
116126

117127
def getMe():
118-
return EC2.get_only_instances(instance_ids=[getInstanceId()])[0]
128+
me = EC2.get_only_instances(instance_ids=[getInstanceId()])[0]
129+
log("me: %s" % me)
130+
return me
119131

120132
def disableSourceDestChecks():
121133
EC2.modify_instance_attribute(getInstanceId(), "sourceDestCheck", False)

0 commit comments

Comments
 (0)