Skip to content

Commit adfefd0

Browse files
committed
additional mcp functions
1 parent b460d3a commit adfefd0

File tree

3 files changed

+620
-49
lines changed

3 files changed

+620
-49
lines changed

kcli.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ rm -rf %{buildroot}
5252
%attr(0755,root,root) %{_bindir}/kcli
5353
%attr(0755,root,root) %{_bindir}/kweb
5454
%attr(0755,root,root) %{_bindir}/klist.py
55+
%attr(0755,root,root) %{_bindir}/kmcp.py
5556
%attr(0755,root,root) %{_bindir}/ksushy
5657
%attr(0755,root,root) %{_bindir}/ignitionmerger
5758
%attr(0755,root,root) %{_bindir}/ekstoken

kvirt/cli.py

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def _parse_vms_list(_list, overrides={}):
790790
print(vmstable)
791791

792792

793-
def list_vm(args):
793+
def list_vms(args):
794794
output = args.global_output or args.output
795795
overrides = handle_parameters(args.param, args.paramfile)
796796
filter_keys = ['name', 'ip', 'status', 'image', 'network', 'plan', 'profile']
@@ -842,7 +842,7 @@ def list_vm(args):
842842
print(vmstable)
843843

844844

845-
def list_clusterprofile(args):
845+
def list_clusterprofiles(args):
846846
baseconfig = Kbaseconfig(client=args.client, debug=args.debug)
847847
clusterprofiles = baseconfig.list_clusterprofiles()
848848
output = args.global_output or args.output
@@ -855,7 +855,7 @@ def list_clusterprofile(args):
855855
print(clusterprofilestable)
856856

857857

858-
def list_confpool(args):
858+
def list_confpools(args):
859859
baseconfig = Kbaseconfig(client=args.client, debug=args.debug)
860860
confpools = baseconfig.list_confpools()
861861
output = args.global_output or args.output
@@ -868,7 +868,7 @@ def list_confpool(args):
868868
print(confpoolstable)
869869

870870

871-
def list_container(args):
871+
def list_containers(args):
872872
filters = args.filters
873873
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
874874
cont = Kcontainerconfig(config, client=args.containerclient).cont
@@ -888,7 +888,7 @@ def list_container(args):
888888
print(containerstable)
889889

890890

891-
def profilelist_container(args):
891+
def list_containerprofiles(args):
892892
short = args.short
893893
baseconfig = Kbaseconfig(client=args.client, debug=args.debug)
894894
profiles = baseconfig.list_containerprofiles()
@@ -908,7 +908,7 @@ def profilelist_container(args):
908908
print(profilestable)
909909

910910

911-
def list_containerimage(args):
911+
def list_containerimages(args):
912912
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
913913
if config.type not in ['kvm', 'proxmox']:
914914
error("Operation not supported on this kind of client.Leaving...")
@@ -925,7 +925,7 @@ def list_containerimage(args):
925925
print(imagestable)
926926

927927

928-
def list_client(args):
928+
def list_clients(args):
929929
clientstable = PrettyTable(["Client", "Type", "Enabled", "Current"])
930930
clientstable.align["Client"] = "l"
931931
baseconfig = Kbaseconfig(client=args.client, debug=args.debug)
@@ -943,7 +943,7 @@ def list_client(args):
943943
print(clientstable)
944944

945945

946-
def list_kubeconfig(args):
946+
def list_kubeconfigs(args):
947947
homedir = os.path.expanduser("~")
948948
clustersdir = f"{homedir}/.kcli/clusters"
949949
kubeconfigstable = PrettyTable(["Kubeconfig", "Current"])
@@ -956,7 +956,7 @@ def list_kubeconfig(args):
956956
print(kubeconfigstable)
957957

958958

959-
def list_lb(args):
959+
def list_lbs(args):
960960
short = args.short
961961
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
962962
lbs = config.list_loadbalancers()
@@ -1013,7 +1013,7 @@ def info_profile(args):
10131013
print(f"{key}: {profile[key]}")
10141014

10151015

1016-
def list_profile(args):
1016+
def list_profiles(args):
10171017
short = args.short
10181018
baseconfig = Kbaseconfig(client=args.client, debug=args.debug)
10191019
profiles = baseconfig.list_profiles()
@@ -1131,7 +1131,7 @@ def list_available_images(args):
11311131
print(imagestable)
11321132

11331133

1134-
def list_image(args):
1134+
def list_images(args):
11351135
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
11361136
if config.client != 'all':
11371137
k = config.k
@@ -1146,7 +1146,7 @@ def list_image(args):
11461146
print(imagestable)
11471147

