Skip to main content

Server

The Server class represents an OpenStack server (virtual machine) instance and provides access to server properties including status, flavor, image, user, and hypervisor information.

Constructor

Server(server_id=None, name=None, cloud=Cloud())
server_id
str
The unique identifier for the server. Use either server_id or name to identify the server.
name
str
The name of the server. Use either server_id or name to identify the server.
cloud
Cloud
default:"Cloud()"
The Cloud instance to use for API calls. Defaults to a new Cloud() instance.

Properties

name
str
Returns the name associated to this Server
server = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
print(server.name)
id
str
Returns the server_id associated to this Server
server = Server(name="my-server")
print(server.id)
status
str
Returns the status of this Server (e.g., “ACTIVE”, “SHUTOFF”, “ERROR”)
server = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
print(f"Server status: {server.status}")
flavor
Flavor
Returns the Flavor of this Server
server = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
flavor = server.flavor
print(f"Flavor: {flavor.name}")
image
Image
Returns the Image of this Server
server = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
image = server.image
print(f"Image: {image.name}")
user
User
Returns the User who created this Server
server = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
user = server.user
print(f"Created by: {user.name}")
hypervisor
Hypervisor
Returns the Hypervisor where this Server is running
server = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
hypervisor = server.hypervisor
print(f"Running on: {hypervisor.hostname}")

Usage Example

from myos.server import Server
from myos.cloud import Cloud

# Initialize server by ID
server = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
print(f"Server name: {server.name}")
print(f"Server ID: {server.id}")
print(f"Status: {server.status}")

# Initialize server by name
server = Server(name="vwn-gpu-2025-12-17-13-17-19-0")
print(f"Server ID: {server.id}")

# Get server details
flavor = server.flavor
print(f"Flavor: {flavor.name} (ID: {flavor.id})")

image = server.image
print(f"Image: {image.name} (ID: {image.id})")

# Get user information
user = server.user
print(f"Created by: {user.name}")
print(f"User email: {user.email}")

# Get hypervisor information
hypervisor = server.hypervisor
print(f"Running on hypervisor: {hypervisor.hostname}")

# Use custom cloud configuration
custom_cloud = Cloud("production")
server = Server(name="prod-server-01", cloud=custom_cloud)
if server.status == "ACTIVE":
    print(f"Server {server.name} is running")
elif server.status == "SHUTOFF":
    print(f"Server {server.name} is shut down")

Build docs developers (and LLMs) love