918
918
log.info("State-Server backup at %s", backup_file_path)
919
919
return backup_file_path
921
def get_restore_client(self, new_name):
922
"""Return a juju client that can be bootstrapped, to restore.
924
new_name will be used as the controller name.
926
new_env = self.env.clone()
927
new_env.environment = new_name
928
return self.clone(env=new_env)
930
921
def restore_backup(self, backup_file):
932
return self.get_juju_output('restore-backup', '--file', backup_file)
922
return self.get_juju_output('restore-backup', '-b', '--constraints',
923
'mem=2G', '--file', backup_file)
935
925
def restore_backup_async(self, backup_file):
936
with self.bootstrap_async():
938
self.juju('restore-backup', ('--file', backup_file))
926
return self.juju_async('restore-backup', ('-b', '--constraints',
927
'mem=2G', '--file', backup_file))
940
929
def enable_ha(self):
941
930
self.juju('enable-ha', ('-n', '3'))
1038
1027
args = args + ('--bootstrap-series', bootstrap_series)
1041
def get_restore_client(self, new_name):
1042
"""Return a juju client that can restored using -b or equivalent.
1044
For jujus where -b (or equivalent) is supported, this is the same
1045
client, and new_name is ignored.
1049
def restore_backup(self, backup_file):
1050
return self.get_juju_output('restore-backup', '-b', '--constraints',
1051
'mem=2G', '--file', backup_file)
1053
def restore_backup_async(self, backup_file):
1054
return self.juju_async('restore-backup', ('-b', '--constraints',
1055
'mem=2G', '--file', backup_file))
1058
1031
class EnvJujuClient2A1(EnvJujuClient2A2):
1059
1032
"""Drives Juju 2.0-alpha1 clients."""
1731
1704
class JujuData(SimpleEnvironment):
1733
def __init__(self, environment, config=None, juju_home=None,
1734
credentials=None, clouds=None):
1706
def __init__(self, environment, config=None, juju_home=None):
1735
1707
if juju_home is None:
1736
1708
juju_home = get_juju_home()
1737
1709
super(JujuData, self).__init__(environment, config, juju_home)
1738
if credentials is None:
1740
self.credentials = credentials
1743
self.clouds = clouds
1710
self.credentials = {}
1746
1714
def from_env(cls, env):
1748
1716
juju_data.load_yaml()
1749
1717
return juju_data
1752
result = self.__class__(
1753
self.environment, self.config, self.juju_home, self.credentials,
1757
1719
def load_yaml(self):
1758
1720
with open(os.path.join(self.juju_home, 'credentials.yaml')) as f:
1759
1721
self.credentials = yaml.safe_load(f)