Skip to content
48 changes: 24 additions & 24 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ pub enum ResourceType {
Dataset,
Disk,
Image,
Instance,
VmInstance,
IpPool,
NetworkInterface,
Rack,
Expand Down Expand Up @@ -590,12 +590,12 @@ pub struct IdentityMetadataUpdateParams {

// Specific API resources

// INSTANCES
// VM INSTANCES

/// Running state of an Instance (primarily: booted or stopped)
/// Running state of a VmInstance (primarily: booted or stopped)
///
/// This typically reflects whether it's starting, running, stopping, or stopped,
/// but also includes states related to the Instance's lifecycle
/// but also includes states related to the VmInstance's lifecycle
#[derive(
Copy,
Clone,
Expand Down Expand Up @@ -676,7 +676,7 @@ impl InstanceState {
}
}

/// Returns true if the given state represents a fully stopped Instance.
/// Returns true if the given state represents a fully stopped VmInstance.
/// This means that a transition from an !is_stopped() state must go
/// through Stopping.
pub fn is_stopped(&self) -> bool {
Expand All @@ -696,7 +696,7 @@ impl InstanceState {
}
}

/// The number of CPUs in an Instance
/// The number of CPUs in a VmInstance
#[derive(Copy, Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct InstanceCpuCount(pub u16);

Expand Down Expand Up @@ -732,21 +732,21 @@ impl From<crate::api::internal::nexus::InstanceRuntimeState>
}
}

