本文整理汇总了Python中xosconfig.Config.clear方法的典型用法代码示例。如果您正苦于以下问题:Python Config.clear方法的具体用法?Python Config.clear怎么用?Python Config.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xosconfig.Config
的用法示例。
在下文中一共展示了Config.clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
self.sys_path_save = sys.path
# Setting up the config module
from xosconfig import Config
config = os.path.join(test_path, "test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
from xossynchronizer.mock_modelaccessor_build import build_mock_modelaccessor
# FIXME this is to get jenkins to pass the tests, somehow it is running tests in a different order
# and apparently it is not overriding the generated model accessor
build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir, [])
import xossynchronizer.modelaccessor
# import all class names to globals
for (
k,
v,
) in xossynchronizer.modelaccessor.model_accessor.all_model_classes.items():
globals()[k] = v
self.log = Mock()
示例2: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
self.sys_path_save = sys.path
self.cwd_save = os.getcwd()
config = os.path.join(test_path, "test_config.yaml")
from xosconfig import Config
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
from xossynchronizer.mock_modelaccessor_build import (
build_mock_modelaccessor,
)
build_mock_modelaccessor(sync_lib_dir, xos_dir, services_dir=None, service_xprotos=[])
# The test config.yaml references files in `xos-synchronizer-tests/` so make sure we're in the parent
# directory of the test directory.
os.chdir(os.path.join(test_path, ".."))
import xossynchronizer.event_loop
reload(xossynchronizer.event_loop)
import xossynchronizer.backend
reload(xossynchronizer.backend)
from xossynchronizer.modelaccessor import model_accessor
b = xossynchronizer.backend.Backend(model_accessor=model_accessor)
steps_dir = Config.get("steps_dir")
self.steps = b.load_sync_step_modules(steps_dir)
self.synchronizer = xossynchronizer.event_loop.XOSObserver(self.steps, model_accessor)
示例3: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
global ComputeNodePolicy, MockObjectList
self.sys_path_save = sys.path
config = os.path.join(test_path, "../test_config.yaml")
from xosconfig import Config
Config.clear()
Config.init(config, 'synchronizer-config-schema.yaml')
from xossynchronizer.mock_modelaccessor_build import mock_modelaccessor_config
mock_modelaccessor_config(test_path, [("fabric", "fabric.xproto")])
import xossynchronizer.modelaccessor
import mock_modelaccessor
imp.reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
imp.reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test
from model_policy_compute_nodes import ComputeNodePolicy, model_accessor
self.model_accessor = model_accessor
from mock_modelaccessor import MockObjectList
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
# Some of the functions we call have side-effects. For example, creating a VSGServiceInstance may lead to
# creation of tags. Ideally, this wouldn't happen, but it does. So make sure we reset the world.
model_accessor.reset_all_object_stores()
self.policy = ComputeNodePolicy
self.model = Mock()
示例4: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
from xosconfig import Config
test_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
config = os.path.join(test_path, "test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
if USE_FAKE_STUB:
sys.path.append(PARENT_DIR)
示例5: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
self.sys_path_save = sys.path
# Setting up the config module
from xosconfig import Config
config = os.path.join(test_path, "../test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
from xossynchronizer.mock_modelaccessor_build import mock_modelaccessor_config
mock_modelaccessor_config(test_path, [("vrouter", "vrouter.xproto")])
import xossynchronizer.modelaccessor
import mock_modelaccessor
reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test
from sync_routes import SyncRoutes, model_accessor
self.model_accessor = model_accessor
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
self.sync_step = SyncRoutes
self.sync_step.log = Mock()
# mock onos-fabric
onos_fabric = Mock()
onos_fabric.name = "onos-fabric"
onos_fabric.rest_hostname = "onos-fabric"
onos_fabric.rest_port = "8181"
onos_fabric.rest_username = "onos"
onos_fabric.rest_password = "rocks"
onos_fabric_base = Mock()
onos_fabric_base.leaf_model = onos_fabric
self.fabric = Mock()
self.fabric.name = "fabric"
self.fabric.provider_services = [onos_fabric_base]
self.vrouter = Mock()
self.vrouter.name = "vrouter"
self.vrouter.provider_services = [self.fabric]
# create a mock VRouterStaticRoute instance
self.o = Mock()
self.o.id = 1
self.o.vrouter.owner = self.vrouter
self.o.tologdict.return_value = {}
示例6: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
global VSGServiceInstancePolicy, LeastLoadedNodeScheduler, MockObjectList
self.sys_path_save = sys.path
sys.path.append(xos_dir)
sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
config = os.path.join(test_path, "test_config.yaml")
from xosconfig import Config
Config.clear()
Config.init(config, 'synchronizer-config-schema.yaml')
from synchronizers.new_base.mock_modelaccessor_build import build_mock_modelaccessor
build_mock_modelaccessor(xos_dir, services_dir, [get_models_fn("vsg", "vsg.xproto"),
get_models_fn("addressmanager", "addressmanager.xproto")])
import synchronizers.new_base.modelaccessor
import synchronizers.new_base.model_policies.model_policy_tenantwithcontainer
import model_policy_vsgserviceinstance
from model_policy_vsgserviceinstance import VSGServiceInstancePolicy, model_accessor
from synchronizers.new_base.model_policies.model_policy_tenantwithcontainer import LeastLoadedNodeScheduler
from mock_modelaccessor import MockObjectList
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
# Some of the functions we call have side-effects. For example, creating a VSGServiceInstance may lead to creation of
# tags. Ideally, this wouldn't happen, but it does. So make sure we reset the world.
model_accessor.reset_all_object_stores()
# attic functions that are not present in the mock model accessor
VSGServiceInstance.volt = PropertyMock(return_value = None)
AddressManagerServiceInstance.set_attribute = Mock()
self.policy = VSGServiceInstancePolicy()
self.tenant = VSGServiceInstance()
self.user = User(email="[email protected]")
self.tenant = VSGServiceInstance(id=1)
self.flavor = Flavor(name="m1.small")
self.npt_ctag = NetworkParameterType(name="c_tag", id=1)
self.npt_stag = NetworkParameterType(name="s_tag", id=2)
self.npt_neutron_port_name = NetworkParameterType(name="neutron_port_name", id=3)
self.node = Node(hostname="my.node.com")
self.slice = Slice(name="mysite_test1", default_flavor=self.flavor, default_isolation="vm")
self.priv_template = NetworkTemplate(name="access_network", visibility="private")
self.priv_network = Network(name="mysite_test1_private", template=self.priv_template)
self.image = Image(name="trusty-server-multi-nic")
self.deployment = Deployment(name="testdeployment")
Tag.objects.item_list = []
示例7: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
self.sys_path_save = sys.path
self.cwd_save = os.getcwd()
config = os.path.join(test_path, "test_config.yaml")
from xosconfig import Config
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
from xossynchronizer.mock_modelaccessor_build import build_mock_modelaccessor
build_mock_modelaccessor(
sync_lib_dir, xos_dir, services_dir=None, service_xprotos=[]
)
os.chdir(
os.path.join(test_path, "..")
) # config references xos-synchronizer-tests/model-deps
import xossynchronizer.event_loop
reload(xossynchronizer.event_loop)
import xossynchronizer.backend
reload(xossynchronizer.backend)
from xossynchronizer.modelaccessor import model_accessor
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
from xossynchronizer.modelaccessor import model_accessor
b = xossynchronizer.backend.Backend(model_accessor=model_accessor)
steps_dir = Config.get("steps_dir")
self.steps = b.load_sync_step_modules(steps_dir)
self.synchronizer = xossynchronizer.event_loop.XOSObserver(
self.steps, model_accessor
)
try:
os.remove("/tmp/sync_ports")
except OSError:
pass
try:
os.remove("/tmp/delete_ports")
except OSError:
pass
示例8: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
self.sys_path_save = sys.path
# Setting up the config module
from xosconfig import Config
config = os.path.join(test_path, "../test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
from xossynchronizer.mock_modelaccessor_build import build_mock_modelaccessor
# Can't use mock_modelaccessor_config because we're not in the xos-services directory, so do it
# the long way...
xos_dir = os.path.join(test_path, "../../../../xos")
services_dir = os.path.join(test_path, "../../../..")
service_xprotos = [os.path.join(test_path, "../models/testservice.xproto")]
build_mock_modelaccessor(None, xos_dir, services_dir, service_xprotos)
import xossynchronizer.modelaccessor
import mock_modelaccessor
imp.reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
imp.reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test
from sync_testservice_serviceinstance import SyncTestserviceServiceInstance
from xossynchronizer.modelaccessor import model_accessor
self.model_accessor = model_accessor
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
self.sync_step = SyncTestserviceServiceInstance
# TODO: Use modelaccessor instead
# create a mock instance instance
self.model = Mock(name="Example",
some_integer=0,
sync_after_policy=False,
sync_during_policy=False,
policy_after_sync=False,
policy_during_sync=False,
update_during_sync=False,
update_during_policy=False,
create_duplicate=False)
示例9: setup_sync_unit_test
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setup_sync_unit_test(test_path, globals_dict, models, config_fn="test_config.yaml"):
""" Perform the common steps associated with setting up a synchronizer unit test.
1) Import xosconfig.Config and set it up to test_config.yaml in the current dir
2) Build the mock modelaccessor and import it
3) Import all model accessor classes into global space
Arguments:
test_path - path to the test case that is being run
globals_dict - a dictionary to add global models to
models - a list of pairs (service_name, xproto_name)
config_fn - filename of config file)
Returns:
Dictionary containing the following:
sys_path_save: the original sys.path
model_accessor: model accessor class
Config: the Config object
xos_dir: xos directory
services_dir: services directory
"""
sys_path_save = sys.path
# Setting up the config module
from xosconfig import Config
config = os.path.join(test_path, config_fn)
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
from xossynchronizer.mock_modelaccessor_build import mock_modelaccessor_config
mock_modelaccessor_config(test_path, models)
import xossynchronizer.modelaccessor
reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous testp
from xossynchronizer.modelaccessor import model_accessor
# modelaccessor.py will have ensure mock_modelaccessor is in sys.path
from mock_modelaccessor import MockObjectList
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals_dict[k] = v
return {"sys_path_save": sys_path_save,
"model_accessor": model_accessor,
"Config": Config,
"MockObjectList": MockObjectList}
示例10: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
self.sys_path_save = sys.path
# Setting up the config module
from xosconfig import Config
config = os.path.join(test_path, "../test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
from xossynchronizer.mock_modelaccessor_build import build_mock_modelaccessor
# Can't use mock_modelaccessor_config because we're not in the xos-services directory, so do it
# the long way...
xos_dir = os.path.join(test_path, "../../../../xos")
services_dir = os.path.join(test_path, "../../../..")
service_xprotos = [os.path.join(test_path, "../models/testservice.xproto")]
build_mock_modelaccessor(None, xos_dir, services_dir, service_xprotos)
# mock_modelaccessor_config(test_path, [("testservice", "testservice.xproto")])
import xossynchronizer.modelaccessor
import mock_modelaccessor
imp.reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
imp.reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test
from model_policy_testservice_serviceinstance import TestserviceServiceInstancePolicy
from xossynchronizer.modelaccessor import model_accessor
self.model_accessor = model_accessor
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
# Some of the functions we call have side-effects, reset the world.
model_accessor.reset_all_object_stores()
self.policy = TestserviceServiceInstancePolicy(self.model_accessor)
self.si = Mock(sync_after_policy=False,
sync_during_policy=False,
policy_after_sync=False,
policy_during_sync=False,
update_during_sync=False,
update_during_policy=False,
create_duplicate=False)
示例11: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
global DeferredException
self.sys_path_save = sys.path
# Setting up the config module
from xosconfig import Config
config = os.path.join(test_path, "../test_config.yaml")
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
# END Setting up the config module
from xossynchronizer.mock_modelaccessor_build import mock_modelaccessor_config
mock_modelaccessor_config(test_path, [("fabric", "fabric.xproto")])
import xossynchronizer.modelaccessor
import mock_modelaccessor
imp.reload(mock_modelaccessor) # in case nose2 loaded it in a previous test
imp.reload(xossynchronizer.modelaccessor) # in case nose2 loaded it in a previous test
from xossynchronizer.modelaccessor import model_accessor
self.model_accessor = model_accessor
from sync_fabric_port import SyncFabricPort
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
self.sync_step = SyncFabricPort
self.sync_step.log = Mock()
# mock onos-fabric
onos_fabric = Mock()
onos_fabric.name = "onos-fabric"
onos_fabric.rest_hostname = "onos-fabric"
onos_fabric.rest_port = "8181"
onos_fabric.rest_username = "onos"
onos_fabric.rest_password = "rocks"
onos_fabric_base = Mock()
onos_fabric_base.leaf_model = onos_fabric
self.fabric = Mock()
self.fabric.name = "fabric"
self.fabric.provider_services = [onos_fabric_base]
示例12: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
self.sys_path_save = sys.path
self.cwd_save = os.getcwd()
config = os.path.join(test_path, "test_config.yaml")
from xosconfig import Config
Config.clear()
Config.init(config, "synchronizer-config-schema.yaml")
from xossynchronizer import loadmodels
from xossynchronizer.loadmodels import ModelLoadClient
self.loadmodels = loadmodels
self.api = MagicMock()
self.api.dynamicload_pb2.LoadModelsRequest = MockLoadModelsRequest
self.loader = ModelLoadClient(self.api)
示例13: tearDown
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def tearDown(self):
# NOTE clear the config after each test
Config.clear()
示例14: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
# In case some other testcase in nose has left config in an unclean state
Config.clear()
示例15: setUp
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import clear [as 别名]
def setUp(self):
global SyncVSGServiceInstance, LeastLoadedNodeScheduler, MockObjectList
self.sys_path_save = sys.path
sys.path.append(xos_dir)
sys.path.append(os.path.join(xos_dir, 'synchronizers', 'new_base'))
config = os.path.join(test_path, "test_config.yaml")
from xosconfig import Config
Config.clear()
Config.init(config, 'synchronizer-config-schema.yaml')
from synchronizers.new_base.mock_modelaccessor_build import build_mock_modelaccessor
build_mock_modelaccessor(xos_dir, services_dir, [get_models_fn("vsg", "vsg.xproto"),
get_models_fn("addressmanager", "addressmanager.xproto")])
import synchronizers.new_base.modelaccessor
import synchronizers.new_base.model_policies.model_policy_tenantwithcontainer
import sync_vsgserviceinstance
from sync_vsgserviceinstance import SyncVSGServiceInstance, model_accessor
from mock_modelaccessor import MockObjectList
# import all class names to globals
for (k, v) in model_accessor.all_model_classes.items():
globals()[k] = v
# Some of the functions we call have side-effects. For example, creating a VSGServiceInstance may lead to creation of
# tags. Ideally, this wouldn't happen, but it does. So make sure we reset the world.
model_accessor.reset_all_object_stores()
# attic functions that are not present in the mock model accessor
AddressManagerServiceInstance.set_attribute = Mock()
self.syncstep = SyncVSGServiceInstance()
# set up an object hierarchy that represents a Service and ServiceInstance
self.user = User(email="[email protected]")
self.service = VSGService(name="the_vsg_service",
id=1,
docker_image_name="reg/vsg_docker",
docker_insecure_registry=True,
dns_servers="dnsone,dnstwo",
url_filter_kind=None,
private_key_fn=os.path.join(test_path, "test_private_key"))
self.subscriber = MagicMock(firewall_rules = "rule1",
firewall_enable = True,
url_filter_enable = True,
url_filter_level="R",
cdn_enable=True,
uplink_speed=1234,
downlink_speed=5678,
enable_uverse=False,
status="suspended",
sync_attributes=["firewall_rules", "firewall_enable", "url_filter_enable",
"url_filter_level", "cdn_enable", "uplink_speed",
"downlink_speed", "enable_uverse", "status"])
self.volt = MagicMock(s_tag=111, c_tag=222, subscriber=self.subscriber)
self.tenant = VSGServiceInstance(id=401,
volt=self.volt,
owner=self.service,
wan_container_ip="10.7.1.3",
wan_container_netbits="24",
wan_container_mac="02:42:0a:07:01:03",
wan_container_gateway_ip="10.7.1.1",
wan_vm_ip="10.7.1.2",
wan_vm_mac="02:42:0a:07:01:02",
sync_attributes = ["wan_container_ip", "wan_container_netbits", "wan_container_mac",
"wan_container_gateway_ip", "wan_vm_ip", "wan_vm_mac"])
self.flavor = Flavor(name="m1.small")
self.npt_ctag = NetworkParameterType(name="c_tag", id=1)
self.npt_stag = NetworkParameterType(name="s_tag", id=2)
self.npt_neutron_port_name = NetworkParameterType(name="neutron_port_name", id=501)
self.priv_template = NetworkTemplate(name="access_network", visibility="private")
self.priv_network = Network(name="mysite_test1_private", template=self.priv_template)
self.image = Image(name="trusty-server-multi-nic")
self.deployment = Deployment(name="testdeployment")
self.user = User(email="smbaker", id=701)
self.controller = Controller(id=101)
self.node = Node(name="testnode")
self.slice = Slice(name="mysite_test1", default_flavor=self.flavor, default_isolation="vm", service=self.service, id=301)
self.instance = Instance(slice=self.slice,
instance_name="testinstance1_instance_name",
instance_id="testinstance1_instance_id",
name="testinstance1_name",
node=self.node,
creator=self.user,
controller=self.controller)
self.tenant.instance = self.instance
self.instance.get_ssh_ip = Mock(return_value="1.2.3.4")
self.controllerslice = ControllerSlice(slice_id=self.slice.id, controller_id=self.controller.id, id=201)
self.controlleruser = ControllerUser(user_id=self.user.id, controller_id=self.controller.id, id=601)