Struct zone::Config

source ·
pub struct Config { /* private fields */ }
Expand description

Entry point for zonecfg commands.

This struct can be used to construct arguments to the underlying zonecfg command. It does not actually issue any commands to the underlying utility until [Config::run] is issued.

Examples

Creation of a new zone.

let mut cfg = zone::Config::create(
    /* zone name= */ "myzone",
    /* overwrite= */ true,
    zone::CreationOptions::Default);

cfg.get_global()
   .set_path("/my/path")
   .set_autoboot(false);
cfg.add_fs(&zone::Fs {
    ty: "lofs".to_string(),
    dir: "/usr/local".to_string(),
    special: "/opt/local".to_string(),
    ..Default::default()
});

// Issues the previously enqueued operations to zonecfg.
cfg.run_blocking().unwrap();

Selection and modification of an existing zone.

let mut cfg = zone::Config::new("myzone");

// Clear the hostid.
cfg.get_global().set_hostid(None);

// Select an existing attribute and modify.
cfg.select_net_by_physical("eth0")
   .set_allowed_address(Some("127.0.0.1".to_string()));

// Remove all resources relating to capped memory.
cfg.remove_all_capped_memory();

// Issues the previously enqueued operations to zonecfg.
cfg.run_blocking().unwrap();

Implementations§

source§

impl Config

source

pub fn get_global(&mut self) -> GlobalScope<'_>

Acquire a reference to the global resource scope. This scope allows callers to safely set values within the Global object.

source§

impl Config

source

pub fn add_fs(&mut self, values: &Fs) -> FsScope<'_>

Creates a new scope from a Fs object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_fs(&mut self)

Deletes resources associated with the Fs object.

source§

impl Config

source

pub fn select_fs_by_type(&mut self, value: impl Into<String>) -> FsScope<'_>

Generated selector for the Fs resource.

Allows the selection of an existing resource for modification with a matching value of Fs::ty.

source

pub fn remove_fs_by_type(&mut self, value: impl Into<String>)

Generated removal function for the Fs resource

Allows the removal of all existing resources with a matching value of Fs::ty.

source§

impl Config

source

pub fn select_fs_by_dir(&mut self, value: impl Into<String>) -> FsScope<'_>

Generated selector for the Fs resource.

Allows the selection of an existing resource for modification with a matching value of Fs::dir.

source

pub fn remove_fs_by_dir(&mut self, value: impl Into<String>)

Generated removal function for the Fs resource

Allows the removal of all existing resources with a matching value of Fs::dir.

source§

impl Config

source

pub fn select_fs_by_special(&mut self, value: impl Into<String>) -> FsScope<'_>

Generated selector for the Fs resource.

Allows the selection of an existing resource for modification with a matching value of Fs::special.

source

pub fn remove_fs_by_special(&mut self, value: impl Into<String>)

Generated removal function for the Fs resource

Allows the removal of all existing resources with a matching value of Fs::special.

source§

impl Config

source

pub fn add_net(&mut self, values: &Net) -> NetScope<'_>

Creates a new scope from a Net object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_net(&mut self)

Deletes resources associated with the Net object.

source§

impl Config

source

pub fn select_net_by_physical( &mut self, value: impl Into<String> ) -> NetScope<'_>

Generated selector for the Net resource.

Allows the selection of an existing resource for modification with a matching value of Net::physical.

source

pub fn remove_net_by_physical(&mut self, value: impl Into<String>)

Generated removal function for the Net resource

Allows the removal of all existing resources with a matching value of Net::physical.

source§

impl Config

source

pub fn add_device(&mut self, values: &Device) -> DeviceScope<'_>

Creates a new scope from a Device object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_device(&mut self)

Deletes resources associated with the Device object.

source§

impl Config

source

pub fn add_rctl(&mut self, values: &Rctl) -> RctlScope<'_>

Creates a new scope from a Rctl object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_rctl(&mut self)

Deletes resources associated with the Rctl object.

source§

impl Config

source

pub fn select_rctl_by_name(&mut self, value: impl Into<String>) -> RctlScope<'_>

Generated selector for the Rctl resource.