/// Client view of an [`Instance`]
/// Client view of an [`VmInstance`]
#[derive(ObjectIdentity, Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct Instance {
pub struct VmInstance {
// TODO is flattening here the intent in RFD 4?
#[serde(flatten)]
pub identity: IdentityMetadata,

/// id for the project containing this Instance
/// id for the project containing this VmInstance
pub project_id: Uuid,

/// number of CPUs allocated for this Instance
/// number of CPUs allocated for this VmInstance
pub ncpus: InstanceCpuCount,
/// memory allocated for this Instance
/// memory allocated for this VmInstance
pub memory: ByteCount,
/// RFC1035-compliant hostname for the Instance.
/// RFC1035-compliant hostname for the VmInstance.
pub hostname: String, // TODO-cleanup different type?

#[serde(flatten)]
Expand Down Expand Up @@ -785,14 +785,14 @@ pub struct Disk {
pub enum DiskState {
/// Disk is being initialized
Creating,
/// Disk is ready but detached from any Instance
/// Disk is ready but detached from any VmInstance
Detached,
/// Disk is being attached to the given Instance
Attaching(Uuid), // attached Instance id
/// Disk is attached to the given Instance
Attached(Uuid), // attached Instance id
/// Disk is being detached from the given Instance
Detaching(Uuid), // attached Instance id
/// Disk is being attached to the given VmInstance
Attaching(Uuid), // attached VmInstance id
/// Disk is attached to the given VmInstance
Attached(Uuid), // attached VmInstance id
/// Disk is being detached from the given VmInstance
Detaching(Uuid), // attached VmInstance id
/// Disk has been destroyed
Destroyed,
/// Disk is unavailable
Expand Down Expand Up @@ -842,13 +842,13 @@ impl DiskState {
}

/// Returns whether the Disk is currently attached to, being attached to, or
/// being detached from any Instance.
/// being detached from any VmInstance.
pub fn is_attached(&self) -> bool {
self.attached_instance_id().is_some()
}

/// If the Disk is attached to, being attached to, or being detached from an
/// Instance, returns the id for that Instance. Otherwise returns `None`.
/// VmInstance, returns the id for that VmInstance. Otherwise returns `None`.
pub fn attached_instance_id(&self) -> Option<&Uuid> {
match self {
DiskState::Attaching(id) => Some(id),
Expand Down Expand Up @@ -1523,7 +1523,7 @@ pub enum VpcFirewallRuleAction {
Deny,
}

/// A `VpcFirewallRuleTarget` is used to specify the set of [`Instance`]s to
/// A `VpcFirewallRuleTarget` is used to specify the set of [`VmInstance`]s to
/// which a firewall rule applies.
#[derive(
Clone,
Expand Down Expand Up @@ -1843,8 +1843,8 @@ pub struct NetworkInterface {
#[serde(flatten)]
pub identity: IdentityMetadata,

/// The Instance to which the interface belongs.
pub instance_id: Uuid,
/// The VmInstance to which the interface belongs.
pub vm_instance_id: Uuid,

/// The VPC to which the interface belongs.
pub vpc_id: Uuid,
Expand Down
28 changes: 14 additions & 14 deletions common/src/sql/dbinit.sql
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ CREATE UNIQUE INDEX ON omicron.public.project (
time_deleted IS NULL;

/*
* Instances
* Vm Instances
*/

CREATE TYPE omicron.public.instance_state AS ENUM (
Expand All @@ -430,21 +430,21 @@ CREATE TYPE omicron.public.instance_state AS ENUM (

/*
* TODO consider how we want to manage multiple sagas operating on the same
* Instance -- e.g., reboot concurrent with destroy or concurrent reboots or the
* like. Or changing # of CPUs or memory size.
* VmInstance -- e.g., reboot concurrent with destroy or concurrent reboots or
* the like. Or changing # of CPUs or memory size.
*/
CREATE TABLE omicron.public.instance (
CREATE TABLE omicron.public.vm_instance (
/* Identity metadata (resource) */
id UUID PRIMARY KEY,
name STRING(63) NOT NULL,
description STRING(512) NOT NULL,
time_created TIMESTAMPTZ NOT NULL,
time_modified TIMESTAMPTZ NOT NULL,
/* Indicates that the object has been deleted */
/* This is redundant for Instances, but we keep it here for consistency. */
/* This is redundant for VmInstances, but we keep it here for consistency. */
time_deleted TIMESTAMPTZ,

/* Every Instance is in exactly one Project at a time. */
/* Every VmInstance is in exactly one Project at a time. */
project_id UUID NOT NULL,

/* user data for instance initialization systems (e.g. cloud-init) */
Expand All @@ -461,7 +461,7 @@ CREATE TABLE omicron.public.instance (
/*
* Server where the VM is currently running, if any. Note that when we
* support live migration, there may be multiple servers associated with
* this Instance, but only one will be truly active. Still, consumers of
* this VmInstance, but only one will be truly active. Still, consumers of
* this information should consider whether they also want to know the other
* servers involved in the migration.
*/
Expand All @@ -478,13 +478,13 @@ CREATE TABLE omicron.public.instance (
*/
migration_id UUID,

/* Instance configuration */
/* VmInstance configuration */
ncpus INT NOT NULL,
memory INT NOT NULL,
hostname STRING(63) NOT NULL
);

CREATE UNIQUE INDEX ON omicron.public.instance (
CREATE UNIQUE INDEX ON omicron.public.vm_instance (
project_id,
name
) WHERE
Expand Down Expand Up @@ -549,7 +549,7 @@ CREATE TABLE omicron.public.disk (
disk_state STRING(15) NOT NULL,
/*
* Every Disk may be attaching to, attached to, or detaching from at most
* one Instance at a time.
* one VmInstance at a time.
*/
attach_instance_id UUID,
state_generation INT NOT NULL,
Expand Down Expand Up @@ -760,11 +760,11 @@ CREATE TABLE omicron.public.network_interface (
/* Indicates that the object has been deleted */
time_deleted TIMESTAMPTZ,

/* FK into Instance table.
/* FK into VmInstance table.
* Note that interfaces are always attached to a particular instance.
* IP addresses may be reserved, but this is a different resource.
*/
instance_id UUID NOT NULL,
vm_instance_id UUID NOT NULL,

/* FK into VPC table */
vpc_id UUID NOT NULL,
Expand Down Expand Up @@ -819,7 +819,7 @@ CREATE UNIQUE INDEX ON omicron.public.network_interface (
time_deleted IS NULL;

/*
* Index used to verify that an Instance's networking is contained
* Index used to verify that a VmInstance's networking is contained
* within a single VPC, and that all interfaces are in unique VPC
* Subnets.
*
Expand All @@ -828,7 +828,7 @@ CREATE UNIQUE INDEX ON omicron.public.network_interface (
* mostly used when setting a new primary interface for an instance.
*/
CREATE UNIQUE INDEX ON omicron.public.network_interface (
instance_id,
vm_instance_id,
name
)
STORING (vpc_id, subnet_id, is_primary)
Expand Down
4 changes: 2 additions & 2 deletions nexus/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use uuid::Uuid;
mod disk;
mod iam;
mod image;
mod instance;
mod ip_pool;
mod organization;
mod oximeter;
Expand All @@ -35,6 +34,7 @@ mod silo;
mod sled;
pub mod test_interfaces;
mod update;
mod vm_instance;
mod vpc;
mod vpc_router;
mod vpc_subnet;
Expand Down Expand Up @@ -88,7 +88,7 @@ pub struct Nexus {
/// The tunable parameters from a configuration file
tunables: config::Tunables,

/// Operational context used for Instance allocation
/// Operational context used for VmInstance allocation
opctx_alloc: OpContext,

/// Operational context used for external request authentication
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/instance_migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use super::instance_create::allocate_sled_ipv6;
use super::vm_instance_create::allocate_sled_ipv6;
use super::{impl_authenticated_saga_params, saga_generate_uuid};
use crate::authn;
use crate::context::OpContext;
Expand Down
6 changes: 3 additions & 3 deletions nexus/src/app/sagas/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use uuid::Uuid;

pub mod disk_create;
pub mod disk_delete;
pub mod instance_create;
pub mod instance_migrate;
pub mod vm_instance_create;

// We'll need a richer mechanism for registering sagas, but this works for now.
lazy_static! {
Expand All @@ -35,8 +35,8 @@ fn all_templates(
) -> BTreeMap<&'static str, Arc<dyn SagaTemplateGeneric<Arc<SagaContext>>>> {
vec![
(
instance_create::SAGA_NAME,
Arc::clone(&instance_create::SAGA_TEMPLATE)
vm_instance_create::SAGA_NAME,
Arc::clone(&vm_instance_create::SAGA_TEMPLATE)
as Arc<dyn SagaTemplateGeneric<Arc<SagaContext>>>,
),
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ async fn sic_create_instance_record(
time_updated: Utc::now(),
};

let new_instance = db::model::Instance::new(
let new_instance = db::model::VmInstance::new(
instance_id,
params.project_id,
&params.create_params,
Expand Down Expand Up @@ -673,7 +673,7 @@ async fn sic_delete_instance_record(
// failed, so update the state accordingly to allow deletion.
let (.., authz_instance, db_instance) = LookupPath::new(&opctx, &datastore)
.project_id(params.project_id)
.instance_name(&instance_name)
.vm_instance_name(&instance_name)
.fetch()
.await
.map_err(ActionError::action_failed)?;
Expand Down Expand Up @@ -728,7 +728,7 @@ async fn sic_instance_ensure(

let (.., authz_instance, db_instance) = LookupPath::new(&opctx, &datastore)
.project_id(params.project_id)
.instance_name(&instance_name)
.vm_instance_name(&instance_name)
.fetch()
.await
.map_err(ActionError::action_failed)?;
Expand Down
Loading