コード例 #1
0
def create_servers(size=SIZE, total=PERFORMERS):
    """create some servers"""

    # get the last server number
    servers = get_servers()
    if len(servers) > 0:
        names = [s.title for s in servers]
        nums = sorted([int(n.split("-")[-1]) for n in names], reverse=True)
        start = nums[0] + 1
    else:
        start = 0

    template_id = get_image()

    for i in range(start, start + total):
        name = f"{NAME}-{i}"
        server = upcloud_api.Server(
            plan=SIZE,
            hostname=name,
            zone="us-nyc1",
            storage_devices=[
                upcloud_api.Storage(uuid=template_id, size=80),
            ],
        )
        manager.create_server(server)
コード例 #2
0
ファイル: servers.py プロジェクト: mklatsky/homebrew-yucc
    def do_command(self):
        loaded_ssh_key = self._load_ssh_keyfile(self.ssh_key)
        user_block = upcloud_api.login_user_block(username=self.login_user,
                                                  ssh_keys=[loaded_ssh_key],
                                                  create_password=False)

        server = upcloud_api.Server(
            plan=self.plan,
            hostname=self.hostname,
            zone=self.zone,
            storage_devices=[upcloud_api.Storage(os=self.os, size=10)],
            login_user=user_block)
        created_server = self._sdk_call(
            lambda: self._manager.create_server(server))
        if self.ensure_started:
            self._sdk_call(lambda: created_server.ensure_started())

        self._output = {'uuid': created_server.uuid}
コード例 #3
0
    text=True,
)
ssh_key_value = res.stdout.strip()
rtmp_user_desc = up.login_user_block(
    username='******',
    ssh_keys=[ssh_key_value],
    create_password=False,
)

rtmp_server_desc = up.Server(
    core_number=upcloud_cores,  # CPU cores
    memory_amount=upcloud_ram,  # RAM in MB
    zone=upcloud_region,
    title='Multiservice RTMP Broadcaster',
    # UpCloud strangely requires that every server have a qualified domain
    # name. (?!) Using a totaly made up name here.
    hostname='multiservice-rtmp-server.com',
    storage_devices=[
        up.Storage(os='Ubuntu 18.04', size=upcloud_disk),
    ],
    login_user=rtmp_user_desc,  # user and ssh-keys
    user_data=INIT_SCRIPT,
)

print('Starting creation of server with these parameters:')
print('    cores = {0}\n'
      '    RAM = {1} MB\n'
      '    disk = {2} GB\n'
      '    region = {3}'.format(upcloud_cores, upcloud_ram, upcloud_disk,
                                upcloud_region))
rtmp_server = manager.create_server(rtmp_server_desc)
ip_addr = rtmp_server.get_ip()