Skip to content

Commit

Permalink
username for switch
Browse files Browse the repository at this point in the history
  • Loading branch information
kthare10 committed Dec 13, 2024
2 parents ccabc82 + b752af4 commit e5160a2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

<<<<<<< HEAD
## 1.8.0 - TBD

### Added
- Advance Scheduling Improvements (Issue [#388](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/388))
=======
### Fixed
- Ensure slice key and bastion key names are not identical (Issue [#389](https://github.com/fabric-testbed/fabrictestbed-extensions/issues/389))
>>>>>>> b752af49b5c3a6dc72a90081639e603bf037a597
## [1.7.4] - 11/05/2024

Expand Down
1 change: 1 addition & 0 deletions fabrictestbed_extensions/fablib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ class Constants:
SSH_KEYS = "sshkeys"
EXPIRES_ON = "expires_on"
LEASE_TIME_FORMAT = "%Y-%m-%d %H:%M:%S %z"
FABRIC_KEY_TYPE = "fabric_key_type"

NON_PRETTY_NAME = "non_pretty_name"
PRETTY_NAME = "pretty_name"
Expand Down
17 changes: 17 additions & 0 deletions fabrictestbed_extensions/fablib/fablib.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,19 @@ def verify_and_configure(self):
Utils.is_reachable(hostname=self.get_core_api_host(), port=443)
Utils.is_reachable(hostname=self.get_bastion_host(), port=22)

if (
self.get_default_slice_private_key_file() is not None
and self.get_bastion_key_location() is not None
and self.get_default_slice_private_key_file()
== self.get_bastion_key_location()
):
logging.error(
"Sliver Key and Bastion key can not be same! Please use different key names!"
)
raise Exception(
"Sliver Key and Bastion key can not be same! Please use different key names!"
)

self.validate_and_update_bastion_keys()

if (
Expand Down Expand Up @@ -949,6 +962,10 @@ def validate_and_update_bastion_keys(self):
if now > expires_on_dt:
keys_to_remove.append(key)
continue
key_type = key.get(Constants.FABRIC_KEY_TYPE)
if key_type and key_type != Constants.KEY_TYPE_BASTION:
keys_to_remove.append(key)
continue

for key in keys_to_remove:
ssh_keys.remove(key)
Expand Down
2 changes: 2 additions & 0 deletions fabrictestbed_extensions/fablib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,8 @@ def set_username(self, username: str = None):
self.username = "openbsd"
elif "kali" in self.get_image():
self.username = "kali"
elif "onl" in self.get_image():
self.username = "fabric"
else:
self.username = None

Expand Down
4 changes: 2 additions & 2 deletions fabrictestbed_extensions/fablib/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(
super(Switch, self).__init__(
slice=slice, node=node, validate=validate, raise_exception=raise_exception
)
self.username = "rare"
self.username = "fabric"

def __str__(self):
"""
Expand Down Expand Up @@ -140,7 +140,7 @@ def new_switch(
logging.info(f"Adding node: {name}, slice: {slice.get_name()}, site: {site}")
node = Switch(
slice,
slice.topology.add_switch(name=name, site=site),
slice.topology.add_switch(name=name, site=site, image="onl"),
validate=validate,
raise_exception=raise_exception,
)
Expand Down

0 comments on commit e5160a2

Please sign in to comment.