Skip to content

Commit c805b9f

Browse files
author
guido tijskens
committed
kvm image build scripts
1 parent fa0661a commit c805b9f

19 files changed

+577
-153
lines changed

buildrpm/oci-utils.spec

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ rm -rf %{buildroot}
178178
/opt/oci-utils/tests/__init__*
179179

180180
%changelog
181-
* Mon Jun 28 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.5-2
181+
* Fri Jul 2 2021 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.5-3
182+
- LINUX-11255 output of oci-public-ip -g has a # at then end
183+
- LINUX-11261 ocid does not enable vnics at reboot/ocid configures unconfigured vnics
184+
- LINUX-9680 move KVM image scripts to github
185+
- image build scripts
186+
187+
* Mon Jun 28 2021 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.5-2
182188
- OLUEK-5005 oci-metadata (oci-utils) value-only flag broken
183189

184190
* Wed Jun 23 2021 Guido Tijskens <guido.tijskens@oracle.com> -- 0.12.5-1

data/00-oci-utils.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@
5656
;
5757
; Number of seconds to sleep between refresh attempts
5858
; refresh_interval=600
59+
[ocid]
60+
; debug=true

lib/oci_utils/impl/network_interface.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ class _intf_dict(dict):
1919
"""
2020
Creates a new dictionnary representing an interface
2121
keys are
22-
CONFSTATE 'uncfg' indicates missing IP config, 'missing' missing VNIC,
23-
'excl' excluded (-X), '-' hist configuration match oci vcn configuration
22+
CONFSTATE 'uncfg' indicates missing IP config,
23+
'missing' missing VNIC,
24+
'excl' excluded (-X),
25+
'-' hist configuration match oci vcn configuration
2426
"""
2527

2628
def __init__(self, other=None):

lib/oci_utils/impl/oci-network-config-main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,8 @@ def do_detach_vnic(detach_options):
577577
_logger.info('VNIC [%s] is detached.', v_ocid)
578578
break
579579
raise Exception("The primary VNIC cannot be detached.")
580-
else:
581-
_logger.error('VNIC %s [%s] is not attached to this instance.', v_ip, v_ocid)
580+
else:
581+
_logger.error('VNIC %s [%s] is not attached to this instance.', detach_options.ip_address, detach_options.ocid)
582582

583583

584584
def do_create_vnic(create_options):

lib/oci_utils/impl/oci-public-ip-main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def _display_ip_list(ip_list, displayALL, outputMode, displayDetails):
9494
if displayALL:
9595
_ip_list_to_display = ip_list
9696
else:
97-
# We assume that primary is the first one and we want ot display only it
97+
# We assume that primary is the first one and we want to display only it
9898
_ip_list_to_display = ip_list[:1]
9999

100100
_title = 'Public IPs information (primary on top)'
@@ -181,7 +181,15 @@ def main():
181181
stun_log.info("No public IP address found.\n")
182182
return 1
183183

184-
_display_ip_list(_all_p_ips, args.all, args.output_mode, args.details)
184+
if args.get:
185+
#
186+
# for compatibility mode, the parsable output mode is not really appropriate
187+
# LINUX-11255
188+
for ip in _all_p_ips:
189+
print('%16s' % ip['ip'])
190+
else:
191+
_display_ip_list(_all_p_ips, args.all, args.output_mode, args.details)
192+
185193
return 0
186194

187195

lib/oci_utils/impl/oci_resources.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,8 @@ def all_vnics(self):
512512
# compartment_id=self._data['compartment_id'],
513513
# instance_id=self._ocid)
514514
except oci_sdk.exceptions.ServiceError as e:
515-
OCIInstance._logger.debug('sdk call failed', exc_info=True)
516-
OCIInstance._logger.warning('sdk call failed [%s]', str(e))
515+
OCIInstance._logger.debug('SDK call failed', exc_info=True)
516+
OCIInstance._logger.warning('SDK call failed [%s]', str(e))
517517
return []
518518
for v_a_data in vnic_atts.data:
519519
try:
@@ -528,7 +528,7 @@ def all_vnics(self):
528528
except oci_sdk.exceptions.ServiceError:
529529
# ignore these, it means the current user has no
530530
# permission to list the instances in the compartment
531-
OCIInstance._logger.debug('current user has no permission to list the vcns in the compartment')
531+
OCIInstance._logger.debug('Current user has no permission to list the vcns in the compartment')
532532

533533
return vnics
534534

lib/oci_utils/impl/ocid-main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ def vnic_func(context, func_logger):
537537
#
538538
# GT
539539
# LINUX-10360 ocid service configures unconfigured vnics; commented out in case of side effects.
540-
# _vnic_utils.auto_config([])
540+
_vnic_utils.auto_config([], deconfigured=False)
541541