11481148

1149-
def list_iso(args):
1149+
def list_isos(args):
11501150
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
11511151
if config.client != 'all':
11521152
k = config.k
@@ -1191,7 +1191,7 @@ def list_networks(args):
11911191
print(networkstable)
11921192

11931193

1194-
def list_plan(args):
1194+
def list_plans(args):
11951195
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
11961196
if config.extraclients:
11971197
allclients = config.extraclients.copy()
@@ -1290,7 +1290,7 @@ def delete_app(args):
12901290
overrides = handle_parameters(args.param, args.paramfile, cluster=True)
12911291
kubectl = which('kubectl') or which('oc')
12921292
if kubectl is None:
1293-
error("You need kubectl/oc to install apps")
1293+
error("You need kubectl/oc to delete apps")
12941294
sys.exit(1)
12951295
if 'KUBECONFIG' not in os.environ:
12961296
warning("KUBECONFIG not set...Using .kube/config instead")
@@ -1323,7 +1323,7 @@ def list_apps(args):
13231323
print(appstable)
13241324

13251325

1326-
def list_cluster(args):
1326+
def list_clusters(args):
13271327
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
13281328
if config.extraclients:
13291329
kubestable = PrettyTable(["Cluster", "Type", "Plan", "Host", "Vms"])
@@ -1357,7 +1357,7 @@ def list_cluster(args):
13571357
print(kubestable)
13581358

13591359

1360-
def list_pool(args):
1360+
def list_pools(args):
13611361
short = args.short
13621362
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
13631363
k = config.k
@@ -1379,7 +1379,7 @@ def list_pool(args):
13791379
print(poolstable)
13801380

13811381

1382-
def list_vmdisk(args):
1382+
def list_vmdisks(args):
13831383
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
13841384
k = config.k
13851385
pprint("Listing disks...")
@@ -3025,7 +3025,7 @@ def snapshotrevert_vm(args):
30253025
sys.exit(code)
30263026

30273027

3028-
def snapshotlist_vm(args):
3028+
def list_vmsnapshots(args):
30293029
name = args.name
30303030
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
30313031
k = config.k
@@ -3039,7 +3039,7 @@ def snapshotlist_vm(args):
30393039
print(snapshot)
30403040

30413041

3042-
def snapshotlist_plan(args):
3042+
def list_plansnapshots(args):
30433043
plan = args.name
30443044
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
30453045
k = config.k
@@ -3075,7 +3075,7 @@ def delete_bucket(args):
30753075
k.delete_bucket(bucket)
30763076

30773077

3078-
def list_bucket(args):
3078+
def list_buckets(args):
30793079
pprint("Listing buckets...")
30803080
config = Kconfig(client=args.client, debug=args.debug, region=args.region, zone=args.zone, namespace=args.namespace)
30813081
k = config.k
@@ -3202,7 +3202,7 @@ def switch_kubeconfig(args):
32023202
warning("run the following command for this to apply\nunset KUBECONFIG")
32033203

32043204

3205-
def list_keyword(args):
3205+
def list_keywords(args):
32063206
baseconfig = Kbaseconfig(client=args.client, debug=args.debug)
32073207
default = baseconfig.default
32083208
keywordstable = PrettyTable(["Keyword", "Default Value", "Current Value"])
@@ -4644,7 +4644,7 @@ def cli():
46444644
bucketlist_desc = 'List Buckets'
46454645
bucketlist_parser = list_subparsers.add_parser('bucket', description=bucketlist_desc, help=bucketlist_desc,
46464646
aliases=['buckets'], parents=[output_parser])
4647-
bucketlist_parser.set_defaults(func=list_bucket)
4647+
bucketlist_parser.set_defaults(func=list_buckets)
46484648

46494649
bucketfileslist_desc = 'List Bucket files'
46504650
bucketfileslist_parser = list_subparsers.add_parser('bucket-file', description=bucketfileslist_desc,
@@ -4656,12 +4656,12 @@ def cli():
46564656
clientlist_desc = 'List Clients'
46574657
clientlist_parser = list_subparsers.add_parser('client', description=clientlist_desc, help=clientlist_desc,
46584658
aliases=['clients', 'host', 'hosts'], parents=[output_parser])
4659-
clientlist_parser.set_defaults(func=list_client)
4659+
clientlist_parser.set_defaults(func=list_clients)
46604660

46614661
clusterlist_desc = 'List Clusters'
46624662
clusterlist_parser = list_subparsers.add_parser('cluster', description=clusterlist_desc, help=clusterlist_desc,
46634663
aliases=['clusters', 'kube', 'kubes'], parents=[output_parser])
4664-
clusterlist_parser.set_defaults(func=list_cluster)
4664+
clusterlist_parser.set_defaults(func=list_clusters)
46654665

46664666
clusterprofilelist_desc = 'List Clusterprofiles'
46674667
clusterprofilelist_parser = list_subparsers.add_parser('clusterprofile', description=clusterprofilelist_desc,
@@ -4670,37 +4670,37 @@ def cli():
46704670
'cluster-profiles', 'kube-profile', 'kube-profiles',
46714671
'kubeprofile', 'kubeprofiles'],
46724672
parents=[output_parser])
4673-
clusterprofilelist_parser.set_defaults(func=list_clusterprofile)
4673+
clusterprofilelist_parser.set_defaults(func=list_clusterprofiles)
46744674

