rev439ベースにライブマイグレーションの機能をマージ
このバージョンはEBSなし、CPUフラグのチェックなし
This commit is contained in:
parent
ba22e9db54
commit
ddf1160f59
@ -195,6 +195,11 @@ def floating_ip_get_by_address(context, address):
|
||||
return IMPL.floating_ip_get_by_address(context, address)
|
||||
|
||||
|
||||
# this method is created by masumotok
|
||||
def floating_ip_update(context, address, values):
|
||||
"""update floating ip information."""
|
||||
return IMPL.floating_ip_update(context, address, values)
|
||||
|
||||
####################
|
||||
|
||||
|
||||
@ -334,6 +339,36 @@ def instance_add_security_group(context, instance_id, security_group_id):
|
||||
security_group_id)
|
||||
|
||||
|
||||
# created by masumotok
|
||||
def instance_get_all_by_host(context, hostname):
|
||||
"""Get instances by host"""
|
||||
return IMPL.instance_get_all_by_host(context, hostname)
|
||||
|
||||
|
||||
# created by masumotok
|
||||
def instance_get_vcpu_sum_by_host_and_project(context, hostname, proj_id):
|
||||
"""Get instances.vcpus by host and project"""
|
||||
return IMPL.instance_get_vcpu_sum_by_host_and_project(context,
|
||||
hostname,
|
||||
proj_id)
|
||||
|
||||
|
||||
# created by masumotok
|
||||
def instance_get_memory_sum_by_host_and_project(context, hostname, proj_id):
|
||||
"""Get amount of memory by host and project """
|
||||
return IMPL.instance_get_memory_sum_by_host_and_project(context,
|
||||
hostname,
|
||||
proj_id)
|
||||
|
||||
|
||||
# created by masumotok
|
||||
def instance_get_disk_sum_by_host_and_project(context, hostname, proj_id):
|
||||
"""Get total amount of disk by host and project """
|
||||
return IMPL.instance_get_disk_sum_by_host_and_project(context,
|
||||
hostname,
|
||||
proj_id)
|
||||
|
||||
|
||||
###################
|
||||
|
||||
|
||||
@ -833,3 +868,37 @@ def host_get_networks(context, host):
|
||||
|
||||
"""
|
||||
return IMPL.host_get_networks(context, host)
|
||||
|
||||
|
||||
# below all methods related to host table are created by masumotok
|
||||
###################
|
||||
|
||||
|
||||
def host_create(context, value):
|
||||
"""Create a host from the values dictionary."""
|
||||
return IMPL.host_create(context, value)
|
||||
|
||||
|
||||
def host_get(context, host_id):
|
||||
"""Get an host or raise if it does not exist."""
|
||||
return IMPL.host_get(context, host_id)
|
||||
|
||||
|
||||
def host_get_all(context, session=None):
|
||||
"""Get all hosts or raise if it does not exist."""
|
||||
return IMPL.host_get_all(context)
|
||||
|
||||
|
||||
def host_get_by_name(context, host):
|
||||
"""Get an host or raise if it does not exist."""
|
||||
return IMPL.host_get_by_name(context, host)
|
||||
|
||||
|
||||
def host_update(context, host, values):
|
||||
"""Set the given properties on an host and update it."""
|
||||
return IMPL.host_update(context, host, values)
|
||||
|
||||
|
||||
def host_deactivated(context, host):
|
||||
"""set deleted flag to a given host"""
|
||||
return IMPL.host_deactivated(context, host)
|
||||
|
@ -394,6 +394,17 @@ def floating_ip_get_by_address(context, address, session=None):
|
||||
return result
|
||||
|
||||
|
||||
# created by masumotok
|
||||
@require_context
|
||||
def floating_ip_update(context, address, values):
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
floating_ip_ref = floating_ip_get_by_address(context, address, session)
|
||||
for (key, value) in values.iteritems():
|
||||
floating_ip_ref[key] = value
|
||||
floating_ip_ref.save(session=session)
|
||||
|
||||
|
||||
###################
|
||||
|
||||
|
||||
@ -746,6 +757,52 @@ def instance_add_security_group(context, instance_id, security_group_id):
|
||||
instance_ref.save(session=session)
|
||||
|
||||
|
||||
# created by masumotok
|
||||
def instance_get_all_by_host(context, hostname):
|
||||
session = get_session()
|
||||
if not session:
|
||||
session = get_session()
|
||||
|
||||
result = session.query(models.Instance
|
||||
).filter_by(host=hostname
|
||||
).filter_by(deleted=can_read_deleted(context)
|
||||
).all()
|
||||
if None == result:
|
||||
return []
|
||||
return result
|
||||
|
||||
|
||||
# created by masumotok
|
||||
def _instance_get_sum_by_host_and_project(context, column, hostname, proj_id):
|
||||
session = get_session()
|
||||
|
||||
result = session.query(models.Instance
|
||||
).filter_by(host=hostname
|
||||
).filter_by(project_id=proj_id
|
||||
).filter_by(deleted=can_read_deleted(context)
|
||||
).value(column)
|
||||
if None == result:
|
||||
return 0
|
||||
return result
|
||||
|
||||
|
||||
# created by masumotok
|
||||
def instance_get_vcpu_sum_by_host_and_project(context, hostname, proj_id):
|
||||
return _instance_get_sum_by_host_and_project(context, 'vcpus', hostname,
|
||||
proj_id)
|
||||
|
||||
|
||||
# created by masumotok
|
||||
def instance_get_memory_sum_by_host_and_project(context, hostname, proj_id):
|
||||
return _instance_get_sum_by_host_and_project(context, 'memory_mb',
|
||||
hostname, proj_id)
|
||||
|
||||
|
||||
# created by masumotok
|
||||
def instance_get_disk_sum_by_host_and_project(context, hostname, proj_id):
|
||||
return _instance_get_sum_by_host_and_project(context, 'local_gb',
|
||||
hostname, proj_id)
|
||||
|
||||
###################
|
||||
|
||||
|
||||
@ -1746,3 +1803,77 @@ def host_get_networks(context, host):
|
||||
filter_by(deleted=False).\
|
||||
filter_by(host=host).\
|
||||
all()
|
||||
|
||||
|
||||
#below all methods related to host table are created by masumotok
|
||||
###################
|
||||
|
||||
@require_admin_context
|
||||
def host_create(context, values):
|
||||
host_ref = models.Host()
|
||||
for (key, value) in values.iteritems():
|
||||
host_ref[key] = value
|
||||
host_ref.save()
|
||||
return host_ref
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def host_get(context, host_id, session=None):
|
||||
if not session:
|
||||
session = get_session()
|
||||
|
||||
result = session.query(models.Host
|
||||
).filter_by(deleted=False
|
||||
).filter_by(id=host_id
|
||||
).first()
|
||||
|
||||
if not result:
|
||||
raise exception.NotFound('No host for id %s' % host_id)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def host_get_all(context, session=None):
|
||||
if not session:
|
||||
session = get_session()
|
||||
|
||||
result = session.query(models.Host
|
||||
).filter_by(deleted=False
|
||||
).all()
|
||||
|
||||
if not result:
|
||||
raise exception.NotFound('No host record found .')
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def host_get_by_name(context, host, session=None):
|
||||
if not session:
|
||||
session = get_session()
|
||||
|
||||
result = session.query(models.Host
|
||||
).filter_by(deleted=False
|
||||
).filter_by(name=host
|
||||
).first()
|
||||
|
||||
if not result:
|
||||
raise exception.NotFound('No host for name %s' % host)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def host_update(context, host_id, values):
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
host_ref = host_get(context, host_id, session=session)
|
||||
for (key, value) in values.iteritems():
|
||||
host_ref[key] = value
|
||||
host_ref.save(session=session)
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def host_deactivated(context, host):
|
||||
host_update(context, host, {'deleted': True})
|
||||
|
@ -133,9 +133,16 @@ def runthis(prompt, cmd, check_exit_code=True):
|
||||
|
||||
|
||||
def generate_uid(topic, size=8):
|
||||
characters = '01234567890abcdefghijklmnopqrstuvwxyz'
|
||||
choices = [random.choice(characters) for x in xrange(size)]
|
||||
return '%s-%s' % (topic, ''.join(choices))
|
||||
#modified by masumotok
|
||||
#characters = '01234567890abcdefghijklmnopqrstuvwxyz'
|
||||
#choices = [random.choice(characters) for x in xrange(size)]
|
||||
#return '%s-%s' % (topic, ''.join(choices))
|
||||
if topic == "i":
|
||||
return random.randint(0, 2 ** 28 - 1)
|
||||
else:
|
||||
characters = '01234567890abcdefghijklmnopqrstuvwxyz'
|
||||
choices = [random.choice(characters) for x in xrange(size)]
|
||||
return '%s-%s' % (topic, ''.join(choices))
|
||||
|
||||
|
||||
def generate_mac():
|
||||
|
5
setup.py
5
setup.py
@ -25,6 +25,7 @@ from sphinx.setup_command import BuildDoc
|
||||
|
||||
from nova.utils import parse_mailmap, str_dict_replace
|
||||
|
||||
|
||||
class local_BuildDoc(BuildDoc):
|
||||
def run(self):
|
||||
for builder in ['html', 'man']:
|
||||
@ -54,8 +55,8 @@ setup(name='nova',
|
||||
author='OpenStack',
|
||||
author_email='nova@lists.launchpad.net',
|
||||
url='http://www.openstack.org/',
|
||||
cmdclass={ 'sdist': local_sdist,
|
||||
'build_sphinx' : local_BuildDoc },
|
||||
cmdclass={'sdist': local_sdist,
|
||||
'build_sphinx': local_BuildDoc},
|
||||
packages=find_packages(exclude=['bin', 'smoketests']),
|
||||
include_package_data=True,
|
||||
scripts=['bin/nova-api',
|
||||
|
Loading…
x
Reference in New Issue
Block a user