- def __init__(self, parent):
- self.parent = parent
-
- @handler(u'Adds a host')
- def add(self, ip):
- if ip in self.parent.hosts:
- raise HostAlreadyExistsError(ip)
- self.parent.hosts[ip] = Host(ip)
-
- @handler(u'Deletes a host')
- def delete(self, ip):
- if not ip in self.parent.hosts:
- raise HostNotFoundError(ip)
- del self.parent.hosts[ip]
-
- @handler(u'Shows all hosts')
- def list(self):
- return self.parent.hosts.keys()
-
- @handler(u'Get information about all hosts')
- def show(self):
- return self.parent.hosts.items()
-
-
-class UserHandler(Handler):
-
- def __init__(self, parent):
- self.parent = parent
-
- @handler('Adds a user')
- def add(self, user, password):
- if user in self.parent.users:
- raise UserAlreadyExistsError(user)
- self.parent.users[user] = crypt.crypt(password,'BA')
-
- @handler('Deletes a user')
- def delete(self, user):
- if not user in self.parent.users:
- raise UserNotFound(user)
- del self.parent.users[user]