From aeb2791f4d3a5e23090e56c330436205a61629d7 Mon Sep 17 00:00:00 2001 From: Trevor Bramwell Date: Fri, 22 Sep 2017 11:48:38 -0700 Subject: Remove 'tools' Directory All tools (and history) have been moved to the pharos-tools repository: https://git.opnfv.org/pharos-tools/ Change-Id: I84fa9b6ebd9b27f42d41f2722eb1221ec39a8c94 Signed-off-by: Trevor Bramwell --- tools/laas-fog/source/network.py | 103 --------------------------------------- 1 file changed, 103 deletions(-) delete mode 100644 tools/laas-fog/source/network.py (limited to 'tools/laas-fog/source/network.py') diff --git a/tools/laas-fog/source/network.py b/tools/laas-fog/source/network.py deleted file mode 100644 index 234ba22e..00000000 --- a/tools/laas-fog/source/network.py +++ /dev/null @@ -1,103 +0,0 @@ -""" -############################################################################# -#Copyright 2017 Parker Berberian and others # -# # -#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 xml.dom -import xml.dom.minidom -import yaml - - -class Network: - """ - This class has a similar role as the Domain class. - This class will parse a config file and - write the xml definitions of those networks for libvirt. - """ - - def __init__(self, propertiesDict): - """ - init. propertiesDict should be - one of the dictionaries returned by parseConfigFile - """ - self.name = propertiesDict['name'] - self.brName = propertiesDict['brName'] - self.brAddr = propertiesDict['brAddr'] - self.netmask = propertiesDict['netmask'] - self.forward = propertiesDict['forward'] - self.dhcp = propertiesDict['dhcp'] - self.cidr = propertiesDict['cidr'] - - def toXML(self): - """ - Takes the config of this network and writes a valid xml definition - for libvirt. - returns a string - """ - definition = xml.dom.minidom.parseString("\n") - nameElem = definition.createElement('name') - nameElem.appendChild(definition.createTextNode(self.name)) - definition.documentElement.appendChild(nameElem) - - if self.forward['used']: - forwardElem = definition.createElement('forward') - forwardElem.setAttribute('mode', self.forward['type']) - definition.documentElement.appendChild(forwardElem) - - bridgeElem = definition.createElement('bridge') - bridgeElem.setAttribute('name', self.brName) - bridgeElem.setAttribute('stp', 'on') - bridgeElem.setAttribute('delay', '5') - definition.documentElement.appendChild(bridgeElem) - - ipElem = definition.createElement('ip') - ipElem.setAttribute('address', self.brAddr) - ipElem.setAttribute('netmask', self.netmask) - if self.dhcp['used']: - dhcpElem = definition.createElement('dhcp') - rangeElem = definition.createElement('range') - rangeElem.setAttribute('start', self.dhcp['rangeStart']) - rangeElem.setAttribute('end', self.dhcp['rangeEnd']) - dhcpElem.appendChild(rangeElem) - ipElem.appendChild(dhcpElem) - - definition.documentElement.appendChild(ipElem) - - self.xml = definition.toprettyxml() - return self.xml - - def writeXML(self, filePath): - """ - writes xml definition to given file - """ - f = open(filePath, 'w') - f.write(self.toXML()) - f.close() - - @staticmethod - def parseConfigFile(path): - """ - parses given config file - """ - configFile = open(path, 'r') - try: - config = yaml.safe_load(configFile) - except Exception: - print "Bad network configuration file. exiting" - sys.exit(1) - - return config -- cgit 1.2.3-korg