-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #318 from rapyuta-robotics/devel
🎉 release: v7.5.0
- Loading branch information
Showing
20 changed files
with
512 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 2024 Rapyuta Robotics | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import click | ||
from click_help_colors import HelpColorsCommand | ||
from yaspin.core import Yaspin | ||
|
||
from riocli.config import new_client | ||
from riocli.device.util import migrate_device_to_project, name_to_guid | ||
from riocli.project.util import name_to_guid as project_name_to_guid | ||
|
||
from riocli.constants import Colors, Symbols | ||
from riocli.utils.spinner import with_spinner | ||
|
||
|
||
@click.command( | ||
'migrate', | ||
cls=HelpColorsCommand, | ||
help_headers_color=Colors.YELLOW, | ||
help_options_color=Colors.GREEN | ||
) | ||
@click.argument('device-name', type=str) | ||
@click.argument('project-name', type=str) | ||
@click.option('--enable-vpn', is_flag=True, | ||
type=click.BOOL, default=False, | ||
help="Enable VPN after migrating to the destination project.") | ||
@click.option('--advertise-routes', is_flag=True, | ||
type=click.BOOL, default=False, | ||
help="Advertise subnets configured in project to VPN peers") | ||
@name_to_guid | ||
@project_name_to_guid | ||
@click.pass_context | ||
@with_spinner(text="Migrating device...") | ||
def migrate_project(ctx: click.Context, device_name: str, device_guid: str, | ||
project_name: str, project_guid: str, | ||
enable_vpn: bool, advertise_routes: bool, | ||
spinner: Yaspin) -> None: | ||
""" | ||
Migrate the device from current project to the target project. | ||
""" | ||
try: | ||
migrate_device_to_project(ctx, device_guid, project_guid) | ||
spinner.write( | ||
click.style('{} Device {} migrated successfully.'.format(Symbols.SUCCESS, device_name), | ||
fg=Colors.GREEN)) | ||
|
||
if enable_vpn: | ||
spinner.text = 'Enabling VPN on device...' | ||
client = new_client() | ||
client.set_project(project_guid) | ||
client.toggle_features(device_id=device_guid, features=[('vpn', True)], | ||
config={'vpn': {'advertise_routes': advertise_routes}}) | ||
spinner.write(click.style('{} Enabled VPN on the device.'.format(Symbols.SUCCESS), fg=Colors.GREEN)) | ||
except Exception as e: | ||
spinner.text = click.style( | ||
'Failed to migrate device: {}'.format(e), Colors.RED) | ||
spinner.red.fail(Symbols.ERROR) | ||
raise SystemExit(1) from e | ||
|
Oops, something went wrong.