Merge "Remove obsolete helper scripts"
This commit is contained in:
commit
783bb1ac80
@ -1,50 +0,0 @@
|
||||
# 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 sys
|
||||
import yaml
|
||||
|
||||
|
||||
def main():
|
||||
def pull(ifaces):
|
||||
for iface in ifaces:
|
||||
yield (iface['name'],
|
||||
iface['assigned_networks'])
|
||||
|
||||
def merge(src, dst):
|
||||
mapping = dict((a['name'], a['id']) for _, ns in dst for a in ns)
|
||||
for name, networks in src:
|
||||
yield (name, [{
|
||||
'id': mapping[n['name']],
|
||||
'name': n['name'],
|
||||
} for n in networks])
|
||||
|
||||
def push(ifaces, assignments):
|
||||
for iface in ifaces:
|
||||
networks = assignments.get(iface['name'], [])
|
||||
yield dict(iface,
|
||||
assigned_networks=networks,
|
||||
)
|
||||
|
||||
src = yaml.load(open(sys.argv[1]))
|
||||
dst = yaml.load(open(sys.argv[2]))
|
||||
|
||||
src_assign = pull(src)
|
||||
dst_assign = pull(dst)
|
||||
assign = merge(src_assign, dst_assign)
|
||||
ifaces = push(dst, dict(assign))
|
||||
|
||||
yaml.dump(list(ifaces), stream=sys.stdout, default_flow_style=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,39 +0,0 @@
|
||||
# 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 argparse
|
||||
import yaml
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description="ips copy script")
|
||||
parser.add_argument('source_yaml', metavar='<file>', type=str,
|
||||
help='source yaml file')
|
||||
parser.add_argument('destination_yaml', metavar='<file>', type=str,
|
||||
help='destination yaml file')
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.source_yaml, 'r') as source:
|
||||
source_yaml = yaml.load(source)
|
||||
|
||||
with open(args.destination_yaml, 'r') as dest:
|
||||
dest_yaml = yaml.load(dest)
|
||||
dest_yaml["management_vip"] = source_yaml["management_vip"]
|
||||
dest_yaml["public_vip"] = source_yaml["public_vip"]
|
||||
for i in source_yaml["nodes"]:
|
||||
for j in dest_yaml["nodes"]:
|
||||
if i["name"] == j["name"] and i["role"] in ["controller",
|
||||
"primary-controller"]:
|
||||
j["internal_address"] = i["internal_address"]
|
||||
j["public_address"] = i["public_address"]
|
||||
|
||||
with open(args.destination_yaml, 'w') as target:
|
||||
target.write(yaml.dump(dest_yaml, default_flow_style=False))
|
@ -1,36 +0,0 @@
|
||||
#!/bin/env python
|
||||
# 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 json
|
||||
import sys
|
||||
|
||||
|
||||
def join(a, b):
|
||||
t = {}
|
||||
for k, v in a.iteritems():
|
||||
nv = b.get(k)
|
||||
if nv is not None:
|
||||
if isinstance(v, basestring):
|
||||
t[k] = nv
|
||||
else:
|
||||
t[k] = join(v, nv)
|
||||
else:
|
||||
t[k] = v
|
||||
return t
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
a = json.loads(sys.stdin.readline())
|
||||
b = json.loads(sys.stdin.readline())
|
||||
c = json.dumps(join(a, b))
|
||||
sys.stdout.write(c)
|
Loading…
Reference in New Issue
Block a user