Skip to content

Commit

Permalink
Fix manifest and some fixes for the switch zone set up command
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv committed May 7, 2024
1 parent c792fc7 commit 89ac45a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
5 changes: 4 additions & 1 deletion illumos-utils/src/running_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ impl RunningZone {
/// Note that the zone must already be configured to be booted.
pub async fn boot(zone: InstalledZone) -> Result<Self, BootError> {
// Boot the zone.
info!(zone.log, "Zone booting");
info!(zone.log, "Booting {} zone", zone.name);

Zones::boot(&zone.name).await?;

Expand All @@ -528,6 +528,9 @@ impl RunningZone {
zone: zone.name.to_string(),
})?;

// TODO https://github.com/oxidecomputer/omicron/issues/1898:
// Remove all non-self assembling code

// If the zone is self-assembling, then SMF service(s) inside the zone
// will be creating the listen address for the zone's service(s),
// setting the appropriate ifprop MTU, and so on. The idea behind
Expand Down
6 changes: 3 additions & 3 deletions sled-agent/src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl Display for PropertyGroupBuilder {
if values.len() == 1 {
write!(
f,
r#" <propval type="{ty}" name="{name}" value="{value}"/>
r#" <propval type="{ty}" name="{name}" value='{value}'/>
"#,
name = property_name,
value = &values[0],
Expand Down Expand Up @@ -298,7 +298,7 @@ mod tests {
<service_bundle type="profile" name="myprofile">
<service version="1" type="service" name="myservice">
<property_group type="application" name="mypg">
<propval type="astring" name="myprop" value="myvalue"/>
<propval type="astring" name="myprop" value='myvalue'/>
</property_group>
</service>
</service_bundle>"#,
Expand Down Expand Up @@ -380,7 +380,7 @@ mod tests {
<service version="1" type="service" name="myservice">
<instance enabled="true" name="default">
<property_group type="application" name="mypg">
<propval type="type" name="prop" value="value"/>
<propval type="type" name="prop" value='value'/>
</property_group>
</instance>
</service>
Expand Down
5 changes: 3 additions & 2 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2507,11 +2507,11 @@ impl ServiceManager {
);

let baseboard_info =
serde_json::to_string_pretty(&baseboard)?;
serde_json::to_string(&baseboard)?;

switch_zone_setup_config =
switch_zone_setup_config.clone().add_property(
"config/baseboard_info",
"baseboard_info",
"astring",
&baseboard_info,
);
Expand Down Expand Up @@ -2972,6 +2972,7 @@ impl ServiceManager {
.add_property_group(switch_zone_setup_config),
);

// What happens if I change this to "switch"?
let profile = ProfileBuilder::new("omicron")
.add_service(nw_setup_service)
.add_service(disabled_dns_client_service)
Expand Down
2 changes: 1 addition & 1 deletion smf/switch_zone_setup/manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</dependency>

<exec_method type='method' name='start'
exec='/opt/oxide/zone-setup-cli/bin/zone-setup switch-zone -i %{config/baseboard_info} -l %{config/link_local_links} -z %{config/zone_name} -a %{config/bootstrap_addr} -n %{config/bootstrap_name} -v %{config/bootstrap_vnic} -g %{config/gz_local_link_addr}'
exec='/opt/oxide/zone-setup-cli/bin/zone-setup switch-zone -i "%{config/baseboard_info}" -l %{config/link_local_links} -z %{config/zone_name} -a %{config/bootstrap_addr} -n %{config/bootstrap_name} -v %{config/bootstrap_vnic} -g %{config/gz_local_link_addr}'
timeout_seconds='300'>
</exec_method>
<exec_method type='method' name='stop' exec=':true' timeout_seconds='3' />
Expand Down
18 changes: 11 additions & 7 deletions zone-setup/src/bin/zone-setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl SwitchZoneUser {
} else {
info!(&log, "Remove user profiles"; "user" => self.user.clone());
let cmd = std::process::Command::new("usermod")
.args(["-P", "''", &self.user])
.args(["-P", "", &self.user])
.output()
.map_err(|err| {
CmdError::Failure(anyhow!(
Expand Down Expand Up @@ -558,6 +558,7 @@ async fn switch_zone_setup(
) -> Result<(), CmdError> {
let file: &String = matches.get_one("baseboard_file").unwrap();
let info: &String = matches.get_one("baseboard_info").unwrap();
// TODO: Get rid of zone name?
let zone_name: &String = matches.get_one("zone_name").unwrap();
let bootstrap_addr: &Ipv6Addr = matches.get_one("bootstrap_addr").unwrap();
let bootstrap_name: &String = matches.get_one("bootstrap_name").unwrap();
Expand Down Expand Up @@ -602,17 +603,17 @@ async fn switch_zone_setup(
// Clap only checks if a flag is present or not. In this case, an
// empty list could sneak through if the flag is set without a value
// like `-l ""`.
if !links.is_empty() {
if links.is_empty() {
return Err(CmdError::Failure(anyhow!(
"At least one link local link must be provided"
)));
} else {
info!(&log, "Ensuring link local links"; "links" => ?links, "zone name" => ?zone_name);
for link in &links {
println!("{link}");
println!("{zone_name}");
// println!("{link}");
// println!("{zone_name}");
Zones::ensure_has_link_local_v6_address(
Some(zone_name),
None,
&AddrObject::new(link, IPV6_LINK_LOCAL_NAME).unwrap(),
)
.map_err(|err| {
Expand All @@ -638,10 +639,13 @@ async fn switch_zone_setup(
err
))
})?;
let _ = Zones::ensure_address(Some(&zone_name), &addrobj, addrtype)
// TODO: Fix error
// root@oxz_switch:~# /usr/sbin/ipadm create-addr -t -T static -a fdb0:a8a1:59c7:4e85::2/64 oxBootstrap0/bootstrap6
// ipadm: Could not create address: Can't assign requested address
let _ = Zones::ensure_address(None, &addrobj, addrtype)
.map_err(|err| {
CmdError::Failure(anyhow!(
"Could not address {} {:?}: {}",
"Could not ensure address {} {:?}: {}",
addrobj,
addrtype,
err
Expand Down

0 comments on commit 89ac45a

Please sign in to comment.