def delete_node(self, lb, node): """ Delete a node from a LoadBalancer. :param lb: The :class:`LoadBalancer` (or its ID). :param node: The :class:`Node` (or its ID). """ url = '/loadbalancers/%s/nodes/%s' % (getid(lb), getid(node)) self._delete(url)
def get_node(self, lb, node): """ Get a Node belonging to a LoadBalancer :param lb: The :class:`LoadBalancer` (or its ID). :param node: The :class:`Node` (or its ID). """ url = '/loadbalancers/%s/nodes/%s' % (getid(lb), getid(node)) return self._get(url, obj_class=Node)
def update_monitor(self, lb, type_='CONNECT', delay=30, timeout=30, attempts=2, path=None): """ Update a Monitor in a LoadBalancer :param lb: The :class:`LoadBalancer` (or its ID). :param type_: Monitor type. :param delay: Numeric delay, must be less then timeout. :param timeout: Numeric timeout, must be geater then delay. :param attempts: Max attempts before deactivation. :param path: URI path when using HTTP type. """ data = {} data['type'] = type_ if timeout > delay: raise ValueError('Timeout can\'t be greater then Delay') data['delay'] = delay data['timeout'] = timeout data['attemptsBeforeDeactivation'] = attempts if type_.upper() != 'CONNECT': data['path'] = path url = '/loadbalancers/%s/healthmonitor' % getid(lb) return self._put(url, data, obj_class=Monitor)
def update_node(self, lb, node, condition=None, weight=None): """ Update a node :param lb: The :class:`LoadBalancer` (or its ID). :param node: The :class:`Node` (or its ID). :param condition: Set the conditioon. :param weight: Set the weight. """ data = {} if condition is not None: data['condition'] = condition if weight is not None: data['weight'] = weight url = '/loadbalancers/%s/nodes/%s' % (getid(lb), getid(node)) return self._put(url, data, obj_class=Node)
def create_node(self, lb, node): data = {} data['nodes'] = self._parse_nodes(node) url = '/loadbalancers/%s/nodes' % getid(lb) nodes = self._post(url, data, return_raw=True, response_key='nodes') return [Node(self, n) for n in nodes]
def delete(self, lb): """ Delete a LoadBalancer :param lb: The :class:`LoadBalancer` (or its ID). """ self._delete('/loadbalancers/%s' % getid(lb))
def list_vip(self, lb): """ List Virtual IPs for a LoadBalancer :param lb: The :class:`LoadBalancer` (or its ID) to update. """ return self._list('loadbalancers/%s/virtualips' % getid(lb), response_key='virtualIps', obj_class=VirtualIP)
def delete_monitor(self, lb): """ Delete monitor from a LoadBalancer :param lb: The :class:`LoadBalancer` (or its ID). """ url = '/loadbalancers/%s/healthmonitor' % getid(lb) self._delete(url)
def get_monitor(self, lb): """ Get a Monitor for a LoadBalancer :param lb: The :class:`LoadBalancer` (or its ID). """ url = '/loadbalancers/%s/healthmonitor' % getid(lb) return self._get(url, obj_class=Monitor)
def list_nodes(self, lb): """ List Nodes belonging to a LoadBalancer. :param lb: The :class:`LoadBalancer` (or its ID).. """ url = '/loadbalancers/%s/nodes' % getid(lb) return self._list(url, 'nodes', obj_class=Node)
def get(self, lb): """ Get a LoadBalancer. :param lb: The :class:`LoadBalancer` (or its ID) to update. """ lb = self._get('/loadbalancers/%s' % getid(lb)) return lb
def send_logs(self, lb, values): """ Send a snapshot of logs somewhere. :param lb: The :class:`LoadBalancer` (or its ID). :param storage: Storage type. :param kw: The values to send it with, pass as kw. """ self.client.post('/loadbalancers/%s/logs' % getid(lb), json=values)
def update(self, lb, name=None, algorithm=None): """ Update a LoadBalancer :param lb: The :class:`LoadBalancer` (or its ID). :param name: Set the name of the LoadBalancer. :param algorithm: Algorithm (ROUND_ROBIN for example.) """ data = {} if name is not None: data['name'] = name if algorithm is not None: data['algorithm'] = algorithm return self._put('/loadbalancers/%s' % getid(lb), data)