コード例 #1
0
ファイル: api.py プロジェクト: tpot/dwarf
def _route_os_keypairs_name(dummy_tenant_id, keypair_name):
    """
    Route:  /v1.1/<dummy_tenant_id>/os-keypairs/<keypair_name>
    Method: DELETE
    """
    utils.show_request(bottle.request)

    KEYPAIRS.delete(keypair_name)
コード例 #2
0
ファイル: api.py プロジェクト: tpot/dwarf
def _route_os_keypairs(dummy_tenant_id):
    """
    Route:  /v1.1/<dummy_tenant_id>/os-keypairs
    Method: GET, POST
    """
    utils.show_request(bottle.request)

    # nova keypair-add
    if bottle.request.method == 'POST':
        body = json.load(bottle.request.body)
        return {'keypair': KEYPAIRS.add(body['keypair'])}

    # nova keypair-list
    return {'keypairs': KEYPAIRS.list()}
コード例 #3
0
ファイル: servers.py プロジェクト: tpot/dwarf
    def boot(self, server):
        """
        Boot a new server
        """
        LOG.info('boot(server=%s)', server)

        name = server['name']
        image_id = server['imageRef']
        flavor_id = server['flavorRef']
        key_name = server.get('key_name', None)

        # Sanity checks, will throw exceptions if they fail
        IMAGES.exists(image_id)
        FLAVORS.exists(flavor_id)
        if key_name is not None:
            KEYPAIRS.exists(key_name)

        # Create a new server in the database
        server = DB.servers.create(name=name, image_id=image_id,
                                   flavor_id=flavor_id, key_name=key_name,
                                   status='BUILDING')
        server_id = server['id']

        # Generate some more server properties and update the database
        mac_address = _generate_mac()
        server = DB.servers.update(id=server_id, mac_address=mac_address)

        # Extend the server details
        server = self._extend(server)

        # Create the server directory
        basepath = os.path.join(CONF.instances_dir, server_id)
        os.makedirs(basepath)

        # Create the server disk images
        _create_disks(server)

        # Finally boot the server
        VIRT.boot_server(server)

        # Update the status of the server
        server = DB.servers.update(id=server_id, status='NETWORKING')

        # Start a task to wait for the server to get its DHCP IP address
        task.start(server_id, 2, 60/2, [True], self._wait_for_ip, server)

        return utils.sanitize(server, SERVERS_DETAIL)