~thedac/ubuntu/vivid/neutron-lbaas/2015.1.1

« back to all changes in this revision

Viewing changes to neutron_lbaas/agent/agent_api.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-03-30 11:19:14 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20150330111914-yz6470mej0tb0rp6
Tags: 1:2015.1~b3-0ubuntu1
* New upstream milestone release:
  - d/control: Align version requirements with upstream, add new
    dependencies on oslo-log and python-barbicanclient.
* Enable unit test suite execution:
  - d/control: Switch BD on python-neutron -> neutron-common.
  - d/rules: Enable execution of unit tests, skipping tests that require
    access to /etc/neutron/neutron.conf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2013 New Dream Network, LLC (DreamHost)
 
2
# Copyright 2015 Rackspace
 
3
#
 
4
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
5
#    not use this file except in compliance with the License. You may obtain
 
6
#    a copy of the License at
 
7
#
 
8
#         http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
10
#    Unless required by applicable law or agreed to in writing, software
 
11
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
12
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
13
#    License for the specific language governing permissions and limitations
 
14
#    under the License.
 
15
 
 
16
from neutron.common import rpc as n_rpc
 
17
import oslo_messaging
 
18
 
 
19
 
 
20
class LbaasAgentApi(object):
 
21
    """Agent side of the Agent to Plugin RPC API."""
 
22
 
 
23
    # history
 
24
    #   1.0 Initial version
 
25
 
 
26
    def __init__(self, topic, context, host):
 
27
        self.context = context
 
28
        self.host = host
 
29
        target = oslo_messaging.Target(topic=topic, version='1.0')
 
30
        self.client = n_rpc.get_client(target)
 
31
 
 
32
    def get_ready_devices(self):
 
33
        cctxt = self.client.prepare()
 
34
        return cctxt.call(self.context, 'get_ready_devices', host=self.host)
 
35
 
 
36
    def get_loadbalancer(self, loadbalancer_id):
 
37
        cctxt = self.client.prepare()
 
38
        return cctxt.call(self.context, 'get_loadbalancer',
 
39
                          loadbalancer_id=loadbalancer_id)
 
40
 
 
41
    def loadbalancer_deployed(self, loadbalancer_id):
 
42
        cctxt = self.client.prepare()
 
43
        return cctxt.call(self.context, 'loadbalancer_deployed',
 
44
                          loadbalancer_id=loadbalancer_id)
 
45
 
 
46
    def update_status(self, obj_type, obj_id, provisioning_status=None,
 
47
                      operating_status=None):
 
48
        cctxt = self.client.prepare()
 
49
        return cctxt.call(self.context, 'update_status', obj_type=obj_type,
 
50
                          obj_id=obj_id,
 
51
                          provisioning_status=provisioning_status,
 
52
                          operating_status=operating_status)
 
53
 
 
54
    def loadbalancer_destroyed(self, loadbalancer_id):
 
55
        cctxt = self.client.prepare()
 
56
        return cctxt.call(self.context, 'loadbalancer_destroyed',
 
57
                          loadbalancer_id=loadbalancer_id)
 
58
 
 
59
    def plug_vip_port(self, port_id):
 
60
        cctxt = self.client.prepare()
 
61
        return cctxt.call(self.context, 'plug_vip_port', port_id=port_id,
 
62
                          host=self.host)
 
63
 
 
64
    def unplug_vip_port(self, port_id):
 
65
        cctxt = self.client.prepare()
 
66
        return cctxt.call(self.context, 'unplug_vip_port', port_id=port_id,
 
67
                          host=self.host)
 
68
 
 
69
    def update_loadbalancer_stats(self, loadbalancer_id, stats):
 
70
        cctxt = self.client.prepare()
 
71
        return cctxt.call(self.context, 'update_loadbalancer_stats',
 
72
                          loadbalancer_id=loadbalancer_id, stats=stats)