Re: [Cloud-init-dev] [Merge] lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init
merged into git at https://git.launchpad.net/cloud-init/commit/?id=c52b8eb9671be454d22283c81057f97b98bb49fe -- https://code.launchpad.net/~smoser/cloud-init/trunk.smartos-fabric/+merge/300115 Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
[Cloud-init-dev] [Merge] lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init
The proposal to merge lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init has been updated. Status: Needs review => Merged For more details, see: https://code.launchpad.net/~smoser/cloud-init/trunk.smartos-fabric/+merge/300115 -- Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
Re: [Cloud-init-dev] [Merge] lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init
Review: Approve continuous-integration PASSED: Continuous integration, rev:1259 https://server-team-jenkins.canonical.com/job/cloud-init-ci/1/ Executed test runs: SUCCESS: https://server-team-jenkins.canonical.com/job/cloud-init-ci/nodes=amd64/1 SUCCESS: https://server-team-jenkins.canonical.com/job/cloud-init-ci/nodes=ppc64el/1 Click here to trigger a rebuild: https://server-team-jenkins.canonical.com/job/cloud-init-ci/1/rebuild -- https://code.launchpad.net/~smoser/cloud-init/trunk.smartos-fabric/+merge/300115 Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
Re: [Cloud-init-dev] [Merge] lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init
Review: Approve continuous-integration PASSED: Continuous integration, rev:1257 https://server-team-jenkins.canonical.com/job/cloud-init-ci/28/ Executed test runs: None: https://server-team-jenkins.canonical.com/job/lp-vote-on-merge/2/console Click here to trigger a rebuild: https://server-team-jenkins.canonical.com/job/cloud-init-ci/28/rebuild -- https://code.launchpad.net/~smoser/cloud-init/trunk.smartos-fabric/+merge/300115 Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
[Cloud-init-dev] [Merge] lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init
The proposal to merge lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init has been updated. Commit Message changed to: SmartOS: more improvements for network configuration This improves smart os network configuration - fix the SocketClient which was previously completely broken. - adds support for configuring dns servers and dns search (based off the sdc:dns_domain). - support 'sdc:gateways' information from the datasource for configuring default routes. - add converted network information to output when module is run as a main TODO: add support for sdc:routes as described at http://eng.joyent.com/mdata/datadict.html For more details, see: https://code.launchpad.net/~smoser/cloud-init/trunk.smartos-fabric/+merge/300115 -- Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init. ___ Mailing list: https://launchpad.net/~cloud-init-dev Post to : cloud-init-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~cloud-init-dev More help : https://help.launchpad.net/ListHelp
[Cloud-init-dev] [Merge] lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init
Scott Moser has proposed merging lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init. Requested reviews: cloud init development team (cloud-init-dev) For more details, see: https://code.launchpad.net/~smoser/cloud-init/trunk.smartos-fabric/+merge/300115 -- Your team cloud init development team is requested to review the proposed merge of lp:~smoser/cloud-init/trunk.smartos-fabric into lp:cloud-init. === modified file 'cloudinit/sources/DataSourceSmartOS.py' --- cloudinit/sources/DataSourceSmartOS.py 2016-07-13 22:18:46 + +++ cloudinit/sources/DataSourceSmartOS.py 2016-07-14 19:15:20 + @@ -60,11 +60,14 @@ 'availability_zone': ('sdc:datacenter_name', True), 'vendor-data': ('sdc:vendor-data', False), 'operator-script': ('sdc:operator-script', False), +'hostname': ('sdc:hostname', True), +'dns_domain': ('sdc:dns_domain', True), } SMARTOS_ATTRIB_JSON = { # Cloud-init Key : (SmartOS Key known JSON) 'network-data': 'sdc:nics', +'dns_servers': 'sdc:resolvers' } SMARTOS_ENV_LX_BRAND = "lx-brand" @@ -311,7 +314,10 @@ if self._network_config is None: if self.network_data is not None: self._network_config = ( -convert_smartos_network_data(self.network_data)) +convert_smartos_network_data( +network_data=self.network_data, +dns_servers=self.metadata['dns_servers'], +dns_domain=self.metadata['dns_domain'])) return self._network_config @@ -445,7 +451,8 @@ class JoyentMetadataSocketClient(JoyentMetadataClient): -def __init__(self, socketpath): +def __init__(self, socketpath, smartos_type=SMARTOS_ENV_LX_BRAND): +super(JoyentMetadataSocketClient, self).__init__(smartos_type) self.socketpath = socketpath def open_transport(self): @@ -461,7 +468,7 @@ class JoyentMetadataSerialClient(JoyentMetadataClient): -def __init__(self, device, timeout=10, smartos_type=None): +def __init__(self, device, timeout=10, smartos_type=SMARTOS_ENV_KVM): super(JoyentMetadataSerialClient, self).__init__(smartos_type) self.device = device self.timeout = timeout @@ -583,7 +590,8 @@ device=serial_device, timeout=serial_timeout, smartos_type=smartos_type) elif smartos_type == SMARTOS_ENV_LX_BRAND: -return JoyentMetadataSocketClient(socketpath=metadata_sockfile) +return JoyentMetadataSocketClient(socketpath=metadata_sockfile, + smartos_type=smartos_type) raise ValueError("Unknown value for smartos_type: %s" % smartos_type) @@ -671,8 +679,9 @@ return None -# Covert SMARTOS 'sdc:nics' data to network_config yaml -def convert_smartos_network_data(network_data=None): +# Convert SMARTOS 'sdc:nics' data to network_config yaml +def convert_smartos_network_data(network_data=None, + dns_servers=None, dns_domain=None): """Return a dictionary of network_config by parsing provided SMARTOS sdc:nics configuration data @@ -706,9 +715,7 @@ 'broadcast', 'dns_nameservers', 'dns_search', -'gateway', 'metric', -'netmask', 'pointopoint', 'routes', 'scope', @@ -716,6 +723,29 @@ ], } +if dns_servers: +if not isinstance(dns_servers, (list, tuple)): +dns_servers = [dns_servers] +else: +dns_servers = [] + +if dns_domain: +if not isinstance(dns_domain, (list, tuple)): +dns_domain = [dns_domain] +else: +dns_domain = [] + +def is_valid_ipv4(addr): +return '.' in addr + +def is_valid_ipv6(addr): +return ':' in addr + +pgws = { +'ipv4': {'match': is_valid_ipv4, 'gw': None}, +'ipv6': {'match': is_valid_ipv6, 'gw': None}, +} + config = [] for nic in network_data: cfg = dict((k, v) for k, v in nic.items() @@ -727,18 +757,40 @@ cfg.update({'mac_address': nic['mac']}) subnets = [] -for ip, gw in zip(nic['ips'], nic['gateways']): -subnet = dict((k, v) for k, v in nic.items() - if k in valid_keys['subnet']) -subnet.update({ -'type': 'static', -'address': ip, -'gateway': gw, -}) +for ip in nic.get('ips', []): +if ip == "dhcp": +subnet = {'type': 'dhcp4'} +else: +subnet = dict((k, v) for k, v in nic.items() + if k in valid_keys['subnet']) +subnet.update({ +'type': 'static', +'address': ip, +}) + +proto = 'ipv4' if is_valid_ipv4(ip) else 'ipv6' +