def deploy(args): """Deploy a ZeroVM application This deploys a zapp onto Swift. The zapp can be one you have downloaded or produced yourself with "zpm bundle". You will need to know the Swift authentication URL, username, password, and tenant name. These can be supplied with command line flags (see below) or you can set the corresponding environment variables. The environment variables are the same as the ones used by the Swift command line tool, so if you're already using that to upload files to Swift, you will be ready to go. """ LOG.info('deploying %s' % args.zapp) zpm.deploy_project(args)
def test_deploy_project_execute(self): parser = commands.set_up_arg_parser() args = parser.parse_args(['deploy', 'foo', self.zapp_path, '--exec']) job_path = 'boot/system.map' job_json = self.job_json_contents.decode('utf-8') job = json.loads(job_json) with mock.patch('zpmlib.zpm._get_zerocloud_conn') as gzc: gzc.return_value = self.conn get_object = self.conn.get_object get_object.return_value = ([], job_json) post_job = self.conn.post_job zpm.deploy_project(args) assert get_object.call_args_list == [mock.call('foo', job_path)] assert post_job.call_args_list == [mock.call(job)]
def test_deploy_project_execute(self): job_path = 'boot/system.map' job_json = self.job_json_contents.decode('utf-8') job_dict = json.loads(job_json) class FakeZeroCloudConnection(mock.Mock): url = 'http://127.0.0.1' token = 'abc123' def post_job(self, job, response_dict=None, response_body_buffer=None): response_dict['status'] = 200 response_dict['reason'] = 'OK' response_dict['headers'] = { 'x-nexe-system': 'node-1', 'x-nexe-cdr-line': ('5.121, 4.993, 0.13 3.84 1025 75943662 23 735 8 399 0 ' '0'), 'x-nexe-status': 'ok', 'x-nexe-retcode': '0', } # Check the job is passed properly here assert job == job_dict def get_container(self, *args, **kwargs): return {}, [] self.conn = FakeZeroCloudConnection() self.conn.auth_version = '1.0' parser = commands.set_up_arg_parser() args = parser.parse_args(['deploy', 'foo', self.zapp_path, '--exec']) with mock.patch('zpmlib.zpm._get_zerocloud_conn') as gzc: gzc.return_value = self.conn self.conn.get_object = mock.Mock() get_object = self.conn.get_object get_object.return_value = ([], job_json) zpm.deploy_project(args) assert get_object.call_args_list == [mock.call('foo', job_path)]
def test_deploy_project_execute(self): job_path = 'boot/system.map' job_json = self.job_json_contents.decode('utf-8') job_dict = json.loads(job_json) class FakeZeroCloudConnection(mock.Mock): url = 'http://127.0.0.1' token = 'abc123' def post_job(self, job, response_dict=None, response_body_buffer=None): response_dict['status'] = 200 response_dict['reason'] = 'OK' response_dict['headers'] = { 'x-nexe-system': 'node-1', 'x-nexe-cdr-line': ( '5.121, 4.993, 0.13 3.84 1025 75943662 23 735 8 399 0 ' '0' ), 'x-nexe-status': 'ok', 'x-nexe-retcode': '0', } # Check the job is passed properly here assert job == job_dict def get_container(self, *args, **kwargs): return {}, [] self.conn = FakeZeroCloudConnection() self.conn.auth_version = '1.0' parser = commands.set_up_arg_parser() args = parser.parse_args(['deploy', 'foo', self.zapp_path, '--exec']) with mock.patch('zpmlib.zpm._get_zerocloud_conn') as gzc: gzc.return_value = self.conn self.conn.get_object = mock.Mock() get_object = self.conn.get_object get_object.return_value = ([], job_json) zpm.deploy_project(args) assert get_object.call_args_list == [mock.call('foo', job_path)]