예제 #1
0
파일: create.go 프로젝트: flazz/rack
func (command *commandCreate) Execute(resource *handler.Resource) {
	opts := resource.Params.(*paramsCreate).opts
	port, err := ports.Create(command.Ctx.ServiceClient, opts).Extract()
	if err != nil {
		resource.Err = err
		return
	}
	resource.Result = portSingle(port)
}
예제 #2
0
func createPort(t *testing.T, networkID, subnetID string) string {
	enable := true
	opts := osPorts.CreateOpts{
		NetworkID:    networkID,
		Name:         "my_port",
		AdminStateUp: &enable,
		FixedIPs:     []osPorts.IP{osPorts.IP{SubnetID: subnetID}},
	}
	p, err := ports.Create(Client, opts).Extract()
	th.AssertNoErr(t, err)
	th.AssertEquals(t, networkID, p.NetworkID)
	th.AssertEquals(t, "my_port", p.Name)
	th.AssertEquals(t, true, p.AdminStateUp)

	return p.ID
}
예제 #3
0
func createSecGroupPort(t *testing.T, groupID string) (string, string) {
	n, err := rsNetworks.Create(Client, osNetworks.CreateOpts{Name: "tmp_network"}).Extract()
	th.AssertNoErr(t, err)
	t.Logf("Created network %s", n.ID)

	opts := osPorts.CreateOpts{
		NetworkID:      n.ID,
		Name:           "my_port",
		SecurityGroups: []string{groupID},
	}
	p, err := rsPorts.Create(Client, opts).Extract()
	th.AssertNoErr(t, err)
	t.Logf("Created port %s with security group %s", p.ID, groupID)

	return n.ID, p.ID
}