summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authormasumotok <masumotok@nttdata.co.jp>2010-12-31 04:03:37 +0900
committermasumotok <masumotok@nttdata.co.jp>2010-12-31 04:03:37 +0900
commitbf7bc8725fcc26cc5074ea1628bcba6ac6093768 (patch)
treedd845322f758c2353f295afa44d4e6455564ffff /bin
parent85acbbe916df8b2d18f0dc3a0b8cad9fcfdd6907 (diff)
parentbd6a3cb1acb68ac2252c1bafc531b3b12f9746d8 (diff)
merge recent revision(version of 2010/12/28)
Change: 1. Use greenthread instead of defer at nova.virt.libvirt_conn.live_migration. 2. Move nova.scheduler.manager.live_migration to nova.scheduler.driver 3. Move nova.scheduler.manager.has_enough_resource to nova.scheduler.driver 4. Any check routine in nova-manage.instance.live_migration is moved to nova.scheduler.driver.schedule_live_migration.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-api23
-rwxr-xr-xbin/nova-combined68
-rwxr-xr-xbin/nova-compute18
-rwxr-xr-xbin/nova-dhcpbridge4
-rwxr-xr-xbin/nova-import-canonical-imagestore3
-rwxr-xr-xbin/nova-instancemonitor3
-rwxr-xr-xbin/nova-manage177
-rwxr-xr-xbin/nova-network18
-rwxr-xr-xbin/nova-objectstore3
-rwxr-xr-xbin/nova-scheduler18
-rwxr-xr-xbin/nova-volume18
11 files changed, 214 insertions, 139 deletions
diff --git a/bin/nova-api b/bin/nova-api
index a9c53dbcd..1c671201e 100755
--- a/bin/nova-api
+++ b/bin/nova-api
@@ -17,10 +17,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
-"""
-Nova API daemon.
-"""
+"""Starter script for Nova API."""
+
+import gettext
import os
import sys
@@ -32,9 +32,13 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
+from nova import api
from nova import flags
from nova import utils
-from nova import server
+from nova import wsgi
+
FLAGS = flags.FLAGS
flags.DEFINE_integer('osapi_port', 8774, 'OpenStack API port')
@@ -43,15 +47,10 @@ flags.DEFINE_integer('ec2api_port', 8773, 'EC2 API port')
flags.DEFINE_string('ec2api_host', '0.0.0.0', 'EC2 API host')
-def main(_args):
- from nova import api
- from nova import wsgi
+if __name__ == '__main__':
+ utils.default_flagfile()
+ FLAGS(sys.argv)
server = wsgi.Server()
server.start(api.API('os'), FLAGS.osapi_port, host=FLAGS.osapi_host)
server.start(api.API('ec2'), FLAGS.ec2api_port, host=FLAGS.ec2api_host)
server.wait()
-
-
-if __name__ == '__main__':
- utils.default_flagfile()
- server.serve('nova-api', main)
diff --git a/bin/nova-combined b/bin/nova-combined
new file mode 100755
index 000000000..53322f1a0
--- /dev/null
+++ b/bin/nova-combined
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""Combined starter script for Nova services."""
+
+import eventlet
+eventlet.monkey_patch()
+
+import gettext
+import os
+import sys
+
+# If ../nova/__init__.py exists, add ../ to Python search path, so that
+# it will override what happens to be installed in /usr/(local/)lib/python...
+possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
+ os.pardir,
+ os.pardir))
+if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
+ sys.path.insert(0, possible_topdir)
+
+gettext.install('nova', unicode=1)
+
+from nova import api
+from nova import flags
+from nova import service
+from nova import utils
+from nova import wsgi
+
+
+FLAGS = flags.FLAGS
+flags.DEFINE_integer('osapi_port', 8774, 'OpenStack API port')
+flags.DEFINE_string('osapi_host', '0.0.0.0', 'OpenStack API host')
+flags.DEFINE_integer('ec2api_port', 8773, 'EC2 API port')
+flags.DEFINE_string('ec2api_host', '0.0.0.0', 'EC2 API host')
+
+
+if __name__ == '__main__':
+ utils.default_flagfile()
+ FLAGS(sys.argv)
+
+ compute = service.Service.create(binary='nova-compute')
+ network = service.Service.create(binary='nova-network')
+ volume = service.Service.create(binary='nova-volume')
+ scheduler = service.Service.create(binary='nova-scheduler')
+ #objectstore = service.Service.create(binary='nova-objectstore')
+
+ service.serve(compute, network, volume, scheduler)
+
+ server = wsgi.Server()
+ server.start(api.API('os'), FLAGS.osapi_port, host=FLAGS.osapi_host)
+ server.start(api.API('ec2'), FLAGS.ec2api_port, host=FLAGS.ec2api_host)
+ server.wait()
diff --git a/bin/nova-compute b/bin/nova-compute
index ac6378f75..d2d352da2 100755
--- a/bin/nova-compute
+++ b/bin/nova-compute
@@ -17,10 +17,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-"""
- Twistd daemon for the nova compute nodes.
-"""
+"""Starter script for Nova Compute."""
+import eventlet
+eventlet.monkey_patch()
+
+import gettext
import os
import sys
@@ -32,14 +34,12 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import service
-from nova import twistd
from nova import utils
-
if __name__ == '__main__':
utils.default_flagfile()
- twistd.serve(__file__)
-
-if __name__ == '__builtin__':
- application = service.Service.create() # pylint: disable=C0103
+ service.serve()
+ service.wait()
diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge
index 17c62da0a..828aba3d1 100755
--- a/bin/nova-dhcpbridge
+++ b/bin/nova-dhcpbridge
@@ -21,6 +21,7 @@
Handle lease database updates from DHCP servers.
"""
+import gettext
import logging
import os
import sys
@@ -33,6 +34,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import context
from nova import db
from nova import flags
@@ -107,7 +110,6 @@ def main():
FLAGS.num_networks = 5
path = os.path.abspath(os.path.join(os.path.dirname(__file__),
'..',
- '_trial_temp',
'nova.sqlite'))
FLAGS.sql_connection = 'sqlite:///%s' % path
action = argv[1]
diff --git a/bin/nova-import-canonical-imagestore b/bin/nova-import-canonical-imagestore
index 4ed9e8365..036b41e48 100755
--- a/bin/nova-import-canonical-imagestore
+++ b/bin/nova-import-canonical-imagestore
@@ -21,6 +21,7 @@
Download images from Canonical Image Store
"""
+import gettext
import json
import os
import tempfile
@@ -37,6 +38,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import flags
from nova import utils
from nova.objectstore import image
diff --git a/bin/nova-instancemonitor b/bin/nova-instancemonitor
index 9b6c40e82..5dac3ffe6 100755
--- a/bin/nova-instancemonitor
+++ b/bin/nova-instancemonitor
@@ -21,6 +21,7 @@
Daemon for Nova RRD based instance resource monitoring.
"""
+import gettext
import os
import logging
import sys
@@ -34,6 +35,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import utils
from nova import twistd
from nova.compute import monitor
diff --git a/bin/nova-manage b/bin/nova-manage
index d6aa29679..7c87d21ff 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -53,6 +53,7 @@
CLI interface for nova management.
"""
+import gettext
import logging
import os
import sys
@@ -68,20 +69,19 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import context
+from nova import crypto
from nova import db
from nova import exception
from nova import flags
from nova import quota
from nova import utils
from nova.auth import manager
-from nova.cloudpipe import pipelib
-#added by masumotok
from nova import rpc
-# added by masumotok
+from nova.cloudpipe import pipelib
from nova.api.ec2 import cloud
-# added by masumotok
-from nova.compute import power_state
@@ -100,47 +100,43 @@ class VpnCommands(object):
self.manager = manager.AuthManager()
self.pipe = pipelib.CloudPipe()
- def list(self):
- """Print a listing of the VPNs for all projects."""
+ def list(self, project=None):
+ """Print a listing of the VPN data for one or all projects.
+
+ args: [project=all]"""
print "%-12s\t" % 'project',
print "%-20s\t" % 'ip:port',
+ print "%-20s\t" % 'private_ip',
print "%s" % 'state'
- for project in self.manager.get_projects():
+ if project:
+ projects = [self.manager.get_project(project)]
+ else:
+ projects = self.manager.get_projects()
+ # NOTE(vish): This hits the database a lot. We could optimize
+ # by getting all networks in one query and all vpns
+ # in aother query, then doing lookups by project
+ for project in projects:
print "%-12s\t" % project.name,
-
- try:
- s = "%s:%s" % (project.vpn_ip, project.vpn_port)
- except exception.NotFound:
- s = "None"
- print "%-20s\t" % s,
-
- vpn = self._vpn_for(project.id)
+ ipport = "%s:%s" % (project.vpn_ip, project.vpn_port)
+ print "%-20s\t" % ipport,
+ ctxt = context.get_admin_context()
+ vpn = db.instance_get_project_vpn(ctxt, project.id)
if vpn:
- command = "ping -c1 -w1 %s > /dev/null; echo $?"
- out, _err = utils.execute(command % vpn['private_dns_name'],
- check_exit_code=False)
- if out.strip() == '0':
- net = 'up'
- else:
- net = 'down'
- print vpn['private_dns_name'],
- print vpn['node_name'],
- print vpn['instance_id'],
+ address = None
+ state = 'down'
+ if vpn.get('fixed_ip', None):
+ address = vpn['fixed_ip']['address']
+ if project.vpn_ip and utils.vpn_ping(project.vpn_ip,
+ project.vpn_port):
+ state = 'up'
+ print address,
+ print vpn['host'],
+ print vpn['ec2_id'],
print vpn['state_description'],
- print net
-
+ print state
else:
print None
- def _vpn_for(self, project_id):
- """Get the VPN instance for a project ID."""
- for instance in db.instance_get_all(context.get_admin_context()):
- if (instance['image_id'] == FLAGS.vpn_image_id
- and not instance['state_description'] in
- ['shutting_down', 'shutdown']
- and instance['project_id'] == project_id):
- return instance
-
def spawn(self):
"""Run all VPNs."""
for p in reversed(self.manager.get_projects()):
@@ -153,6 +149,21 @@ class VpnCommands(object):
"""Start the VPN for a given project."""
self.pipe.launch_vpn_instance(project_id)
+ def change(self, project_id, ip, port):
+ """Change the ip and port for a vpn.
+
+ args: project, ip, port"""
+ project = self.manager.get_project(project_id)
+ if not project:
+ print 'No project %s' % (project_id)
+ return
+ admin = context.get_admin_context()
+ network_ref = db.project_get_network(admin, project_id)
+ db.network_update(admin,
+ network_ref['id'],
+ {'vpn_public_address': ip,
+ 'vpn_public_port': int(port)})
+
class ShellCommands(object):
def bpython(self):
@@ -299,6 +310,14 @@ class UserCommands(object):
is_admin = False
self.manager.modify_user(name, access_key, secret_key, is_admin)
+ def revoke(self, user_id, project_id=None):
+ """revoke certs for a user
+ arguments: user_id [project_id]"""
+ if project_id:
+ crypto.revoke_certs_by_user_and_project(user_id, project_id)
+ else:
+ crypto.revoke_certs_by_user(user_id)
+
class ProjectCommands(object):
"""Class for managing projects."""
@@ -366,9 +385,14 @@ class ProjectCommands(object):
def zipfile(self, project_id, user_id, filename='nova.zip'):
"""Exports credentials for project to a zip file
arguments: project_id user_id [filename='nova.zip]"""
- zip_file = self.manager.get_credentials(user_id, project_id)
- with open(filename, 'w') as f:
- f.write(zip_file)
+ try:
+ zip_file = self.manager.get_credentials(user_id, project_id)
+ with open(filename, 'w') as f:
+ f.write(zip_file)
+ except db.api.NoMoreNetworks:
+ print ('No more networks available. If this is a new '
+ 'installation, you need\nto call something like this:\n\n'
+ ' nova-manage network create 10.0.0.0/8 10 64\n\n')
class FloatingIpCommands(object):
@@ -431,7 +455,7 @@ class NetworkCommands(object):
int(network_size), int(vlan_start),
int(vpn_start))
-# this class is added by masumotok
+
class InstanceCommands(object):
"""Class for mangaging VM instances."""
@@ -441,43 +465,29 @@ class InstanceCommands(object):
logging.basicConfig()
ctxt = context.get_admin_context()
- # 1. whether destination host exists
- host_ref = db.host_get_by_name(ctxt, dest)
-
- # 2. whether instance exists and running
- # try-catch clause is necessary because only internal_id is shown
- # when NotFound exception occurs. it isnot understandable to admins.
- try :
+ try:
internal_id = cloud.ec2_id_to_internal_id(ec2_id)
instance_ref = db.instance_get_by_internal_id(ctxt, internal_id)
- except exception.NotFound :
- print 'Not found instance_id(%s (internal_id:%s))' % ( ec2_id, internal_id)
- raise
+ instance_id = instance_ref['id']
+ except exception.NotFound as e:
+ msg = _('instance(%s) is not found')
+ e.args += (msg % ec2_id,)
+ raise e
- if power_state.RUNNING != instance_ref['state'] or \
- 'running' != instance_ref['state_description']:
- raise exception.Invalid('Instance(%s) is not running' % ec2_id)
-
- # 3. the host where instance is running and dst host is not same
- if dest == instance_ref['host'] :
- msg = '%s is where %s is running now. choose other host.' % (dest, ec2_id)
- raise exception.Invalid(msg)
-
- # 4. live migration
ret = rpc.call(ctxt,
FLAGS.scheduler_topic,
- { "method": "live_migration",
- "args": {"ec2_id": ec2_id,
- "dest":dest}})
+ {"method": "live_migration",
+ "args": {"instance_id": instance_id,
+ "dest": dest,
+ "topic": FLAGS.compute_topic}})
- if None != ret :
+ if None != ret:
raise ret
- print 'Finished all procedure. check instance are migrated successfully'
+ print 'Finished all procedure. Check migrating finishes successfully'
print 'check status by using euca-describe-instances.'
-# this class is created by masumotok
class HostCommands(object):
"""Class for mangaging host(physical nodes)."""
@@ -485,17 +495,18 @@ class HostCommands(object):
def list(self):
"""describe host list."""
- # to supress msg: No handlers could be found for logger "amqplib"
+ # To supress msg: No handlers could be found for logger "amqplib"
logging.basicConfig()
host_refs = db.host_get_all(context.get_admin_context())
for host_ref in host_refs:
print host_ref['name']
+
def show(self, host):
"""describe cpu/memory/hdd info for host."""
- # to supress msg: No handlers could be found for logger "amqplib"
+ # To supress msg: No handlers could be found for logger "amqplib"
logging.basicConfig()
result = rpc.call(context.get_admin_context(),
@@ -503,41 +514,27 @@ class HostCommands(object):
{"method": "show_host_resource",
"args": {"host": host}})
- # checing result msg format is necessary, that will have done
+ # Checking result msg format is necessary, that will have done
# when this feture is included in API.
if dict != type(result):
print 'Unexpected error occurs'
- elif not result['ret'] :
+ elif not result['ret']:
print '%s' % result['msg']
- else :
+ else:
cpu = result['phy_resource']['vcpus']
mem = result['phy_resource']['memory_mb']
hdd = result['phy_resource']['local_gb']
print 'HOST\t\tPROJECT\t\tcpu\tmem(mb)\tdisk(gb)'
- print '%s\t\t\t%s\t%s\t%s' % ( host,cpu, mem, hdd)
- for p_id, val in result['usage'].items() :
- print '%s\t%s\t\t%s\t%s\t%s' % ( host,
+ print '%s\t\t\t%s\t%s\t%s' % (host, cpu, mem, hdd)
+ for p_id, val in result['usage'].items():
+ print '%s\t%s\t\t%s\t%s\t%s' % (host,
p_id,
val['vcpus'],
val['memory_mb'],
val['local_gb'])
- def has_keys(self, dic, keys):
- not_found = [ key for key in keys if not dict.has_key(key) ]
- return ( (0 == len(not_found)), not_found )
-
-
-# modified by masumotok
-#CATEGORIES = [
-# ('user', UserCommands),
-# ('project', ProjectCommands),
-# ('role', RoleCommands),
-# ('shell', ShellCommands),
-# ('vpn', VpnCommands),
-# ('floating', FloatingIpCommands),
-# ('network', NetworkCommands)]
CATEGORIES = [
('user', UserCommands),
('project', ProjectCommands),
@@ -547,7 +544,7 @@ CATEGORIES = [
('floating', FloatingIpCommands),
('network', NetworkCommands),
('instance', InstanceCommands),
- ('host',HostCommands)]
+ ('host', HostCommands)]
def lazy_match(name, key_value_tuples):
"""Finds all objects that have a key that case insensitively contains
diff --git a/bin/nova-network b/bin/nova-network
index d1fb55261..0143846a7 100755
--- a/bin/nova-network
+++ b/bin/nova-network
@@ -17,10 +17,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-"""
- Twistd daemon for the nova network nodes.
-"""
+"""Starter script for Nova Network."""
+import eventlet
+eventlet.monkey_patch()
+
+import gettext
import os
import sys
@@ -32,14 +34,12 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import service
-from nova import twistd
from nova import utils
-
if __name__ == '__main__':
utils.default_flagfile()
- twistd.serve(__file__)
-
-if __name__ == '__builtin__':
- application = service.Service.create() # pylint: disable-msg=C0103
+ service.serve()
+ service.wait()
diff --git a/bin/nova-objectstore b/bin/nova-objectstore
index 00ae27af9..9fbe228a2 100755
--- a/bin/nova-objectstore
+++ b/bin/nova-objectstore
@@ -21,6 +21,7 @@
Twisted daemon for nova objectstore. Supports S3 API.
"""
+import gettext
import os
import sys
@@ -32,6 +33,8 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import flags
from nova import utils
from nova import twistd
diff --git a/bin/nova-scheduler b/bin/nova-scheduler
index 4d1a40cf1..f4c0eaed6 100755
--- a/bin/nova-scheduler
+++ b/bin/nova-scheduler
@@ -17,10 +17,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-"""
- Twistd daemon for the nova scheduler nodes.
-"""
+"""Starter script for Nova Scheduler."""
+import eventlet
+eventlet.monkey_patch()
+
+import gettext
import os
import sys
@@ -32,14 +34,12 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import service
-from nova import twistd
from nova import utils
-
if __name__ == '__main__':
utils.default_flagfile()
- twistd.serve(__file__)
-
-if __name__ == '__builtin__':
- application = service.Service.create()
+ service.serve()
+ service.wait()
diff --git a/bin/nova-volume b/bin/nova-volume
index e7281d6c0..ad3ddc405 100755
--- a/bin/nova-volume
+++ b/bin/nova-volume
@@ -17,10 +17,12 @@
# License for the specific language governing permissions and limitations
# under the License.
-"""
- Twistd daemon for the nova volume nodes.
-"""
+"""Starter script for Nova Volume."""
+import eventlet
+eventlet.monkey_patch()
+
+import gettext
import os
import sys
@@ -32,14 +34,12 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+gettext.install('nova', unicode=1)
+
from nova import service
-from nova import twistd
from nova import utils
-
if __name__ == '__main__':
utils.default_flagfile()
- twistd.serve(__file__)
-
-if __name__ == '__builtin__':
- application = service.Service.create() # pylint: disable-msg=C0103
+ service.serve()
+ service.wait()