instance runs

This commit is contained in:
Vishvananda Ishaya
2010-08-30 00:55:19 -07:00
parent ad7b34ecb3
commit f1c8df8d6f
4 changed files with 50 additions and 41 deletions

View File

@@ -29,4 +29,4 @@ if __name__ == '__main__':
twistd.serve(__file__) twistd.serve(__file__)
if __name__ == '__builtin__': if __name__ == '__builtin__':
application = service.ComputeService.create() # pylint: disable-msg=C0103 application = service.ComputeService.create() # pylint: disable=C0103

View File

@@ -33,5 +33,4 @@ if __name__ == '__main__':
twistd.serve(__file__) twistd.serve(__file__)
if __name__ == '__builtin__': if __name__ == '__builtin__':
# pylint: disable-msg=C0103 application = service.NetworkService.create() # pylint: disable-msg=C0103
application = service.type_to_class(FLAGS.network_type).create()

View File

@@ -29,4 +29,4 @@ if __name__ == '__main__':
twistd.serve(__file__) twistd.serve(__file__)
if __name__ == '__builtin__': if __name__ == '__builtin__':
application = service.VolumeService.create() # pylint: disable-msg=C0103 application = service.VolumeService.create() # pylint: disable-msg=C0103

View File

@@ -233,7 +233,8 @@ class CloudController(object):
return rpc.call('%s.%s' % (FLAGS.compute_topic, return rpc.call('%s.%s' % (FLAGS.compute_topic,
instance_ref['node_name']), instance_ref['node_name']),
{"method": "get_console_output", {"method": "get_console_output",
"args": {"instance_id": instance_ref['id']}}) "args": {"context": None,
"instance_id": instance_ref['id']}})
@rbac.allow('projectmanager', 'sysadmin') @rbac.allow('projectmanager', 'sysadmin')
def describe_volumes(self, context, **kwargs): def describe_volumes(self, context, **kwargs):
@@ -300,9 +301,10 @@ class CloudController(object):
host = db.instance_get_host(context, instance_ref['id']) host = db.instance_get_host(context, instance_ref['id'])
rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host), rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "attach_volume", {"method": "attach_volume",
"args": {"volume_id": volume_ref['id'], "args": {"context": None,
"instance_id": instance_ref['id'], "volume_id": volume_ref['id'],
"mountpoint": device}}) "instance_id": instance_ref['id'],
"mountpoint": device}})
return defer.succeed({'attachTime': volume_ref['attach_time'], return defer.succeed({'attachTime': volume_ref['attach_time'],
'device': volume_ref['mountpoint'], 'device': volume_ref['mountpoint'],
'instanceId': instance_ref['id_str'], 'instanceId': instance_ref['id_str'],
@@ -324,8 +326,9 @@ class CloudController(object):
host = db.instance_get_host(context, instance_ref['id']) host = db.instance_get_host(context, instance_ref['id'])
rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host), rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "detach_volume", {"method": "detach_volume",
"args": {"instance_id": instance_ref['id'], "args": {"context": None,
"volume_id": volume_ref['id']}}) "instance_id": instance_ref['id'],
"volume_id": volume_ref['id']}})
except exception.NotFound: except exception.NotFound:
# If the instance doesn't exist anymore, # If the instance doesn't exist anymore,
# then we need to call detach blind # then we need to call detach blind
@@ -437,7 +440,8 @@ class CloudController(object):
network_topic = yield self._get_network_topic(context) network_topic = yield self._get_network_topic(context)
public_ip = yield rpc.call(network_topic, public_ip = yield rpc.call(network_topic,
{"method": "allocate_floating_ip", {"method": "allocate_floating_ip",
"args": {"project_id": context.project.id}}) "args": {"context": None,
"project_id": context.project.id}})
defer.returnValue({'addressSet': [{'publicIp': public_ip}]}) defer.returnValue({'addressSet': [{'publicIp': public_ip}]})
@rbac.allow('netadmin') @rbac.allow('netadmin')
@@ -448,7 +452,8 @@ class CloudController(object):
network_topic = yield self._get_network_topic(context) network_topic = yield self._get_network_topic(context)
rpc.cast(network_topic, rpc.cast(network_topic,
{"method": "deallocate_floating_ip", {"method": "deallocate_floating_ip",
"args": {"floating_ip": floating_ip_ref['str_id']}}) "args": {"context": None,
"floating_ip": floating_ip_ref['str_id']}})
defer.returnValue({'releaseResponse': ["Address released."]}) defer.returnValue({'releaseResponse': ["Address released."]})
@rbac.allow('netadmin') @rbac.allow('netadmin')
@@ -460,7 +465,8 @@ class CloudController(object):
network_topic = yield self._get_network_topic(context) network_topic = yield self._get_network_topic(context)
rpc.cast(network_topic, rpc.cast(network_topic,
{"method": "associate_floating_ip", {"method": "associate_floating_ip",
"args": {"floating_ip": floating_ip_ref['str_id'], "args": {"context": None,
"floating_ip": floating_ip_ref['str_id'],
"fixed_ip": fixed_ip_ref['str_id'], "fixed_ip": fixed_ip_ref['str_id'],
"instance_id": instance_ref['id']}}) "instance_id": instance_ref['id']}})
defer.returnValue({'associateResponse': ["Address associated."]}) defer.returnValue({'associateResponse': ["Address associated."]})
@@ -472,7 +478,8 @@ class CloudController(object):
network_topic = yield self._get_network_topic(context) network_topic = yield self._get_network_topic(context)
rpc.cast(network_topic, rpc.cast(network_topic,
{"method": "disassociate_floating_ip", {"method": "disassociate_floating_ip",
"args": {"floating_ip": floating_ip_ref['str_id']}}) "args": {"context": None,
"floating_ip": floating_ip_ref['str_id']}})
defer.returnValue({'disassociateResponse': ["Address disassociated."]}) defer.returnValue({'disassociateResponse': ["Address disassociated."]})
@defer.inlineCallbacks @defer.inlineCallbacks
@@ -483,7 +490,8 @@ class CloudController(object):
if not host: if not host:
host = yield rpc.call(FLAGS.network_topic, host = yield rpc.call(FLAGS.network_topic,
{"method": "set_network_host", {"method": "set_network_host",
"args": {"project_id": context.project.id}}) "args": {"context": None,
"project_id": context.project.id}})
defer.returnValue(db.queue_get_for(context, FLAGS.network_topic, host)) defer.returnValue(db.queue_get_for(context, FLAGS.network_topic, host))
@rbac.allow('projectmanager', 'sysadmin') @rbac.allow('projectmanager', 'sysadmin')
@@ -568,7 +576,7 @@ class CloudController(object):
@rbac.allow('projectmanager', 'sysadmin') @rbac.allow('projectmanager', 'sysadmin')
# @defer.inlineCallbacks @defer.inlineCallbacks
def terminate_instances(self, context, instance_id, **kwargs): def terminate_instances(self, context, instance_id, **kwargs):
logging.debug("Going to start terminating instances") logging.debug("Going to start terminating instances")
# network_topic = yield self._get_network_topic(context) # network_topic = yield self._get_network_topic(context)
@@ -582,36 +590,37 @@ class CloudController(object):
continue continue
# FIXME(ja): where should network deallocate occur? # FIXME(ja): where should network deallocate occur?
# floating_ip = network_model.get_public_ip_for_instance(i) address = db.instance_get_floating_address(context,
# if floating_ip: instance_ref['id'])
# logging.debug("Disassociating address %s" % floating_ip) if address:
# # NOTE(vish): Right now we don't really care if the ip is logging.debug("Disassociating address %s" % address)
# # disassociated. We may need to worry about # NOTE(vish): Right now we don't really care if the ip is
# # checking this later. Perhaps in the scheduler? # disassociated. We may need to worry about
# rpc.cast(network_topic, # checking this later. Perhaps in the scheduler?
# {"method": "disassociate_floating_ip", network_topic = yield self._get_network_topic(context)
# "args": {"floating_ip": floating_ip}}) rpc.cast(network_topic,
# {"method": "disassociate_floating_ip",
# fixed_ip = instance.get('private_dns_name', None) "args": {"context": None,
# if fixed_ip: "address": address}})
# logging.debug("Deallocating address %s" % fixed_ip)
# # NOTE(vish): Right now we don't really care if the ip is address = db.instance_get_fixed_address(context,
# # actually removed. We may need to worry about instance_ref['id'])
# # checking this later. Perhaps in the scheduler? if address:
# rpc.cast(network_topic, logging.debug("Deallocating address %s" % address)
# {"method": "deallocate_fixed_ip", # NOTE(vish): Currently, nothing needs to be done on the
# "args": {"fixed_ip": fixed_ip}}) # network node until release. If this changes,
# we will need to cast here.
db.fixed_ip_deallocate(context, address)
host = db.instance_get_host(context, instance_ref['id']) host = db.instance_get_host(context, instance_ref['id'])
if host is not None: if host:
# NOTE(joshua?): It's also internal default
rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host), rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "terminate_instance", {"method": "terminate_instance",
"args": {"instance_id": instance_ref['id']}}) "args": {"context": None,
"instance_id": instance_ref['id']}})
else: else:
db.instance_destroy(context, instance_ref['id']) db.instance_destroy(context, instance_ref['id'])
# defer.returnValue(True) defer.returnValue(True)
return True
@rbac.allow('projectmanager', 'sysadmin') @rbac.allow('projectmanager', 'sysadmin')
def reboot_instances(self, context, instance_id, **kwargs): def reboot_instances(self, context, instance_id, **kwargs):
@@ -621,7 +630,8 @@ class CloudController(object):
host = db.instance_get_host(context, instance_ref['id']) host = db.instance_get_host(context, instance_ref['id'])
rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host), rpc.cast(db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "reboot_instance", {"method": "reboot_instance",
"args": {"instance_id": instance_ref['id']}}) "args": {"context": None,
"instance_id": instance_ref['id']}})
return defer.succeed(True) return defer.succeed(True)
@rbac.allow('projectmanager', 'sysadmin') @rbac.allow('projectmanager', 'sysadmin')