Allows the selection of an existing resource for modification with a matching value of Rctl::name.

source

pub fn remove_rctl_by_name(&mut self, value: impl Into<String>)

Generated removal function for the Rctl resource

Allows the removal of all existing resources with a matching value of Rctl::name.

source§

impl Config

source

pub fn add_attr(&mut self, values: &Attr) -> AttrScope<'_>

Creates a new scope from a Attr object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_attr(&mut self)

Deletes resources associated with the Attr object.

source§

impl Config

source

pub fn select_attr_by_name(&mut self, value: impl Into<String>) -> AttrScope<'_>

Generated selector for the Attr resource.

Allows the selection of an existing resource for modification with a matching value of Attr::name.

source

pub fn remove_attr_by_name(&mut self, value: impl Into<String>)

Generated removal function for the Attr resource

Allows the removal of all existing resources with a matching value of Attr::name.

source§

impl Config

source

pub fn add_dataset(&mut self, values: &Dataset) -> DatasetScope<'_>

Creates a new scope from a Dataset object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_dataset(&mut self)

Deletes resources associated with the Dataset object.

source§

impl Config

source

pub fn add_dedicated_cpu( &mut self, values: &DedicatedCpu ) -> DedicatedCpuScope<'_>

Creates a new scope from a DedicatedCpu object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_dedicated_cpu(&mut self)

Deletes resources associated with the DedicatedCpu object.

source§

impl Config

source

pub fn add_capped_memory( &mut self, values: &CappedMemory ) -> CappedMemoryScope<'_>

Creates a new scope from a CappedMemory object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_capped_memory(&mut self)

Deletes resources associated with the CappedMemory object.

source§

impl Config

source

pub fn add_capped_cpu(&mut self, values: &CappedCpu) -> CappedCpuScope<'_>

Creates a new scope from a CappedCpu object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_capped_cpu(&mut self)

Deletes resources associated with the CappedCpu object.

source§

impl Config

source

pub fn add_security_flags( &mut self, values: &SecurityFlags ) -> SecurityFlagsScope<'_>

Creates a new scope from a SecurityFlags object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_security_flags(&mut self)

Deletes resources associated with the SecurityFlags object.

source§

impl Config

source

pub fn add_admin(&mut self, values: &Admin) -> AdminScope<'_>

Creates a new scope from a Admin object. This begins specification for the resource, and returns an object which represents the new scope.

source

pub fn remove_all_admin(&mut self)

Deletes resources associated with the Admin object.

source§

impl Config

source

pub fn select_admin_by_user( &mut self, value: impl Into<String> ) -> AdminScope<'_>

Generated selector for the Admin resource.

Allows the selection of an existing resource for modification with a matching value of Admin::user.

source

pub fn remove_admin_by_user(&mut self, value: impl Into<String>)

Generated removal function for the Admin resource

Allows the removal of all existing resources with a matching value of Admin::user.

source§

impl Config

source

pub fn new(name: impl AsRef<str>) -> Self

Instantiate a zone configuration object, wrapping an existing zone.

source

pub fn create( name: impl AsRef<str>, overwrite: bool, options: CreationOptions ) -> Self

Creates a new zone with the provided name.

  • overwrite specifies if the new zone should overwrite any existing zone with the same name, if one exists.
  • options specifies background information about the zone.

This method does not execute zonecfg until [Config::run] is invoked.

source

pub fn export(&mut self, p: impl AsRef<Path>) -> &mut Self

Enqueues a command to export the zone configuration to a specified path.

This method does not execute zonecfg until [Config::run] is invoked.

source

pub fn delete(&mut self, force: bool) -> &mut Self

Enqueues a command to delete the zone configuration.

This method does not execute zonecfg until [Config::run] is invoked.

source

pub fn as_command(&mut self) -> Command

Creates a Command which can be executed to send the queued command to the host.

Addiitonally, clears the previously queued arguments.

source

pub fn parse_output(output: &Output) -> Result<String, ZoneError>

Parses the output from a command which was emitted from Self::as_command.

source

pub fn run_blocking(&mut self) -> Result<String, ZoneError>

Executes the queued commands for the zone, and clears the current queued arguments.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.