542542
return context
543543

lib/oci_utils/impl/virt/oci-kvm-main.py

Lines changed: 114 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -44,84 +44,126 @@ def parse_args():
4444
-------
4545
The command line namespace.
4646
"""
47-
parser = argparse.ArgumentParser(description='Utility for creating and '
48-
'managing KVM virtual '
49-
'machines on an OCI '
50-
'instance.')
47+
parser = argparse.ArgumentParser(description='Utility for creating and managing KVM virtual machines '
48+
'on an OCI instance.')
5149
subparser = parser.add_subparsers(dest='mode')
50+
#
5251
create_parser = subparser.add_parser(_create,
53-
help='Create a new virtual machine')
52+
help='Create a new virtual machine.')
53+
create_parser.add_argument('-d', '--disk',
54+
action='store',
55+
type=str,
56+
help='The path to the root disk of the VM.')
57+
create_parser.add_argument('-p', '--pool',
58+
action='store',
59+
type=str,
60+
help='The name a of storage pool to be used for root disk.')
61+
create_parser.add_argument('-s', '--disk-size',
62+
action='store',
63+
type=_disk_size_in_gb,
64+
help='The size of the disk in GB to be created when using storage pool.')
65+
create_parser.add_argument('-n', '--net',
66+
action='append',
67+
type=str,
68+
help='The IP or name of the VNIC that should be attached to the VM.')
69+
create_parser.add_argument('-v', '--virtual-network',
70+
action='append',
71+
type=str,
72+
help='The name of libvirt nework to attach the guest to.')
73+
create_parser.add_argument('-D', '--domain',
74+
action='store',
75+
type=str,
76+
help='The name of the virtual machine.',
77+
required=True)
78+
create_parser.add_argument('-V', '--virt',
79+
nargs=argparse.REMAINDER,
80+
help='Additional arguments to provide to virt-install. '
81+
'All arguments that appear after this one will be passed unmodified into '\
82+
'virt-install, even if they are arguments that oci-kvm would otherwise understand.',
83+
required=True)
84+
#
5485
destroy_parser = subparser.add_parser(_destroy,
55-
help='Destroy an existing virtual '
56-
'machine')
86+
help='Destroy an existing virtual machine.')
87+
destroy_parser.add_argument('-D', '--domain',
88+
action='store',
89+
type=str,
90+
help='The name of the virtual machine.',
91+
required=True)
92+
destroy_parser.add_argument('--destroy-disks',
93+
action='store_true',
94+
help='Also delete storage pool based disks.')
95+
destroy_parser.add_argument('-s', '--stop',
96+
action='store_true',
97+
default=False,
98+
help='First stop the guess if it is running.')
99+
destroy_parser.add_argument('-f', '--force',
100+
action='store_true',
101+
default=False,
102+
help='Forced operation, no gracefull shutdown.')
103+
#
57104
create_pool_parser = subparser.add_parser(_create_pool,
58-
help='Create a filesystem storage pool')
105+
help='Create a filesystem storage pool.')
106+
dbp_group = create_pool_parser.add_argument_group(title='disk pool',
107+
description='The options for disk based storage pool.')
108+
dbp_group.add_argument('-d', '--disk',
109+
action='store',
110+
type=str,
111+
help='The path to the root disk of the storage pool.')
112+
#
113+
nfsp_group = create_pool_parser.add_argument_group(title='NETFS pool',
114+
description='The options for NETFS based storage pool.')
115+
nfsp_group.add_argument('-N', '--netfshost',
116+
action='store',
117+
type=str,
118+
help='The name or IP of the NFS server.')
119+
nfsp_group.add_argument('-p', '--path',
120+
action='store',
121+
type=str,
122+
help='The path of the NETFS resource.')
123+
create_pool_parser.add_argument('-n', '--name',
124+
action='store',
125+
type=str,
126+
help='The name of the pool.',
127+
required=True)
128+
#
59129
create_network_parser = subparser.add_parser(_create_network,
60-
help='Create a libvirt network on an OCI vNIC')
130+
help='Create a libvirt network on an OCI vNIC.')
131+
create_network_parser.add_argument('-n', '--net',
132+
action='store',
133+
required=True, type=str,
134+
help='The IP of the VNIC used to build the network.')
135+
create_network_parser.add_argument('-N', '--network-name',
136+
action='store',
137+
required=True,
138+
type=str,
139+
help='The name of the network.')
140+
create_network_parser.add_argument('-B', '--ip-bridge',
141+
action='store',
142+
required=True,
143+
type=str,
144+
help='The bridge IP for virtual network address space.')
145+
create_network_parser.add_argument('-S', '--ip-start',
146+
action='store',
147+
required=True,
148+
type=str,
149+
help='The guest first IP range in virtual network address space.')
150+
create_network_parser.add_argument('-E', '--ip-end',
151+
action='store',
152+
required=True,
153+
type=str,
154+
help='The guest last IP range in virtual network address space.')
155+
create_network_parser.add_argument('-P', '--ip-prefix',
156+
action='store',
157+
required=True,
158+
type=str,
159+
help='The IP prefix to be used in virtual network.')
160+
#
61161
delete_network_parser = subparser.add_parser(_delete_network,
62-
help='Delete a libvirt network on an OCI vNIC')
63-
64-
create_parser.add_argument('-d', '--disk', action='store', type=str,
65-
help='Path to the root disk of the VM')
66-
create_parser.add_argument('-p', '--pool', action='store', type=str,
67-
help='Name a of storage pool to be used for root disk')
68-
create_parser.add_argument('-s', '--disk-size', action='store', type=_disk_size_in_gb,
69-
help='Size of the disk in GB to be created when using storage pool')
70-
create_parser.add_argument('-n', '--net', action='append', type=str,
71-
help='IP or name of the VNIC that should be attached '
72-
'to the VM')
73-
create_parser.add_argument('-v', '--virtual-network', action='append', type=str,
74-
help='The name of libvirt nework to attach the guest to')
75-
create_parser.add_argument('-D', '--domain', action='store', type=str,
76-
help='Name of the virtual machine',
77-
required=True)
78-
create_parser.add_argument('-V', '--virt', nargs=argparse.REMAINDER,
79-
help='Additional arguments to provide to '
80-
'virt-install. All arguments that appear '
81-
'after this one will be passed unmodified '
82-
'into virt-install, even if they are '
83-
'arguments that oci-kvm would otherwise '
84-
'understand.',
85-
required=True)
86-
87-
destroy_parser.add_argument('-D', '--domain', action='store', type=str,
88-
help='Name of the virtual machine',
89-
required=True)
90-
destroy_parser.add_argument('--destroy-disks', action='store_true',
91-
help='Also delete storage pool based disks')
92-
destroy_parser.add_argument('-s', '--stop', action='store_true', default=False,
93-
help='First stop the guess if it si running')
94-
destroy_parser.add_argument('-f', '--force', action='store_true', default=False,
95-
help='Forced operation, no gracefull shutdown')
96-
97-
dbp_group = create_pool_parser.add_argument_group(
98-
title='disk pool', description='Options for disk based storage pool')
99-
dbp_group.add_argument('-d', '--disk', action='store', type=str,
100-
help='Path to the root disk of the storage pool')
101-
nfsp_group = create_pool_parser.add_argument_group(
102-
title='NETFS pool', description='Options for NETFS based storage pool')
103-
nfsp_group.add_argument('-N', '--netfshost', action='store', type=str,
104-
help='name or IP of the NFS server')
105-
nfsp_group.add_argument('-p', '--path', action='store', type=str,
106-
help='path of the NETFS resource')
107-
create_pool_parser.add_argument('-n', '--name', action='store', type=str,
108-
help='name of the pool', required=True)
109-
110-
create_network_parser.add_argument('-n', '--net', action='store', required=True, type=str,
111-
help='IP of the VNIC used to build the network')
112-
create_network_parser.add_argument('-N', '--network-name', action='store', required=True, type=str,
113-
help='the name of the network')
114-
create_network_parser.add_argument('-B', '--ip-bridge', action='store', required=True, type=str,
115-
help='Bridge IP for virtual network address space')
116-
create_network_parser.add_argument('-S', '--ip-start', action='store', required=True, type=str,
117-
help='guest first IP range in virtual network address space')
118-
create_network_parser.add_argument('-E', '--ip-end', action='store', required=True, type=str,
119-
help='guest last IP range in virtual network address space')
120-
create_network_parser.add_argument('-P', '--ip-prefix', action='store', required=True, type=str,
121-
help='IP prefix to be used in virtual network')
122-
123-
delete_network_parser.add_argument('-N', '--network-name', action='store', required=True, type=str,
124-
help='the name of the network')
162+
help='Delete a libvirt network on an OCI vNIC.')
163+
delete_network_parser.add_argument('-N', '--network-name',
164+
action='store',
165+
required=True, type=str,
166+
help='The name of the network.')
125167

126168
return parser
127169

lib/oci_utils/impl/virt/sysconfig.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
__sysconfig = '/etc/sysconfig'
1717
__netscripts = __sysconfig + '/network-scripts'
18-
1918
__iface_prefix = 'ifcfg-'
2019

2120

0 commit comments

Comments
 (0)