~citrix-openstack/nova/xenapi

« back to all changes in this revision

Viewing changes to nova/compute/disk.py

  • Committer: Tarmac
  • Author(s): Todd Willey, root, Vishvananda Ishaya, Joe Heck, root, Andy Smith, Anne Gentle, Dean Troyer, Devin Carlen
  • Date: 2010-11-16 02:34:47 UTC
  • mfrom: (386.2.71 trunkdoc)
  • Revision ID: hudson@openstack.org-20101116023447-pz7n6ps5rf0fnjea
Lots of documentation and docstring updates.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
16
#    License for the specific language governing permissions and limitations
17
17
#    under the License.
18
 
 
19
18
"""
20
19
Utility methods to resize, repartition, and modify disk images.
 
20
 
21
21
Includes injection of SSH PGP keys into authorized_keys file.
 
22
 
22
23
"""
23
24
 
24
25
import logging
41
42
@defer.inlineCallbacks
42
43
def partition(infile, outfile, local_bytes=0, resize=True,
43
44
              local_type='ext2', execute=None):
44
 
    """Takes a single partition represented by infile and writes a bootable
45
 
    drive image into outfile.
 
45
    """
 
46
    Turns a partition (infile) into a bootable drive image (outfile).
46
47
 
47
48
    The first 63 sectors (0-62) of the resulting image is a master boot record.
48
49
    Infile becomes the first primary partition.
49
50
    If local bytes is specified, a second primary partition is created and
50
51
    formatted as ext2.
51
52
 
52
 
    In the diagram below, dashes represent drive sectors.
53
 
    +-----+------. . .-------+------. . .------+
54
 
    | 0  a| b               c|d               e|
55
 
    +-----+------. . .-------+------. . .------+
56
 
    | mbr | primary partiton | local partition |
57
 
    +-----+------. . .-------+------. . .------+
 
53
    ::
 
54
 
 
55
        In the diagram below, dashes represent drive sectors.
 
56
        +-----+------. . .-------+------. . .------+
 
57
        | 0  a| b               c|d               e|
 
58
        +-----+------. . .-------+------. . .------+
 
59
        | mbr | primary partiton | local partition |
 
60
        +-----+------. . .-------+------. . .------+
 
61
 
58
62
    """
59
63
    sector_size = 512
60
64
    file_size = os.path.getsize(infile)