我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用amulet.Deployment()。
def setUpClass(cls): cls.deployment = amulet.Deployment(series='xenial') with open(cls.bundle_file) as stream: bundle_yaml = stream.read() bundle = yaml.safe_load(bundle_yaml) cls.deployment.load(bundle) # Allow some time for Juju to provision and deploy the bundle. cls.deployment.setup(timeout=SECONDS_TO_WAIT) # Wait for the system to settle down. wait(cls.deployment.sentry) # Make every unit available through self reference # eg: for worker in self.workers: # print(worker.info['public-address']) cls.easyrsas = cls.deployment.sentry['easyrsa'] cls.etcds = cls.deployment.sentry['etcd'] cls.flannels = cls.deployment.sentry['flannel'] cls.loadbalancers = cls.deployment.sentry['kubeapi-load-balancer'] cls.masters = cls.deployment.sentry['kubernetes-master'] cls.workers = cls.deployment.sentry['kubernetes-worker']
def setUpClass(cls): cls.deployment = amulet.Deployment(series='xenial') with open(cls.bundle_file) as stream: bundle_yaml = stream.read() bundle = yaml.safe_load(bundle_yaml) if 'options' not in bundle['services']['kubernetes-worker']: labels = {'labels': "mylabel=thebest"} bundle['services']['kubernetes-worker']['options'] = labels else: if 'labels' not in bundle['services']['kubernetes-worker']['options']: bundle['services']['kubernetes-worker']['options']['labels'] = "mylabel=thebest" else: bundle['services']['kubernetes-worker']['options']['labels'] += " mylabel=thebest" cls.deployment.load(bundle) # Allow some time for Juju to provision and deploy the bundle. cls.deployment.setup(timeout=SECONDS_TO_WAIT) # Wait for the system to settle down. wait(cls.deployment.sentry)
def setUpClass(cls): """Setup the deployment for this class once and deploy.""" cls.deployment = amulet.Deployment(series='xenial') cls.deployment.add('ubuntu') cls.deployment.add('packetbeat') cls.deployment.relate('ubuntu:juju-info', 'packetbeat:beats-host') try: cls.deployment.setup(timeout=seconds) cls.deployment.sentry.wait() except amulet.helpers.TimeoutError: message = "The deploy did not setup in {0} seconds".format(seconds) amulet.raise_status(amulet.SKIP, msg=message) except: raise cls.unit = cls.deployment.sentry['packetbeat'][0]
def setUpClass(cls): cls.d = amulet.Deployment(series='xenial') cls.d.add('etcd') cls.d.add('easyrsa', 'cs:~containers/easyrsa') cls.d.configure('etcd', {'channel': '3.0/stable'}) cls.d.relate('easyrsa:client', 'etcd:certificates') cls.d.setup(timeout=1200) cls.d.sentry.wait_for_messages({'etcd': re.compile('Healthy*|Unhealthy*')}) # cls.d.sentry.wait() cls.etcd = cls.d.sentry['etcd'] # find the leader for unit in cls.etcd: leader_result = unit.run('is-leader') if leader_result[0] == 'True': cls.leader = unit
def __init__(self, series=None): """Initialize the deployment environment.""" self.series = None if series: self.series = series self.d = amulet.Deployment(series=self.series) else: self.d = amulet.Deployment()
def _deploy(self): """Deploy environment and wait for all hooks to finish executing.""" try: self.d.setup(timeout=900) self.d.sentry.wait(timeout=900) except amulet.helpers.TimeoutError: amulet.raise_status(amulet.FAIL, msg="Deployment timed out") except Exception: raise
def _deploy(self): """Deploy environment and wait for all hooks to finish executing.""" timeout = int(os.environ.get('AMULET_SETUP_TIMEOUT', 900)) try: self.d.setup(timeout=timeout) self.d.sentry.wait(timeout=timeout) except amulet.helpers.TimeoutError: amulet.raise_status( amulet.FAIL, msg="Deployment timed out ({}s)".format(timeout) ) except Exception: raise
def test_deploy(self): self.d = amulet.Deployment(series='xenial') self.d.add('client', 'hadoop-client') self.d.setup(timeout=900) self.d.sentry.wait(timeout=1800) self.unit = self.d.sentry['client'][0]
def setUpClass(cls): cls.deployment = amulet.Deployment(series='xenial') with open(cls.bundle_file) as stream: bundle_yaml = stream.read() bundle = yaml.safe_load(bundle_yaml) cls.deployment.load(bundle) # Allow some time for Juju to provision and deploy the bundle. cls.deployment.setup(timeout=SECONDS_TO_WAIT) # Wait for the system to settle down. wait(cls.deployment.sentry)
def setUpClass(cls): cls.d = amulet.Deployment(series='xenial') cls.d.add('ubuntu-devenv', 'cs:xenial/ubuntu-devenv') cls.d.add('openjdk', 'cs:xenial/openjdk') cls.d.relate('ubuntu-devenv:java', 'openjdk:java') cls.d.setup(timeout=900) cls.d.sentry.wait(timeout=1800) cls.unit = cls.d.sentry['ubuntu-devenv'][0]
def __init__(self, series="xenial", storage=True): self.series = series self.storage = storage self.deployment = Deployment(series=self.series) self._run_hooks("init")