~zulcss/ubuntu/precise/quantum/trunk

« back to all changes in this revision

Viewing changes to quantum/debug/commands.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short, Soren Hansen
  • Date: 2012-09-07 18:50:09 UTC
  • mfrom: (2.1.11)
  • Revision ID: package-import@ubuntu.com-20120907185009-n6lh5tkcci19jz1h
Tags: 2012.2~rc1~20120907.1154-0ubuntu1
[ Adam Gandelman ]
* debian/control: Add missing python-keystone dependency.
* wrap-and-sort.

[ Chuck Short ]
* debian/rules:
  - Run testsuite on build.
  - Use get-orig-source.
  - Add python-amqplib, python-anyjson, python-httplib2, python-iso8601,
    python-kombu, python-lxml, python-netadr, python-pyudev to build depends
    and run time deps.
  - Add python-mock, python-mox, and python-unitest2 to build deps.
  - Add adduser as a dep to quantum-common.
* debian/control: Bump standards version to 3.9.3
* debian/quantum-common.install: Add missing configuration files.
  (LP: #988999)
* debian/quantum-plugin-linuxbridge.install: Make isntallable.
* Add manpages: gratitously ripped from debian.
* Fix up lintian warnings. (LP: #1025203), (LP: #1021921)
* Add metaplugin plugin.
* debian/patches/fix-namespace.patch: Dropped it was causing
  python namespace issues.
  (LP: #1045064)
* debian/*.upstart:
  - Specify configuration file and log directory.
  - Start on the right transition.
* debian/rules:
  - Allow to disable testsuite.
  - Dont fail if the testsuite fails.
* debian/patches/fix-quantum-configuration.patch: Fix configuration files.
* Add packaging for quantum-plugin-l3 and quantum-plugin-l3-agent
* Add packaging for quantum-plugin-dhcp-agent and quantum-plugin-dchp-agent
* debian/patches/fix-ubuntu-tests.patch: Fix testsuite failures.

[ Soren Hansen ]
* Update debian/watch to account for symbolically named tarballs and
  use newer URL.
* Add python-configobj as a build and run time dependency. Recently added
  tests need it, and the Cisco plugin has needed it for a while.
* Fix Launchpad URLs in debian/watch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/python
 
2
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
3
#
 
4
# Copyright 2012,  Nachi Ueno,  NTT MCL,  Inc.
 
5
# All Rights Reserved.
 
6
#
 
7
#    Licensed under the Apache License,  Version 2.0 (the "License"); you may
 
8
#    not use this file except in compliance with the License. You may obtain
 
9
#    a copy of the License at
 
10
#
 
11
#         http://www.apache.org/licenses/LICENSE-2.0
 
12
#
 
13
#    Unless required by applicable law or agreed to in writing,  software
 
14
#    distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT
 
15
#    WARRANTIES OR CONDITIONS OF ANY KIND,  either express or implied. See the
 
16
#    License for the specific language governing permissions and limitations
 
17
#    under the License.
 
18
 
 
19
import logging
 
20
 
 
21
from cliff import lister
 
22
 
 
23
from quantumclient.common import utils
 
24
from quantumclient.quantum.v2_0 import QuantumCommand
 
25
from quantumclient.quantum.v2_0.port import _format_fixed_ips
 
26
 
 
27
 
 
28
class ProbeCommand(QuantumCommand):
 
29
    log = logging.getLogger(__name__ + '.ProbeCommand')
 
30
 
 
31
    def get_debug_agent(self):
 
32
        return self.app.debug_agent
 
33
 
 
34
    def run(self, parsed_args):
 
35
        self.log.debug('run(%s)' % parsed_args)
 
36
        self.app.stdout.write(_('Unimplemented commands') + '\n')
 
37
 
 
38
 
 
39
class CreateProbe(ProbeCommand):
 
40
    """Create probe port and interface, then plug it in."""
 
41
 
 
42
    log = logging.getLogger(__name__ + '.CreateProbe')
 
43
 
 
44
    def get_parser(self, prog_name):
 
45
        parser = super(CreateProbe, self).get_parser(prog_name)
 
46
        parser.add_argument(
 
47
            'id', metavar='network_id',
 
48
            help='ID of network to probe')
 
49
        return parser
 
50
 
 
51
    def run(self, parsed_args):
 
52
        self.log.debug('run(%s)' % parsed_args)
 
53
        debug_agent = self.get_debug_agent()
 
54
        port = debug_agent.create_probe(parsed_args.id)
 
55
        self.app.stdout.write(_('Probe created : %s ') % port.id + '\n')
 
56
 
 
57
 
 
58
class DeleteProbe(ProbeCommand):
 
59
    """Delete probe - delete port then uplug """
 
60
 
 
61
    log = logging.getLogger(__name__ + '.DeleteProbe')
 
62
 
 
63
    def get_parser(self, prog_name):
 
64
        parser = super(DeleteProbe, self).get_parser(prog_name)
 
65
        parser.add_argument(
 
66
            'id', metavar='port_id',
 
67
            help='ID of probe port to delete')
 
68
        return parser
 
69
 
 
70
    def run(self, parsed_args):
 
71
        self.log.debug('run(%s)' % parsed_args)
 
72
        debug_agent = self.get_debug_agent()
 
73
        debug_agent.delete_probe(parsed_args.id)
 
74
        self.app.stdout.write(_('Probe %s deleted') % parsed_args.id + '\n')
 
75
 
 
76
 
 
77
class ListProbe(QuantumCommand, lister.Lister):
 
78
    """ List probes """
 
79
 
 
80
    log = logging.getLogger(__name__ + '.ListProbe')
 
81
    _formatters = {'fixed_ips': _format_fixed_ips, }
 
82
 
 
83
    def get_debug_agent(self):
 
84
        return self.app.debug_agent
 
85
 
 
86
    def get_data(self, parsed_args):
 
87
 
 
88
        debug_agent = self.get_debug_agent()
 
89
        info = debug_agent.list_probes()
 
90
        columns = len(info) > 0 and sorted(info[0].keys()) or []
 
91
        return (columns, (utils.get_item_properties(
 
92
            s, columns, formatters=self._formatters, )
 
93
            for s in info), )
 
94
 
 
95
 
 
96
class ClearProbe(ProbeCommand):
 
97
    """Clear All probes """
 
98
 
 
99
    log = logging.getLogger(__name__ + '.ClearProbe')
 
100
 
 
101
    def run(self, parsed_args):
 
102
        self.log.debug('run(%s)' % parsed_args)
 
103
        debug_agent = self.get_debug_agent()
 
104
        debug_agent.clear_probe()
 
105
        self.app.stdout.write(_('All Probes deleted ') + '\n')
 
106
 
 
107
 
 
108
class ExecProbe(ProbeCommand):
 
109
    """Exec commands on the namespace of the probe
 
110
    """
 
111
 
 
112
    log = logging.getLogger(__name__ + '.ExecProbe')
 
113
 
 
114
    def get_parser(self, prog_name):
 
115
        parser = super(ExecProbe, self).get_parser(prog_name)
 
116
        parser.add_argument(
 
117
            'id', metavar='port_id',
 
118
            help='ID of probe port to execute command')
 
119
        parser.add_argument(
 
120
            'command', metavar='command',
 
121
            nargs='?',
 
122
            default=None,
 
123
            help='Command to execute')
 
124
        return parser
 
125
 
 
126
    def run(self, parsed_args):
 
127
        self.log.debug('run(%s)' % parsed_args)
 
128
        debug_agent = self.get_debug_agent()
 
129
        result = debug_agent.exec_command(parsed_args.id, parsed_args.command)
 
130
        self.app.stdout.write(result + '\n')
 
131
 
 
132
 
 
133
class PingAll(ProbeCommand):
 
134
    """Ping all fixed_ip
 
135
    """
 
136
 
 
137
    log = logging.getLogger(__name__ + '.ExecProbe')
 
138
 
 
139
    def get_parser(self, prog_name):
 
140
        parser = super(PingAll, self).get_parser(prog_name)
 
141
        parser.add_argument(
 
142
            '--timeout', metavar='<timeout>',
 
143
            default=10,
 
144
            help='Ping timeout')
 
145
        parser.add_argument(
 
146
            '--id', metavar='network_id',
 
147
            default=None,
 
148
            help='ID of network')
 
149
        return parser
 
150
 
 
151
    def run(self, parsed_args):
 
152
        self.log.debug('run(%s)' % parsed_args)
 
153
        debug_agent = self.get_debug_agent()
 
154
        result = debug_agent.ping_all(parsed_args.id,
 
155
                                      timeout=parsed_args.timeout)
 
156
        self.app.stdout.write(result + '\n')