diff options
| author | Soren Hansen <soren.hansen@rackspace.com> | 2010-11-29 13:14:26 +0100 |
|---|---|---|
| committer | Soren Hansen <soren.hansen@rackspace.com> | 2010-11-29 13:14:26 +0100 |
| commit | c5d3e310376b3fb5c548e1d2e70c5ce7a489bb9f (patch) | |
| tree | 15a73446e1daa6829a68e05a3cef862924428473 /nova/compute | |
| parent | b65b41e5957d5ded516343b3611292c9744d169f (diff) | |
| parent | 4f92d1d39fcfda4dad73e6e0339351f0d7d00d61 (diff) | |
| download | nova-c5d3e310376b3fb5c548e1d2e70c5ce7a489bb9f.tar.gz nova-c5d3e310376b3fb5c548e1d2e70c5ce7a489bb9f.tar.xz nova-c5d3e310376b3fb5c548e1d2e70c5ce7a489bb9f.zip | |
Merge trunk.
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/disk.py | 38 | ||||
| -rw-r--r-- | nova/compute/manager.py | 39 | ||||
| -rw-r--r-- | nova/compute/monitor.py | 4 |
3 files changed, 56 insertions, 25 deletions
diff --git a/nova/compute/disk.py b/nova/compute/disk.py index e362b4507..4338d39f0 100644 --- a/nova/compute/disk.py +++ b/nova/compute/disk.py @@ -15,10 +15,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - """ Utility methods to resize, repartition, and modify disk images. + Includes injection of SSH PGP keys into authorized_keys file. + """ import logging @@ -41,20 +42,23 @@ flags.DEFINE_integer('block_size', 1024 * 1024 * 256, @defer.inlineCallbacks def partition(infile, outfile, local_bytes=0, resize=True, local_type='ext2', execute=None): - """Takes a single partition represented by infile and writes a bootable - drive image into outfile. + """ + Turns a partition (infile) into a bootable drive image (outfile). The first 63 sectors (0-62) of the resulting image is a master boot record. Infile becomes the first primary partition. If local bytes is specified, a second primary partition is created and formatted as ext2. - In the diagram below, dashes represent drive sectors. - +-----+------. . .-------+------. . .------+ - | 0 a| b c|d e| - +-----+------. . .-------+------. . .------+ - | mbr | primary partiton | local partition | - +-----+------. . .-------+------. . .------+ + :: + + In the diagram below, dashes represent drive sectors. + +-----+------. . .-------+------. . .------+ + | 0 a| b c|d e| + +-----+------. . .-------+------. . .------+ + | mbr | primary partiton | local partition | + +-----+------. . .-------+------. . .------+ + """ sector_size = 512 file_size = os.path.getsize(infile) @@ -161,6 +165,11 @@ def inject_data(image, key=None, net=None, partition=None, execute=None): @defer.inlineCallbacks def _inject_key_into_fs(key, fs, execute=None): + """Add the given public ssh key to root's authorized_keys. + + key is an ssh key string. + fs is the path to the base of the filesystem into which to inject the key. + """ sshdir = os.path.join(os.path.join(fs, 'root'), '.ssh') yield execute('sudo mkdir -p %s' % sshdir) # existing dir doesn't matter yield execute('sudo chown root %s' % sshdir) @@ -171,6 +180,13 @@ def _inject_key_into_fs(key, fs, execute=None): @defer.inlineCallbacks def _inject_net_into_fs(net, fs, execute=None): - netfile = os.path.join(os.path.join(os.path.join( - fs, 'etc'), 'network'), 'interfaces') + """Inject /etc/network/interfaces into the filesystem rooted at fs. + + net is the contents of /etc/network/interfaces. + """ + netdir = os.path.join(os.path.join(fs, 'etc'), 'network') + yield execute('sudo mkdir -p %s' % netdir) # existing dir doesn't matter + yield execute('sudo chown root:root %s' % netdir) + yield execute('sudo chmod 755 %s' % netdir) + netfile = os.path.join(netdir, 'interfaces') yield execute('sudo tee %s' % netfile, net) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 65fa50431..50a9d316b 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -17,7 +17,21 @@ # under the License. """ -Handles all code relating to instances (guest vms) +Handles all processes relating to instances (guest vms). + +The :py:class:`ComputeManager` class is a :py:class:`nova.manager.Manager` that +handles RPC calls relating to creating instances. It is responsible for +building a disk image, launching it via the underlying virtualization driver, +responding to calls to check it state, attaching persistent as well as +termination. + +**Related Flags** + +:instances_path: Where instances are kept on disk +:compute_driver: Name of class that is used to handle virtualization, loaded + by :func:`nova.utils.import_object` +:volume_manager: Name of class that handles persistent storage, loaded by + :func:`nova.utils.import_object` """ import datetime @@ -40,12 +54,12 @@ flags.DEFINE_string('compute_driver', 'nova.virt.connection.get_connection', class ComputeManager(manager.Manager): - """ - Manages the running instances. - """ + """Manages the running instances from creation to destruction.""" + def __init__(self, compute_driver=None, *args, **kwargs): """Load configuration options and connect to the hypervisor.""" # TODO(vish): sync driver creation logic with the rest of the system + # and redocument the module docstring if not compute_driver: compute_driver = FLAGS.compute_driver self.driver = utils.import_object(compute_driver) @@ -54,7 +68,7 @@ class ComputeManager(manager.Manager): super(ComputeManager, self).__init__(*args, **kwargs) def _update_state(self, context, instance_id): - """Update the state of an instance from the driver info""" + """Update the state of an instance from the driver info.""" # FIXME(ja): include other fields from state? instance_ref = self.db.instance_get(context, instance_id) try: @@ -67,6 +81,7 @@ class ComputeManager(manager.Manager): @defer.inlineCallbacks @exception.wrap_exception def refresh_security_group(self, context, security_group_id, **_kwargs): + """This call passes stright through to the virtualization driver.""" yield self.driver.refresh_security_group(security_group_id) def create_instance(self, context, security_groups=None, **kwargs): @@ -76,9 +91,9 @@ class ComputeManager(manager.Manager): :param context: The security context :param security_groups: list of security group ids to attach to the instance - :param **kwargs: All additional keyword args are treated - as data fields of the instance to be - created + :param kwargs: All additional keyword args are treated + as data fields of the instance to be + created :retval Returns a mapping of the instance information that has just been created @@ -97,13 +112,13 @@ class ComputeManager(manager.Manager): return instance_ref def update_instance(self, context, instance_id, **kwargs): - """Updates the instance in the datastore + """Updates the instance in the datastore. :param context: The security context :param instance_id: ID of the instance to update - :param **kwargs: All additional keyword args are treated - as data fields of the instance to be - updated + :param kwargs: All additional keyword args are treated + as data fields of the instance to be + updated :retval None diff --git a/nova/compute/monitor.py b/nova/compute/monitor.py index 024f3ed3c..22653113a 100644 --- a/nova/compute/monitor.py +++ b/nova/compute/monitor.py @@ -211,8 +211,8 @@ def store_graph(instance_id, filename): # the response we can make our own client that does the actual # request and hands it off to the response parser. s3 = boto.s3.connection.S3Connection( - aws_access_key_id='admin', - aws_secret_access_key='admin', + aws_access_key_id=FLAGS.aws_access_key_id, + aws_secret_access_key=FLAGS.aws_secret_access_key, is_secure=False, calling_format=boto.s3.connection.OrdinaryCallingFormat(), port=FLAGS.s3_port, |
