本文整理匯總了Python中devops.manager.Manager.create_network_pool方法的典型用法代碼示例。如果您正苦於以下問題:Python Manager.create_network_pool方法的具體用法?Python Manager.create_network_pool怎麽用?Python Manager.create_network_pool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類devops.manager.Manager
的用法示例。
在下文中一共展示了Manager.create_network_pool方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: EnvironmentModel
# 需要導入模塊: from devops.manager import Manager [as 別名]
# 或者: from devops.manager.Manager import create_network_pool [as 別名]
#.........這裏部分代碼省略.........
"""
environment = self.manager.environment_create(self.env_name)
networks = []
interfaces = settings.INTERFACE_ORDER
if self.multiple_cluster_networks:
logger.info('Multiple cluster networks feature is enabled!')
if settings.BONDING:
interfaces = settings.BONDING_INTERFACES.keys()
for name in interfaces:
networks.append(self.create_networks(name, environment))
for name in self.node_roles.admin_names:
self.describe_admin_node(name, networks)
for name in self.node_roles.other_names:
if self.multiple_cluster_networks:
networks1 = [net for net in networks if net.name
in settings.NODEGROUPS[0]['pools']]
networks2 = [net for net in networks if net.name
in settings.NODEGROUPS[1]['pools']]
# If slave index is even number, then attach to
# it virtual networks from the second network group.
if int(name[-2:]) % 2 == 1:
self.describe_empty_node(name, networks1)
elif int(name[-2:]) % 2 == 0:
self.describe_empty_node(name, networks2)
else:
self.describe_empty_node(name, networks)
return environment
def create_networks(self, name, environment):
ip_networks = [
IPNetwork(x) for x in settings.POOLS.get(name)[0].split(',')]
new_prefix = int(settings.POOLS.get(name)[1])
pool = self.manager.create_network_pool(networks=ip_networks,
prefix=int(new_prefix))
return self.manager.network_create(
name=name,
environment=environment,
pool=pool,
forward=settings.FORWARDING.get(name),
has_dhcp_server=settings.DHCP.get(name))
def devops_nodes_by_names(self, devops_node_names):
return map(
lambda name:
self.get_virtual_environment().node_by_name(name),
devops_node_names)
@logwrap
def describe_admin_node(self, name, networks):
node = self.add_node(
memory=settings.HARDWARE.get("admin_node_memory", 1024),
vcpu=settings.HARDWARE.get("admin_node_cpu", 1),
name=name,
boot=['hd', 'cdrom'])
self.create_interfaces(networks, node)
if self.os_image is None:
self.add_empty_volume(node, name + '-system')
self.add_empty_volume(
node,
name + '-iso',
capacity=_get_file_size(settings.ISO_PATH),
format='raw',
device='cdrom',
bus='ide')
示例2: EnvironmentModel
# 需要導入模塊: from devops.manager import Manager [as 別名]
# 或者: from devops.manager.Manager import create_network_pool [as 別名]
#.........這裏部分代碼省略.........
def add_syslog_server(self, cluster_id, port=5514):
self.fuel_web.add_syslog_server(
cluster_id, self.get_host_node_ip(), port)
def bootstrap_nodes(self, devops_nodes, timeout=600):
"""Lists registered nailgun nodes
Start vms and wait until they are registered on nailgun.
:rtype : List of registered nailgun nodes
"""
for node in devops_nodes:
node.start()
wait(lambda: all(self.nailgun_nodes(devops_nodes)), 15, timeout)
for node in self.nailgun_nodes(devops_nodes):
self.sync_node_time(self.get_ssh_to_remote(node["ip"]))
return self.nailgun_nodes(devops_nodes)
def create_interfaces(self, networks, node,
model=settings.INTERFACE_MODEL):
for network in networks:
self.manager.interface_create(network, node=node, model=model)
def describe_environment(self):
"""Environment
:rtype : Environment
"""
environment = self.manager.environment_create(self.env_name)
networks = []
for name in settings.INTERFACE_ORDER:
ip_networks = [
IPNetwork(x) for x in settings.POOLS.get(name)[0].split(',')]
new_prefix = int(settings.POOLS.get(name)[1])
pool = self.manager.create_network_pool(networks=ip_networks,
prefix=int(new_prefix))
networks.append(self.manager.network_create(
name=name,
environment=environment,
pool=pool,
forward=settings.FORWARDING.get(name),
has_dhcp_server=settings.DHCP.get(name)))
for name in self.node_roles.admin_names:
self.describe_admin_node(name, networks)
for name in self.node_roles.other_names:
self.describe_empty_node(name, networks)
return environment
def devops_nodes_by_names(self, devops_node_names):
return map(
lambda name:
self.get_virtual_environment().node_by_name(name),
devops_node_names)
@logwrap
def describe_admin_node(self, name, networks):
node = self.add_node(
memory=settings.HARDWARE.get("admin_node_memory", 1024),
vcpu=settings.HARDWARE.get("admin_node_cpu", 1),
name=name,
boot=['hd', 'cdrom'])
self.create_interfaces(networks, node)
if self.os_image is None:
self.add_empty_volume(node, name + '-system')
self.add_empty_volume(
示例3: EnvironmentModel
# 需要導入模塊: from devops.manager import Manager [as 別名]
# 或者: from devops.manager.Manager import create_network_pool [as 別名]
#.........這裏部分代碼省略.........
def create_interfaces(self, networks, node,
model=settings.INTERFACE_MODEL):
if settings.BONDING:
for network in networks:
self.manager.interface_create(
network, node=node, model=model,
interface_map=settings.BONDING_INTERFACES)
else:
for network in networks:
self.manager.interface_create(network, node=node, model=model)
def describe_environment(self):
"""Environment
:rtype : Environment
"""
environment = self.manager.environment_create(self.env_name)
networks = []
interfaces = settings.INTERFACE_ORDER
if settings.BONDING:
interfaces = settings.BONDING_INTERFACES.keys()
for name in interfaces:
networks.append(self.create_networks(name, environment))
for name in self.node_roles.admin_names:
self.describe_admin_node(name, networks)
for name in self.node_roles.other_names:
self.describe_empty_node(name, networks)
return environment
def create_networks(self, name, environment):
ip_networks = [
IPNetwork(x) for x in settings.POOLS.get(name)[0].split(',')]
new_prefix = int(settings.POOLS.get(name)[1])
pool = self.manager.create_network_pool(networks=ip_networks,
prefix=int(new_prefix))
return self.manager.network_create(
name=name,
environment=environment,
pool=pool,
forward=settings.FORWARDING.get(name),
has_dhcp_server=settings.DHCP.get(name))
def devops_nodes_by_names(self, devops_node_names):
return map(
lambda name:
self.get_virtual_environment().node_by_name(name),
devops_node_names)
@logwrap
def describe_admin_node(self, name, networks):
node = self.add_node(
memory=settings.HARDWARE.get("admin_node_memory", 1024),
vcpu=settings.HARDWARE.get("admin_node_cpu", 1),
name=name,
boot=['hd', 'cdrom'])
self.create_interfaces(networks, node)
if self.os_image is None:
self.add_empty_volume(node, name + '-system')
self.add_empty_volume(
node,
name + '-iso',
capacity=_get_file_size(settings.ISO_PATH),
format='raw',
device='cdrom',
bus='ide')
示例4: EnvironmentModel
# 需要導入模塊: from devops.manager import Manager [as 別名]
# 或者: from devops.manager.Manager import create_network_pool [as 別名]
#.........這裏部分代碼省略.........
def add_syslog_server(self, cluster_id, port=5514):
self.fuel_web.add_syslog_server(
cluster_id, self.get_host_node_ip(), port)
def bootstrap_nodes(self, devops_nodes, timeout=600):
"""
Start vms and wait they are registered on nailgun.
:rtype : List of registered nailgun nodes
"""
for node in devops_nodes:
node.start()
wait(lambda: all(self.nailgun_nodes(devops_nodes)), 15, timeout)
for node in self.nailgun_nodes(devops_nodes):
self.sync_node_time(self.get_ssh_to_remote(node["ip"]))
return self.nailgun_nodes(devops_nodes)
def create_interfaces(self, networks, node,
model=settings.INTERFACE_MODEL):
for network in networks:
self.manager.interface_create(network, node=node, model=model)
def describe_environment(self):
"""
:rtype : Environment
"""
environment = self.manager.environment_create(self.env_name)
networks = []
for name in settings.INTERFACE_ORDER:
ip_networks = [
IPNetwork(x) for x in settings.POOLS.get(name)[0].split(',')]
new_prefix = int(settings.POOLS.get(name)[1])
pool = self.manager.create_network_pool(networks=ip_networks,
prefix=int(new_prefix))
networks.append(self.manager.network_create(
name=name,
environment=environment,
pool=pool,
forward=settings.FORWARDING.get(name),
has_dhcp_server=settings.DHCP.get(name)))
for name in self.node_roles.admin_names:
self.describe_admin_node(name, networks)
for name in self.node_roles.other_names:
self.describe_empty_node(name, networks)
return environment
def devops_nodes_by_names(self, devops_node_names):
return map(
lambda name:
self.get_virtual_environment().node_by_name(name),
devops_node_names)
@logwrap
def describe_admin_node(self, name, networks):
node = self.add_node(
memory=settings.HARDWARE.get("admin_node_memory", 1024),
vcpu=settings.HARDWARE.get("admin_node_cpu", 1),
name=name,
boot=['hd', 'cdrom'])
self.create_interfaces(networks, node)
self.add_empty_volume(node, name + '-system')
self.add_empty_volume(
node,
name + '-iso',
示例5: EnvironmentModel
# 需要導入模塊: from devops.manager import Manager [as 別名]
# 或者: from devops.manager.Manager import create_network_pool [as 別名]
class EnvironmentModel(object):
hostname = "nailgun"
domain = "test.domain.local"
installation_timeout = 1800
deployment_timeout = 1800
puppet_timeout = 1000
nat_interface = "" # INTERFACES.get('admin')
admin_net = "admin"
def __init__(self):
self._virtual_environment = None
self._keys = None
self.manager = Manager()
self._fuel_web = FuelWebClient(self.get_admin_node_ip(), self)
def _get_or_create(self):
try:
return self.manager.environment_get(self.env_name)
except:
self._virtual_environment = self.describe_environment()
self._virtual_environment.define()
return self._virtual_environment
def router(self, router_name=None):
router_name = router_name or self.admin_net
return str(IPNetwork(self.get_virtual_environment().network_by_name(router_name).ip_network)[1])
@property
def fuel_web(self):
"""
:rtype: FuelWebClient
"""
return self._fuel_web
@property
def node_roles(self):
return NodeRoles(admin_names=["admin"], other_names=["slave-%02d" % x for x in range(1, 10)])
@property
def env_name(self):
return ENV_NAME
def add_empty_volume(
self, node, name, capacity=NODE_VOLUME_SIZE * 1024 * 1024 * 1024, device="disk", bus="virtio", format="qcow2"
):
self.manager.node_attach_volume(
node=node,
volume=self.manager.volume_create(
name=name, capacity=capacity, environment=self.get_virtual_environment(), format=format
),
device=device,
bus=bus,
)
def add_node(self, memory, name, vcpu=1, boot=None):
return self.manager.node_create(
name=name, memory=memory, vcpu=vcpu, environment=self.get_virtual_environment(), boot=boot
)
@logwrap
def add_syslog_server(self, cluster_id, port=5514):
self.fuel_web.add_syslog_server(cluster_id, self.get_host_node_ip(), port)
def bootstrap_nodes(self, devops_nodes, timeout=600):
"""
Start vms and wait they are registered on nailgun.
:rtype : List of registered nailgun nodes
"""
for node in devops_nodes:
node.start()
wait(lambda: all(self.nailgun_nodes(devops_nodes)), 15, timeout)
for node in self.nailgun_nodes(devops_nodes):
self.sync_node_time(self.get_ssh_to_remote(node["ip"]))
return self.nailgun_nodes(devops_nodes)
def create_interfaces(self, networks, node, model=INTERFACE_MODEL):
for network in networks:
self.manager.interface_create(network, node=node, model=model)
def describe_environment(self):
"""
:rtype : Environment
"""
environment = self.manager.environment_create(self.env_name)
networks = []
for name in INTERFACE_ORDER:
ip_networks = [IPNetwork(x) for x in POOLS.get(name)[0].split(",")]
new_prefix = int(POOLS.get(name)[1])
pool = self.manager.create_network_pool(networks=ip_networks, prefix=int(new_prefix))
networks.append(
self.manager.network_create(
name=name,
environment=environment,
pool=pool,
forward=FORWARDING.get(name),
has_dhcp_server=DHCP.get(name),
)
)
#.........這裏部分代碼省略.........
示例6: Environment
# 需要導入模塊: from devops.manager import Manager [as 別名]
# 或者: from devops.manager.Manager import create_network_pool [as 別名]
class Environment(object):
capacity = 20 * 1024 * 1024 * 1024
boot = ['hd', 'cdrom']
login = "root"
password = "r00tme"
name = 'fuel'
def __init__(self, name=name, base_image=None):
self.manager = Manager()
self.name = name
self.base_image = base_image
self.environment = self._get_or_create()
def _get_or_create(self):
try:
return self.manager.environment_get(self.name)
except:
self.environment = self._create()
self.environment.define()
return self.environment
def nodes(self):
return Nodes(self.environment, self._node_roles())
def get_empty_state(self):
if self.environment.has_snapshot(EMPTY_SNAPSHOT):
self.environment.revert(EMPTY_SNAPSHOT)
return True
return None
def get_env(self):
return self.environment
def add_empty_volume(self, node, name, capacity=capacity, device='disk', bus='virtio', format='qcow2'):
self.manager.node_attach_volume(node=node,
volume=self.manager.volume_create(name=name,
capacity=capacity,
environment=self.environment,
format=format),
device=device,
bus=bus)
def add_node(self, name, memory, boot=None):
return self.manager.node_create(name=name,
memory=memory,
environment=self.environment,
boot=boot)
def create_interfaces(self, node, networks):
for network in networks:
self.manager.interface_create(network, node=node)
def describe_admin_node(self, name, networks, memory=DEFAULT_RAM_SIZE, boot=boot):
node = self.add_node(memory=memory, name=name, boot=boot)
self.create_interfaces(node, networks)
if self.base_image is None:
self.add_empty_volume(node, name + '-system')
self.add_empty_volume(node, name + '-iso', capacity=_get_file_size(ISO_PATH), format='raw', device='cdrom', bus='ide')
else:
volume = self.manager.volume_get_predefined(self.base_image)
v = self.manager.volume_create_child(name + '-system', backing_store=volume, environment=self.environment)
self.manager.node_attach_volume(node=node, volume=v)
return node
def describe_node(self, name, networks, memory=DEFAULT_RAM_SIZE):
node = self.add_node(name, memory)
self.create_interfaces(node, networks)
self.add_empty_volume(node, name + '-system')
# self.add_empty_volume(node, name + '-cinder')
#self.add_empty_volume(node, name + '-swift')
return node
def _node_roles(self):
controllers = ['fuel-controller-%02d' % x for x in range(1, 1 + COUNT_NODES[DEPLOYMENT_MODE]['CONTROLLERS'])]
computes = ['fuel-compute-%02d' % x for x in range(1, 1 + COUNT_NODES[DEPLOYMENT_MODE]['COMPUTES'])]
storages = ['fuel-swift-%02d' % x for x in range(1, 1 + COUNT_NODES[DEPLOYMENT_MODE]['STORAGES'])]
proxies = ['fuel-swift-proxy-%02d' % x for x in range(1, 1 + COUNT_NODES[DEPLOYMENT_MODE]['PROXIES'])]
quantums = ['fuel-quantum-%02d' % x for x in range(1, 1 + COUNT_NODES[DEPLOYMENT_MODE]['QUANTUMS'])]
return NodeRoles(admin_names=['master'],
other_names=controllers + computes + storages + proxies + quantums
)
def _create(self):
self.environment = self.manager.environment_create(self.name)
networks = []
for name in INTERFACE_ORDER:
ip_networks = [IPNetwork(x) for x in POOLS.get(name)[0].split(',')]
new_prefix = int(POOLS.get(name)[1])
pool = self.manager.create_network_pool(networks=ip_networks, prefix=int(new_prefix))
networks.append(self.manager.network_create(name=name,
environment=self.environment,
pool=pool,
forward=FORWARDING.get(name),
has_dhcp_server=DHCP.get(name)))
#.........這裏部分代碼省略.........