Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add vswitch_id and tags parameters into create_instance method #36

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
python-aliyun
=============

```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```


Python API wrapper for the Aliyun cloud. This project is starting to use [git-flow](http://nvie.com/posts/a-successful-git-branching-model/).

Installing
Expand Down
47 changes: 44 additions & 3 deletions aliyun/ecs/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,13 @@ def create_instance(
internet_charge_type=None,
instance_charge_type='PrePaid', period=1,
io_optimized=None,
data_disks=None, description=None, zone_id=None):
data_disks=None, description=None, zone_id=None,
vswitch_id=None,
tag1_key=None, tag1_value=None,
tag2_key=None, tag2_value=None,
tag3_key=None, tag3_value=None,
tag4_key=None, tag4_value=None,
tag5_key=None, tag5_value=None):
"""Create an instance.

Args:
Expand Down Expand Up @@ -657,6 +663,29 @@ def create_instance(
if zone_id:
params['ZoneId'] = zone_id

if vswitch_id:
params['VSwitchId'] = vswitch_id
if tag1_key:
params['Tag.1.Key'] = tag1_key
if tag1_value:
params['Tag.1.Value'] = tag1_value
if tag2_key:
params['Tag.2.Key'] = tag2_key
if tag2_value:
params['Tag.2.Value'] = tag2_value
if tag3_key:
params['Tag.3.Key'] = tag3_key
if tag3_value:
params['Tag.3.Value'] = tag3_value
if tag4_key:
params['Tag.4.Key'] = tag4_key
if tag4_value:
params['Tag.4.Value'] = tag4_value
if tag5_key:
params['Tag.5.Key'] = tag5_key
if tag5_value:
params['Tag.5.Value'] = tag5_value

return self.get(params)['InstanceId']

def allocate_public_ip(self, instance_id):
Expand All @@ -680,7 +709,13 @@ def create_and_start_instance(
internet_charge_type=None,
instance_charge_type='PrePaid', period=1,
assign_public_ip=True, block_till_ready=True,
data_disks=None, description=None, zone_id=None):
data_disks=None, description=None, zone_id=None,
vswitch_id=None,
tag1_key=None, tag1_value=None,
tag2_key=None, tag2_value=None,
tag3_key=None, tag3_value=None,
tag4_key=None, tag4_value=None,
tag5_key=None, tag5_value=None):
"""Create and start an instance.

This is a convenience method that does more than just create_instance.
Expand Down Expand Up @@ -771,7 +806,13 @@ def create_and_start_instance(
system_disk_type=system_disk_type,
internet_charge_type=internet_charge_type,
instance_charge_type=instance_charge_type,
data_disks=data_disks, description=description, zone_id=zone_id)
data_disks=data_disks, description=description, zone_id=zone_id,
vswitch_id=vswitch_id, tag1_key=tag1_key,
tag1_value=tag1_value,
tag2_key=tag2_key, tag2_value=tag2_value,
tag3_key=tag3_key, tag3_value=tag3_value,
tag4_key=tag4_key, tag4_value=tag4_value,
tag5_key=tag5_key, tag5_value=tag5_value)

# Modify the security groups.
if additional_security_group_ids:
Expand Down