3 # Configuration Fallbacks. All can(must for some of them) be overwritten by /etc/default/snf-network
5 # the bind server IP/FQDN
7 # this is the .vm.synnefo.live.
8 # Leave empty if only reverse dns management is needed.
9 # TODO: make this zone to be instance specific!!!
11 # the file with dns authorization keys
13 MAC2EUI64="/usr/bin/mac2eui64"
15 source /etc/default/snf-network
16 source /usr/lib/snf-network/common.sh
18 if [ -z "$SERVER" -o -z "$FZONE" -o ! -e "$KEYFILE" ]; then
24 if [ "x$GANETI_OP_CODE" = "xOP_INSTANCE_CREATE" ]; then
26 elif [ "x$GANETI_OP_CODE" = "xOP_INSTANCE_REMOVE" ]; then
28 elif [ "x$GANETI_OP_CODE" = "xOP_INSTANCE_RENAME" ]; then
30 # Let's override a variable and add ourselves
31 GANETI_INSTANCE_NAME=$GANETI_INSTANCE_NEW_NAME
33 elif [ "x$GANETI_OP_CODE" = "xOP_INSTANCE_STARTUP" ]; then
35 elif [ "x$GANETI_OP_CODE" = "xOP_INSTANCE_SHUTDOWN" ]; then
37 elif [ "x$GANETI_OP_CODE" = "xOP_INSTANCE_REBOOT" ]; then
39 elif [ "x$GANETI_OP_CODE" = "xOP_INSTANCE_SET_PARAMS" ]; then
46 # Query nameserver for entries related to the specific instance
47 # An example output is the following:
48 # www.google.com has address 173.194.113.114
49 # www.google.com has address 173.194.113.115
50 # www.google.com has address 173.194.113.116
51 # www.google.com has address 173.194.113.112
52 # www.google.com has address 173.194.113.113
53 # www.google.com has IPv6 address 2a00:1450:4001:80b::1012
56 HOSTQ="host -s -R 3 -W 3"
57 HOST_IP_ALL=$($HOSTQ $GANETI_INSTANCE_NAME.$FZONE $SERVER | sed -n 's/.*has address //p')
58 HOST_IP6_ALL=$($HOSTQ $GANETI_INSTANCE_NAME.$FZONE $SERVER | sed -n 's/.*has IPv6 address //p')
63 # Reset all entries related to the specific instance
64 # This should be invoced only during instance modification
65 # because we do not know which nics have been modify
68 if [ "x$GANETI_OP_CODE" = "xOP_INSTANCE_SET_PARAMS" ]; then
70 # This should remove the A, AAAA, CNAME entries
71 send_command "update delete $GANETI_INSTANCE_NAME.$FZONE"
72 for ip in $HOST_IP_ALL; do
74 # This should remove the IPv4 reverse entry
75 send_command "update delete $RLPART.$RZONE"
77 for ip6 in $HOST_IP6_ALL; do
79 # This should remove the IPv6 reverse entry
80 send_command "update delete $R6LPART$R6ZONE."
90 # Exit if we do not have instance name.
91 # It should be exported to hooks for instance related opcodes.
92 if [ -z "$GANETI_INSTANCE_NAME" ]; then
96 # This runs only for instance modification
99 # If GANETI_INSTANCE_NIC_COUNT is not set then nothing happens
101 LAST=$((GANETI_INSTANCE_NIC_COUNT - 1))
102 for idx in $(seq $FIRST $LAST); do
103 ip=GANETI_INSTANCE_NIC${idx}_IP
104 mac=GANETI_INSTANCE_NIC${idx}_MAC
105 mode=GANETI_INSTANCE_NIC${idx}_MODE
106 link=GANETI_INSTANCE_NIC${idx}_LINK
107 subnet=GANETI_INSTANCE_NIC${idx}_NETWORK_SUBNET
108 subnet6=GANETI_INSTANCE_NIC${idx}_NETWORK_SUBNET6
109 tags=GANETI_INSTANCE_NIC${idx}_NETWORK_TAGS
114 eval SUBNET=\$$subnet
115 eval SUBNET6=\$$subnet6
123 get_eui64 "$MAC" "$SUBNET6"
124 get_rev6_info "$EUI64"
125 $SNF_NETWORK_LOG dnshook "update dns for $GANETI_INSTANCE_NAME $IP $EUI64"