46754675
confpoollist_desc = 'List Confpools'
46764676
confpoollist_parser = list_subparsers.add_parser('confpool', description=confpoollist_desc, help=confpoollist_desc,
46774677
aliases=['confpools'], parents=[output_parser])
4678-
confpoollist_parser.set_defaults(func=list_confpool)
4678+
confpoollist_parser.set_defaults(func=list_confpools)
46794679

46804680
containerimagelist_desc = 'List Container Images'
46814681
containerimagelist_parser = list_subparsers.add_parser('container-image', description=containerimagelist_desc,
46824682
help=containerimagelist_desc,
46834683
aliases=['container-images'], parents=[output_parser])
4684-
containerimagelist_parser.set_defaults(func=list_containerimage)
4684+
containerimagelist_parser.set_defaults(func=list_containerimages)
46854685

46864686
containerlist_desc = 'List Containers'
46874687
containerlist_parser = list_subparsers.add_parser('container', description=containerlist_desc,
46884688
help=containerlist_desc, aliases=['containers'],
46894689
parents=[output_parser])
46904690
containerlist_parser.add_argument('--filters', choices=('up', 'down'))
4691-
containerlist_parser.set_defaults(func=list_container)
4691+
containerlist_parser.set_defaults(func=list_containers)
46924692

46934693
containerprofilelist_desc = 'List Container Profiles'
46944694
containerprofilelist_parser = list_subparsers.add_parser('container-profile', description=containerprofilelist_desc,
46954695
help=containerprofilelist_desc,
46964696
aliases=['container-profiles'], parents=[output_parser])
46974697
containerprofilelist_parser.add_argument('-s', '--short', action='store_true')
4698-
containerprofilelist_parser.set_defaults(func=profilelist_container)
4698+
containerprofilelist_parser.set_defaults(func=list_containerprofiles)
46994699

47004700
vmdisklist_desc = 'List All Vm Disks'
47014701
vmdisklist_parser = list_subparsers.add_parser('disk', parents=[output_parser], description=vmdisklist_desc,
47024702
help=vmdisklist_desc, aliases=['disks'])
4703-
vmdisklist_parser.set_defaults(func=list_vmdisk)
4703+
vmdisklist_parser.set_defaults(func=list_vmdisks)
47044704

