コード例 #1
0
    def create_standard_config(self, uuid, name, mem_kb, vcpus, disk, mac):
        # First, populate the XML with the appropriate values.
        boot_params = { 'name'       : name,
                        'mem_kb'     : mem_kb,
                        'vcpus'      : vcpus,
                        'uuid'       : hyphenize_uuid(uuid),
                        'disk'       : disk,
                        'mac'        : mac }

        xml = STANDARD_CONFIG_TEMPLATE % boot_params

        self.__write_xml_file(uuid, xml)
コード例 #2
0
def _get_domain(uuid):
    """
    Lookup the domain by its UUID.  If not found, raise an exception.
    """
    conn = libvirt.open(None)
    domain = None
    hyphenized_uuid = hyphenize_uuid(uuid)
    try:
        domain = conn.lookupByUUIDString(hyphenized_uuid)
    except libvirt.libvirtError, lve:
        raise VirtualizationException, \
              "Domain UUID '%s' not found: %s" (hyphenized_uuid, str(lve)), sys.exc_info()[2]
コード例 #3
0
def _get_domain(uuid):
    """
    Lookup the domain by its UUID.  If not found, raise an exception.
    """
    conn = libvirt.open(None)
    domain = None
    hyphenized_uuid = hyphenize_uuid(uuid)
    try:
        domain = conn.lookupByUUIDString(hyphenized_uuid)
    except libvirt.libvirtError, lve:
        raise VirtualizationException, \
              "Domain UUID '%s' not found: %s", (hyphenized_uuid, str(lve))
コード例 #4
0
    def create_standard_config(self, uuid, name, mem_kb, vcpus, disk, mac):
        # First, populate the XML with the appropriate values.
        boot_params = { 'name'       : name,
                        'mem_kb'     : mem_kb,
                        'vcpus'      : vcpus,
                        'uuid'       : hyphenize_uuid(uuid),
                        'disk'       : disk,
                        'mac'        : mac }

        xml = STANDARD_CONFIG_TEMPLATE % boot_params

        self.__write_xml_file(uuid, xml)
コード例 #5
0
def _get_domain(uuid):
    """
    Lookup the domain by its UUID.  If not found, raise an exception.
    """
    conn = libvirt.open(None)
    domain = None
    hyphenized_uuid = hyphenize_uuid(uuid)
    try:
        domain = conn.lookupByUUIDString(hyphenized_uuid)
    except libvirt.libvirtError:
        lve = sys.exc_info()[1]
        raise_with_tb(VirtualizationException("Domain UUID '%s' not found: %s" % (hyphenized_uuid, str(lve))),
                      sys.exc_info()[2])
    return (conn, domain)
コード例 #6
0
    def create_standard_config(self, uuid, name, mem_kb, vcpus, disk, mac):
        # First, populate the XML with the appropriate values.
        boot_params = {
            "name": name,
            "mem_kb": mem_kb,
            "vcpus": vcpus,
            "uuid": hyphenize_uuid(uuid),
            "disk": disk,
            "mac": mac,
        }

        xml = STANDARD_CONFIG_TEMPLATE % boot_params

        self.__write_xml_file(uuid, xml)
コード例 #7
0
ファイル: poller.py プロジェクト: adelton/spacewalk
def poll_state(uuid):
    """
    Polls just the state of the guest with the provided UUID.  This state is
    returned.
    """
    conn = libvirt.openReadOnly(None)
    if not conn:
        raise VirtualizationException, \
              "Failed to open connection to hypervisor."

    # Attempt to connect to the domain.  Since there is technically no
    # "stopped" state, we will assume that if we cannot connect the domain is
    # not running.  Unfortunately, we can't really determine if the domain
    # actually exists.
    domain = None
    try:
        domain = conn.lookupByUUIDString(hyphenize_uuid(uuid))
    except libvirt.libvirtError, lve:
        # Can't find domain.  Return stopped state.
        return State(None)
コード例 #8
0
ファイル: poller.py プロジェクト: dmacvicar/spacewalk
def poll_state(uuid):
    """
    Polls just the state of the guest with the provided UUID.  This state is
    returned.
    """
    conn = libvirt.openReadOnly(None)
    if not conn:
        raise VirtualizationException, \
              "Failed to open connection to hypervisor."

    # Attempt to connect to the domain.  Since there is technically no
    # "stopped" state, we will assume that if we cannot connect the domain is
    # not running.  Unfortunately, we can't really determine if the domain
    # actually exists.
    domain = None
    try:
        domain = conn.lookupByUUIDString(hyphenize_uuid(uuid))
    except libvirt.libvirtError, lve:
        # Can't find domain.  Return stopped state.
        return State(None)
コード例 #9
0
def _begin_domain_installation(connection,
                               name,
                               install_kernel_path,
                               install_initrd_path,
                               extra_append,
                               mem_kb,
                               vcpus,
                               uuid,
                               disk_image_path,
                               disk_image_type,
                               mac):
    """
    Creates and begins installation of the Xen instance.
    """

    syslog = 'syslog=%s:%s' % (socket.gethostname(), SYSLOG_PORT)

    if DEBUG:
        syslog  = ''

    create_params = { 'name'           : name,
                      'install_kernel' : install_kernel_path,
                      'install_initrd' : install_initrd_path,
                      'extra'          : extra_append,
                      'mem_kb'         : mem_kb,
                      'vcpus'          : vcpus,
                      'uuid'           : hyphenize_uuid(uuid),
                      'disk'           : disk_image_path,
                      'mac'            : mac,
                      'syslog'         : syslog}

    create_xml = XEN_CREATE_TEMPLATE % create_params

    # Now actually create the domain.
    domain = None
    try:
        domain = connection.createLinux(create_xml, 0)
    except Exception, e:
        raise VirtualizationKickstartException, \
              "Error occurred while attempting to create domain %s: %s" % \
                  (name, str(e)), sys.exc_info()[2]
コード例 #10
0
ファイル: kickstart_guest.py プロジェクト: lpramuk/spacewalk
def _begin_domain_installation(connection,
                               name,
                               install_kernel_path,
                               install_initrd_path,
                               extra_append,
                               mem_kb,
                               vcpus,
                               uuid,
                               disk_image_path,
                               disk_image_type,
                               mac):
    """
    Creates and begins installation of the Xen instance.
    """

    syslog = 'syslog=%s:%s' % (socket.gethostname(), SYSLOG_PORT)

    if DEBUG:
        syslog  = ''

    create_params = { 'name'           : name,
                      'install_kernel' : install_kernel_path,
                      'install_initrd' : install_initrd_path,
                      'extra'          : extra_append,
                      'mem_kb'         : mem_kb,
                      'vcpus'          : vcpus,
                      'uuid'           : hyphenize_uuid(uuid),
                      'disk'           : disk_image_path,
                      'mac'            : mac,
                      'syslog'         : syslog}

    create_xml = XEN_CREATE_TEMPLATE % create_params

    # Now actually create the domain.
    domain = None
    try:
        domain = connection.createLinux(create_xml, 0)
    except Exception, e:
        raise VirtualizationKickstartException, \
              "Error occurred while attempting to create domain %s: %s" % \
                  (name, str(e)), sys.exc_info()[2]