当前位置: 首页>>代码示例>>Python>>正文


Python Environment.get方法代码示例

本文整理汇总了Python中devops.models.Environment.get方法的典型用法代码示例。如果您正苦于以下问题:Python Environment.get方法的具体用法?Python Environment.get怎么用?Python Environment.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在devops.models.Environment的用法示例。


在下文中一共展示了Environment.get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_object_not_found_exceptions

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
    def test_object_not_found_exceptions(self):
        with self.assertRaises(DevopsObjNotFound):
            Environment.get(name='other-env')

        with self.assertRaises(DevopsObjNotFound):
            self.env.get_group(name='other-rack')

        with self.assertRaises(DevopsObjNotFound):
            self.env.get_address_pool(name='other-pool')

        with self.assertRaises(DevopsObjNotFound):
            self.env.get_node(name='other-node')

        group = self.env.get_group(name='rack-01')

        with self.assertRaises(DevopsObjNotFound):
            group.get_l2_network_device(name='other-device')

        with self.assertRaises(DevopsObjNotFound):
            group.get_network_pool(name='other-pool')

        with self.assertRaises(DevopsObjNotFound):
            group.get_node(name='other-node')

        with self.assertRaises(DevopsObjNotFound):
            Group.get(name='other-group')

        node = self.env.get_node(name='slave-01')

        with self.assertRaises(DevopsObjNotFound):
            node.get_volume(name='other-volume')
开发者ID:TregubovYury,项目名称:fuel-devops,代码行数:33,代码来源:test_template.py

示例2: d_env

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
 def d_env(self):
     if self._virt_env is None:
         if not self._config:
             try:
                 return Environment.get(name=settings.ENV_NAME)
             except Exception:
                 self._virt_env = Environment.describe_environment(boot_from=settings.ADMIN_BOOT_DEVICE)
                 self._virt_env.define()
         else:
             try:
                 return Environment.get(name=self._config["template"]["devops_settings"]["env_name"])
             except Exception:
                 self._virt_env = Environment.create_environment(full_config=self._config)
                 self._virt_env.define()
     return self._virt_env
开发者ID:asledzinskiy,项目名称:fuel-qa,代码行数:17,代码来源:environment.py

示例3: get_env

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
 def get_env(cls, env_name):
     """Find and return env by name."""
     try:
         return EnvProxy(Environment.get(name=env_name))
     except Exception as e:
         logger.error(
             'failed to find the last created environment{}'.format(e))
         raise
开发者ID:TatyanaGladysheva,项目名称:mos-integration-tests,代码行数:10,代码来源:devops_client.py

示例4: d_env

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
 def d_env(self):
     if self._virtual_environment is None:
         try:
             return Environment.get(name=settings.ENV_NAME)
         except Exception:
             self._virtual_environment = Environment.describe_environment(
                 boot_from=settings.ADMIN_BOOT_DEVICE)
             self._virtual_environment.define()
     return self._virtual_environment
开发者ID:aglarendil,项目名称:fuel-qa,代码行数:11,代码来源:environment.py

示例5: __init__

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
 def __init__(self, args):
     self.args = args
     self.params = self.get_params()
     if getattr(self.params, "snapshot-name", None):
         self.snapshot_name = getattr(self.params, "snapshot-name")
     if getattr(self.params, "name", None) and getattr(self.params, "command", None) != "create":
         try:
             self.env = Environment.get(name=self.params.name)
         except Environment.DoesNotExist:
             self.env = None
             sys.exit("Enviroment with name {} doesn't exist." "".format(self.params.name))
开发者ID:TracyHe,项目名称:fuel-devops,代码行数:13,代码来源:shell.py

示例6: __init__

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
 def __init__(self, args):
     self.args = args
     self.params = self.get_params()
     if getattr(self.params, 'snapshot-name', None):
         self.snapshot_name = getattr(self.params, 'snapshot-name')
     if (getattr(self.params, 'name', None) and
             getattr(self.params, 'command', None) != 'create'):
         try:
             self.env = Environment.get(name=self.params.name)
         except DevopsObjNotFound:
             self.env = None
             sys.exit("Enviroment with name {} doesn't exist."
                      "".format(self.params.name))
开发者ID:TregubovYury,项目名称:fuel-devops,代码行数:15,代码来源:shell.py