47054705
dnsentrylist_desc = 'List Dns Entries'
47064706
dnsentrylist_parser = list_subparsers.add_parser('dns-entry', parents=[output_parser],
@@ -4726,30 +4726,30 @@ def cli():
47264726
imagelist_desc = 'List Images'
47274727
imagelist_parser = list_subparsers.add_parser('image', description=imagelist_desc, help=imagelist_desc,
47284728
aliases=['images', 'template', 'templates'], parents=[output_parser])
4729-
imagelist_parser.set_defaults(func=list_image)
4729+
imagelist_parser.set_defaults(func=list_images)
47304730

47314731
isolist_desc = 'List Isos'
47324732
isolist_parser = list_subparsers.add_parser('iso', description=isolist_desc, help=isolist_desc, aliases=['isos'],
47334733
parents=[output_parser])
4734-
isolist_parser.set_defaults(func=list_iso)
4734+
isolist_parser.set_defaults(func=list_isos)
47354735

47364736
keywordlist_desc = 'List Keywords'
47374737
keywordlist_parser = list_subparsers.add_parser('keyword', description=keywordlist_desc, help=keywordlist_desc,
47384738
aliases=['keywords', 'parameter', 'parameters'],
47394739
parents=[output_parser])
4740-
keywordlist_parser.set_defaults(func=list_keyword)
4740+
keywordlist_parser.set_defaults(func=list_keywords)
47414741

47424742
kubeconfiglist_desc = 'List Kubeconfigs'
47434743
kubeconfiglist_parser = list_subparsers.add_parser('kubeconfig', description=kubeconfiglist_desc,
47444744
help=kubeconfiglist_desc, aliases=['kubeconfigs'],
47454745
parents=[output_parser])
4746-
kubeconfiglist_parser.set_defaults(func=list_kubeconfig)
4746+
kubeconfiglist_parser.set_defaults(func=list_kubeconfigs)
47474747

47484748
lblist_desc = 'List Load Balancers'
47494749
lblist_parser = list_subparsers.add_parser('lb', description=lblist_desc, help=lblist_desc,
47504750
aliases=['loadbalancers', 'lbs'], parents=[output_parser])
47514751
lblist_parser.add_argument('-s', '--short', action='store_true')
4752-
lblist_parser.set_defaults(func=list_lb)
4752+
lblist_parser.set_defaults(func=list_lbs)
47534753

47544754
networklist_desc = 'List Networks'
47554755
networklist_parser = list_subparsers.add_parser('network', description=networklist_desc, help=networklist_desc,
@@ -4760,7 +4760,7 @@ def cli():
47604760
planlist_desc = 'List Plans'
47614761
planlist_parser = list_subparsers.add_parser('plan', description=planlist_desc, help=planlist_desc,
47624762
aliases=['plans'], parents=[output_parser])
4763-
planlist_parser.set_defaults(func=list_plan)
4763+
planlist_parser.set_defaults(func=list_plans)
47644764

47654765
plantypeslist_desc = 'List Plan types'
47664766
plantypeslist_parser = list_subparsers.add_parser('plan-type', description=plantypeslist_desc,
@@ -4772,13 +4772,13 @@ def cli():
47724772
poollist_parser = list_subparsers.add_parser('pool', description=poollist_desc, help=poollist_desc,
47734773
aliases=['pools'], parents=[output_parser])
47744774
poollist_parser.add_argument('-s', '--short', action='store_true')
4775-
poollist_parser.set_defaults(func=list_pool)
4775+
poollist_parser.set_defaults(func=list_pools)
47764776

47774777
profilelist_desc = 'List Profiles'
47784778
profilelist_parser = list_subparsers.add_parser('profile', description=profilelist_desc, help=profilelist_desc,
47794779
aliases=['profiles'], parents=[output_parser])
47804780
profilelist_parser.add_argument('-s', '--short', action='store_true')
4781-
profilelist_parser.set_defaults(func=list_profile)
4781+
profilelist_parser.set_defaults(func=list_profiles)
47824782

47834783
securitygrouplist_desc = 'List Security Groups'
47844784
securitygrouplist_parser = list_subparsers.add_parser('security-group', description=securitygrouplist_desc,
@@ -4800,22 +4800,22 @@ def cli():
48004800
vmlist_parser = list_subparsers.add_parser('vm', parents=[parent_parser, output_parser], description=vmlist_desc,
48014801
help=vmlist_desc, aliases=['vms'], epilog=vmlist_epilog,
48024802
formatter_class=rawhelp)
4803-
vmlist_parser.set_defaults(func=list_vm)
4803+
vmlist_parser.set_defaults(func=list_vms)
48044804

48054805
plansnapshotlist_desc = 'List Snapshots Of a Plan'
48064806
plansnapshotlist_parser = list_subparsers.add_parser('plan-snapshot', description=plansnapshotlist_desc,
48074807
help=plansnapshotlist_desc, aliases=['plan-snapshots'],
48084808
parents=[output_parser])
48094809
plansnapshotlist_parser.add_argument('name', metavar='PLAN')
4810-
plansnapshotlist_parser.set_defaults(func=snapshotlist_plan)
4810+
plansnapshotlist_parser.set_defaults(func=list_plansnapshots)
48114811

48124812
vmsnapshotlist_desc = 'List Snapshots Of a Vm'
48134813
vmsnapshotlist_parser = list_subparsers.add_parser('snapshot', description=vmsnapshotlist_desc,
48144814
help=vmsnapshotlist_desc, aliases=['snapshots', 'vm-snapshot',
48154815
'vm-snapshots'],
48164816
parents=[output_parser])
48174817
vmsnapshotlist_parser.add_argument('name', metavar='VMNAME')
4818-
vmsnapshotlist_parser.set_defaults(func=snapshotlist_vm)
4818+
vmsnapshotlist_parser.set_defaults(func=list_vmsnapshots)
48194819

48204820
render_desc = 'Render file'
48214821
render_parser = subparsers.add_parser('render', description=render_desc, help=render_desc, parents=[parent_parser])

0 commit comments

Comments
 (0)