Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
feature(vm): check pattern of instance name and instance name unique
Browse files Browse the repository at this point in the history
  • Loading branch information
eKatchko authored Aug 19, 2019
1 parent 27b8478 commit f7cede3
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 5 deletions.
6 changes: 6 additions & 0 deletions VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,12 @@ def create_and_deploy_playbook(self, public_key, playbooks_information, openstac
active_playbooks[openstack_id] = playbook
return 0

def exist_server(self, name):
if self.conn.compute.find_server(name) is not None:
return True
else:
return False

def get_playbook_logs(self, openstack_id):
global active_playbooks
if self.redis.exists(openstack_id) == 1 and openstack_id in active_playbooks:
Expand Down
7 changes: 7 additions & 0 deletions VirtualMachineService/VirtualMachineService-remote
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print(' bool create_connection(string username, string password, string auth_url, string user_domain_name, string project_domain_name)')
print(' start_server(string flavor, string image, string public_key, string servername, metadata, string diskspace, string volumename)')
print(' start_server_with_custom_key(string flavor, string image, string servername, metadata, string diskspace, string volumename)')
print(' bool exist_server(string name)')
print(' int create_and_deploy_playbook(string public_key, playbooks_information, string openstack_id)')
print(' PlaybookResult get_playbook_logs(string openstack_id)')
print(' bool add_security_group_to_server(bool http, bool https, bool udp, string server_id)')
Expand Down Expand Up @@ -217,6 +218,12 @@ elif cmd == 'start_server_with_custom_key':
sys.exit(1)
pp.pprint(client.start_server_with_custom_key(args[0], args[1], args[2], eval(args[3]), args[4], args[5],))

elif cmd == 'exist_server':
if len(args) != 1:
print('exist_server requires 1 args')
sys.exit(1)
pp.pprint(client.exist_server(args[0],))

elif cmd == 'create_and_deploy_playbook':
if len(args) != 3:
print('create_and_deploy_playbook requires 3 args')
Expand Down
191 changes: 191 additions & 0 deletions VirtualMachineService/VirtualMachineService.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions portal_client.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ const string VERSION= '1.0.0'

/** List of tags from flavor */
7: required list<string> tags


}
/**
* This Struct defines an Image.
*/
struct Image{
struct Image{

/** The name of the image*/
1:required string name

Expand Down Expand Up @@ -75,7 +75,7 @@ struct Image{
* This Struct defines a VirtualMachine.
*/
struct VM {

/** The flavor of the VM*/
1: required Flavor flav,

Expand Down Expand Up @@ -346,6 +346,11 @@ service VirtualMachineService {

throws (1:nameException e,2:ressourceException r,3:serverNotFoundException s,4: networkNotFoundException n,5:imageNotFoundException i,6:flavorNotFoundException f,7:otherException o)

/** Check if there is an instance with name */
bool exist_server(
1:string name
)

/** Create and deploy an anaconda ansible playbook*/
int create_and_deploy_playbook(
1:string public_key,
Expand Down

0 comments on commit f7cede3

Please sign in to comment.