Overview
The Server class provides comprehensive access to VM instance information, including its configuration, owner, and the hypervisor where it’s running.
Basic Server Lookup
Retrieve server information by ID:
from myos.server import Server
server = Server( server_id = '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b' )
print (server.name)
# Output: 'vwn-gpu-2025-12-05-21-03-17-0'
print (server.id)
# Output: '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b'
You can initialize a Server by either server_id or name.
Server Owner
Access the user who created the server:
from myos.server import Server
server = Server( server_id = '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b' )
print (server.user.email)
# Output: '[email protected] '
print (server.user.name)
# Output: 'wup22514'
The user property returns a full User object, so you can access all user properties and methods.
Server Flavor
Get detailed flavor information including CPU, RAM, and disk:
Server Flavor Details
Output
from myos.server import Server
server = Server( server_id = '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b' )
print (server.flavor.name)
print ( f "CPU: { server.flavor.cpu } " )
print ( f "RAM: { server.flavor.ram } MB" )
print ( f "Disk: { server.flavor.disk } GB" )
Server Image
Access the image used to create the server:
from myos.server import Server
server = Server( server_id = '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b' )
print (server.image.name)
# Output: 'rocky-8-aqml'
print (server.image.id)
# Output: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890'
Server Status
Check the current status of a server:
from myos.server import Server
server = Server( server_id = '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b' )
print (server.status)
# Output: 'ACTIVE' (or 'SHUTOFF', 'ERROR', etc.)
Hypervisor Location
Find out which hypervisor is hosting the server:
from myos.server import Server
server = Server( server_id = '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b' )
print (server.hypervisor.hostname)
# Output: 'hv-a100x8-8.matrix.net'
print (server.hypervisor.status)
# Output: 'enabled'
The hypervisor property returns a full Hypervisor object, allowing you to query other servers on the same host.
Here’s a comprehensive example showing all server details:
from myos.server import Server
def print_server_details ( server_id ):
"""Print complete server information"""
server = Server( server_id = server_id)
print ( f "Server Details:" )
print ( f " Name: { server.name } " )
print ( f " ID: { server.id } " )
print ( f " Status: { server.status } " )
print ( f " \n Owner:" )
print ( f " Name: { server.user.name } " )
print ( f " Email: { server.user.email } " )
print ( f " Domain: { server.user.domain.name } " )
print ( f " \n Flavor:" )
print ( f " Name: { server.flavor.name } " )
print ( f " CPUs: { server.flavor.cpu } " )
print ( f " RAM: { server.flavor.ram } MB" )
print ( f " Disk: { server.flavor.disk } GB" )
print ( f " \n Image:" )
print ( f " Name: { server.image.name } " )
print ( f " ID: { server.image.id } " )
print ( f " \n Hypervisor:" )
print ( f " Hostname: { server.hypervisor.hostname } " )
print ( f " Status: { server.hypervisor.status } " )
print ( f " State: { server.hypervisor.state } " )
# Run the details
print_server_details( '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b' )
Working with Server Collections
When working with multiple servers from a project or user:
from myos.project import Project
project = Project( name = 'Condor' )
servers = project.servers
for server in servers:
print ( f " { server.name } :" )
print ( f " Status: { server.status } " )
print ( f " Flavor: { server.flavor.name } " )
print ( f " Owner: { server.user.email } " )
print ( f " Hypervisor: { server.hypervisor.hostname } " )
print ()
Each property access makes an API call. If you’re working with many servers, consider caching frequently accessed data.
Filtering Servers by Property
Use EntityList filtering to find specific servers:
from myos.project import Project
project = Project( name = 'Condor' )
servers = project.servers
# Find all servers using a specific flavor
gpu_servers = servers.filter( lambda s : 'gpu' in s.flavor.name.lower())
print ( f "GPU servers: { len (gpu_servers) } " )
for server in gpu_servers:
print ( f " - { server.name } ( { server.flavor.name } )" )
Finding Servers by Image
Get all servers using a specific image:
from myos.image import Image
image = Image( name = 'rocky-8-aqml' )
servers = image.servers
print ( f "Servers using { image.name } : { len (servers) } " )
for server in servers:
print ( f " - { server.name } " )
Finding Servers by Flavor
Get all servers using a specific flavor:
from myos.flavor import Flavor
flavor = Flavor( name = 'g-a100-80gb-2022.x1' )
servers = flavor.servers
print ( f "Servers using { flavor.name } : { len (servers) } " )
for server in servers:
print ( f " - { server.name } " )
print ( f " Owner: { server.user.email } " )
Using Different Clouds
Query servers from a different cloud:
from myos.server import Server
from myos.cloud import Cloud
dev_cloud = Cloud( "admin-dev" )
server = Server( server_id = '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b' , cloud = dev_cloud)
print (server.name)
print (server.status)
Resource Relationships
The Server object connects to many other resources:
from myos.server import Server
server = Server( server_id = '79b3b46d-c7d8-47d2-a59d-ce5ded79b63b' )
# Get other servers owned by the same user
user_servers = server.user.servers
print ( f "User has { len (user_servers) } servers total" )
# Get other servers on the same hypervisor
hv_servers = server.hypervisor.servers
print ( f "Hypervisor hosts { len (hv_servers) } servers total" )
# Get other servers using the same image
image_servers = server.image.servers
print ( f " { len (image_servers) } servers use this image" )
These relationship properties make it easy to explore your cloud infrastructure and understand resource usage patterns.
Available Properties
Property Type Description namestr Server name idstr Server unique identifier statusstr Current server status (ACTIVE, SHUTOFF, etc.) userUser User who created the server flavorFlavor Server flavor with CPU/RAM/disk specs imageImage Image used to create the server hypervisorHypervisor Hypervisor hosting the server
Next Steps