File: resIpFreeBSD.py

package info (click to toggle)
opensvc 1.8~20170412-3
  • links: PTS
  • area: main
  • in suites: buster
  • size: 6,492 kB
  • ctags: 7,845
  • sloc: python: 77,169; sh: 339; xml: 39; makefile: 7
file content (27 lines) | stat: -rw-r--r-- 920 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import resIp as Res
import rcExceptions as ex
from rcUtilitiesFreeBSD import check_ping
from rcUtilities import to_cidr, to_dotted

class Ip(Res.Ip):
    def check_ping(self, count=1, timeout=5):
        self.log.info("checking %s availability"%self.addr)
        return check_ping(self.addr, count=count, timeout=timeout)

    def arp_announce(self):
        return

    def startip_cmd(self):
        if ':' in self.addr:
            cmd = ['ifconfig', self.ipdev, 'inet6', '/'.join([self.addr, to_cidr(self.mask)]), 'add']
        else:
            cmd = ['ifconfig', self.ipdev, 'inet', self.addr, 'netmask', to_dotted(self.mask), 'add']
        return self.vcall(cmd)

    def stopip_cmd(self):
        if ':' in self.addr:
            cmd = ['ifconfig', self.ipdev, 'inet6', self.addr, 'delete']
        else:
            cmd = ['ifconfig', self.ipdev, 'inet', self.addr, 'delete']
        return self.vcall(cmd)