~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to bin/nova-manage

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandleman, Chuck Short
  • Date: 2012-03-02 11:04:04 UTC
  • mfrom: (1.1.47)
  • Revision ID: package-import@ubuntu.com-20120302110404-fr230yakr8hov3dj
Tags: 2012.1~e4-0ubuntu1
[ Adam Gandleman ]
* debian/patches/libvirt-use-console-pipe.patch: Refreshed. 
* debain/nova-volume.upstart.in: Ensure lock directory is created
  (LP: #940780)
* debain/control: Fix nova-compute-$flavor Depends
* debian/control: Add python-iso8601 to python-nova Depends

[ Chuck Short ]
* debian/rules: Fix FTBFS.
* Merge Ubuntu/Debian packaging:
  - Thanks to Julien Danjou, Ghe Rivero, and Thomas Goirand
  - debian/copyright: Update copyright file.
  - debian/nova-api.init, debian/nova-compute.init,
    debian/nova-network.init, debian/nova-objectstore,
    debian/nova-scheduler, debian/nova-volume.init:
    Synchronize init scripts.
  - nova-common.install, debian/rules: Install policy.json
  - debian/rules, debian/nova-xcp-network.install,
    debian/nova-xcp-plugins.install, nova-xcp-plugins.postrm,
    debian/nova-xcp-plugins.doc, debian/nova-xcp-plugins.postinst,
    debian/README.xcp_and_openstack, debian/control,
    debian/ubuntu_xen-openvswitch-nova.rules,
    debian/patches/path-to-the-xenhost.conf-fixup.patch:
    Add Xen XCP support.
  - debian/control,
    debian/nova-compute-{kvm,lxc,qemu,xen,uml}.postinst: Make
    nova-compute a virtual package.
  - Dropped ubuntu_ubuntu_control_vars: We dont use it
* New upstream release.
* Dropped python-babel, it will be handled by langpacks.
* debian/patches/ec2-fixes.patch: Backport turnk fix for ec2
  permissions.
* debian/patches/path-to-the-xenhost.conf-fixup.patch: Refreshed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
from nova import vsa
93
93
from nova.api.ec2 import ec2utils
94
94
from nova.auth import manager
95
 
from nova.cloudpipe import pipelib
96
95
from nova.compute import instance_types
97
96
from nova.compute import vm_states
98
97
from nova.db import migration
132
131
 
133
132
    def __init__(self):
134
133
        self.manager = manager.AuthManager()
135
 
        self.pipe = pipelib.CloudPipe()
136
 
 
137
 
    @args('--project', dest="project", metavar='<Project name>',
138
 
            help='Project name')
139
 
    def list(self, project=None):
140
 
        """Print a listing of the VPN data for one or all projects."""
141
 
        print "WARNING: This method only works with deprecated auth"
142
 
        print "%-12s\t" % 'project',
143
 
        print "%-20s\t" % 'ip:port',
144
 
        print "%-20s\t" % 'private_ip',
145
 
        print "%s" % 'state'
146
 
        if project:
147
 
            projects = [self.manager.get_project(project)]
148
 
        else:
149
 
            projects = self.manager.get_projects()
150
 
            # NOTE(vish): This hits the database a lot.  We could optimize
151
 
            #             by getting all networks in one query and all vpns
152
 
            #             in aother query, then doing lookups by project
153
 
        for project in projects:
154
 
            print "%-12s\t" % project.name,
155
 
            ipport = "%s:%s" % (project.vpn_ip, project.vpn_port)
156
 
            print "%-20s\t" % ipport,
157
 
            ctxt = context.get_admin_context()
158
 
            vpn = db.instance_get_project_vpn(ctxt, project.id)
159
 
            if vpn:
160
 
                address = None
161
 
                state = 'down'
162
 
                if vpn.get('fixed_ip', None):
163
 
                    address = vpn['fixed_ip']['address']
164
 
                if project.vpn_ip and utils.vpn_ping(project.vpn_ip,
165
 
                                                     project.vpn_port):
166
 
                    state = 'up'
167
 
                print address,
168
 
                print vpn['host'],
169
 
                print ec2utils.id_to_ec2_id(vpn['id']),
170
 
                print vpn['vm_state'],
171
 
                print state
172
 
            else:
173
 
                print None
174
 
 
175
 
    def spawn(self):
176
 
        """Run all VPNs."""
177
 
        print "WARNING: This method only works with deprecated auth"
178
 
        ctxt = context.get_admin_context()
179
 
        for p in reversed(self.manager.get_projects()):
180
 
            if self._vpn_for(ctxt, p.id):
181
 
                print 'spawning %s' % p.id
182
 
                self.pipe.launch_vpn_instance(p.id, p.project_manager_id)
183
 
                time.sleep(10)
184
 
 
185
 
    @args('--project', dest="project_id", metavar='<Project name>',
186
 
            help='Project name')
187
 
    @args('--user', dest="user_id", metavar='<user name>', help='User name')
188
 
    def run(self, project_id, user_id):
189
 
        """Start the VPN for a given project and user."""
190
 
        if not user_id:
191
 
            print "WARNING: This method only works with deprecated auth"
192
 
            user_id = self.manager.get_project(project_id).project_manager_id
193
 
        self.pipe.launch_vpn_instance(project_id, user_id)
194
134
 
195
135
    @args('--project', dest="project_id", metavar='<Project name>',
196
136
            help='Project name')
213
153
                              {'vpn_public_address': ip,
214
154
                               'vpn_public_port': int(port)})
215
155
 
216
 
    def _vpn_for(self, context, project_id):
217
 
        """Get the VPN instance for a project ID."""
218
 
        for instance in db.instance_get_all_by_project(context, project_id):
219
 
            if (instance['image_id'] == str(FLAGS.vpn_image_id)
220
 
                and not instance['vm_state'] in [vm_states.DELETED]):
221
 
                return instance
222
 
 
223
156
 
224
157
class ShellCommands(object):
225
158
    def bpython(self):