示例7: do_list

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
    def do_list(self):
        env_list = Environment.list_all().values("name", "created")
        columns = []
        for env in env_list:
            column = collections.OrderedDict({"NAME": env["name"]})
            if self.params.list_ips:
                cur_env = Environment.get(name=env["name"])
                admin_ip = ""
                if "admin" in [node.name for node in cur_env.get_nodes()]:
                    admin_ip = cur_env.get_node(name="admin").get_ip_address_by_network_name("admin")
                column["ADMIN IP"] = admin_ip
            if self.params.timestamps:
                column["CREATED"] = env["created"].strftime("%Y-%m-%d_%H:%M:%S")
            columns.append(column)

        self.print_table(headers="keys", columns=columns)
开发者ID:TracyHe,项目名称:fuel-devops,代码行数:18,代码来源:shell.py

示例8: get_env

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
    def get_env(cls, env_name=''):
        """Find and return env by name.

        If name is empty will try to find the last created env.
        Will return None is failed to find any env at all.
        """
        env = None
        try:
            if env_name:
                env = Environment.get(name=env_name)
            else:
                env = Environment.objects.all().order_by('created').last()
        except Exception as e:
            logger.error('failed to find the last created environment{}'.
                         format(e))
            raise
        return env
开发者ID:AlexGromov,项目名称:mos-integration-tests,代码行数:19,代码来源:devops_client.py

示例9: do_list

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
    def do_list(self):
        env_list = Environment.list().values('name', 'created')
        for env in env_list:
            if self.params.list_ips:
                cur_env = Environment.get(name=env['name'])
                admin_ip = ''
                if 'admin' in [node.name for node in cur_env.get_nodes()]:
                    admin_ip = (cur_env.get_node(name='admin').
                                get_ip_address_by_network_name('admin'))
                print('{0}\t{1}'.format(env['name'], admin_ip))
            elif self.params.timestamps:
                created_text = env['created'].strftime('%Y-%m-%d_%H:%M:%S')
                print('{0} {1}'.format(env['name'], created_text))
            else:
                print(env['name'])

        return env_list
开发者ID:chirag028,项目名称:fuel-devops,代码行数:19,代码来源:shell.py

示例10: do_list

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
    def do_list(self):
        env_list = Environment.list_all().values('name', 'created')
        columns = []
        for env in env_list:
            column = collections.OrderedDict({'NAME': env['name']})
            if self.params.list_ips:
                cur_env = Environment.get(name=env['name'])
                admin_ip = ''
                if 'admin' in [node.name for node in cur_env.get_nodes()]:
                    admin_ip = (cur_env.get_node(name='admin').
                                get_ip_address_by_network_name('admin'))
                column['ADMIN IP'] = admin_ip
            if self.params.timestamps:
                column['CREATED'] = env['created'].strftime(
                    '%Y-%m-%d_%H:%M:%S')
            columns.append(column)

        self.print_table(headers="keys", columns=columns)
开发者ID:jeromeshi,项目名称:fuel-devops,代码行数:20,代码来源:shell.py

示例11: __init__

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
 def __init__(self, args):
     self.args = args
     self.params = self.get_params()
     if (getattr(self.params, 'name', None) and
             getattr(self.params, 'command', None) != 'create'):
         self.env = Environment.get(name=self.params.name)
开发者ID:jeromeshi,项目名称:fuel-devops,代码行数:8,代码来源:shell.py

