def test_set_region_setting(self): ident = pyos.identity ident.region = "DFW" pyos.set_setting("region", "ORD") self.assertEqual(ident.region, "DFW") pyos.set_setting("region", "LON") self.assertEqual(ident.region, "LON")
def test_connect_to_cloudfiles_ServiceNet(self): orig = pyos.get_setting("use_servicenet") pyos.set_setting("use_servicenet", True) pyos.cloudfiles = None pyos.connect_to_cloudfiles = self.orig_connect_to_cloudfiles sav = pyos._create_client pyos._create_client = Mock() cf = pyos.connect_to_cloudfiles(public=False) pyos._create_client.assert_called_once_with(ep_name="object_store", region=None, public=False) pyos.set_setting("use_servicenet", orig) pyos._create_client = sav
def test_safe_region(self): # Pass direct reg = utils.random_unicode() ret = pyos._safe_region(reg) self.assertEqual(reg, ret) # From config setting orig_reg = pyos.get_setting("region") reg = utils.random_unicode() pyos.set_setting("region", reg) ret = pyos._safe_region() self.assertEqual(reg, ret) # Identity default pyos.set_setting("region", None) orig_defreg = pyos.identity.get_default_region reg = utils.random_unicode() pyos.identity.get_default_region = Mock(return_value=reg) ret = pyos._safe_region() self.assertEqual(reg, ret) pyos.identity.get_default_region = orig_defreg pyos.set_setting("region", orig_reg)
# a copy of the License at # # 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()