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())
The unique identifier for the server. Use either server_id or name to identify the server.
The name of the server. Use either server_id or name to identify the server.
The Cloud instance to use for API calls. Defaults to a new Cloud() instance.
Properties
Returns the name associated to this Serverserver = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
print(server.name)
Returns the server_id associated to this Serverserver = Server(name="my-server")
print(server.id)
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}")
Returns the Flavor of this Serverserver = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
flavor = server.flavor
print(f"Flavor: {flavor.name}")
Returns the Image of this Serverserver = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
image = server.image
print(f"Image: {image.name}")
Returns the User who created this Serverserver = Server(server_id="79b3b46d-c7d8-47d2-a59d-ce5ded79b63b")
user = server.user
print(f"Created by: {user.name}")
Returns the Hypervisor where this Server is runningserver = 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")