示例12: setup_env_network

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
def setup_env_network(fuel_port=8000):
    from os import environ
    environ.setdefault("DJANGO_SETTINGS_MODULE", "devops.settings")

    from devops.models import Environment
    s = Environment.get(name=env.host)
    for net in s.get_networks():
        print net.name, net.ip, net.netmask, net.default_gw

    def get_net(name):
        return next(x for x in s.get_networks() if x.name == name)

    def make_ip(ip, last_octet):
        ip = str(ip.ip).split('.')
        ip[3] = str(last_octet)
        return '.'.join(ip)

    for cluster in clusters('{}:{}'.format(env.host, fuel_port), 'admin', 'admin'):
        net = get_network('{}:{}'.format(env.host, fuel_port), 'admin', 'admin', cluster['id'])

        public = get_net('public')
        management = get_net('management')
        private = get_net('private')

        net['public_vrouter_vip'] = make_ip(public, 2)
        net['public_vip'] = make_ip(public, 3)



        net['vips']['vrouter_pub']['ipaddr'] = make_ip(public, 2)  # "10.21.1.2",
        net['vips']['management']['ipaddr'] = make_ip(management, 2)  # "10.21.2.2"
        net['vips']['public']['ipaddr'] = make_ip(public, 3) # "10.21.1.3",
        net['vips']['vrouter']['ipaddr'] = make_ip(management, 2)  # "10.21.2.1",

        net['networking_parameters']['floating_ranges'] = [
          [
             make_ip(public, 130), make_ip(public, 254)
          ]
        ]

        # "internal_gateway": "10.21.3.1",
        net['networking_parameters']['internal_gateway'] = make_ip(private, 1)

        # "internal_cidr": "10.21.3.0/24",
        net['networking_parameters']['internal_cidr'] = str(get_net('private').ip)

        for network in net['networks']:

            if network['name'] == 'private':
                continue

            try:
                kvm_net = get_net(network['name'])
            except StopIteration:
                continue

            network['ip_ranges'] = [
              [
                 make_ip(kvm_net, 1), make_ip(public, 254)
              ]
            ]
            network['cidr'] = str(kvm_net.ip)

            if network['name'] == 'public':
                 network['ip_ranges'] = [
                              [
                                 make_ip(kvm_net, 2), make_ip(kvm_net, 126)
                              ] ]

            network['gateway'] = make_ip(kvm_net, 1)

        net['management_vrouter_vip'] = make_ip(management, 1)  # "10.21.2.1",
        net['management_vip'] = make_ip(management, 2)  # "10.21.2.2",

        pprint.pprint(net)
        put_network('{}:{}'.format(env.host, fuel_port), 'admin', 'admin', cluster['id'], net)
开发者ID:nikitamarchenko,项目名称:mazut,代码行数:78,代码来源:fabfile.py

示例13: _attach_diagnostic_snapshot

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
def _attach_diagnostic_snapshot():
    _configure_log()

    # FIXME(schipiga): include already installed packages for import visibility
    sys.path.extend(['/usr/lib/python2.7',
                     '/usr/lib/python2.7/dist-packages',
                     '/usr/local/lib/python2.7/dist-packages'])

    try:
        from devops.models import Environment
        from fuelclient import client, fuelclient_settings
        from fuelclient.objects import SnapshotTask
    except ImportError as e:
        LOGGER.error(e)
        return

    job_name = os.environ.get('JOB_NAME')
    if not job_name:
        LOGGER.info("Diagnostic snapshot is attached only on CI server")
        return

    env_name = os.environ.get('ENV_NAME')
    if not env_name:
        LOGGER.error("Environment name isn't specified at build")
        return

    try:
        env = Environment.get(name=env_name)
        master = env.get_nodes(role__in=('fuel_master', 'admin'))[0]
        admin_ip = master.get_ip_address_by_network_name('admin')

        os.environ.update({
            'SERVER_ADDRESS': admin_ip,
            'OS_USERNAME': 'admin',
            'OS_PASSWORD': 'admin',
        })
        fuelclient_settings._SETTINGS = None
        client.APIClient.__init__()

        config = SnapshotTask.get_default_config()
        task = SnapshotTask.start_snapshot_task(config)

        LOGGER.info('Starting snapshot creating...')
        task.wait()
        if task.status != 'ready':
            LOGGER.error("Snapshot creating is finished with error: {}".format(
                task.data["message"]))
            return
        LOGGER.info("Snapshot creating is finished")

        response = requests.get(
            'http://{}:8000{}'.format(admin_ip, task.data["message"]),
            stream=True,
            headers={'x-auth-token': client.APIClient.auth_token})

        file_path = os.path.join(_reports_dir(), 'diagnostic_snapshot.tar.xz')
        with open(file_path, 'wb') as f:
            for chunk in response.iter_content(65536):
                if chunk:
                    f.write(chunk)
    except Exception as e:
        LOGGER.error(e)
开发者ID:AlexandraAllakhverdieva,项目名称:mos-horizon,代码行数:64,代码来源:__init__.py

示例14: get_env

# 需要导入模块: from devops.models import Environment [as 别名]
# 或者: from devops.models.Environment import get [as 别名]
def get_env():
    env = os.environ
    env_name = env['ENV_NAME']
    return Environment.get(name=env_name)
开发者ID:pigmej,项目名称:mcpinstall,代码行数:6,代码来源:env.py


注:本文中的devops.models.Environment.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。