コード例 #1
0
ファイル: policy_fixture.py プロジェクト: liunian0o0/nova-1
    def _prepare_policy(self):
        policy = jsonutils.load(open(CONF.policy_file))

        # Convert all actions to require specified role
        for action, rule in policy.iteritems():
            policy[action] = 'role:%s' % self.role

        self.policy_dir = self.useFixture(fixtures.TempDir())
        self.policy_file = os.path.join(self.policy_dir.path, 'policy.json')
        with open(self.policy_file, 'w') as f:
            jsonutils.dump(policy, f)
コード例 #2
0
ファイル: policy_fixture.py プロジェクト: Dynavisor/nova
    def _prepare_policy(self):
        policy = jsonutils.load(open(CONF.policy_file))

        # Convert all actions to require specified role
        for action, rule in policy.iteritems():
            policy[action] = 'role:%s' % self.role

        self.policy_dir = self.useFixture(fixtures.TempDir())
        self.policy_file = os.path.join(self.policy_dir.path,
                                            'policy.json')
        with open(self.policy_file, 'w') as f:
            jsonutils.dump(policy, f)
コード例 #3
0
ファイル: policy_fixture.py プロジェクト: VinceOnGit/nova
    def setUp(self):
        """Copy live policy.json file and convert all actions to
           allow users of the specified role only
        """
        super(RoleBasedPolicyFixture, self).setUp()
        policy = jsonutils.load(open(CONF.policy_file))

        # Convert all actions to require specified role
        for action, rule in policy.iteritems():
            policy[action] = "role:%s" % self.role

        self.policy_dir = self.useFixture(fixtures.TempDir())
        self.policy_file_name = os.path.join(self.policy_dir.path, "policy.json")
        with open(self.policy_file_name, "w") as policy_file:
            jsonutils.dump(policy, policy_file)
        CONF.set_override("policy_file", self.policy_file_name)
        nova.policy.reset()
        nova.policy.init()
        self.addCleanup(nova.policy.reset)
コード例 #4
0
ファイル: policy_fixture.py プロジェクト: bopopescu/nova-24
    def setUp(self):
        """Copy live policy.json file and convert all actions to
           allow users of the specified role only
        """
        super(RoleBasedPolicyFixture, self).setUp()
        policy = jsonutils.load(open(CONF.policy_file))

        # Convert all actions to require specified role
        for action, rule in policy.iteritems():
            policy[action] = 'role:%s' % self.role

        self.policy_dir = self.useFixture(fixtures.TempDir())
        self.policy_file_name = os.path.join(self.policy_dir.path,
                                             'policy.json')
        with open(self.policy_file_name, 'w') as policy_file:
            jsonutils.dump(policy, policy_file)
        CONF.set_override('policy_file', self.policy_file_name)
        nova.policy.reset()
        nova.policy.init()
        self.addCleanup(nova.policy.reset)