示例#1
0
 def test_set_credential_file(self):
     with utils.SelfDeletingTempfile() as tmpname:
         with open(tmpname, "wb") as tmp:
             tmp.write("[keystone]\n")
             tmp.write("username = %s\n" % self.username)
             tmp.write("password = %s\n" % self.password)
             tmp.write("tenant_id = %s\n" % self.tenant_id)
         pyos.set_credential_file(tmpname)
         self.assertEqual(pyos.identity.username, self.username)
         self.assertEqual(pyos.identity.password, self.password)
         self.assertTrue(pyos.identity.authenticated)
示例#2
0
 def test_set_credential_file(self):
     with utils.SelfDeletingTempfile() as tmpname:
         with open(tmpname, "wb") as tmp:
             tmp.write("[keystone]\n")
             tmp.write("username = %s\n" % self.username)
             tmp.write("password = %s\n" % self.password)
             tmp.write("tenant_id = %s\n" % self.tenant_id)
         pyos.set_credential_file(tmpname)
         self.assertEqual(pyos.identity.username, self.username)
         self.assertEqual(pyos.identity.password, self.password)
         self.assertTrue(pyos.identity.authenticated)
示例#3
0
#         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.

from __future__ import print_function

import os
import pyos

pyos.set_setting("identity_type", "rackspace")
creds_file = os.path.expanduser("~/.rackspace_cloud_credentials")
pyos.set_credential_file(creds_file)
cbs = pyos.cloud_blockstorage

# This assumes that you have are deleting the volumes named 'my_fast_volume'
# and 'my_standard_volume' that were created in create_volume.py.
for nm in ("my_fast_volume", "my_standard_volume"):
    try:
        vol = cbs.findall(name=nm)[0]
    except IndexError:
        print("There is no volume named '%s'. Skipping..." % nm)
        vol = None
    if vol:
        print("Deleting", vol)
        vol.delete()
print()
print("Done.")
示例#4
0
 def setUp(self):
     pyos.set_credential_file(creds_file)