# UpCloud

Ops can integrate with your existing UpCloud account. You can use Ops CLI to create and upload an image in UpCloud account. Once, you have uploaded image, you can also create an instance with a particular image using CLI.

## Pre-requisites

1. Create an UpCloud account (<https://upcloud.com/signup/>).
2. Set next environment variables.

```sh
$ export UPCLOUD_USER=<your account username>

$ export UPCLOUD_PASSWORD=<your account password>

$ export UPCLOUD_ZONE=<location of your images and instances>
```

**Note:** Check the available zones in [Upcloud Documentation](https://developers.upcloud.com/1.2/5-zones/).

You also need to enable API access:

![enabling upcloud api](https://github.com/nanovms/ops-documentation/blob/master/upcloud_api.png)

## Image Operations

Images for UpCloud are created by directly creating storage through the api not by uploading to a bucket.

### Create Image

You can create an image in UpCloud with the following command.

```sh
$ ops image create <elf_file> -i <image_name> -t upcloud
```

Note: Creating an image can take a while in certain regions. There is a default timeout of 10min but can be adjusted via <https://github.com/nanovms/ops/blob/master/provider/upcloud/upcloud.go#L68> . You can see the status live via <https://hub.upcloud.com/storage/devices> as well.

For creating an image using a particular package, you need to provide the package name to `ops image create` command with `-p` option.

```sh
$ ops image create -c config.json -p node_v14.2.0 -a ex.js -i <image_name> -t upcloud
```

### List Images

You can list existing images on Upcloud with `ops image list -t upcloud`.

```sh
$ ops image list -t upcloud
+--------------------------------------+------------------------+--------+---------+------------------+
|                 UUID                 |          NAME          | STATUS |  SIZE   |    CREATEDAT     |
+--------------------------------------+------------------------+--------+---------+------------------+
| 01071a8d-eb59-49c1-aa69-028f84cc6d06 | nanos-main-image       | online | 10.0 GB | 3 days ago       |
+--------------------------------------+------------------------+--------+---------+------------------+
| 01c5bd28-aa19-4883-a4c9-31f3ff9fd061 | nanos-node-image       | online | 10.0 GB | 1 month ago      |
+--------------------------------------+------------------------+--------+---------+------------------+
| 01cd3190-df52-47e8-b5c3-b05f7107819e | nanos-server-image     | online | 10.0 GB | 1 year ago       |
+--------------------------------------+------------------------+--------+---------+------------------+
```

### Delete Image

`ops image delete <imagename>` can be used to delete an image from UpCloud.

```
$ ops delete image nanos-main-image -t upcloud
```

## Instance Operations

### Create Instance

After the successful creation of an image in UpCloud, we can create an instance from an existing image.

```sh
$ ops instance create <image_name> -t upcloud
```

### List Instances

You can list instance on UpCloud using `ops instance list` command.

```sh
$ ops instance list -t upcloud
+--------------------------------------+------------------------+---------+-------------+-----------------------------------------+
|                  ID                  |          NAME          | STATUS  | PRIVATE IPS |               PUBLIC IPS                |
+--------------------------------------+------------------------+---------+-------------+-----------------------------------------+
| 00d954cc-9603-43a0-915b-5c2ae75772b6 | nanos-main-image-15566 | stopped | 10.8.3.63   | 209.151.144.166                         |
+--------------------------------------+------------------------+---------+-------------+-----------------------------------------+
```

### Get Logs for Instance

Work in progress.

### Delete Instance

`ops instance delete` command can be used to delete instance on UpCloud.

```sh
$ ops instance delete my-instance-running -t upcloud
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ops.city/ops/clouds/upcloud.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
