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
impl Config
sourcepub fn get_global(&mut self) -> GlobalScope<'_>
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
impl Config
sourcepub fn select_fs_by_type(&mut self, value: impl Into<String>) -> FsScope<'_>
pub fn select_fs_by_type(&mut self, value: impl Into<String>) -> FsScope<'_>
source§impl Config
impl Config
sourcepub fn select_fs_by_special(&mut self, value: impl Into<String>) -> FsScope<'_>
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.
sourcepub fn remove_fs_by_special(&mut self, value: impl Into<String>)
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
impl Config
sourcepub fn select_net_by_physical(
&mut self,
value: impl Into<String>
) -> NetScope<'_>
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.
sourcepub fn remove_net_by_physical(&mut self, value: impl Into<String>)
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
impl Config
sourcepub fn add_device(&mut self, values: &Device) -> DeviceScope<'_>
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.
sourcepub fn remove_all_device(&mut self)
pub fn remove_all_device(&mut self)
Deletes resources associated with the Device object.
source§impl Config
impl Config
sourcepub fn select_rctl_by_name(&mut self, value: impl Into<String>) -> RctlScope<'_>
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.
sourcepub fn remove_rctl_by_name(&mut self, value: impl Into<String>)
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
impl Config
sourcepub fn select_attr_by_name(&mut self, value: impl Into<String>) -> AttrScope<'_>
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.
sourcepub fn remove_attr_by_name(&mut self, value: impl Into<String>)
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
impl Config
sourcepub fn add_dataset(&mut self, values: &Dataset) -> DatasetScope<'_>
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.
sourcepub fn remove_all_dataset(&mut self)
pub fn remove_all_dataset(&mut self)
Deletes resources associated with the Dataset object.
source§impl Config
impl Config
sourcepub fn add_dedicated_cpu(
&mut self,
values: &DedicatedCpu
) -> DedicatedCpuScope<'_>
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.
sourcepub fn remove_all_dedicated_cpu(&mut self)
pub fn remove_all_dedicated_cpu(&mut self)
Deletes resources associated with the DedicatedCpu object.
source§impl Config
impl Config
sourcepub fn add_capped_memory(
&mut self,
values: &CappedMemory
) -> CappedMemoryScope<'_>
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.
sourcepub fn remove_all_capped_memory(&mut self)
pub fn remove_all_capped_memory(&mut self)
Deletes resources associated with the CappedMemory object.
source§impl Config
impl Config
sourcepub fn add_capped_cpu(&mut self, values: &CappedCpu) -> CappedCpuScope<'_>
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.
sourcepub fn remove_all_capped_cpu(&mut self)
pub fn remove_all_capped_cpu(&mut self)
Deletes resources associated with the CappedCpu object.
source§impl Config
impl Config
sourcepub fn add_security_flags(
&mut self,
values: &SecurityFlags
) -> SecurityFlagsScope<'_>
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.
sourcepub fn remove_all_security_flags(&mut self)
pub fn remove_all_security_flags(&mut self)
Deletes resources associated with the SecurityFlags object.
source§impl Config
impl Config
sourcepub fn add_admin(&mut self, values: &Admin) -> AdminScope<'_>
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.
sourcepub fn remove_all_admin(&mut self)
pub fn remove_all_admin(&mut self)
Deletes resources associated with the Admin object.
source§impl Config
impl Config
sourcepub fn select_admin_by_user(
&mut self,
value: impl Into<String>
) -> AdminScope<'_>
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.
sourcepub fn remove_admin_by_user(&mut self, value: impl Into<String>)
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
impl Config
sourcepub fn new(name: impl AsRef<str>) -> Self
pub fn new(name: impl AsRef<str>) -> Self
Instantiate a zone configuration object, wrapping an existing zone.
sourcepub fn create(
name: impl AsRef<str>,
overwrite: bool,
options: CreationOptions
) -> Self
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.
sourcepub fn export(&mut self, p: impl AsRef<Path>) -> &mut Self
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.
sourcepub fn delete(&mut self, force: bool) -> &mut Self
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.
sourcepub fn as_command(&mut self) -> Command
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.
sourcepub fn parse_output(output: &Output) -> Result<String, ZoneError>
pub fn parse_output(output: &Output) -> Result<String, ZoneError>
Parses the output from a command which was emitted from Self::as_command.
sourcepub fn run_blocking(&mut self) -> Result<String, ZoneError>
pub fn run_blocking(&mut self) -> Result<String, ZoneError>
Executes the queued commands for the zone, and clears the current queued arguments.