ic-code 1.5.2__py3-none-any.whl → 1.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ic/__init__.py +1 -1
- ic/config/installer.py +8 -8
- ic/config/migration.py +28 -23
- ic/config/secrets.py +5 -5
- ic/platforms/aws/disk/__init__.py +1 -0
- ic/platforms/aws/disk/info.py +32 -0
- ic/platforms/aws/ebs/__init__.py +1 -0
- ic/platforms/aws/ebs/info.py +528 -0
- ic/platforms/aws/ebs/mock_data.json +90 -0
- ic/platforms/aws/iam/__init__.py +1 -0
- ic/platforms/aws/iam/user.py +559 -0
- ic/platforms/aws/profile/info.py +55 -10
- ic/platforms/aws/profile/switch.py +365 -0
- ic/platforms/gcp/billing/info.py +3 -3
- ic/platforms/gcp/compute/info.py +50 -15
- ic/platforms/gcp/disk/__init__.py +1 -0
- ic/platforms/gcp/disk/info.py +566 -0
- ic/platforms/gcp/disk/mock_data.json +96 -0
- ic/platforms/ssh/__init__.py +2 -1
- ic/platforms/ssh/auto_ssh.py +7 -24
- ic/platforms/ssh/policy.py +61 -0
- ic/platforms/ssh/server_info.py +6 -14
- ic/platforms/tencent/cam/__init__.py +1 -0
- ic/platforms/tencent/cam/user.py +582 -0
- ic/platforms/tencent/cbs/__init__.py +1 -0
- ic/platforms/tencent/cbs/info.py +556 -0
- ic/platforms/tencent/cbs/mock_data.json +74 -0
- ic/platforms/tencent/client.py +370 -10
- ic/platforms/tencent/disk/__init__.py +1 -0
- ic/platforms/tencent/disk/info.py +32 -0
- ic/platforms/tencent/lighthouse/firewall.py +477 -0
- ic/platforms/tencent/lighthouse/info.py +32 -5
- ic/platforms/tencent/profile/info.py +82 -5
- ic/platforms/tencent/profile/switch.py +162 -0
- {ic_code-1.5.2.dist-info → ic_code-1.6.0.dist-info}/METADATA +183 -37
- {ic_code-1.5.2.dist-info → ic_code-1.6.0.dist-info}/RECORD +40 -19
- {ic_code-1.5.2.dist-info → ic_code-1.6.0.dist-info}/WHEEL +0 -0
- {ic_code-1.5.2.dist-info → ic_code-1.6.0.dist-info}/entry_points.txt +0 -0
- {ic_code-1.5.2.dist-info → ic_code-1.6.0.dist-info}/licenses/LICENSE +0 -0
- {ic_code-1.5.2.dist-info → ic_code-1.6.0.dist-info}/top_level.txt +0 -0
ic/__init__.py
CHANGED
|
@@ -4,7 +4,7 @@ IC (Infra Resource Management CLI) - A comprehensive tool for managing cloud inf
|
|
|
4
4
|
This package provides CLI tools and libraries for managing AWS, GCP, OCI, CloudFlare, and SSH resources.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
__version__ = "1.
|
|
7
|
+
__version__ = "1.6.0"
|
|
8
8
|
__author__ = "SangYun"
|
|
9
9
|
__email__ = "cruiser594@gmail.com"
|
|
10
10
|
|
ic/config/installer.py
CHANGED
|
@@ -104,15 +104,15 @@ class ConfigInstaller:
|
|
|
104
104
|
|
|
105
105
|
def _install_secrets_example(self, target_path: Path) -> None:
|
|
106
106
|
"""Install secrets.yaml.example file."""
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
template_file_content = self.config_generator.generate_secrets_example()
|
|
108
|
+
example_file_path = target_path / 'secrets.yaml.example'
|
|
109
109
|
|
|
110
|
-
with open(
|
|
111
|
-
f.write(
|
|
110
|
+
with open(example_file_path, 'w') as f:
|
|
111
|
+
f.write(template_file_content)
|
|
112
112
|
|
|
113
113
|
# Set file permissions
|
|
114
114
|
if os.name != 'nt': # Not Windows
|
|
115
|
-
os.chmod(
|
|
115
|
+
os.chmod(example_file_path, 0o644)
|
|
116
116
|
|
|
117
117
|
|
|
118
118
|
class DefaultConfigGenerator:
|
|
@@ -181,7 +181,7 @@ class DefaultConfigGenerator:
|
|
|
181
181
|
Returns:
|
|
182
182
|
Example secrets configuration as YAML string
|
|
183
183
|
"""
|
|
184
|
-
|
|
184
|
+
template_config = {
|
|
185
185
|
'aws': {
|
|
186
186
|
'profile': 'your-aws-profile-name',
|
|
187
187
|
'access_key_id': 'AKIA...',
|
|
@@ -209,9 +209,9 @@ class DefaultConfigGenerator:
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
# Add comprehensive comments for secrets
|
|
212
|
-
|
|
212
|
+
yaml_file_content = self._add_secrets_comments()
|
|
213
213
|
|
|
214
|
-
return
|
|
214
|
+
return yaml_file_content
|
|
215
215
|
|
|
216
216
|
def _add_yaml_comments(self) -> str:
|
|
217
217
|
"""Add comprehensive comments to default YAML configuration."""
|
ic/config/migration.py
CHANGED
|
@@ -50,9 +50,9 @@ class MigrationManager:
|
|
|
50
50
|
# Check if YAML files already exist
|
|
51
51
|
config_dir = Path("config")
|
|
52
52
|
default_yaml = config_dir / "default.yaml"
|
|
53
|
-
|
|
53
|
+
secrets_file_path = config_dir / "secrets.yaml"
|
|
54
54
|
|
|
55
|
-
if not force and (default_yaml.exists() or
|
|
55
|
+
if not force and (default_yaml.exists() or secrets_file_path.exists()):
|
|
56
56
|
logger.warning("YAML configuration files already exist. Use force=True to overwrite.")
|
|
57
57
|
return False
|
|
58
58
|
|
|
@@ -69,8 +69,8 @@ class MigrationManager:
|
|
|
69
69
|
# Backup existing files if they exist
|
|
70
70
|
if default_yaml.exists():
|
|
71
71
|
self._backup_file(default_yaml)
|
|
72
|
-
if
|
|
73
|
-
self._backup_file(
|
|
72
|
+
if secrets_file_path.exists():
|
|
73
|
+
self._backup_file(secrets_file_path)
|
|
74
74
|
|
|
75
75
|
# Save configurations
|
|
76
76
|
success = True
|
|
@@ -81,11 +81,11 @@ class MigrationManager:
|
|
|
81
81
|
|
|
82
82
|
# Save secrets configuration
|
|
83
83
|
if secrets_config:
|
|
84
|
-
success &= self._save_yaml_config(
|
|
84
|
+
success &= self._save_yaml_config(secrets_file_path, secrets_config)
|
|
85
85
|
|
|
86
86
|
# Set restrictive permissions on secrets file
|
|
87
87
|
try:
|
|
88
|
-
|
|
88
|
+
secrets_file_path.chmod(0o600)
|
|
89
89
|
except Exception as e:
|
|
90
90
|
logger.warning(f"Failed to set restrictive permissions on secrets file: {e}")
|
|
91
91
|
|
|
@@ -94,7 +94,7 @@ class MigrationManager:
|
|
|
94
94
|
self._backup_file(env_path)
|
|
95
95
|
|
|
96
96
|
# Record migration
|
|
97
|
-
self._record_migration(env_path, default_yaml,
|
|
97
|
+
self._record_migration(env_path, default_yaml, secrets_file_path)
|
|
98
98
|
|
|
99
99
|
logger.info("Successfully migrated .env file to YAML configuration")
|
|
100
100
|
return True
|
|
@@ -388,11 +388,11 @@ class MigrationManager:
|
|
|
388
388
|
yaml.dump(config, f, default_flow_style=False, indent=2,
|
|
389
389
|
allow_unicode=True, sort_keys=False)
|
|
390
390
|
|
|
391
|
-
logger.info(
|
|
391
|
+
logger.info("Saved configuration to %s", file_path.name)
|
|
392
392
|
return True
|
|
393
393
|
|
|
394
394
|
except Exception as e:
|
|
395
|
-
logger.error(
|
|
395
|
+
logger.error("Failed to save configuration to %s: %s", file_path.name, e)
|
|
396
396
|
return False
|
|
397
397
|
|
|
398
398
|
def _backup_file(self, file_path: Path) -> Optional[Path]:
|
|
@@ -418,20 +418,20 @@ class MigrationManager:
|
|
|
418
418
|
|
|
419
419
|
try:
|
|
420
420
|
shutil.copy2(file_path, backup_path)
|
|
421
|
-
logger.info(
|
|
421
|
+
logger.info("Backed up %s to %s", file_path.name, backup_path.name)
|
|
422
422
|
return backup_path
|
|
423
423
|
except Exception as e:
|
|
424
|
-
logger.error(
|
|
424
|
+
logger.error("Failed to backup %s: %s", file_path.name, e)
|
|
425
425
|
return None
|
|
426
426
|
|
|
427
|
-
def _record_migration(self, env_path: Path, default_yaml: Path,
|
|
427
|
+
def _record_migration(self, env_path: Path, default_yaml: Path, secrets_file_path: Path):
|
|
428
428
|
"""Record migration details for history."""
|
|
429
429
|
migration_record = {
|
|
430
430
|
"timestamp": datetime.now().isoformat(),
|
|
431
431
|
"source_file": str(env_path),
|
|
432
432
|
"target_files": {
|
|
433
|
-
"
|
|
434
|
-
"
|
|
433
|
+
"default_config_path": str(default_yaml),
|
|
434
|
+
"secrets_config_path": str(secrets_file_path) if secrets_file_path.exists() else None
|
|
435
435
|
},
|
|
436
436
|
"backup_location": str(self.backup_dir)
|
|
437
437
|
}
|
|
@@ -446,17 +446,17 @@ class MigrationManager:
|
|
|
446
446
|
True if document was created successfully
|
|
447
447
|
"""
|
|
448
448
|
try:
|
|
449
|
-
|
|
449
|
+
history_file_content = self._generate_migration_history_content()
|
|
450
450
|
|
|
451
|
-
|
|
452
|
-
with open(
|
|
453
|
-
f.write(
|
|
451
|
+
history_file_path = self.backup_dir / "migration_history.md"
|
|
452
|
+
with open(history_file_path, 'w', encoding='utf-8') as f:
|
|
453
|
+
f.write(history_file_content)
|
|
454
454
|
|
|
455
|
-
logger.info(
|
|
455
|
+
logger.info("Created migration history document at %s", history_file_path.name)
|
|
456
456
|
return True
|
|
457
457
|
|
|
458
458
|
except Exception as e:
|
|
459
|
-
logger.error(
|
|
459
|
+
logger.error("Failed to create migration history document: %s", e)
|
|
460
460
|
return False
|
|
461
461
|
|
|
462
462
|
def _generate_migration_history_content(self) -> str:
|
|
@@ -507,10 +507,15 @@ backup/
|
|
|
507
507
|
content += f"### Migration {i}\n\n"
|
|
508
508
|
content += f"- **Date**: {record['timestamp']}\n"
|
|
509
509
|
content += f"- **Source**: {record['source_file']}\n"
|
|
510
|
-
content += f"- **Default Config**: {record['target_files']['default_config']}\n"
|
|
511
510
|
|
|
512
|
-
|
|
513
|
-
|
|
511
|
+
target_files = record.get('target_files', {})
|
|
512
|
+
default_file_path = target_files.get('default_config_path')
|
|
513
|
+
if default_file_path:
|
|
514
|
+
content += f"- **Default Config**: {default_file_path}\n"
|
|
515
|
+
|
|
516
|
+
secrets_file_path = target_files.get('secrets_config_path')
|
|
517
|
+
if secrets_file_path:
|
|
518
|
+
content += f"- **Secrets Config**: {secrets_file_path}\n"
|
|
514
519
|
|
|
515
520
|
content += f"- **Backup Location**: {record['backup_location']}\n\n"
|
|
516
521
|
else:
|
ic/config/secrets.py
CHANGED
|
@@ -60,8 +60,9 @@ class SecretsManager:
|
|
|
60
60
|
|
|
61
61
|
# Try to load from secrets.yaml file with new path structure
|
|
62
62
|
secrets_paths = [
|
|
63
|
-
Path.home() / ".ic" / "config" / "secrets.yaml", #
|
|
64
|
-
Path("
|
|
63
|
+
Path.home() / ".ic" / "config" / "secrets.yaml", # Preferred location
|
|
64
|
+
Path.home() / ".ic" / "secrets.yaml", # Alternative location in ~/.ic
|
|
65
|
+
Path("config/secrets.yaml") # Legacy location for backward compatibility
|
|
65
66
|
]
|
|
66
67
|
|
|
67
68
|
secrets = {}
|
|
@@ -80,11 +81,10 @@ class SecretsManager:
|
|
|
80
81
|
secrets = self._merge_secrets(secrets, env_secrets)
|
|
81
82
|
logger.debug("Merged secrets from environment variables")
|
|
82
83
|
|
|
83
|
-
# Validate that secrets are properly separated (log
|
|
84
|
+
# Validate that secrets are properly separated (log summary only, no cleartext secret keys)
|
|
84
85
|
validation_warnings = self.validate_secrets_separation(secrets)
|
|
85
86
|
if validation_warnings:
|
|
86
|
-
|
|
87
|
-
logger.debug(f"Secrets validation: {warning}") # Changed to debug level
|
|
87
|
+
logger.debug("Secrets validation completed with %d checks", len(validation_warnings))
|
|
88
88
|
|
|
89
89
|
self.secrets_data = secrets
|
|
90
90
|
return secrets
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""AWS Disk (EBS alias) module for IC CLI."""
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
AWS Disk Info Command (Alias to AWS EBS Info Command).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
from typing import Any, Optional
|
|
8
|
+
from ic.platforms.aws.ebs.info import (
|
|
9
|
+
EbsInfoCommand,
|
|
10
|
+
main as ebs_main,
|
|
11
|
+
add_arguments as ebs_add_arguments,
|
|
12
|
+
format_table_output,
|
|
13
|
+
format_tree_output,
|
|
14
|
+
print_paste_format
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class AwsDiskInfoCommand(EbsInfoCommand):
|
|
19
|
+
"""AWS Disk (EBS) 볼륨 정보 조회 커맨드 (Alias)"""
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def main(args: Optional[argparse.Namespace] = None, config: Any = None) -> None:
|
|
24
|
+
ebs_main(args, config)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def add_arguments(parser: argparse.ArgumentParser) -> None:
|
|
28
|
+
ebs_add_arguments(parser)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
if __name__ == "__main__":
|
|
32
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""AWS EBS (Elastic Block Store) module for IC CLI."""
|